示例#1
0
        static string[] BndFunctions(IGridData g)
        {
            int D = g.SpatialDimension;

            //return ArrayTools.Cat(VariableNames.VelocityVector(D), VariableNames.Temperature, "HeatFlux");
            return(ArrayTools.Cat(VariableNames.HeatFluxVector(D), VariableNames.Temperature, VariableNames.VelocityVector(D)));
        }
        /// <summary>
        /// ctor for the operator factory, where the equation compnents are set
        /// </summary>
        /// <param name="_config"></param>
        /// <param name="_LsTrk"></param>
        /// <param name="_HMFdegree"></param>
        /// <param name="BcMap"></param>
        /// <param name="thermBcMap"></param>
        /// <param name="degU"></param>
        public XNSFE_OperatorFactory(XNSFE_OperatorConfiguration _config, LevelSetTracker _LsTrk, int _HMFdegree,
                                     IncompressibleMultiphaseBoundaryCondMap BcMap, ThermalMultiphaseBoundaryCondMap thermBcMap, int degU, IDictionary <SpeciesId, IEnumerable <double> > MassScale)
        {
            this.config = _config;
            this.LsTrk  = _LsTrk;
            this.D      = _LsTrk.GridDat.SpatialDimension;

            this.HMFDegree = _HMFdegree;

            this.physParams  = config.getPhysParams;
            this.thermParams = config.getThermParams;
            this.dntParams   = config.getDntParams;


            // test input
            // ==========
            {
                if ((config.getPhysParams.mu_A <= 0) && (config.getPhysParams.mu_B <= 0))
                {
                    config.isViscous = false;
                }
                else
                {
                    if ((config.getPhysParams.mu_A <= 0) || (config.getPhysParams.mu_B <= 0))
                    {
                        throw new ArgumentException();
                    }
                }

                if ((config.getPhysParams.rho_A <= 0) || (config.getPhysParams.rho_B <= 0))
                {
                    throw new ArgumentException();
                }

                if (_LsTrk.SpeciesNames.Count != 2)
                {
                    throw new ArgumentException();
                }

                if (!(_LsTrk.SpeciesNames.Contains("A") && _LsTrk.SpeciesNames.Contains("B")))
                {
                    throw new ArgumentException();
                }
            }


            // full operator:
            // ==============
            CodName = ArrayTools.Cat(EquationNames.MomentumEquations(D), EquationNames.ContinuityEquation);
            Params  = ArrayTools.Cat(
                VariableNames.Velocity0Vector(D),
                VariableNames.Velocity0MeanVector(D),
                VariableNames.NormalVector(D),
                VariableNames.Curvature,
                VariableNames.SurfaceForceVector(D)
                );
            DomName = ArrayTools.Cat(VariableNames.VelocityVector(D), VariableNames.Pressure);

            if (config.solveEnergy)
            {
                CodName = ArrayTools.Cat(CodName, EquationNames.KineticEnergyEquation);
                Params  = ArrayTools.Cat(Params,
                                         VariableNames.VelocityX_GradientVector(),
                                         VariableNames.VelocityY_GradientVector(),
                                         new string[] { "VelocityXGradX_GradientX", "VelocityXGradX_GradientY" },
                                         new string[] { "VelocityXGradY_GradientX", "VelocityXGradY_GradientY" },
                                         new string[] { "VelocityYGradX_GradientX", "VelocityYGradX_GradientY" },
                                         new string[] { "VelocityYGradY_GradientX", "VelocityYGradY_GradientY" },
                                         VariableNames.Pressure0,
                                         VariableNames.PressureGradient(D),
                                         VariableNames.GravityVector(D)
                                         );
                DomName = ArrayTools.Cat(DomName, VariableNames.KineticEnergy);
            }

            if (config.solveHeat)
            {
                Params = ArrayTools.Cat(Params,
                                        VariableNames.Temperature0,
                                        VariableNames.HeatFlux0Vector(D),
                                        VariableNames.DisjoiningPressure
                                        );
                if (config.conductMode == ConductivityInSpeciesBulk.ConductivityMode.SIP)
                {
                    CodName = ArrayTools.Cat(CodName, EquationNames.HeatEquation);
                    DomName = ArrayTools.Cat(DomName, VariableNames.Temperature);
                }
                else
                {
                    CodName = ArrayTools.Cat(CodName, EquationNames.HeatEquation, EquationNames.AuxHeatFlux(D));
                    DomName = ArrayTools.Cat(DomName, VariableNames.Temperature, VariableNames.HeatFluxVector(D));
                }
            }

            storedParams = new DGField[Params.Length];

            // selected part:
            if (config.getCodBlocks[0])
            {
                CodNameSelected = ArrayTools.Cat(CodNameSelected, CodName.GetSubVector(0, D));
            }
            if (config.getCodBlocks[1])
            {
                CodNameSelected = ArrayTools.Cat(CodNameSelected, CodName.GetSubVector(D, 1));
            }

            if (config.getDomBlocks[0])
            {
                DomNameSelected = ArrayTools.Cat(DomNameSelected, DomName.GetSubVector(0, D));
            }
            if (config.getDomBlocks[1])
            {
                DomNameSelected = ArrayTools.Cat(DomNameSelected, DomName.GetSubVector(D, 1));
            }

            int nBlocks = 2;

            if (config.solveEnergy)
            {
                nBlocks = 3;
                if (config.getCodBlocks[2])
                {
                    CodNameSelected = ArrayTools.Cat(CodNameSelected, CodName.GetSubVector(D + 1, 1));
                }
                if (config.getDomBlocks[2])
                {
                    DomNameSelected = ArrayTools.Cat(DomNameSelected, DomName.GetSubVector(D + 1, 1));
                }
            }

            if (config.solveHeat)
            {
                if (config.getCodBlocks[nBlocks])
                {
                    CodNameSelected = ArrayTools.Cat(CodNameSelected, CodName.GetSubVector(nBlocks + (D - 1) + 1, 1));
                }
                if (config.getDomBlocks[nBlocks])
                {
                    DomNameSelected = ArrayTools.Cat(DomNameSelected, DomName.GetSubVector(nBlocks + (D - 1) + 1, 1));
                }

                if (config.conductMode != ConductivityInSpeciesBulk.ConductivityMode.SIP)
                {
                    if (config.getCodBlocks[nBlocks + 1])
                    {
                        CodNameSelected = ArrayTools.Cat(CodNameSelected, CodName.GetSubVector(nBlocks + (D - 1) + 2, D));
                    }
                    if (config.getDomBlocks[nBlocks + 1])
                    {
                        DomNameSelected = ArrayTools.Cat(DomNameSelected, DomName.GetSubVector(nBlocks + (D - 1) + 2, D));
                    }
                }
            }


            // create Operator
            // ===============
            m_XOp = new XSpatialOperatorMk2(DomNameSelected, Params, CodNameSelected, (A, B, C) => _HMFdegree, this.LsTrk.SpeciesNames);

            // add Navier-Stokes components
            // ============================

            // species bulk components
            for (int spc = 0; spc < LsTrk.TotalNoOfSpecies; spc++)
            {
                // Navier Stokes equations
                Solution.XNSECommon.XOperatorComponentsFactory.AddSpeciesNSE(m_XOp, config, D, LsTrk.SpeciesNames[spc], LsTrk.SpeciesIdS[spc], BcMap, LsTrk, out U0meanrequired);

                // continuity equation
                if (config.isContinuity)
                {
                    Solution.XNSECommon.XOperatorComponentsFactory.AddSpeciesContinuityEq(m_XOp, config, D, LsTrk.SpeciesNames[spc], LsTrk.SpeciesIdS[spc], BcMap);
                }
            }

            // interface components
            Solution.XNSECommon.XOperatorComponentsFactory.AddInterfaceNSE(m_XOp, config, D, BcMap, LsTrk);                                                          // surface stress tensor
            Solution.XNSECommon.XOperatorComponentsFactory.AddSurfaceTensionForce(m_XOp, config, D, BcMap, LsTrk, degU, out NormalsRequired, out CurvatureRequired); // surface tension force

            if (config.isContinuity)
            {
                Solution.XNSECommon.XOperatorComponentsFactory.AddInterfaceContinuityEq(m_XOp, config, D, LsTrk);       // continuity equation
            }
            // add kinetic energy equation components
            // ======================================
            if (config.solveEnergy)
            {
                // species bulk components
                for (int spc = 0; spc < LsTrk.TotalNoOfSpecies; spc++)
                {
                    Solution.EnergyCommon.XOperatorComponentsFactory.AddSpeciesKineticEnergyEquation(m_XOp, config, D, LsTrk.SpeciesNames[spc], LsTrk.SpeciesIdS[spc], BcMap, LsTrk);
                }

                // interface components
                Solution.EnergyCommon.XOperatorComponentsFactory.AddInterfaceKineticEnergyEquation(m_XOp, config, D, BcMap, LsTrk, degU);
                CurvatureRequired = true;
            }


            // add Heat equation components
            // ============================
            if (config.solveHeat)
            {
                // species bulk components
                for (int spc = 0; spc < LsTrk.TotalNoOfSpecies; spc++)
                {
                    Solution.XheatCommon.XOperatorComponentsFactory.AddSpeciesHeatEq(m_XOp, config,
                                                                                     D, LsTrk.SpeciesNames[spc], LsTrk.SpeciesIdS[spc], thermBcMap, LsTrk);
                }

                // interface components
                Solution.XheatCommon.XOperatorComponentsFactory.AddInterfaceHeatEq(m_XOp, config, D, thermBcMap, LsTrk);
            }


            // add Evaporation interface components
            // ====================================

            if (config.isEvaporation)
            {
                XOperatorComponentsFactory.AddInterfaceNSE_withEvaporation(m_XOp, config, D, LsTrk);
                if (config.isContinuity)
                {
                    XOperatorComponentsFactory.AddInterfaceContinuityEq_withEvaporation(m_XOp, config, D, LsTrk);
                }
            }

            // create temporal operator
            // ========================
            var TempOp = new ConstantXTemporalOperator(m_XOp, 0.0);

            m_XOp.TemporalOperator = TempOp;
            foreach (var kv in MassScale)
            {
                TempOp.DiagonalScale[LsTrk.GetSpeciesName(kv.Key)].SetV(kv.Value.ToArray());
            }

            // Finalize
            // ========

            m_XOp.Commit();
        }