/// <summary> /// Ctor. /// </summary> /// <param name="GravityDirection">Unit vector for spatial direction of gravity.</param> /// <param name="SpatialComponent">Spatial component of source.</param> /// <param name="Froude">Dimensionless Froude number.</param> /// <param name="physicsMode"></param> /// <param name="EoS">Equation of state for calculating density.</param> public Buoyancy(Vector GravityDirection, int SpatialComponent, double Froude, PhysicsMode physicsMode, MaterialLaw EoS) { // Check direction if ((GravityDirection.Abs() - 1.0) > 1.0e-13) { throw new ArgumentException("Length of GravityDirection vector has to be 1.0"); } // Initialize this.GravityDirection = GravityDirection; this.SpatialComponent = SpatialComponent; this.Froude = Froude; this.EoS = EoS; this.physicsMode = physicsMode; switch (physicsMode) { case PhysicsMode.LowMach: this.m_ParameterOrdering = new string[] { VariableNames.Temperature0 }; break; case PhysicsMode.Combustion: this.m_ParameterOrdering = new string[] { VariableNames.Temperature0, VariableNames.MassFraction0_0, VariableNames.MassFraction1_0, VariableNames.MassFraction2_0, VariableNames.MassFraction3_0 }; break; default: throw new ApplicationException("wrong physicsmode"); } }
/// <summary> /// Lambda for convective operators with variable density, /// i.e. momentum equation for multiphase and Low-Mach flows /// and temperature advection for Low-Mach flows. /// </summary> /// <param name="ScalarMean"></param> /// <param name="VelocityMean"></param> /// <param name="Normal"></param> /// <param name="EoS"></param> /// <param name="FactorTwo"> /// True: Lambda = 2.0 * rho * V_n (used for momentum equation). /// False: Lambda = rho * V_n (used for temperature equation). /// </param> /// <returns> /// </returns> static public double GetLambda(double[] VelocityMean, double[] Normal, MaterialLaw EoS, bool FactorTwo, params double[] ScalarMean) { Debug.Assert(VelocityMean.Length == Normal.Length, "Mismatch in dimensions!"); double V_n = 0.0; for (int d = 0; d < VelocityMean.Length; d++) { V_n += VelocityMean[d] * Normal[d]; } double rhoMean = EoS.GetDensity(ScalarMean); double Lambda = rhoMean * V_n; if (FactorTwo) { Lambda *= 2.0; } if (double.IsNaN(Lambda) || double.IsInfinity(Lambda)) { throw new NotFiniteNumberException(); } return(Math.Abs(Lambda)); }
/// <summary> /// Ctor. /// <param name="HeatRelease">Heat release computed from the sum of the product of the stoichiometric coefficient, partial heat capacity and molar mass of species alpha for all species. I.e.: sum(alpha = 1.. ns)[v_\alpha cp_alpha M_alpha]. Must be computed locally for non-constant partial heat capacities in later iterations of the code.</param> /// <param name="Reynolds">The Reynolds number</param> /// <param name="Prandtl">The Prandtl number</param> /// <param name="Schmidt">The Schmidt number</param> /// <param name="StoichiometricCoefficients">0. of fuel, 1. of oxidizer, 2. of CO2, 3. of H2O</param> /// <param name="ReactionRateConstants">0. PreExpFactor/Damköhler number, 1. ActivationTemperature, 2. MassFraction0Exponent, 3. MassFraction1Exponent</param> /// <param name="MolarMasses">Array of molar masses of fuel, oxidizer, CO2 and H2O</param> /// <param name="EoS">Material law</param> /// <param name="EqType">Temperature" for temperature equation. "MassFraction" for a MassFraction balance</param> /// <param name="physicsMode"></param> /// <param name="phystime"></param> /// <param name="unsteady"></param> /// <param name="SpeciesIndex">(optional). Necessary for "MassFraction" EqType. Species index: 0 for fuel, 1 for oxidizer, 2 for CO2 and 3 for H2O.</param> /// <param name="chemReactionOK"></param> /// <param name="rhoOne"></param> /// </summary> public RHSManuSourceTransportEq(double HeatRelease, double Reynolds, double Prandtl, double Schmidt, double[] StoichiometricCoefficients, double[] ReactionRateConstants, double[] MolarMasses, MaterialLaw EoS, String EqType, PhysicsMode physicsMode, int SpeciesIndex = -1, bool chemReactionOK = true, bool rhoOne = false, Func <double[], double, double> _sourceFunc = null) { this.HeatRelease = HeatRelease; this.ReynoldsNumber = Reynolds; this.PrandtlNumber = Prandtl; this.SchmidtNumber = Schmidt; this.Eos = EoS; this.EqType = EqType; this.physicsMode = physicsMode; this.chemReactionOK = chemReactionOK; this.rhoOne = rhoOne; if (EqType == "MassFraction") { this.SpeciesIndex = SpeciesIndex; this.StoichiometricCoeff = StoichiometricCoefficients[SpeciesIndex]; } this.Da = ReactionRateConstants[0]; // Damköhler number this.Ta = ReactionRateConstants[1]; this.a = ReactionRateConstants[2]; this.b = ReactionRateConstants[3]; this.MolarMasses = MolarMasses; this.sourceFunc = _sourceFunc; }
/// <summary> /// Ctor. /// <param name="HeatReleaseFactor">Heat release computed from the sum of the product of the stoichiometric coefficient, partial heat capacity and molar mass of species alpha for all species. I.e.: sum(alpha = 1.. ns)[v_\alpha cp_alpha M_alpha]. Must be computed locally for non-constant partial heat capacities in later iterations of the code.</param> /// <param name="Reynolds">The Reynolds number</param> /// <param name="Reynolds">The Prandtl number</param> /// <param name="Reynolds">The Schmidt number</param> /// <param name="StoichiometricCoefficients">0. of fuel, 1. of oxidizer, 2. of CO2, 3. of H2O</param> /// <param name="ReactionRateConstants">0. PreExpFactor/Damköhler number, 1. ActivationTemperature, 2. MassFraction0Exponent, 3. MassFraction1Exponent</param> /// <param name="MolarMasses">Array of molar masses of fuel, oxidizer, CO2 and H2O</param> /// <param name="OneOverMolarMass0MolarMass1"> 1/(M_infty^(a + b -1) * MolarMassFuel^a * MolarMassOxidizer^b). M_infty is the reference for the molar mass steming from non-dimensionalisation of the governing equations.</param> /// <param name="EoS">Material law</param> /// <param name="EqType">Temperature" for temperature equation. "MassFraction" for a MassFraction balance</param> /// <param name="SpeciesIndex">(optional). Necessary for "MassFraction" EqType. Species index: 0 for fuel, 1 for oxidizer, 2 for CO2 and 3 for H2O.</param> /// </summary> public RHSManuSourceTransportEq(double HeatReleaseFactorFactor, double Reynolds, double Prandtl, double Schmidt, double[] StoichiometricCoefficients, double[] ReactionRateConstants, double[] MolarMasses, double OneOverMolarMass0MolarMass1, MaterialLaw EoS, String EqType, bool energyOK, bool speciesOK, int SpeciesIndex = -1) { this.HeatReleaseFactor = HeatReleaseFactorFactor; this.ReynoldsNumber = Reynolds; this.PrandtlNumber = Prandtl; this.SchmidtNumber = Schmidt; this.Eos = EoS; this.EqType = EqType; this.energyOK = energyOK; this.speciesOK = speciesOK; if (EqType == "MassFraction") { this.SpeciesIndex = SpeciesIndex; this.StoichiometricCoeff = StoichiometricCoefficients[SpeciesIndex]; } this.PreExpFactor = ReactionRateConstants[0]; this.ActivationTemperature = ReactionRateConstants[1]; this.MassFraction0Exponent = ReactionRateConstants[2]; this.MassFraction1Exponent = ReactionRateConstants[3]; this.MolarMasses = MolarMasses; this.OneOverMolarMass0MolarMass1 = OneOverMolarMass0MolarMass1; }
/// <summary> /// Ctor for variable density flows /// </summary> /// <param name="EoS">The material law</param> /// <param name="energy">Set conti: true for the energy equation</param> /// <param name="ArgumentOrdering"></param> /// <param name="TimeStepSize"></param> public MassMatrixComponent(MaterialLaw EoS, String[] ArgumentOrdering, int j, PhysicsMode _physicsMode, int spatDim, int NumberOfReactants) { this.j = j; this.EoS = EoS; m_ParameterOrdering = EoS.ParameterOrdering; this.m_SpatialDimension = spatDim; this.NumberOfReactants = NumberOfReactants; int SpatDim = 2; int numberOfReactants = 3; this.physicsMode = _physicsMode; switch (_physicsMode) { case PhysicsMode.Multiphase: m_ArgumentOrdering = new string[] { VariableNames.LevelSet }; m_ParameterOrdering = ArrayTools.Cat(VariableNames.Velocity0Vector(SpatDim), VariableNames.Velocity0MeanVector(SpatDim)); break; case PhysicsMode.LowMach: m_ArgumentOrdering = ArrayTools.Cat(VariableNames.VelocityVector(SpatDim), VariableNames.Temperature); if (EoS == null) { throw new ApplicationException("EoS has to be given for Low-Mach flows to calculate density."); } else { this.EoS = EoS; } break; case PhysicsMode.MixtureFraction: m_ArgumentOrdering = ArrayTools.Cat(VariableNames.VelocityVector(SpatDim), VariableNames.MixtureFraction); if (EoS == null) { throw new ApplicationException("EoS has to be given for Low-Mach flows to calculate density."); } else { this.EoS = EoS; } break; case PhysicsMode.Combustion: m_ArgumentOrdering = ArrayTools.Cat(VariableNames.VelocityVector(SpatDim), VariableNames.Temperature, VariableNames.MassFractions(numberOfReactants - 1)); // u,v,w,T, Y0,Y1,Y2,Y3 as variables (Y4 is calculated as Y4 = 1- (Y0+Y1+Y2+Y3) if (EoS == null) { throw new ApplicationException("EoS has to be given for Low-Mach flows to calculate density."); } else { this.EoS = EoS; } break; default: throw new NotImplementedException(); } }
/// <summary> /// Ctor. /// </summary> /// <param name="EoS">The material law</param> /// <param name="conti">Set conti: true for the continuity equation</param> /// <param name="ArgumentOrdering"></param> /// <param name="TimeStepSize"></param> public TimeDerivativeLinearSource(MaterialLaw EoS, double TimeStepSize, String[] ArgumentOrdering, bool conti = false) { m_ArgumentOrdering = ArgumentOrdering;//.Cat(VariableNames.Rho); this.EoS = EoS; dt = TimeStepSize; m_conti = conti; }
/// <summary> /// Ctor for low Mach number flows. /// </summary> /// <param name="Component"></param> /// <param name="Bcmap"></param> /// <param name="EoS"></param> public Divergence_CentralDifferenceJacobian(int Component, IncompressibleBoundaryCondMap Bcmap, int SpatDim, MaterialLaw EoS, int NumberOfSpecies = -1) : this(Component, Bcmap, SpatDim) { this.EoS = EoS; switch (Bcmap.PhysMode) { case PhysicsMode.Incompressible: case PhysicsMode.Multiphase: throw new ApplicationException("Wrong constructor"); case PhysicsMode.MixtureFraction: m_ArgumentOrdering = ArrayTools.Cat(VariableNames.VelocityVector(SpatDim), new string[] { VariableNames.MixtureFraction }); m_ParameterOrdering = null; this.NumberOfSpecies = NumberOfSpecies; break; case PhysicsMode.LowMach: m_ArgumentOrdering = ArrayTools.Cat(VariableNames.VelocityVector(SpatDim), new string[] { VariableNames.Temperature }); break; case PhysicsMode.Combustion: if (NumberOfSpecies == -1) { throw new ArgumentException("NumberOfSpecies must be specified for combustion flows."); } string[] Parameters = ArrayTools.Cat(new string[] { VariableNames.Temperature }, VariableNames.MassFractions(NumberOfSpecies - 1)); this.NumberOfSpecies = NumberOfSpecies; m_ArgumentOrdering = ArrayTools.Cat(VariableNames.VelocityVector(SpatDim), Parameters); break; default: throw new NotImplementedException(); } }
/// <summary> /// Ctor. /// <param name="HeatReleaseFactor">Heat release computed from the sum of the product of the stoichiometric coefficient, partial heat capacity and molar mass of species alpha for all species. I.e.: sum(alpha = 1.. ns)[v_\alpha cp_alpha M_alpha]. Must be computed locally for non-constant partial heat capacities in later iterations of the code.</param> /// <param name="Reynolds">The Reynolds number</param> /// <param name="Prandtl">The Prandtl number</param> /// <param name="Schmidt">The Schmidt number</param> /// <param name="StoichiometricCoefficients">0. of fuel, 1. of oxidizer, 2. of CO2, 3. of H2O</param> /// <param name="ReactionRateConstants">0. PreExpFactor/Damköhler number, 1. ActivationTemperature, 2. MassFraction0Exponent, 3. MassFraction1Exponent</param> /// <param name="MolarMasses">Array of molar masses of fuel, oxidizer, CO2 and H2O</param> /// <param name="OneOverMolarMass0MolarMass1"> 1/(M_infty^(a + b -1) * MolarMassFuel^a * MolarMassOxidizer^b). M_infty is the reference for the molar mass steming from non-dimensionalisation of the governing equations.</param> /// <param name="EoS">Material law</param> /// <param name="EqType">Temperature" for temperature equation. "MassFraction" for a MassFraction balance</param> /// <param name="physicsMode"></param> /// <param name="phystime"></param> /// <param name="unsteady"></param> /// <param name="SpeciesIndex">(optional). Necessary for "MassFraction" EqType. Species index: 0 for fuel, 1 for oxidizer, 2 for CO2 and 3 for H2O.</param> /// </summary> public RHSManuSourceTransportEq(double HeatReleaseFactor, double Reynolds, double Prandtl, double Schmidt, double[] StoichiometricCoefficients, double[] ReactionRateConstants, double[] MolarMasses, double OneOverMolarMass0MolarMass1, MaterialLaw EoS, String EqType, PhysicsMode physicsMode, double phystime, bool unsteady, SinglePhaseField ThermodynamicPressure, int SpeciesIndex = -1) { this.HeatReleaseFactor = HeatReleaseFactor; this.ReynoldsNumber = Reynolds; this.PrandtlNumber = Prandtl; this.SchmidtNumber = Schmidt; this.Eos = EoS; this.EqType = EqType; this.physicsMode = physicsMode; this.phystime = phystime; this.unsteady = unsteady; if (EqType == "MassFraction") { this.SpeciesIndex = SpeciesIndex; this.StoichiometricCoeff = StoichiometricCoefficients[SpeciesIndex]; } this.PreExpFactor = ReactionRateConstants[0]; this.ActivationTemperature = ReactionRateConstants[1]; this.MassFraction0Exponent = ReactionRateConstants[2]; this.MassFraction1Exponent = ReactionRateConstants[3]; this.MolarMasses = MolarMasses; this.OneOverMolarMass0MolarMass1 = OneOverMolarMass0MolarMass1; this.ThermodynamicPressure = ThermodynamicPressure; }
/// <summary> /// Ctor for low Mach number flows. /// </summary> /// <param name="Component"></param> /// <param name="Bcmap"></param> /// <param name="EoS"></param> public Divergence_CentralDifference(int Component, IncompressibleBoundaryCondMap Bcmap, MaterialLaw EoS, int NumberOfReactants = -1) : this(Component, Bcmap) { this.EoS = EoS; switch (Bcmap.PhysMode) { case PhysicsMode.Incompressible: case PhysicsMode.Multiphase: throw new ApplicationException("Wrong constructor"); case PhysicsMode.LowMach: this.m_ParamterOrdering = new string[] { VariableNames.Temperature0 }; break; case PhysicsMode.Combustion: this.m_ParamterOrdering = ArrayTools.Cat(new string[] { VariableNames.Temperature0 }, VariableNames.MassFractions0(NumberOfReactants)); this.NumberOfReactants = NumberOfReactants; if (NumberOfReactants == -1) { throw new ArgumentException("NumberOfReactants must be specified for combustion flows."); } break; default: throw new NotImplementedException(); } }
/// <summary> /// Ctor. /// </summary> /// <param name="Reynolds"></param> /// <param name="Schmidt"></param> /// <param name="EoS">Material law</param> /// <param name="PenaltyBase">C.f. Calculation of SIP penalty base, cf. Chapter 3 in /// K. Hillewaert, “Development of the discontinuous Galerkin method for high-resolution, large scale CFD and acoustics in industrial geometries”, /// Université catholique de Louvain, 2013.</param> /// <param name="BcMap">Boundary condition map</param> /// <param name="Mode">Equation type. Can be Temperature or MassFraction</param> /// <param name="Argument">The argument of the flux. Must be compatible with the DiffusionMode.</param> /// <param name="PenaltyLengthScales"></param> public SIPDiffusion(double Reynolds, double Schmidt, MaterialLaw EoS, double PenaltyBase, MultidimensionalArray PenaltyLengthScales, IncompressibleBoundaryCondMap BcMap, DiffusionMode Mode, string Argument) { this.m_Reynolds = Reynolds; this.m_Schmidt = Schmidt; this.EoS = EoS; this.PenaltyBase = PenaltyBase; this.BcMap = BcMap; this.ArgumentFunction = BcMap.bndFunction[Argument]; this.Mode = Mode; this.Argument = Argument; this.cj = PenaltyLengthScales; switch (BcMap.PhysMode) { case PhysicsMode.LowMach: this.m_ParameterOrdering = new string[] { VariableNames.Temperature0 }; break; case PhysicsMode.Combustion: this.m_ParameterOrdering = new string[] { VariableNames.Temperature0, VariableNames.MassFraction0_0, VariableNames.MassFraction1_0, VariableNames.MassFraction2_0, VariableNames.MassFraction3_0 }; break; default: throw new ApplicationException("Wrong physicsMode"); } }
/// <summary> /// Ctor. /// <param name="EoS">The material law</param> /// <param name="conti">Set conti: true for the continuity equation</param> /// </summary> public TimeDerivativeLinearSource(MaterialLaw EoS, double TimeStepSize, String[] ArgumentOrdering, String[] ParameterOrdering, bool conti = false) { m_ArgumentOrdering = ArgumentOrdering; m_ParameterOrdering = ParameterOrdering; this.EoS = EoS; dt = TimeStepSize; m_conti = conti; }
/// <summary> /// Ctor. /// </summary> /// <param name="HeatReleaseFactor">Heat release computed from the sum of the product of the stoichiometric coefficient, partial heat capacity and molar mass of species alpha for all species. I.e.: sum(alpha = 1.. ns)[v_\alpha cp_alpha M_alpha]. Must be computed locally for non-constant partial heat capacities in later iterations of the code.</param> /// <param name="ReactionRateConstants">0. PreExpFactor/Damköhler number, 1. ActivationTemperature, 2. MassFraction0Exponent, 3. MassFraction1Exponent</param> /// <param name="OneOverMolarMass0MolarMass1"> 1/(M_infty^(a + b -1) * MolarMassFuel^a * MolarMassOxidizer^b). M_infty is the reference for the molar mass steming from non-dimensionalisation of the governing equations.</param> /// <param name="EoS">MaterialLawCombustion</param> public ReactionHeatSourceLinearized(double HeatReleaseFactor, double[] ReactionRateConstants, double OneOverMolarMass0MolarMass1, MaterialLaw EoS) { m_ArgumentOrdering = new string[] { VariableNames.Temperature }; m_ParameterOrdering = new string[] { VariableNames.Temperature0, VariableNames.MassFraction0_0, VariableNames.MassFraction1_0, VariableNames.MassFraction2_0, VariableNames.MassFraction3_0 }; this.HeatReleaseFactor = HeatReleaseFactor; this.ReactionRateConstants = ReactionRateConstants; this.OneOverMolarMass0MolarMass1 = OneOverMolarMass0MolarMass1; this.EoS = EoS; }
/// <summary> /// Ctor. /// </summary> /// <param name="Reynolds"></param> /// <param name="Prandtl"></param> /// <param name="EoS"></param> /// <param name="PenaltyBase"></param> /// <param name="BcMap"></param> public swipHeatConduction(double Reynolds, double Prandtl, MaterialLaw EoS, double PenaltyBase, IncompressibleBoundaryCondMap BcMap) { this.Reynolds = Reynolds; this.Prandtl = Prandtl; this.EoS = EoS; this.PenaltyBase = PenaltyBase; this.BcMap = BcMap; this.TemperatureFunction = BcMap.bndFunction[VariableNames.Temperature]; }
/// <summary> /// Ctor. /// </summary> /// <param name="Reynolds"></param> /// <param name="Schmidt"></param> /// <param name="EoS">Material law</param> /// <param name="PenaltyBase">C.f. Calculation of SIP penalty base, cf. Chapter 3 in /// K. Hillewaert, “Development of the discontinuous Galerkin method for high-resolution, large scale CFD and acoustics in industrial geometries”, /// Université catholique de Louvain, 2013.</param> /// <param name="BcMap">Boundary condition map</param> /// <param name="Mode">Equation type. Can be Temperature or MassFraction</param> /// <param name="Argument">The argument of the flux. Must be compatible with the DiffusionMode.</param> /// <param name="PenaltyLengthScales"></param> public SIPDiffusion(double Reynolds, double Schmidt, MaterialLaw EoS, double PenaltyBase, MultidimensionalArray PenaltyLengthScales, IncompressibleBoundaryCondMap BcMap, DiffusionMode Mode, string Argument) { this.Reynolds = Reynolds; this.Schmidt = Schmidt; this.EoS = EoS; this.PenaltyBase = PenaltyBase; this.BcMap = BcMap; this.ArgumentFunction = BcMap.bndFunction[Argument]; this.Mode = Mode; this.Argument = Argument; this.cj = PenaltyLengthScales; }
/// <summary> /// Ctor. /// </summary> /// <param name="ReactionRateConstants">constants[0]=PreExpFactor, constants[1]=ActivationTemperature, constants[2]=MassFraction0Exponent, constants[3]=MassFraction1Exponent</param> /// <param name="StoichiometricCoefficients"></param> /// <param name="OneOverMolarMass0MolarMass1"> 1/(M_infty^(a + b -1) * MolarMassFuel^a * MolarMassOxidizer^b). M_infty is the reference for the molar mass steming from non-dimensionalisation of the governing equations.</param> /// <param name="MolarMasses">Array of molar masses. 0 Fuel. 1 Oxidizer, 2 to ns products.</param> /// <param name="EoS">MaterialLawCombustion</param> /// <param name="NumerOfReactants">The number of reactants (i.e. ns)</param> /// <param name="SpeciesIndex">Index of the species being balanced. (I.e. 0 for fuel, 1 for oxidizer, 2 for CO2, 3 for water)</param> public ReactionSpeciesSourceLinearized(double[] ReactionRateConstants, double[] StoichiometricCoefficients, double OneOverMolarMass0MolarMass1, double[] MolarMasses, MaterialLaw EoS, int NumberOfReactants, int SpeciesIndex) { MassFractionNames = new string[] { VariableNames.MassFraction0, VariableNames.MassFraction1, VariableNames.MassFraction2, VariableNames.MassFraction3 }; m_ArgumentOrdering = new string[] { MassFractionNames[SpeciesIndex] }; this.StoichiometricCoefficients = StoichiometricCoefficients; this.ReactionRateConstants = ReactionRateConstants; this.SpeciesIndex = SpeciesIndex; this.NumberOfReactants = NumberOfReactants; this.OneOverMolarMass0MolarMass1 = OneOverMolarMass0MolarMass1; this.MolarMasses = MolarMasses; this.EoS = EoS; }
/// <summary> /// Ctor /// </summary> /// <param name="SpatDim">Spatial dimension (either 2 or 3)</param> /// <param name="BcMap"></param> /// <param name="EoS">Null for multiphase. Has to be given for Low-Mach and combustion to calculate density.</param> /// <param name="Argument">Variable name of the argument (e.g. "Temperature" or "MassFraction0")</param> public LinearizedScalarConvection2(int SpatDim, int NumberOfReactants, IncompressibleBoundaryCondMap BcMap, MaterialLaw EoS, string Argument = null) { this.NumberOfReactants = NumberOfReactants; m_SpatialDimension = SpatDim; m_bcmap = BcMap; switch (BcMap.PhysMode) { case PhysicsMode.Multiphase: this.Argument = VariableNames.LevelSet; m_ArgumentOrdering = new string[] { VariableNames.LevelSet }; m_ParameterOrdering = ArrayTools.Cat(VariableNames.Velocity0Vector(SpatDim), VariableNames.Velocity0MeanVector(SpatDim)); break; case PhysicsMode.LowMach: this.Argument = VariableNames.Temperature; m_ParameterOrdering = ArrayTools.Cat(VariableNames.Velocity0Vector(SpatDim), VariableNames.Velocity0MeanVector(SpatDim), VariableNames.Temperature0, VariableNames.Temperature0Mean); m_ArgumentOrdering = new string[] { VariableNames.Temperature }; if (EoS == null) { throw new ApplicationException("EoS has to be given for Low-Mach flows to calculate density."); } else { this.EoS = EoS; } break; case PhysicsMode.Combustion: this.Argument = Argument; m_ParameterOrdering = ArrayTools.Cat( VariableNames.Velocity0Vector(SpatDim), VariableNames.Velocity0MeanVector(SpatDim), VariableNames.Temperature0, VariableNames.MassFractions0(NumberOfReactants), VariableNames.Temperature0Mean, VariableNames.MassFractionsMean(NumberOfReactants)); m_ArgumentOrdering = new string[] { Argument }; if (EoS == null) { throw new ApplicationException("EoS has to be given for Low-Mach flows to calculate density."); } else { this.EoS = EoS; } break; default: throw new NotImplementedException(); } }
/// <summary> /// Ctor. /// </summary> /// <param name="SpatDimension"></param> /// <param name="EoS"></param> /// <param name="bcmap"></param> public CoupledLaxFriedrichsScalar(int SpatDimension, MaterialLaw EoS, IncompressibleBoundaryCondMap bcmap) { this.SpatDimension = SpatDimension; this.EoS = EoS; this.bcmap = bcmap; velFunction = new Func <double[], double, double> [GridCommons.FIRST_PERIODIC_BC_TAG, SpatDimension]; for (int d = 0; d < SpatDimension; d++) { velFunction.SetColumn(bcmap.bndFunction[VariableNames.Velocity_d(d)], d); } scalarFunction = bcmap.bndFunction[VariableNames.LevelSet]; }
/// <summary> /// Ctor for variable density flows, /// i.e. low Mach number flows and /// multiphase flows with smooth interface. /// </summary> /// <param name="SpatDim"> /// Spatial dimension (either 2 or 3). /// </param> /// <param name="_bcmap"></param> /// <param name="_component"></param> /// <param name="EoS"> /// Material law for variable density flows. /// </param> public LinearizedConvection(int SpatDim, IncompressibleBoundaryCondMap _bcmap, int _component, MaterialLaw EoS, int NumberOfReactants = -1) : this(SpatDim, _bcmap, _component) { //m_VariableDensity = true; this.EoS = EoS; this.NumberOfReactants = NumberOfReactants; switch (_bcmap.PhysMode) { case PhysicsMode.LowMach: scalarFunction = m_bcmap.bndFunction[VariableNames.Temperature]; m_ParameterOrdering = ArrayTools.Cat(VariableNames.Velocity0Vector(SpatDim), VariableNames.Velocity0MeanVector(SpatDim), VariableNames.Temperature0, VariableNames.Temperature0Mean); break; case PhysicsMode.Multiphase: scalarFunction = m_bcmap.bndFunction[VariableNames.LevelSet]; m_ParameterOrdering = ArrayTools.Cat(VariableNames.Velocity0Vector(SpatDim), VariableNames.Velocity0MeanVector(SpatDim), VariableNames.Phi0, VariableNames.Phi0Mean); break; case PhysicsMode.Combustion: if (NumberOfReactants == -1) { throw new ArgumentException("NumberOfReactants needs to be specified!"); } m_ParameterOrdering = ArrayTools.Cat( VariableNames.Velocity0Vector(SpatDim), VariableNames.Velocity0MeanVector(SpatDim), VariableNames.Temperature0, VariableNames.MassFractions0(NumberOfReactants), VariableNames.Temperature0Mean, VariableNames.MassFractionsMean(NumberOfReactants)); break; case PhysicsMode.Viscoelastic: throw new ApplicationException("Using of wrong constructor for viscoelastic flows."); case PhysicsMode.Incompressible: throw new ApplicationException("Using of wrong constructor for incompressible flows."); default: throw new NotImplementedException(); } }
/// <summary> /// Ctor. /// </summary> /// <param name="GravityDirection">Unit vector for spatial direction of gravity.</param> /// <param name="SpatialComponent">Spatial component of source.</param> /// <param name="Froude">Dimensionless Froude number.</param> /// <param name="EoS">Equation of state for calculating density.</param> public Buoyancy(double[] GravityDirection, int SpatialComponent, double Froude, MaterialLaw EoS) { // Check direction double sum = 0.0; for (int i = 0; i < GravityDirection.Length; i++) { sum += GravityDirection[i] * GravityDirection[i]; } double DirectionNorm = Math.Sqrt(sum); if ((DirectionNorm - 1.0) > 1.0e-13) { throw new ArgumentException("Length of GravityDirection vector has to be 1.0"); } // Initialize this.GravityDirection = GravityDirection; this.SpatialComponent = SpatialComponent; this.Froude = Froude; this.EoS = EoS; }
/// <summary> /// Ctor /// </summary> /// <param name="SpatDim">Spatial dimension (either 2 or 3)</param> /// <param name="BcMap"></param> /// <param name="EoS"> /// Null for multiphase. /// Has to be given for Low-Mach to calculate density. /// </param> public LinearizedScalarConvection(int SpatDim, IncompressibleBoundaryCondMap BcMap, MaterialLaw EoS) { m_SpatialDimension = SpatDim; m_bcmap = BcMap; velFunction = new Func <double[], double, double> [SpatDim][]; for (int d = 0; d < SpatDim; d++) { velFunction[d] = m_bcmap.bndFunction[VariableNames.Velocity_d(d)]; } switch (BcMap.PhysMode) { case PhysicsMode.Multiphase: scalarFunction = m_bcmap.bndFunction[VariableNames.LevelSet]; m_ArgumentOrdering = new string[] { VariableNames.LevelSet }; m_ParameterOrdering = ArrayTools.Cat(VariableNames.Velocity0Vector(SpatDim), VariableNames.Velocity0MeanVector(SpatDim)); break; case PhysicsMode.LowMach: case PhysicsMode.Combustion: scalarFunction = m_bcmap.bndFunction[VariableNames.Temperature]; m_ArgumentOrdering = new string[] { VariableNames.Temperature }; m_ParameterOrdering = ArrayTools.Cat(VariableNames.Velocity0Vector(SpatDim), VariableNames.Velocity0MeanVector(SpatDim), VariableNames.Temperature0, VariableNames.Temperature0Mean); if (EoS == null) { throw new ApplicationException("EoS has to be given for Low-Mach flows to calculate density."); } else { this.EoS = EoS; } break; default: throw new NotImplementedException(); } }
/// <summary> /// Ctor. /// </summary> /// <param name="GridDat"></param> /// <param name="Temperature"></param> /// <param name="EoS"></param> /// <param name="edgeTagNames"></param> public NusseltNumber(IGridData GridDat, SinglePhaseField Temperature, MaterialLaw EoS, string[] edgeTagNames) { this.GridDat = GridDat; this.Temperature = Temperature; //Basis BasisDerivative = new Basis(GridDat, Temperature.Basis.Degree - 1); Basis BasisDerivative = new Basis(GridDat, Temperature.Basis.Degree); dTdx = new SinglePhaseField(BasisDerivative); dTdy = new SinglePhaseField(BasisDerivative); NusseltIntegrals = new EdgeIntegral[edgeTagNames.Length]; Nusselt = new double[edgeTagNames.Length]; for (int bc = 0; bc < edgeTagNames.Length; bc++) { NusseltIntegrals[bc] = new EdgeIntegral((BoSSS.Foundation.Grid.Classic.GridData)GridDat, edgeTagNames[bc], new NusseltFlux2D(EoS), new CoordinateMapping(dTdx, dTdy, Temperature), 20); } }
/// <summary> /// Ctor. /// </summary> /// <param name="GravityDirection">Unit vector for spatial direction of gravity.</param> /// <param name="SpatialComponent">Spatial component of source.</param> /// <param name="Froude">Dimensionless Froude number.</param> /// <param name="physicsMode"></param> /// <param name="EoS">Equation of state for calculating density.</param> public Buoyancy(double[] GravityDirection, int SpatialComponent, double Froude, PhysicsMode physicsMode, MaterialLaw EoS) { // Check direction double sum = 0.0; for (int i = 0; i < GravityDirection.Length; i++) { sum += GravityDirection[i] * GravityDirection[i]; } double DirectionNorm = Math.Sqrt(sum); if ((DirectionNorm - 1.0) > 1.0e-13) { throw new ArgumentException("Length of GravityDirection vector has to be 1.0"); } // Initialize this.GravityDirection = GravityDirection; this.SpatialComponent = SpatialComponent; this.Froude = Froude; this.EoS = EoS; this.physicsMode = physicsMode; switch (physicsMode) { case PhysicsMode.LowMach: this.m_ParameterOrdering = new string[] { VariableNames.Temperature0 }; break; case PhysicsMode.Combustion: this.m_ParameterOrdering = new string[] { VariableNames.Temperature0, VariableNames.MassFraction0_0, VariableNames.MassFraction1_0, VariableNames.MassFraction2_0, VariableNames.MassFraction3_0 }; break; default: throw new ApplicationException("wrong physicsmode"); } }
/// <summary> /// ctor for constant density flows /// </summary> /// <param name="EoS"></param> /// <param name="TimeStepSize"></param> /// <param name="ArgumentOrdering"></param> /// <param name="energy"></param> /// <param name="conti"></param> public MassMatrixComponent(String[] ArgumentOrdering) { m_ArgumentOrdering = ArgumentOrdering; this.EoS = null; m_ParameterOrdering = null; }
/// <summary> /// ctor; parameter documentation see <see cref="swipViscosityBase.swipViscosityBase"/>. /// </summary> public swipViscosity_Term3(double _penalty, MultidimensionalArray PenaltyLengthScales, int iComp, int D, IncompressibleBoundaryCondMap bcmap, ViscosityImplementation implMode, ViscosityOption _ViscosityMode, ViscositySolverMode ViscSolverMode = ViscositySolverMode.FullyCoupled, double constantViscosityValue = double.NaN, double reynolds = double.NaN, MaterialLaw EoS = null) : base(_penalty, PenaltyLengthScales, iComp, D, bcmap, implMode, _ViscosityMode, constantViscosityValue, reynolds, EoS) { this.ViscSolverMode = ViscSolverMode; }
/// <summary> /// Ctor /// </summary> /// <param name="SpatDim">Spatial dimension (either 2 or 3)</param> /// <param name="NumberOfReactants"></param> /// <param name="BcMap"></param> /// <param name="EoS">Null for multiphase. Has to be given for Low-Mach and combustion to calculate density.</param> /// <param name="idx">Index of scalar in array, </param> /// <param name="Argument">Variable name of the argument (e.g. "Temperature" or "MassFraction0")</param> public LinearizedScalarConvection2Jacobi(int SpatDim, int NumberOfReactants, IncompressibleBoundaryCondMap BcMap, MaterialLaw EoS, int idx) { this.NumberOfReactants = NumberOfReactants; m_SpatialDimension = SpatDim; m_bcmap = BcMap; argumentIndex = m_SpatialDimension + idx; velFunction = new Func <double[], double, double> [GridCommons.FIRST_PERIODIC_BC_TAG, SpatDim]; for (int d = 0; d < SpatDim; d++) { velFunction.SetColumn(m_bcmap.bndFunction[VariableNames.Velocity_d(d)], d); } switch (BcMap.PhysMode) { case PhysicsMode.Multiphase: //this.Argument = VariableNames.LevelSet; m_ArgumentOrdering = new string[] { VariableNames.LevelSet }; break; case PhysicsMode.LowMach: m_ArgumentOrdering = ArrayTools.Cat(VariableNames.VelocityVector(SpatDim), VariableNames.Temperature); // VelocityX,VelocityY,(VelocityZ), Temperature as variables. if (EoS == null) { throw new ApplicationException("EoS has to be given for Low-Mach flows to calculate density."); } else { this.EoS = EoS; } break; case PhysicsMode.MixtureFraction: ; m_ArgumentOrdering = ArrayTools.Cat(VariableNames.VelocityVector(SpatDim), VariableNames.MixtureFraction); // VelocityX,VelocityY,(VelocityZ), MixtureFraction as variables. if (EoS == null) { throw new ApplicationException("EoS has to be given for Low-Mach flows to calculate density."); } else { this.EoS = EoS; } break; case PhysicsMode.Combustion: m_ArgumentOrdering = ArrayTools.Cat(VariableNames.VelocityVector(SpatDim), VariableNames.Temperature, VariableNames.MassFractions(NumberOfReactants - 1)); // u,v,w,T, Y0,Y1,Y2,Y3 as variables (Y4 is calculated as Y4 = 1- (Y0+Y1+Y2+Y3) if (EoS == null) { throw new ApplicationException("EoS has to be given for Low-Mach flows to calculate density."); } else { this.EoS = EoS; } break; default: throw new NotImplementedException(); } }
public NusseltFlux2D(MaterialLaw EoS) { this.EoS = EoS; }
/// <summary> /// ctor; parameter documentation see <see cref="swipViscosityBase.swipViscosityBase"/>. /// </summary> public swipViscosity_Term2(double _penalty, int iComp, int D, IncompressibleBoundaryCondMap bcmap, ViscosityOption _ViscosityMode, ViscositySolverMode ViscSolverMode = ViscositySolverMode.FullyCoupled, double constantViscosityValue = double.NaN, double reynolds = double.NaN, MaterialLaw EoS = null) : base(_penalty, iComp, D, bcmap, _ViscosityMode, constantViscosityValue, reynolds, EoS) { this.ViscSolverMode = ViscSolverMode; }
/// <summary> /// ctor; parameter documentation see <see cref="swipViscosityBase.swipViscosityBase"/>. /// </summary> public swipViscosity_Term1(double _penalty, int iComp, int D, IncompressibleBoundaryCondMap bcmap, ViscosityOption _ViscosityMode, double constantViscosityValue = double.NaN, double reynolds = double.NaN, MaterialLaw EoS = null) //Func<double, int, int, MultidimensionalArray, double> ComputePenalty = null) : base(_penalty, iComp, D, bcmap, _ViscosityMode, constantViscosityValue, reynolds, EoS) { }
/// <summary> /// ctor. /// </summary> /// <param name="_penaltyBase"></param> /// <param name="iComp"> /// component index /// </param> /// <param name="D"> /// spatial dimension. /// </param> /// <param name="bcmap"></param> /// <param name="_ViscosityMode"> /// see <see cref="ViscosityOption"/> /// </param> /// <param name="constantViscosityValue"> /// Constant value for viscosity. /// Needs to be given for <see cref="ViscosityOption.ConstantViscosity"/>. /// </param> /// <param name="reynolds"> /// Reynolds number for dimensionless formulation. /// Needs to be given for <see cref="ViscosityOption.ConstantViscosityDimensionless"/> and <see cref="ViscosityOption.VariableViscosityDimensionless"/>. /// </param> /// <param name="EoS"> /// Optional material law for calculating the viscosity /// as a function of the level-set. /// Only available for <see cref="ViscosityOption.VariableViscosity"/> and <see cref="ViscosityOption.VariableViscosityDimensionless"/>. /// </param> protected swipViscosityBase( double _penaltyBase, int iComp, int D, IncompressibleBoundaryCondMap bcmap, ViscosityOption _ViscosityMode, double constantViscosityValue = double.NaN, double reynolds = double.NaN, MaterialLaw EoS = null) { //Func<double, int, int, MultidimensionalArray, double> ComputePenalty = null) { this.m_penalty_base = _penaltyBase; //this.m_ComputePenalty = ComputePenalty; this.m_iComp = iComp; this.m_D = D; //this.cj = PenaltyLengthScales; velFunction = D.ForLoop(d => bcmap.bndFunction[VariableNames.Velocity_d(d)]); EdgeTag2Type = bcmap.EdgeTag2Type; this.m_PhysicsMode = bcmap.PhysMode; this.m_ViscosityMode = _ViscosityMode; switch (_ViscosityMode) { case ViscosityOption.ConstantViscosity: if (double.IsNaN(constantViscosityValue)) { throw new ArgumentException("constantViscosityValue is missing!"); } this.m_constantViscosityValue = constantViscosityValue; break; case ViscosityOption.ConstantViscosityDimensionless: if (double.IsNaN(reynolds)) { throw new ArgumentException("reynolds number is missing!"); } this.m_reynolds = reynolds; break; case ViscosityOption.VariableViscosity: this.m_EoS = EoS; break; case ViscosityOption.VariableViscosityDimensionless: if (double.IsNaN(reynolds)) { throw new ArgumentException("reynolds number is missing!"); } this.m_reynolds = reynolds; this.m_EoS = EoS; break; default: throw new NotImplementedException(); } }
/// <summary> /// Lambda for convective operators with variable density, /// i.e. momentum equation for multiphase and Low-Mach flows /// and temperature advection for Low-Mach flows. /// </summary> /// <param name="ScalarMean"></param> /// <param name="VelocityMean"></param> /// <param name="Normal"></param> /// <param name="EoS"></param> /// <param name="FactorTwo"> /// True: Lambda = 2.0 * rho * V_n (used for momentum equation). /// False: Lambda = rho * V_n (used for temperature equation). /// </param> /// <returns> /// </returns> static public double GetLambda(double[] VelocityMean, double[] Normal, MaterialLaw EoS, bool FactorTwo, params double[] ScalarMean) { double rhoMean = EoS.GetDensity(ScalarMean); return(GetLambda(VelocityMean, Normal, FactorTwo, rhoMean)); }