diff --git a/applications/solvers/compressible/rhoPimpleFoam/rhoPimpleDyMFoam/rhoPimpleDyMFoam.C b/applications/solvers/compressible/rhoPimpleFoam/rhoPimpleDyMFoam/rhoPimpleDyMFoam.C index 787d799090..64ea52a4ed 100644 --- a/applications/solvers/compressible/rhoPimpleFoam/rhoPimpleDyMFoam/rhoPimpleDyMFoam.C +++ b/applications/solvers/compressible/rhoPimpleFoam/rhoPimpleDyMFoam/rhoPimpleDyMFoam.C @@ -110,23 +110,28 @@ int main(int argc, char *argv[]) // Do any mesh changes mesh.update(); - if (mesh.changing() && correctPhi) + if (mesh.changing()) { - // Calculate absolute flux from the mapped surface velocity - phi = mesh.Sf() & rhoUf; + MRF.update(); - #include "correctPhi.H" + if (correctPhi) + { + // Calculate absolute flux from the mapped surface velocity + phi = mesh.Sf() & rhoUf; - // Make the fluxes relative to the mesh-motion - fvc::makeRelative(phi, rho, U); + #include "correctPhi.H" + + // Make the fluxes relative to the mesh-motion + fvc::makeRelative(phi, rho, U); + } + + if (checkMeshCourantNo) + { + #include "meshCourantNo.H" + } } } - if (mesh.changing() && checkMeshCourantNo) - { - #include "meshCourantNo.H" - } - #include "rhoEqn.H" Info<< "rhoEqn max/min : " << max(rho).value() << " " << min(rho).value() << endl; diff --git a/applications/solvers/compressible/sonicFoam/sonicDyMFoam/sonicDyMFoam.C b/applications/solvers/compressible/sonicFoam/sonicDyMFoam/sonicDyMFoam.C index 831935caeb..e4ad6017cd 100644 --- a/applications/solvers/compressible/sonicFoam/sonicDyMFoam/sonicDyMFoam.C +++ b/applications/solvers/compressible/sonicFoam/sonicDyMFoam/sonicDyMFoam.C @@ -2,7 +2,7 @@ ========= | \\ / F ield | OpenFOAM: The Open Source CFD Toolbox \\ / O peration | - \\ / A nd | Copyright (C) 2011-2016 OpenFOAM Foundation + \\ / A nd | Copyright (C) 2011-2017 OpenFOAM Foundation \\/ M anipulation | ------------------------------------------------------------------------------- License @@ -92,21 +92,26 @@ int main(int argc, char *argv[]) // Do any mesh changes mesh.update(); - if (mesh.changing() && correctPhi) + if (mesh.changing()) { - // Calculate absolute flux from the mapped surface velocity - phi = mesh.Sf() & rhoUf; + MRF.update(); - #include "correctPhi.H" + if (correctPhi) + { + // Calculate absolute flux from the mapped surface velocity + phi = mesh.Sf() & rhoUf; - // Make the fluxes relative to the mesh-motion - fvc::makeRelative(phi, rho, U); + #include "correctPhi.H" + + // Make the fluxes relative to the mesh-motion + fvc::makeRelative(phi, rho, U); + } } - } - if (mesh.changing() && checkMeshCourantNo) - { - #include "meshCourantNo.H" + if (checkMeshCourantNo) + { + #include "meshCourantNo.H" + } } #include "rhoEqn.H" diff --git a/applications/solvers/incompressible/pimpleFoam/pimpleDyMFoam/pimpleDyMFoam.C b/applications/solvers/incompressible/pimpleFoam/pimpleDyMFoam/pimpleDyMFoam.C index 7de38082e9..f77f2677f8 100644 --- a/applications/solvers/incompressible/pimpleFoam/pimpleDyMFoam/pimpleDyMFoam.C +++ b/applications/solvers/incompressible/pimpleFoam/pimpleDyMFoam/pimpleDyMFoam.C @@ -77,20 +77,25 @@ int main(int argc, char *argv[]) mesh.update(); - // Calculate absolute flux from the mapped surface velocity - phi = mesh.Sf() & Uf; - - if (mesh.changing() && correctPhi) + if (mesh.changing()) { - #include "correctPhi.H" - } + MRF.update(); - // Make the flux relative to the mesh motion - fvc::makeRelative(phi, U); + if (correctPhi) + { + // Calculate absolute flux from the mapped surface velocity + phi = mesh.Sf() & Uf; - if (mesh.changing() && checkMeshCourantNo) - { - #include "meshCourantNo.H" + #include "correctPhi.H" + + // Make the flux relative to the mesh motion + fvc::makeRelative(phi, U); + } + + if (checkMeshCourantNo) + { + #include "meshCourantNo.H" + } } // --- Pressure-velocity PIMPLE corrector loop diff --git a/applications/solvers/lagrangian/sprayFoam/sprayDyMFoam/sprayDyMFoam.C b/applications/solvers/lagrangian/sprayFoam/sprayDyMFoam/sprayDyMFoam.C index 9983f0cf6e..1c1208b9a7 100644 --- a/applications/solvers/lagrangian/sprayFoam/sprayDyMFoam/sprayDyMFoam.C +++ b/applications/solvers/lagrangian/sprayFoam/sprayDyMFoam/sprayDyMFoam.C @@ -96,23 +96,28 @@ int main(int argc, char *argv[]) // Do any mesh changes mesh.update(); - if (mesh.changing() && correctPhi) + if (mesh.changing()) { - // Calculate absolute flux from the mapped surface velocity - phi = mesh.Sf() & rhoUf; + MRF.update(); - #include "correctPhi.H" + if (correctPhi) + { + // Calculate absolute flux from the mapped surface velocity + phi = mesh.Sf() & rhoUf; - // Make the fluxes relative to the mesh-motion - fvc::makeRelative(phi, rho, U); + #include "correctPhi.H" + + // Make the fluxes relative to the mesh-motion + fvc::makeRelative(phi, rho, U); + } + + if (checkMeshCourantNo) + { + #include "meshCourantNo.H" + } } } - if (mesh.changing() && checkMeshCourantNo) - { - #include "meshCourantNo.H" - } - parcels.evolve(); #include "rhoEqn.H" diff --git a/applications/solvers/multiphase/compressibleInterFoam/compressibleInterDyMFoam/compressibleInterDyMFoam.C b/applications/solvers/multiphase/compressibleInterFoam/compressibleInterDyMFoam/compressibleInterDyMFoam.C index 2a91b5996a..e4e1a2e975 100644 --- a/applications/solvers/multiphase/compressibleInterFoam/compressibleInterDyMFoam/compressibleInterDyMFoam.C +++ b/applications/solvers/multiphase/compressibleInterFoam/compressibleInterDyMFoam/compressibleInterDyMFoam.C @@ -110,6 +110,8 @@ int main(int argc, char *argv[]) if (mesh.changing()) { + MRF.update(); + Info<< "Execution time for mesh.update() = " << runTime.elapsedCpuTime() - timeBeforeMeshUpdate << " s" << endl; diff --git a/applications/solvers/multiphase/interFoam/interDyMFoam/interDyMFoam.C b/applications/solvers/multiphase/interFoam/interDyMFoam/interDyMFoam.C index 4fedf55bd7..3a4e0c579c 100644 --- a/applications/solvers/multiphase/interFoam/interDyMFoam/interDyMFoam.C +++ b/applications/solvers/multiphase/interFoam/interDyMFoam/interDyMFoam.C @@ -136,6 +136,8 @@ int main(int argc, char *argv[]) gh = (g & mesh.C()) - ghRef; ghf = (g & mesh.Cf()) - ghRef; + + MRF.update(); } if ((mesh.changing() && correctPhi) || mesh.topoChanging()) diff --git a/applications/solvers/multiphase/potentialFreeSurfaceFoam/potentialFreeSurfaceDyMFoam/potentialFreeSurfaceDyMFoam.C b/applications/solvers/multiphase/potentialFreeSurfaceFoam/potentialFreeSurfaceDyMFoam/potentialFreeSurfaceDyMFoam.C index 0caf4c32f1..13d2ff6b03 100644 --- a/applications/solvers/multiphase/potentialFreeSurfaceFoam/potentialFreeSurfaceDyMFoam/potentialFreeSurfaceDyMFoam.C +++ b/applications/solvers/multiphase/potentialFreeSurfaceFoam/potentialFreeSurfaceDyMFoam/potentialFreeSurfaceDyMFoam.C @@ -2,7 +2,7 @@ ========= | \\ / F ield | OpenFOAM: The Open Source CFD Toolbox \\ / O peration | - \\ / A nd | Copyright (C) 2014-2016 OpenFOAM Foundation + \\ / A nd | Copyright (C) 2014-2017 OpenFOAM Foundation \\/ M anipulation | ------------------------------------------------------------------------------- License @@ -111,22 +111,25 @@ int main(int argc, char *argv[]) Info<< "Execution time for mesh.update() = " << runTime.elapsedCpuTime() - timeBeforeMeshUpdate << " s" << endl; - } - if (mesh.changing() && correctPhi) - { - // Calculate absolute flux from the mapped surface velocity - phi = mesh.Sf() & Uf; + MRF.update(); - #include "correctPhi.H" + if (correctPhi) + { + // Calculate absolute flux + // from the mapped surface velocity + phi = mesh.Sf() & Uf; - // Make the flux relative to the mesh motion - fvc::makeRelative(phi, U); - } + #include "correctPhi.H" - if (mesh.changing() && checkMeshCourantNo) - { - #include "meshCourantNo.H" + // Make the flux relative to the mesh motion + fvc::makeRelative(phi, U); + } + + if (checkMeshCourantNo) + { + #include "meshCourantNo.H" + } } } diff --git a/src/finiteVolume/cfdTools/general/MRF/MRFZone.C b/src/finiteVolume/cfdTools/general/MRF/MRFZone.C index 7cf9160ce1..c68537c81f 100644 --- a/src/finiteVolume/cfdTools/general/MRF/MRFZone.C +++ b/src/finiteVolume/cfdTools/general/MRF/MRFZone.C @@ -2,7 +2,7 @@ ========= | \\ / F ield | OpenFOAM: The Open Source CFD Toolbox \\ / O peration | - \\ / A nd | Copyright (C) 2011-2016 OpenFOAM Foundation + \\ / A nd | Copyright (C) 2011-2017 OpenFOAM Foundation \\/ M anipulation | Copyright (C) 2018 OpenCFD Ltd. ------------------------------------------------------------------------------- License @@ -600,4 +600,13 @@ bool Foam::MRFZone::read(const dictionary& dict) } +void Foam::MRFZone::update() +{ + if (mesh_.topoChanging()) + { + setMRFFaces(); + } +} + + // ************************************************************************* // diff --git a/src/finiteVolume/cfdTools/general/MRF/MRFZone.H b/src/finiteVolume/cfdTools/general/MRF/MRFZone.H index 1b86589daf..2a1f0a8678 100644 --- a/src/finiteVolume/cfdTools/general/MRF/MRFZone.H +++ b/src/finiteVolume/cfdTools/general/MRF/MRFZone.H @@ -2,7 +2,7 @@ ========= | \\ / F ield | OpenFOAM: The Open Source CFD Toolbox \\ / O peration | - \\ / A nd | Copyright (C) 2011-2016 OpenFOAM Foundation + \\ / A nd | Copyright (C) 2011-2017 OpenFOAM Foundation \\/ M anipulation | ------------------------------------------------------------------------------- License @@ -180,87 +180,85 @@ public: // Member Functions - // Access + //- Return const access to the MRF region name + inline const word& name() const; - //- Return const access to the MRF region name - inline const word& name() const; + //- Return const access to the MRF active flag + inline bool active() const; - //- Return const access to the MRF active flag - inline bool active() const; + //- Return the current Omega vector + vector Omega() const; - //- Return the current Omega vector - vector Omega() const; + //- Update the mesh corresponding to given map + void updateMesh(const mapPolyMesh& mpm) + { + // Only updates face addressing + setMRFFaces(); + } + //- Add the Coriolis force contribution to the acceleration field + void addCoriolis + ( + const volVectorField& U, + volVectorField& ddtU + ) const; - // Evaluation + //- Add the Coriolis force contribution to the momentum equation + // Adds to the lhs of the equation; optionally add to rhs + void addCoriolis + ( + fvVectorMatrix& UEqn, + const bool rhs = false + ) const; - //- Update the mesh corresponding to given map - void updateMesh(const mapPolyMesh& mpm) - { - // Only updates face addressing - setMRFFaces(); - } + //- Add the Coriolis force contribution to the momentum equation + // Adds to the lhs of the equation; optionally add to rhs + void addCoriolis + ( + const volScalarField& rho, + fvVectorMatrix& UEqn, + const bool rhs = false + ) const; - //- Add the Coriolis force contribution to the acceleration field - void addCoriolis - ( - const volVectorField& U, - volVectorField& ddtU - ) const; + //- Make the given absolute velocity relative within the MRF region + void makeRelative(volVectorField& U) const; - //- Add the Coriolis force contribution to the momentum equation - // Adds to the lhs of the equation; optionally add to rhs - void addCoriolis - ( - fvVectorMatrix& UEqn, - const bool rhs = false - ) const; + //- Make the given absolute flux relative within the MRF region + void makeRelative(surfaceScalarField& phi) const; - //- Add the Coriolis force contribution to the momentum equation - // Adds to the lhs of the equation; optionally add to rhs - void addCoriolis - ( - const volScalarField& rho, - fvVectorMatrix& UEqn, - const bool rhs = false - ) const; + //- Make the given absolute boundary flux relative + // within the MRF region + void makeRelative(FieldField& phi) const; - //- Make the given absolute velocity relative within the MRF region - void makeRelative(volVectorField& U) const; + //- Make the given absolute patch flux relative + // within the MRF region + void makeRelative(Field& phi, const label patchi) const; - //- Make the given absolute flux relative within the MRF region - void makeRelative(surfaceScalarField& phi) const; + //- Make the given absolute mass-flux relative within the MRF region + void makeRelative + ( + const surfaceScalarField& rho, + surfaceScalarField& phi + ) const; - //- Make the given absolute boundary flux relative - // within the MRF region - void makeRelative(FieldField& phi) const; + //- Make the given relative velocity absolute within the MRF region + void makeAbsolute(volVectorField& U) const; - //- Make the given absolute patch flux relative - // within the MRF region - void makeRelative(Field& phi, const label patchi) const; + //- Make the given relative flux absolute within the MRF region + void makeAbsolute(surfaceScalarField& phi) const; - //- Make the given absolute mass-flux relative within the MRF region - void makeRelative - ( - const surfaceScalarField& rho, - surfaceScalarField& phi - ) const; + //- Make the given relative mass-flux absolute within the MRF region + void makeAbsolute + ( + const surfaceScalarField& rho, + surfaceScalarField& phi + ) const; - //- Make the given relative velocity absolute within the MRF region - void makeAbsolute(volVectorField& U) const; + //- Correct the boundary velocity for the rotation of the MRF region + void correctBoundaryVelocity(volVectorField& U) const; - //- Make the given relative flux absolute within the MRF region - void makeAbsolute(surfaceScalarField& phi) const; - - //- Make the given relative mass-flux absolute within the MRF region - void makeAbsolute - ( - const surfaceScalarField& rho, - surfaceScalarField& phi - ) const; - - //- Correct the boundary velocity for the rotation of the MRF region - void correctBoundaryVelocity(volVectorField& U) const; + //- Update MRFZone faces if the mesh topology changes + void update(); // I-O diff --git a/src/finiteVolume/cfdTools/general/MRF/MRFZoneList.C b/src/finiteVolume/cfdTools/general/MRF/MRFZoneList.C index c8b3ec22a2..7b788ecf06 100644 --- a/src/finiteVolume/cfdTools/general/MRF/MRFZoneList.C +++ b/src/finiteVolume/cfdTools/general/MRF/MRFZoneList.C @@ -2,7 +2,7 @@ ========= | \\ / F ield | OpenFOAM: The Open Source CFD Toolbox \\ / O peration | - \\ / A nd | Copyright (C) 2012-2016 OpenFOAM Foundation + \\ / A nd | Copyright (C) 2012-2017 OpenFOAM Foundation \\/ M anipulation | ------------------------------------------------------------------------------- License @@ -414,6 +414,18 @@ void Foam::MRFZoneList::correctBoundaryFlux } +void Foam::MRFZoneList::update() +{ + if (mesh_.topoChanging()) + { + forAll(*this, i) + { + operator[](i).update(); + } + } +} + + // * * * * * * * * * * * * * * * IOstream Operators * * * * * * * * * * * * // Foam::Ostream& Foam::operator<< diff --git a/src/finiteVolume/cfdTools/general/MRF/MRFZoneList.H b/src/finiteVolume/cfdTools/general/MRF/MRFZoneList.H index fb36e689ea..4c0fffbe2f 100644 --- a/src/finiteVolume/cfdTools/general/MRF/MRFZoneList.H +++ b/src/finiteVolume/cfdTools/general/MRF/MRFZoneList.H @@ -2,7 +2,7 @@ ========= | \\ / F ield | OpenFOAM: The Open Source CFD Toolbox \\ / O peration | - \\ / A nd | Copyright (C) 2012-2016 OpenFOAM Foundation + \\ / A nd | Copyright (C) 2012-2017 OpenFOAM Foundation \\/ M anipulation | ------------------------------------------------------------------------------- License @@ -55,10 +55,8 @@ Ostream& operator<<(Ostream& os, const MRFZoneList& models); class MRFZoneList : - PtrList + public PtrList { -private: - // Private Member Functions //- Disallow default bitwise copy construct @@ -186,6 +184,9 @@ public: surfaceScalarField& phi ) const; + //- Update MRFZone faces if the mesh topology changes + void update(); + // I-O