50 void Foam::solvers::twoPhaseSolver::alphaSolve(
const label nAlphaSubCycles)
75 if (nAlphaSubCycles > 1)
78 <<
"Sub-cycling is not supported "
79 "with the CrankNicolson ddt scheme"
90 refCast<const fv::CrankNicolsonDdtScheme<scalar>>(ddtAlpha)
97 <<
"Only Euler and CrankNicolson ddt schemes are supported"
103 const scalar cnCoeff = 1.0/(1.0 + ocCoeff);
105 tmp<surfaceScalarField> phiCN(phi);
113 cnCoeff*phi + (1.0 - cnCoeff)*phi.oldTime()
117 tmp<volScalarField> divU;
129 tmp<volScalarField::Internal>
Su;
130 tmp<volScalarField::Internal>
Sp;
140 ? fv::localEulerDdtScheme<scalar>(
mesh).fvmDdt(alpha1)
141 : fv::EulerDdtScheme<scalar>(
mesh).fvmDdt(alpha1)
143 + fv::gaussConvectionScheme<scalar>
147 upwind<scalar>(
mesh, phiCN)
148 ).fvmDiv(phiCN, alpha1)
153 alpha1Eqn -=
Su() +
fvm::Sp(
Sp() + divU(), alpha1);
158 Info<<
"Phase-1 volume fraction = "
159 << alpha1.weightedAverage(
mesh.
Vsc()).value()
160 <<
" Min(" << alpha1.name() <<
") = " <<
min(alpha1).value()
161 <<
" Max(" << alpha1.name() <<
") = " <<
max(alpha1).value()
164 tmp<surfaceScalarField> talphaPhi1UD(alpha1Eqn.flux());
165 alphaPhi1 = talphaPhi1UD();
167 if (alphaApplyPrevCorr && talphaPhi1Corr0.valid())
169 Info<<
"Applying the previous iteration compression flux" <<
endl;
176 talphaPhi1Corr0.ref(),
181 alphaPhi1 += talphaPhi1Corr0();
185 talphaPhi1Corr0 = talphaPhi1UD;
187 alpha2 = scalar(1) - alpha1;
188 alphaPhi2 = phi - alphaPhi1;
193 for (
int aCorr=0; aCorr<nAlphaCorr; aCorr++)
195 tmp<volScalarField> talpha1CN(alpha1);
200 talpha1CN = alpha1.clone();
202 (cnCoeff*alpha1 + (1.0 - cnCoeff)*alpha1.oldTime())();
206 tmp<surfaceScalarField> talphaPhi1Un(alphaPhi(phiCN(), talpha1CN()));
210 tmp<surfaceScalarField> talphaPhi1Corr(talphaPhi1Un() - alphaPhi1);
221 talphaPhi1Corr.ref(),
235 talphaPhi1Corr.ref(),
244 alphaPhi1 += talphaPhi1Corr();
248 alpha1 = 0.5*alpha1 + 0.5*alpha10;
249 alphaPhi1 += 0.5*talphaPhi1Corr();
254 alphaPhi1 = talphaPhi1Un;
266 (
Su() + divU()*
min(alpha1(), scalar(1)))(),
286 alpha2 = scalar(1) - alpha1;
287 alphaPhi2 = phi - alphaPhi1;
293 if (alphaApplyPrevCorr && MULESCorr)
295 talphaPhi1Corr0 = alphaPhi1 - talphaPhi1Corr0;
298 talphaPhi1Corr0.ref().rename
302 talphaPhi1Corr0.ref().checkIn();
306 talphaPhi1Corr0.clear();
312 != fv::EulerDdtScheme<vector>::typeName
314 != fv::localEulerDdtScheme<vector>::typeName
321 (alphaPhi1 - (1.0 - cnCoeff)*alphaPhi1.oldTime())/cnCoeff;
322 alphaPhi2 = phi - alphaPhi1;
326 Info<<
"Phase-1 volume fraction = "
327 << alpha1.weightedAverage(
mesh.
Vsc()).value()
328 <<
" Min(" << alpha1.name() <<
") = " <<
min(alpha1).value()
329 <<
" Max(" << alpha1.name() <<
") = " <<
max(alpha1).value()
336 const label nAlphaSubCycles = ceil(nAlphaSubCyclesPtr->value(alphaCoNum));
338 if (nAlphaSubCycles > 1)
369 !(++alphaSubCycle).end();
372 alphaSolve(nAlphaSubCycles);
373 talphaPhi1.
ref() += (runTime.deltaT()/totalDeltaT)*alphaPhi1;
376 alphaPhi1 = talphaPhi1();
377 alphaPhi2 = phi - talphaPhi1();
381 alphaSolve(nAlphaSubCycles);
CMULES: Multidimensional universal limiter for explicit corrected implicit solution.
Generic GeometricField class.
static tmp< GeometricField< Type, GeoMesh, PrimitiveField > > New(const word &name, const Internal &, const PtrList< Patch > &, const HashPtrTable< Source > &=HashPtrTable< Source >())
Return a temporary field constructed from name,.
static word groupName(Name name, const word &group)
label timeIndex() const
Return current time index.
virtual label startTimeIndex() const
Return start time index.
A templated 1D list of pointers to objects of type <T>, where the size of the array is known and used...
const Time & time() const
Return the top-level database.
const surfaceScalarField & phi() const
Return cell face motion fluxes.
const fvSchemes & schemes() const
Return the fvSchemes.
tmp< DimensionedField< scalar, volMesh > > Vsc() const
Return sub-cycle cell volumes.
ITstream & ddt(const word &name) const
ITstream & div(const word &name) const
Second-oder Crank-Nicolson implicit ddt using the current and previous time-step fields as well as th...
Basic first-order Euler implicit/explicit ddt using only the current and previous time-step values.
Abstract base class for ddt schemes.
Local time-step first-order Euler implicit/explicit ddt.
static tmp< volScalarField > localRSubDeltaT(const fvMesh &mesh, const label nAlphaSubCycles)
Calculate and return the reciprocal of the local sub-cycling.
bool moving() const
Is mesh moving.
const fvMesh & mesh
Region mesh.
const word divAlphaName
Name of the alpha convection scheme.
const surfaceScalarField & phi
Reference to the mass-flux field.
void alphaPredictor()
Solve for the phase-fractions.
virtual tmp< surfaceScalarField > alphaPhi(const surfaceScalarField &phi, const volScalarField &alpha)
Perform a subCycleTime on a field or list of fields.
A class for managing temporary objects.
T & ref() const
Return non-const reference or generate a fatal error.
Foam::fvMesh mesh(Foam::IOobject(regionName, runTime.name(), runTime, Foam::IOobject::MUST_READ), false)
#define FatalErrorInFunction
Report an error message using Foam::FatalError.
Calculate the face-flux of the given field.
Calculate the matrix for implicit and explicit sources.
volScalarField alpha(IOobject("alpha", runTime.name(), mesh, IOobject::READ_IF_PRESENT, IOobject::AUTO_WRITE), lambda *max(Ua &U, zeroSensitivity))
void correct(const RdeltaTType &rDeltaT, const RhoType &rho, volScalarField &psi, const surfaceScalarField &phiCorr, const SpType &Sp)
void explicitSolve(const RdeltaTType &rDeltaT, const RhoType &rho, volScalarField &psi, const surfaceScalarField &psiPhi, const SpType &Sp, const SuType &Su)
tmp< SurfaceField< typename innerProduct< vector, Type >::type > > flux(const VolField< Type > &vf)
Return the face-flux field obtained from the given volVectorField.
tmp< VolField< Type > > Su(const VolField< Type > &su, const VolField< Type > &vf)
tmp< VolField< Type > > Sp(const volScalarField &sp, const VolField< Type > &vf)
tmp< VolField< Type > > div(const SurfaceField< Type > &ssf)
tmp< fvMatrix< Type > > Sp(const volScalarField::Internal &, const VolField< Type > &)
errorManipArg< error, int > exit(error &err, const int errNo=1)
intWM_LABEL_SIZE_t label
A label is an int32_t or int64_t as specified by the pre-processor macro WM_LABEL_SIZE.
Ostream & endl(Ostream &os)
Add newline and flush stream.
fvMatrix< scalar > fvScalarMatrix
bool isType(const Type &t)
Check the typeid.
layerAndWeight min(const layerAndWeight &a, const layerAndWeight &b)
VolField< scalar > volScalarField
layerAndWeight max(const layerAndWeight &a, const layerAndWeight &b)
dimensioned< scalar > dimensionedScalar
Dimensioned scalar obtained from generic dimensioned type.