/// <summary> /// Create Operators for Nonconservative Advection /// </summary> public ExplicitNonconservativeAdvection(SinglePhaseField LevelSet, VectorFieldHistory <SinglePhaseField> Velocity, IncompressibleBoundaryCondMap BcMap, bool AssumeDivergenceFreeVelocity = false) : base(LevelSet, BcMap, AssumeDivergenceFreeVelocity) { this.Velocity = Velocity; VelocityInterpolation = new VectorField <SinglePhaseField>(D.ForLoop(d => new SinglePhaseField(Velocity.Current[d].Basis, "VelocityInterpolation" + d))); MeanVelocity = new VectorField <SinglePhaseField>(D.ForLoop(d => new SinglePhaseField(new Basis(GridDat, 0), VariableNames.Velocity0MeanVector(D)[d]))); SpatialOperator Lsevo = CreateAdvectionSpatialOperator(BcMap); DGField[] ParamFields; if (!divUzero) { ParamFields = ArrayTools.Cat(this.Velocity.Current, this.MeanVelocity, this.divU); } else { ParamFields = ArrayTools.Cat(this.Velocity.Current, this.MeanVelocity); } TimeEvo = new RungeKutta(RungeKuttaScheme.TVD3, Lsevo, this.LevelSet.Mapping, new CoordinateMapping(ParamFields)); TimeEvo.OnBeforeComputeChangeRate += RKParamterUpdate; }
/// <summary> /// Spatial Operators and Matrices /// </summary> /// with /// <param name="bcMap">Boundary Conditions</param> public SpatialOperator CreateAdvectionSpatialOperator(IncompressibleBoundaryCondMap bcMap) { Func <int[], int[], int[], int> QuadOrderFunction = QuadOrderFunc.SumOfMaxDegrees(); string[] parameterList; parameterList = ArrayTools.Cat(VariableNames.Velocity0Vector(D), VariableNames.Velocity0MeanVector(D)); if (!divUzero) { parameterList = ArrayTools.Cat(parameterList, "div(U)"); } SpatialOperator SO = new SpatialOperator(new string[] { "LevelSet" }, parameterList, new string[] { "Phi-Evo" }, QuadOrderFunc.NonLinear(2)); //div(u.phi) //SO.EquationComponents["Phi-Evo"].Add(new LevelSetUpwindFlux(GridDat, bcMap)); SO.EquationComponents["Phi-Evo"].Add(new LevelSetLLFFlux(GridDat, bcMap)); //bcMap.PhysMode = PhysicsMode.Multiphase; //SO.EquationComponents["Phi-Evo"].Add(new LinearizedScalarConvection(D, bcMap,null)); //SO.EquationComponents["Phi-Evo"].Add(new LevelSetAdvectionCentralFlux(D)); //-phi*div(u) if (!divUzero) { SO.EquationComponents["Phi-Evo"].Add(new FextSource()); } //penalization //Lsevo.EquationComponents["Phi-Evo"].Add(new JumpPenalization.GradientJumpForm2()); SO.Commit(); return(SO); }
/// <summary> /// ctr /// </summary> /// <param name="LevelSet">the level-set which is to be moved</param> /// <param name="bcMap">boundary conditions</param> /// <param name="AssumeDivergenceFreeVelocity">switch for the nonlinear term on the rhs due to non-divergence free velocity fields</param> public VectorVelocityLevelSetAdvection(SinglePhaseField LevelSet, IncompressibleBoundaryCondMap bcMap, bool AssumeDivergenceFreeVelocity = false) { GridDat = (GridData)(LevelSet.Basis.GridDat); D = GridDat.SpatialDimension; this.LevelSet = LevelSet; divUzero = AssumeDivergenceFreeVelocity; divU = new SinglePhaseField(LevelSet.Basis); }
public LevelSetAdvectionFlux(GridData GridDat, IncompressibleBoundaryCondMap BcMap) { this.GridDat = GridDat; D = this.GridDat.SpatialDimension; this.BcMap = BcMap; VelFunction = new Func <double[], double, double> [GridCommons.FIRST_PERIODIC_BC_TAG, D]; for (int d = 0; d < D; d++) { VelFunction.SetColumn(this.BcMap.bndFunction[VariableNames.Velocity_d(d)], d); } LevelSetFunction = this.BcMap.bndFunction[VariableNames.LevelSet]; }
public ConvectionAtIB(int _d, int _D, LevelSetTracker LsTrk, double _LFFA, IncompressibleBoundaryCondMap _bcmap, Func <double[], double, double[]> getParticleParams, double fluidDensity, bool UseMovingMesh) { m_LsTrk = LsTrk; m_D = _D; m_d = _d; LFFA = _LFFA; this.m_getParticleParams = getParticleParams; //varMode = _varMode; fDensity = fluidDensity; m_UseMovingMesh = UseMovingMesh; NegFlux = new LinearizedConvection(_D, _bcmap, _d); //NegFlux = new ConvectionInBulk_LLF(_D, _bcmap, _d, fluidDensity, 0, _LFFA, double.NaN, LsTrk); //NegFlux.SetParameter("A", LsTrk.GetSpeciesId("A"), null); }
public LevelSetMover(DGField[] _Velocity, VectorFieldHistory <SinglePhaseField> FilteredVelocity, LevelSetTracker _LsTrk, XVelocityProjection.CutCellVelocityProjectiontype _CutCellVelocityProjectiontype, ScalarFieldHistory <SinglePhaseField> _DGLevSet, IncompressibleBoundaryCondMap BcMap) { this.Velocity = _Velocity; this.LsTrk = _LsTrk; this.DGLevSet = _DGLevSet; this.FilteredVelocity = FilteredVelocity; VelocityFilter = new XVelocityProjection(_LsTrk, Velocity, FilteredVelocity.Current); VelocityFilter.Config.CutCellVelocityProjectiontype = _CutCellVelocityProjectiontype; //Advection = new ImplicitNonconservativeAdvection(DGLevSet.Current, FilteredVelocity.Current, BcMap); //Advection = new ImplicitNonconservativeAdvection(DGLevSet.Current, FilteredVelocity.Current, BcMap, AssumeDivergenceFreeVelocity: true); Advection = new ExplicitNonconservativeAdvection(DGLevSet.Current, FilteredVelocity, BcMap, AssumeDivergenceFreeVelocity: true); }
SpatialOperator CreateAdvectionSpatialOperator(IncompressibleBoundaryCondMap bcMap) { Func <int[], int[], int[], int> QuadOrderFunction = QuadOrderFunc.SumOfMaxDegrees(); string[] parameterList; parameterList = ArrayTools.Cat( VariableNames.Velocity0Vector(D), VariableNames.Velocity0MeanVector(D), "div(U)"); SpatialOperator SO = new SpatialOperator(new string[] { "LevelSet" }, parameterList, new string[] { "Phi-Evo" }, QuadOrderFunc.NonLinear(2)); //div(u*phi) SO.EquationComponents["Phi-Evo"].Add(new LevelSetLLFFlux(GridDat, bcMap)); //-phi*div(u) SO.EquationComponents["Phi-Evo"].Add(new FextSource()); SO.Commit(); return(SO); }
protected override void CreateEquationsAndSolvers(GridUpdateDataVaultBase L) { using (FuncTrace tr = new FuncTrace()) { this.BcMap = new IncompressibleBoundaryCondMap(this.GridData, grid.GetBoundaryConfig(), PhysicsMode.Incompressible); // assemble system, create matrix // ------------------------------ int D = GridData.SpatialDimension; //double penalty_base = ((double)((U[0].Basis.Degree + 1) * (U[0].Basis.Degree + D))) / ((double)D); double penalty_base = 1.0; double penalty_factor = 1.2; // equation assembly // ----------------- string[] CodNames = D.ForLoop(i => "C" + i); Operator = new SpatialOperator(VariableNames.VelocityVector(D), new string[] { VariableNames.ViscosityMolecular }, CodNames, QuadOrderFunc.Linear()); for (int d = 0; d < D; d++) { if ((this.whichTerms & Terms.T1) != 0) { var flx1 = new swipViscosity_Term1(penalty_base * penalty_factor, d, D, BcMap, ViscosityOption.VariableViscosity); flx1.g_Diri_Override = this.solution.U; flx1.g_Neu_Override = this.solution.dU; Operator.EquationComponents[CodNames[d]].Add(flx1); } if ((this.whichTerms & Terms.T2) != 0) { var flx2 = new swipViscosity_Term2(penalty_base * penalty_factor, d, D, BcMap, ViscosityOption.VariableViscosity); flx2.g_Diri_Override = this.solution.U; flx2.g_Neu_Override = this.solution.dU; Operator.EquationComponents[CodNames[d]].Add(flx2); } if ((this.whichTerms & Terms.T3) != 0) { var flx3 = new swipViscosity_Term3(penalty_base * penalty_factor, d, D, BcMap, ViscosityOption.VariableViscosity); flx3.g_Diri_Override = this.solution.U; flx3.g_Neu_Override = this.solution.dU; Operator.EquationComponents[CodNames[d]].Add(flx3); } } // */ Operator.Commit(); var map = this.U.Mapping; OperatorMtx = new MsrMatrix(map, map); Operator.ComputeMatrixEx(map, new DGField[] { this.mu }, map, OperatorMtx, this.bnd.CoordinateVector, volQuadScheme: null, edgeQuadScheme: null); // test for matrix symmetry // ======================== if (base.MPISize == 1) { double MatrixAssymmetry = OperatorMtx.SymmetryDeviation(); Console.WriteLine("Matrix asymmetry: " + MatrixAssymmetry); Assert.LessOrEqual(Math.Abs(MatrixAssymmetry), 1.0e-10); } } }
public FSI_ConvectionAtIB(int currentDim, int spatialDim, LevelSetTracker LsTrk, IncompressibleBoundaryCondMap _bcmap, Func <double[], double[]> getParticleParams, bool useMovingMesh) { m_LsTrk = LsTrk; m_D = spatialDim; m_d = currentDim; m_getParticleParams = getParticleParams; m_UseMovingMesh = useMovingMesh; NegFlux = new LinearizedConvection(spatialDim, _bcmap, currentDim); }
/// <summary> /// ctor; parameter documentation see <see cref="swipViscosityBase.swipViscosityBase"/>. /// </summary> public swipViscosity_Term1_variante(double _penalty, int iComp, int D, IncompressibleBoundaryCondMap bcmap, ViscosityOption _ViscosityMode, double constantViscosityValue = double.NaN, double reynolds = double.NaN, MaterialLaw EoS = null) : base(_penalty, iComp, D, bcmap, _ViscosityMode, constantViscosityValue, reynolds, EoS) { }
public LevelSetLLFFlux(GridData GridDat, IncompressibleBoundaryCondMap BcMap) : base(GridDat, BcMap) { }
public ExtensionVelocityBDFMover(LevelSetTracker LSTrk, SinglePhaseField LevelSet, VectorField <SinglePhaseField> LevelSetGradient, VectorField <DGField> Velocity, EllipticExtVelAlgoControl Control, IncompressibleBoundaryCondMap bcMap, int BDForder, VectorField <SinglePhaseField> VectorExtension, double[] Density = null, bool AssumeDivergenceFreeVelocity = false, SubGrid subGrid = null) { this.GridDat = LSTrk.GridDat; D = GridDat.SpatialDimension; this.LevelSetGradient = LevelSetGradient; this.LSTrk = LSTrk; this.LevelSet = LevelSet; this.Velocity = Velocity; this.OldRHS = LevelSet.CloneAs(); this.AdvectionSpatialOperator = CreateAdvectionSpatialOperator(bcMap); this.subGrid = subGrid; this.nearfield = subGrid != null; Basis NonXVelocityBasis; if (Velocity == null) { throw new ArgumentException("Velocity Field not initialized!"); } // Initialize Extension Velocity Algorithm double PenaltyBase = Control.PenaltyMultiplierInterface * ((double)((LevelSet.Basis.Degree + 1) * (LevelSet.Basis.Degree + D))) / ((double)D); ILevelSetForm InterfaceFlux; //VectorExtension = new VectorField<SinglePhaseField>(D, Velocity[0].Basis, "ExtVel", SinglePhaseField.Factory); if (Velocity[0].GetType() == typeof(SinglePhaseField)) { NonXVelocityBasis = ((SinglePhaseField)Velocity[0]).Basis; InterfaceFlux = new SingleComponentInterfaceForm(PenaltyBase, LSTrk); } else if (Velocity[0].GetType() == typeof(XDGField)) { NonXVelocityBasis = ((XDGField)Velocity[0]).Basis.NonX_Basis; InterfaceFlux = new DensityWeightedExtVel(PenaltyBase, LSTrk, Density); } else { throw new ArgumentException("VelocityField must be either a SinglePhaseField or a XDGField!"); }; //VectorExtension = new VectorField<SinglePhaseField>(D, NonXVelocityBasis, "ExtVel", SinglePhaseField.Factory); this.VectorExtension = VectorExtension; VelocityExtender = new Extender[D]; for (int d = 0; d < D; d++) { VelocityExtender[d] = new Extender(VectorExtension[d], LSTrk, InterfaceFlux, new List <DGField> { Velocity[d] }, LevelSetGradient, Control); VelocityExtender[d].ConstructExtension(new List <DGField> { Velocity[d] }, Control.subGridRestriction); } #if DEBUG VectorExtension.CheckForNanOrInf(); #endif // Initialize Advection Algorithm divU = new SinglePhaseField(NonXVelocityBasis); divU.Identification = "Divergence"; divU.Clear(); divU.Divergence(1.0, VectorExtension); MeanVelocity = new VectorField <SinglePhaseField>(D.ForLoop(d => new SinglePhaseField(new Basis(GridDat, 0), VariableNames.Velocity0MeanVector(D)[d]))); MeanVelocity.Clear(); MeanVelocity.AccLaidBack(1.0, VectorExtension); myBDFTimestepper = new BDFTimestepper(AdvectionSpatialOperator, new List <DGField>() { LevelSet }, ArrayTools.Cat(VectorExtension, this.MeanVelocity, this.divU), BDForder, Control.solverFactory, false, subGrid); }
/// <summary> /// Declaration of the spatial operator /// </summary> protected override SpatialOperator GetOperatorInstance(int D) { // instantiate boundary condition mapping // ====================================== boundaryCondMap = new IncompressibleBoundaryCondMap(this.GridData, this.Control.BoundaryValues, PhysicsMode.Incompressible); // instantiate operator // ==================== string[] CodName = (new[] { "ResidualMomentumX", "ResidualMomentumY", "ResidualMomentumZ" }).GetSubVector(0, D).Cat("ResidualConti"); var op = new SpatialOperator( __DomainVar: VariableNames.VelocityVector(D).Cat(VariableNames.Pressure), __ParameterVar: VariableNames.GravityVector(D), __CoDomainVar: CodName, QuadOrderFunc: QuadOrderFunc.NonLinear(2)); op.LinearizationHint = LinearizationHint.GetJacobiOperator; // Temporal Operator // ================= var TempOp = new ConstantTemporalOperator(op, 0.0); // init with entire diagonal set to 0.0 op.TemporalOperator = TempOp; for (int d = 0; d < D; d++) { TempOp.SetDiagonal(CodName[d], Control.Density); // set momentum equation entries to density } // Pressure Reference // ================== // if there is no Dirichlet boundary condition, // the mean value of the pressure is free: op.FreeMeanValue[VariableNames.Pressure] = !boundaryCondMap.DirichletPressureBoundary; // Momentum Equation // ================= // convective part: { for (int d = 0; d < D; d++) { var comps = op.EquationComponents[CodName[d]]; var ConvBulk = new LocalLaxFriedrichsConvection(D, boundaryCondMap, d, Control.Density); comps.Add(ConvBulk); // bulk component } } // pressure part: { for (int d = 0; d < D; d++) { var comps = op.EquationComponents[CodName[d]]; var pres = new PressureGradientLin_d(d, boundaryCondMap); comps.Add(pres); // bulk component } } // viscous part: { for (int d = 0; d < D; d++) { var comps = op.EquationComponents[CodName[d]]; double penalty_bulk = this.Control.PenaltySafety; var Visc = new swipViscosity_Term1(penalty_bulk, d, D, boundaryCondMap, ViscosityOption.ConstantViscosity, constantViscosityValue: Control.Viscosity); comps.Add(Visc); // bulk component GradUTerm } } // Continuity equation // =================== { for (int d = 0; d < D; d++) { var src = new Divergence_DerivativeSource(d, D); var flx = new Divergence_DerivativeSource_Flux(d, boundaryCondMap); op.EquationComponents[CodName[D]].Add(src); op.EquationComponents[CodName[D]].Add(flx); } //IBM_Op.EquationComponents["div"].Add(new PressureStabilization(1, 1.0 / this.Control.PhysicalParameters.mu_A)); } // Gravity parameter // ================= op.ParameterFactories.Add(delegate(IReadOnlyDictionary <string, DGField> DomainVarFields) { return(D.ForLoop(d => (VariableNames.Gravity_d(d), this.Gravity[d] as DGField))); }); // commit & return // =============== op.Commit(); return(op); }
/// <summary> /// ctor; parameter documentation see <see cref="swipViscosityBase.swipViscosityBase"/>. /// </summary> public swipViscosity_Term1_variante(double _penalty, MultidimensionalArray PenaltyLengthScales, int iComp, int D, IncompressibleBoundaryCondMap bcmap, ViscosityImplementation implMode, ViscosityOption _ViscosityMode, double constantViscosityValue = double.NaN, double reynolds = double.NaN, MaterialLaw EoS = null, Func <double, int, int, MultidimensionalArray, double> ComputePenalty = null) : base(_penalty, PenaltyLengthScales, iComp, D, bcmap, implMode, _ViscosityMode, constantViscosityValue, reynolds, EoS, ComputePenalty) { }
/// <summary> /// Setup and initial evaluation of RHS /// </summary> /// <param name="LevelSet"></param> /// <param name="Velocity"></param> /// <param name="bcMap">Boundary Conditions for LevelSet</param> /// <param name="AssumeDivergenceFreeVelocity">Switch for the source term on the rhs arising from a non divergence-free velocity</param> public BDFNonconservativeAdvection(SinglePhaseField LevelSet, VectorField <SinglePhaseField> Velocity, IncompressibleBoundaryCondMap bcMap, int BDForder, SubGrid subGrid = null, bool AssumeDivergenceFreeVelocity = false) : base(LevelSet, bcMap, AssumeDivergenceFreeVelocity) { this.Velocity = Velocity; this.OldRHS = LevelSet.CloneAs(); this.SO = CreateAdvectionSpatialOperator(bcMap); if (Velocity == null) { throw new ArgumentException("Velocity Field not initialized!"); } MeanVelocity = new VectorField <SinglePhaseField>(D.ForLoop(d => new SinglePhaseField(new Basis(GridDat, 0), VariableNames.Velocity0MeanVector(D)[d]))); MeanVelocity.Clear(); MeanVelocity.AccLaidBack(1.0, Velocity); myBDFTimestepper = new BDFTimestepper(SO, new List <DGField>() { LevelSet }, ArrayTools.Cat(this.Velocity, this.MeanVelocity, this.divU), BDForder, () => new ilPSP.LinSolvers.MUMPS.MUMPSSolver(), false, subGrid); }