diff --git a/applications/solvers/multiphase/interFoam/interDyMFoam/interDyMFoam.C b/applications/solvers/multiphase/interFoam/interDyMFoam/interDyMFoam.C index 8e3500c9d6ad7f80d38c7e360c2dabf5ec2f7ae5..1face6ddd57a9ad664f9a7811403fc8cc49d9a68 100644 --- a/applications/solvers/multiphase/interFoam/interDyMFoam/interDyMFoam.C +++ b/applications/solvers/multiphase/interFoam/interDyMFoam/interDyMFoam.C @@ -58,6 +58,9 @@ int main(int argc, char *argv[]) #include "CourantNo.H" #include "setInitialDeltaT.H" + surfaceScalarField phiAbs("phiAbs", phi); + fvc::makeAbsolute(phiAbs, U); + // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // Info<< "\nStarting time loop\n" << endl; @@ -67,9 +70,6 @@ int main(int argc, char *argv[]) #include "alphaCourantNo.H" #include "CourantNo.H" - // Make the fluxes absolute - fvc::makeAbsolute(phi, U); - #include "setDeltaT.H" runTime++; @@ -78,8 +78,18 @@ int main(int argc, char *argv[]) scalar timeBeforeMeshUpdate = runTime.elapsedCpuTime(); - // Do any mesh changes - mesh.update(); + { + // Calculate the relative velocity used to map the relative flux phi + volVectorField Urel("Urel", U); + + if (mesh.moving()) + { + Urel -= fvc::reconstruct(fvc::meshPhi(U)); + } + + // Do any mesh changes + mesh.update(); + } if (mesh.changing()) { @@ -96,9 +106,6 @@ int main(int argc, char *argv[]) #include "correctPhi.H" } - // Make the fluxes relative to the mesh motion - fvc::makeRelative(phi, U); - if (mesh.changing() && checkMeshCourantNo) { #include "meshCourantNo.H" diff --git a/applications/solvers/multiphase/interFoam/interDyMFoam/pEqn.H b/applications/solvers/multiphase/interFoam/interDyMFoam/pEqn.H index 84c1fe45b6a40666d5a7a1f184da5a1700eab522..4b90d9949929bc3a5b7d761acc8294604c9d4b51 100644 --- a/applications/solvers/multiphase/interFoam/interDyMFoam/pEqn.H +++ b/applications/solvers/multiphase/interFoam/interDyMFoam/pEqn.H @@ -3,16 +3,19 @@ surfaceScalarField rAUf(fvc::interpolate(rAU)); U = rAU*UEqn.H(); - surfaceScalarField phiU("phiU", (fvc::interpolate(U) & mesh.Sf())); + + phiAbs = + (fvc::interpolate(U) & mesh.Sf()) + + fvc::ddtPhiCorr(rAU, rho, U, phiAbs); if (p_rgh.needReference()) { - fvc::makeRelative(phiU, U); - adjustPhi(phiU, U, p_rgh); - fvc::makeAbsolute(phiU, U); + fvc::makeRelative(phiAbs, U); + adjustPhi(phiAbs, U, p_rgh); + fvc::makeAbsolute(phiAbs, U); } - phi = phiU + + phi = phiAbs + ( fvc::interpolate(interface.sigmaK())*fvc::snGrad(alpha1) - ghf*fvc::snGrad(rho) @@ -38,11 +41,13 @@ } } - U += rAU*fvc::reconstruct((phi - phiU)/rAUf); + U += rAU*fvc::reconstruct((phi - phiAbs)/rAUf); U.correctBoundaryConditions(); #include "continuityErrs.H" + phiAbs = phi; + // Make the fluxes relative to the mesh motion fvc::makeRelative(phi, U); diff --git a/src/OpenFOAM/interpolations/interpolateSplineXY/interpolateSplineXY.C b/src/OpenFOAM/interpolations/interpolateSplineXY/interpolateSplineXY.C index a73a7bc4e6d9adbabc61e8503dbda6a925ba38d9..c0720d90cbd345132f13a2c104f6c1d7e3c7c4d7 100644 --- a/src/OpenFOAM/interpolations/interpolateSplineXY/interpolateSplineXY.C +++ b/src/OpenFOAM/interpolations/interpolateSplineXY/interpolateSplineXY.C @@ -40,7 +40,7 @@ Foam::Field<Type> Foam::interpolateSplineXY forAll(xNew, i) { - yNew[i] = interpolateSmoothXY(xNew[i], xOld, yOld); + yNew[i] = interpolateSplineXY(xNew[i], xOld, yOld); } return yNew; diff --git a/src/finiteVolume/cfdTools/general/adjustPhi/adjustPhi.C b/src/finiteVolume/cfdTools/general/adjustPhi/adjustPhi.C index 9eb89527f3e54695fd3589abb72d788dd72cd065..7c72beaf99d5a7c4fea84146b544b018de48d2f3 100644 --- a/src/finiteVolume/cfdTools/general/adjustPhi/adjustPhi.C +++ b/src/finiteVolume/cfdTools/general/adjustPhi/adjustPhi.C @@ -107,7 +107,7 @@ bool Foam::adjustPhi { massCorr = (massIn - fixedMassOut)/adjustableMassOut; } - else if (mag(fixedMassOut - massIn)/totalFlux > 1e-10) + else if (mag(fixedMassOut - massIn)/totalFlux > 1e-8) { FatalErrorIn ( diff --git a/src/turbulenceModels/incompressible/LES/derivedFvPatchFields/wallFunctions/nuSgsWallFunctions/nuSgsUSpaldingWallFunction/nuSgsUSpaldingWallFunctionFvPatchScalarField.C b/src/turbulenceModels/incompressible/LES/derivedFvPatchFields/wallFunctions/nuSgsWallFunctions/nuSgsUSpaldingWallFunction/nuSgsUSpaldingWallFunctionFvPatchScalarField.C index 5f28777553f4786c6bd80d1606af72d31aeea48e..73b89be91da5510c941bf1baf5cfd51941ce9eee 100644 --- a/src/turbulenceModels/incompressible/LES/derivedFvPatchFields/wallFunctions/nuSgsWallFunctions/nuSgsUSpaldingWallFunction/nuSgsUSpaldingWallFunctionFvPatchScalarField.C +++ b/src/turbulenceModels/incompressible/LES/derivedFvPatchFields/wallFunctions/nuSgsWallFunctions/nuSgsUSpaldingWallFunction/nuSgsUSpaldingWallFunctionFvPatchScalarField.C @@ -24,6 +24,7 @@ License \*---------------------------------------------------------------------------*/ #include "nuSgsUSpaldingWallFunctionFvPatchScalarField.H" +#include "LESModel.H" #include "fvPatchFieldMapper.H" #include "volFields.H" #include "addToRunTimeSelectionTable.H" @@ -47,8 +48,6 @@ nuSgsUSpaldingWallFunctionFvPatchScalarField ) : fixedValueFvPatchScalarField(p, iF), - UName_("U"), - nuName_("nu"), kappa_(0.41), E_(9.8) {} @@ -64,8 +63,6 @@ nuSgsUSpaldingWallFunctionFvPatchScalarField ) : fixedValueFvPatchScalarField(ptf, p, iF, mapper), - UName_(ptf.UName_), - nuName_(ptf.nuName_), kappa_(ptf.kappa_), E_(ptf.E_) {} @@ -80,8 +77,6 @@ nuSgsUSpaldingWallFunctionFvPatchScalarField ) : fixedValueFvPatchScalarField(p, iF, dict), - UName_(dict.lookupOrDefault<word>("U", "U")), - nuName_(dict.lookupOrDefault<word>("nu", "nu")), kappa_(dict.lookupOrDefault<scalar>("kappa", 0.41)), E_(dict.lookupOrDefault<scalar>("E", 9.8)) {} @@ -94,8 +89,6 @@ nuSgsUSpaldingWallFunctionFvPatchScalarField ) : fixedValueFvPatchScalarField(nwfpsf), - UName_(nwfpsf.UName_), - nuName_(nwfpsf.nuName_), kappa_(nwfpsf.kappa_), E_(nwfpsf.E_) {} @@ -109,8 +102,6 @@ nuSgsUSpaldingWallFunctionFvPatchScalarField ) : fixedValueFvPatchScalarField(nwfpsf, iF), - UName_(nwfpsf.UName_), - nuName_(nwfpsf.nuName_), kappa_(nwfpsf.kappa_), E_(nwfpsf.E_) {} @@ -123,16 +114,15 @@ void nuSgsUSpaldingWallFunctionFvPatchScalarField::evaluate const Pstream::commsTypes ) { - const scalarField& ry = patch().deltaCoeffs(); + const LESModel& lesModel = db().lookupObject<LESModel>("LESProperties"); + const label patchi = patch().index(); + const fvPatchVectorField& U = lesModel.U().boundaryField()[patchi]; + const scalarField nuw = lesModel.nu()().boundaryField()[patchi]; - const fvPatchVectorField& U = - patch().lookupPatchField<volVectorField, vector>(UName_); + const scalarField& ry = patch().deltaCoeffs(); const scalarField magUp(mag(U.patchInternalField() - U)); - const scalarField& nuw = - patch().lookupPatchField<volScalarField, scalar>(nuName_); - scalarField& nuSgsw = *this; const scalarField magFaceGradU(mag(U.snGrad())); @@ -185,8 +175,6 @@ void nuSgsUSpaldingWallFunctionFvPatchScalarField::evaluate void nuSgsUSpaldingWallFunctionFvPatchScalarField::write(Ostream& os) const { fvPatchField<scalar>::write(os); - writeEntryIfDifferent<word>(os, "U", "U", UName_); - writeEntryIfDifferent<word>(os, "nu", "nu", nuName_); os.writeKeyword("kappa") << kappa_ << token::END_STATEMENT << nl; os.writeKeyword("E") << E_ << token::END_STATEMENT << nl; writeEntry("value", os); @@ -201,6 +189,7 @@ makePatchTypeField nuSgsUSpaldingWallFunctionFvPatchScalarField ); + // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // } // End namespace LESModels diff --git a/src/turbulenceModels/incompressible/LES/derivedFvPatchFields/wallFunctions/nuSgsWallFunctions/nuSgsUSpaldingWallFunction/nuSgsUSpaldingWallFunctionFvPatchScalarField.H b/src/turbulenceModels/incompressible/LES/derivedFvPatchFields/wallFunctions/nuSgsWallFunctions/nuSgsUSpaldingWallFunction/nuSgsUSpaldingWallFunctionFvPatchScalarField.H index 1ebccdc8ca10b2ce12ebffaba571e5bd89f62cf5..11de1fb06f3e72d2cfdb347f7e2aa346b05900a3 100644 --- a/src/turbulenceModels/incompressible/LES/derivedFvPatchFields/wallFunctions/nuSgsWallFunctions/nuSgsUSpaldingWallFunction/nuSgsUSpaldingWallFunctionFvPatchScalarField.H +++ b/src/turbulenceModels/incompressible/LES/derivedFvPatchFields/wallFunctions/nuSgsWallFunctions/nuSgsUSpaldingWallFunction/nuSgsUSpaldingWallFunctionFvPatchScalarField.H @@ -58,12 +58,6 @@ class nuSgsUSpaldingWallFunctionFvPatchScalarField { // Private data - //- Name of velocity field - word UName_; - - //- Name of laminar viscosity field - word nuName_; - //- Von Karman constant scalar kappa_; diff --git a/tutorials/multiphase/interDyMFoam/ras/damBreakWithObstacle/constant/dynamicMeshDict b/tutorials/multiphase/interDyMFoam/ras/damBreakWithObstacle/constant/dynamicMeshDict index 105d0818dd5d21194c8f8ff5ebcc27b01ab597cf..64223ec7b8ff667637b4205292da9e398ecc0f21 100644 --- a/tutorials/multiphase/interDyMFoam/ras/damBreakWithObstacle/constant/dynamicMeshDict +++ b/tutorials/multiphase/interDyMFoam/ras/damBreakWithObstacle/constant/dynamicMeshDict @@ -39,7 +39,9 @@ dynamicRefineFvMeshCoeffs // on surfaceScalarFields that do not need to be reinterpolated. correctFluxes ( - (phi U) + (phi Urel) + (phiAbs U) + (phiAbs_0 U_0) (nHatf none) (rho*phi none) (ghf none)