Example #1
0
        private IVector CalculateRhsImplicit(ILinearSystem linearSystem, bool addRhs)
        {
            //TODO: what is the meaning of addRhs? Do we need this when solving dynamic thermal equations?
            //TODO: stabilizingRhs has not been implemented

            // result = (capacity/dt^2-diffusionConductivity/dt-massTransportConductivity/dt+stabilizingConductivity)*temperature - (StabilizingRhs - rhs/dt))
            // result = -dt(conductuvity*temperature - rhs -dt(stabilizingConductivity*temperature + StabilizingRhs))
            double a0 = 1 / Math.Pow(timeStep, 2);
            double a1 = 1 / (2 * timeStep);
            double a2 = 1 / timeStep;
            int    id = linearSystem.Subdomain.ID;

            capacityTimesTemperature[id] = provider.CapacityMatrixVectorProduct(linearSystem.Subdomain, temperature[id]);
            capacityTimesTemperature[id].ScaleIntoThis(a0);
            diffusionConductivityTimesTemperature[id] = provider.DiffusionConductivityMatrixVectorProduct(linearSystem.Subdomain, temperature[id]);
            diffusionConductivityTimesTemperature[id].ScaleIntoThis(a2);
            massTransportConductivityTimesTemperature[id] = provider.MassTransportConductivityMatrixVectorProduct(linearSystem.Subdomain, temperature[id]);
            massTransportConductivityTimesTemperature[id].ScaleIntoThis(a2);
            stabilizingConductivityTimesTemperature[id] = provider.StabilizingConductivityMatrixVectorProduct(linearSystem.Subdomain, temperature[id]);
            rhs[id].ScaleIntoThis(a2);
            var rhsResult = capacityTimesTemperature[id].Subtract(diffusionConductivityTimesTemperature[id]);

            rhsResult.SubtractIntoThis(massTransportConductivityTimesTemperature[id].Subtract(stabilizingConductivityTimesTemperature[id]));
            rhsResult.SubtractIntoThis(stabilizingRhs[id].Subtract(rhs[id]));
            return(rhsResult);
        }
Example #2
0
        private IVector CalculateRhsImplicit(ILinearSystem linearSystem, bool addRhs)
        {
            //TODO: what is the meaning of addRhs? Do we need this when solving dynamic thermal equations?
            //TODO: stabilizingRhs has not been implemented

            // result = (capacity/dt^2-diffusionConductivity/dt-massTransportConductivity/dt+stabilizingConductivity)*temperature - (StabilizingRhs - rhs/dt))
            // result = -dt(conductuvity*temperature - rhs -dt(stabilizingConductivity*temperature + StabilizingRhs))
            int id = linearSystem.Subdomain.ID;

            double[,] kappa = new double[model.Nodes.Count, model.Nodes.Count];
            kappa[0, 0]     = 1;
            kappa[model.Nodes.Count - 1, model.Nodes.Count - 1] = 1;
            IMatrix penalty = Matrix.CreateFromArray(kappa);
            double  a0      = 1 / Math.Pow(timeStep, 2);
            double  a1      = 1 / (2 * timeStep);
            double  a2      = 1 / timeStep;

            dummyWeakImpositionTimesTemperature[id] = penalty.Multiply(temperature[id]);
            dummyWeakImpositionTimesTemperature[id].ScaleIntoThis(a2);
            capacityTimesTemperature[id] = provider.CapacityMatrixVectorProduct(linearSystem.Subdomain, temperature[id]);
            capacityTimesTemperature[id].ScaleIntoThis(a0);
            diffusionConductivityTimesTemperature[id] = provider.DiffusionConductivityMatrixVectorProduct(linearSystem.Subdomain, temperature[id]);
            diffusionConductivityTimesTemperature[id].ScaleIntoThis(a2);
            diffusionConductivityTimesTemperature[id].AddIntoThis(dummyWeakImpositionTimesTemperature[id]);
            massTransportConductivityTimesTemperature[id] = provider.MassTransportConductivityMatrixVectorProduct(linearSystem.Subdomain, temperature[id]);
            massTransportConductivityTimesTemperature[id].ScaleIntoThis(a2);
            stabilizingConductivityTimesTemperature[id] = provider.StabilizingConductivityMatrixVectorProduct(linearSystem.Subdomain, temperature[id]);
            rhs[id].ScaleIntoThis(a2);
            var rhsResult = capacityTimesTemperature[id].Subtract(diffusionConductivityTimesTemperature[id]);

            rhsResult.SubtractIntoThis(massTransportConductivityTimesTemperature[id].Subtract(stabilizingConductivityTimesTemperature[id]));
            rhsResult.SubtractIntoThis(stabilizingRhs[id].Subtract(rhs[id]));
            return(rhsResult);
        }