MRF: Added support for mesh refinement/unrefinement and other topology changes

This commit is contained in:
Henry Weller
2017-08-18 22:22:47 +01:00
parent d43c4ed4b1
commit c57fe2b5fd
11 changed files with 205 additions and 155 deletions

View File

@ -108,23 +108,28 @@ int main(int argc, char *argv[])
// Do any mesh changes // Do any mesh changes
mesh.update(); mesh.update();
if (mesh.changing() && correctPhi) if (mesh.changing())
{ {
// Calculate absolute flux from the mapped surface velocity MRF.update();
phi = mesh.Sf() & rhoUf;
#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 #include "correctPhi.H"
fvc::makeRelative(phi, rho, U);
// 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" #include "rhoEqn.H"
Info<< "rhoEqn max/min : " << max(rho).value() Info<< "rhoEqn max/min : " << max(rho).value()
<< " " << min(rho).value() << endl; << " " << min(rho).value() << endl;

View File

@ -2,7 +2,7 @@
========= | ========= |
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox \\ / F ield | OpenFOAM: The Open Source CFD Toolbox
\\ / O peration | \\ / O peration |
\\ / A nd | Copyright (C) 2011-2016 OpenFOAM Foundation \\ / A nd | Copyright (C) 2011-2017 OpenFOAM Foundation
\\/ M anipulation | \\/ M anipulation |
------------------------------------------------------------------------------- -------------------------------------------------------------------------------
License License
@ -93,21 +93,26 @@ int main(int argc, char *argv[])
// Do any mesh changes // Do any mesh changes
mesh.update(); mesh.update();
if (mesh.changing() && correctPhi) if (mesh.changing())
{ {
// Calculate absolute flux from the mapped surface velocity MRF.update();
phi = mesh.Sf() & rhoUf;
#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 #include "correctPhi.H"
fvc::makeRelative(phi, rho, U);
// Make the fluxes relative to the mesh-motion
fvc::makeRelative(phi, rho, U);
}
} }
}
if (mesh.changing() && checkMeshCourantNo) if (checkMeshCourantNo)
{ {
#include "meshCourantNo.H" #include "meshCourantNo.H"
}
} }
#include "rhoEqn.H" #include "rhoEqn.H"

View File

@ -75,20 +75,25 @@ int main(int argc, char *argv[])
mesh.update(); mesh.update();
// Calculate absolute flux from the mapped surface velocity if (mesh.changing())
phi = mesh.Sf() & Uf;
if (mesh.changing() && correctPhi)
{ {
#include "correctPhi.H" MRF.update();
}
// Make the flux relative to the mesh motion if (correctPhi)
fvc::makeRelative(phi, U); {
// Calculate absolute flux from the mapped surface velocity
phi = mesh.Sf() & Uf;
if (mesh.changing() && checkMeshCourantNo) #include "correctPhi.H"
{
#include "meshCourantNo.H" // Make the flux relative to the mesh motion
fvc::makeRelative(phi, U);
}
if (checkMeshCourantNo)
{
#include "meshCourantNo.H"
}
} }
// --- Pressure-velocity PIMPLE corrector loop // --- Pressure-velocity PIMPLE corrector loop

View File

@ -94,23 +94,28 @@ int main(int argc, char *argv[])
// Do any mesh changes // Do any mesh changes
mesh.update(); mesh.update();
if (mesh.changing() && correctPhi) if (mesh.changing())
{ {
// Calculate absolute flux from the mapped surface velocity MRF.update();
phi = mesh.Sf() & rhoUf;
#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 #include "correctPhi.H"
fvc::makeRelative(phi, rho, U);
// 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(); parcels.evolve();
#include "rhoEqn.H" #include "rhoEqn.H"

View File

@ -116,30 +116,34 @@ int main(int argc, char *argv[])
if (mesh.changing()) if (mesh.changing())
{ {
MRF.update();
Info<< "Execution time for mesh.update() = " Info<< "Execution time for mesh.update() = "
<< runTime.elapsedCpuTime() - timeBeforeMeshUpdate << runTime.elapsedCpuTime() - timeBeforeMeshUpdate
<< " s" << endl; << " s" << endl;
gh = (g & mesh.C()) - ghRef; gh = (g & mesh.C()) - ghRef;
ghf = (g & mesh.Cf()) - ghRef; ghf = (g & mesh.Cf()) - ghRef;
}
if (mesh.changing() && correctPhi) if (correctPhi)
{ {
// Calculate absolute flux from the mapped surface velocity // Calculate absolute flux
phi = mesh.Sf() & Uf; // from the mapped surface velocity
phi = mesh.Sf() & Uf;
#include "correctPhi.H" #include "correctPhi.H"
// Make the fluxes relative to the mesh motion // Make the fluxes relative to the mesh motion
fvc::makeRelative(phi, U); fvc::makeRelative(phi, U);
mixture.correct(); mixture.correct();
} }
if (mesh.changing() && checkMeshCourantNo) if (checkMeshCourantNo)
{ {
#include "meshCourantNo.H" #include "meshCourantNo.H"
}
} }
} }

View File

@ -134,24 +134,27 @@ int main(int argc, char *argv[])
gh = (g & mesh.C()) - ghRef; gh = (g & mesh.C()) - ghRef;
ghf = (g & mesh.Cf()) - ghRef; ghf = (g & mesh.Cf()) - ghRef;
}
if (mesh.changing() && correctPhi) MRF.update();
{
// Calculate absolute flux from the mapped surface velocity
phi = mesh.Sf() & Uf;
#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 #include "correctPhi.H"
fvc::makeRelative(phi, U);
mixture.correct(); // Make the flux relative to the mesh motion
} fvc::makeRelative(phi, U);
if (mesh.changing() && checkMeshCourantNo) mixture.correct();
{ }
#include "meshCourantNo.H"
if (checkMeshCourantNo)
{
#include "meshCourantNo.H"
}
} }
} }

View File

@ -2,7 +2,7 @@
========= | ========= |
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox \\ / F ield | OpenFOAM: The Open Source CFD Toolbox
\\ / O peration | \\ / O peration |
\\ / A nd | Copyright (C) 2014-2016 OpenFOAM Foundation \\ / A nd | Copyright (C) 2014-2017 OpenFOAM Foundation
\\/ M anipulation | \\/ M anipulation |
------------------------------------------------------------------------------- -------------------------------------------------------------------------------
License License
@ -109,22 +109,25 @@ int main(int argc, char *argv[])
Info<< "Execution time for mesh.update() = " Info<< "Execution time for mesh.update() = "
<< runTime.elapsedCpuTime() - timeBeforeMeshUpdate << runTime.elapsedCpuTime() - timeBeforeMeshUpdate
<< " s" << endl; << " s" << endl;
}
if (mesh.changing() && correctPhi) MRF.update();
{
// Calculate absolute flux from the mapped surface velocity
phi = mesh.Sf() & Uf;
#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 #include "correctPhi.H"
fvc::makeRelative(phi, U);
}
if (mesh.changing() && checkMeshCourantNo) // Make the flux relative to the mesh motion
{ fvc::makeRelative(phi, U);
#include "meshCourantNo.H" }
if (checkMeshCourantNo)
{
#include "meshCourantNo.H"
}
} }
} }

View File

@ -2,7 +2,7 @@
========= | ========= |
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox \\ / F ield | OpenFOAM: The Open Source CFD Toolbox
\\ / O peration | \\ / O peration |
\\ / A nd | Copyright (C) 2011-2016 OpenFOAM Foundation \\ / A nd | Copyright (C) 2011-2017 OpenFOAM Foundation
\\/ M anipulation | \\/ M anipulation |
------------------------------------------------------------------------------- -------------------------------------------------------------------------------
License License
@ -601,4 +601,13 @@ bool Foam::MRFZone::read(const dictionary& dict)
} }
void Foam::MRFZone::update()
{
if (mesh_.topoChanging())
{
setMRFFaces();
}
}
// ************************************************************************* // // ************************************************************************* //

View File

@ -2,7 +2,7 @@
========= | ========= |
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox \\ / F ield | OpenFOAM: The Open Source CFD Toolbox
\\ / O peration | \\ / O peration |
\\ / A nd | Copyright (C) 2011-2016 OpenFOAM Foundation \\ / A nd | Copyright (C) 2011-2017 OpenFOAM Foundation
\\/ M anipulation | \\/ M anipulation |
------------------------------------------------------------------------------- -------------------------------------------------------------------------------
License License
@ -180,87 +180,85 @@ public:
// Member Functions // Member Functions
// Access //- Return const access to the MRF region name
inline const word& name() const;
//- Return const access to the MRF region name //- Return const access to the MRF active flag
inline const word& name() const; inline bool active() const;
//- Return const access to the MRF active flag //- Return the current Omega vector
inline bool active() const; vector Omega() const;
//- Return the current Omega vector //- Update the mesh corresponding to given map
vector Omega() const; 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 //- Add the Coriolis force contribution to the momentum equation
void updateMesh(const mapPolyMesh& mpm) // Adds to the lhs of the equation; optionally add to rhs
{ void addCoriolis
// Only updates face addressing (
setMRFFaces(); const volScalarField& rho,
} fvVectorMatrix& UEqn,
const bool rhs = false
) const;
//- Add the Coriolis force contribution to the acceleration field //- Make the given absolute velocity relative within the MRF region
void addCoriolis void makeRelative(volVectorField& U) const;
(
const volVectorField& U,
volVectorField& ddtU
) const;
//- Add the Coriolis force contribution to the momentum equation //- Make the given absolute flux relative within the MRF region
// Adds to the lhs of the equation; optionally add to rhs void makeRelative(surfaceScalarField& phi) const;
void addCoriolis
(
fvVectorMatrix& UEqn,
const bool rhs = false
) const;
//- Add the Coriolis force contribution to the momentum equation //- Make the given absolute boundary flux relative
// Adds to the lhs of the equation; optionally add to rhs // within the MRF region
void addCoriolis void makeRelative(FieldField<fvsPatchField, scalar>& phi) const;
(
const volScalarField& rho,
fvVectorMatrix& UEqn,
const bool rhs = false
) const;
//- Make the given absolute velocity relative within the MRF region //- Make the given absolute patch flux relative
void makeRelative(volVectorField& U) const; // within the MRF region
void makeRelative(Field<scalar>& phi, const label patchi) const;
//- Make the given absolute flux relative within the MRF region //- Make the given absolute mass-flux relative within the MRF region
void makeRelative(surfaceScalarField& phi) const; void makeRelative
(
const surfaceScalarField& rho,
surfaceScalarField& phi
) const;
//- Make the given absolute boundary flux relative //- Make the given relative velocity absolute within the MRF region
// within the MRF region void makeAbsolute(volVectorField& U) const;
void makeRelative(FieldField<fvsPatchField, scalar>& phi) const;
//- Make the given absolute patch flux relative //- Make the given relative flux absolute within the MRF region
// within the MRF region void makeAbsolute(surfaceScalarField& phi) const;
void makeRelative(Field<scalar>& phi, const label patchi) const;
//- Make the given absolute mass-flux relative within the MRF region //- Make the given relative mass-flux absolute within the MRF region
void makeRelative void makeAbsolute
( (
const surfaceScalarField& rho, const surfaceScalarField& rho,
surfaceScalarField& phi surfaceScalarField& phi
) const; ) const;
//- Make the given relative velocity absolute within the MRF region //- Correct the boundary velocity for the rotation of the MRF region
void makeAbsolute(volVectorField& U) const; void correctBoundaryVelocity(volVectorField& U) const;
//- Make the given relative flux absolute within the MRF region //- Update MRFZone faces if the mesh topology changes
void makeAbsolute(surfaceScalarField& phi) const; void update();
//- 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;
// I-O // I-O

View File

@ -2,7 +2,7 @@
========= | ========= |
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox \\ / F ield | OpenFOAM: The Open Source CFD Toolbox
\\ / O peration | \\ / O peration |
\\ / A nd | Copyright (C) 2012-2016 OpenFOAM Foundation \\ / A nd | Copyright (C) 2012-2017 OpenFOAM Foundation
\\/ M anipulation | \\/ M anipulation |
------------------------------------------------------------------------------- -------------------------------------------------------------------------------
License License
@ -414,6 +414,18 @@ void Foam::MRFZoneList::correctBoundaryFlux
} }
void Foam::MRFZoneList::update()
{
if (mesh_.topoChanging())
{
forAll(*this, i)
{
operator[](i).update();
}
}
}
// * * * * * * * * * * * * * * * IOstream Operators * * * * * * * * * * * * // // * * * * * * * * * * * * * * * IOstream Operators * * * * * * * * * * * * //
Foam::Ostream& Foam::operator<< Foam::Ostream& Foam::operator<<

View File

@ -2,7 +2,7 @@
========= | ========= |
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox \\ / F ield | OpenFOAM: The Open Source CFD Toolbox
\\ / O peration | \\ / O peration |
\\ / A nd | Copyright (C) 2012-2016 OpenFOAM Foundation \\ / A nd | Copyright (C) 2012-2017 OpenFOAM Foundation
\\/ M anipulation | \\/ M anipulation |
------------------------------------------------------------------------------- -------------------------------------------------------------------------------
License License
@ -55,10 +55,8 @@ Ostream& operator<<(Ostream& os, const MRFZoneList& models);
class MRFZoneList class MRFZoneList
: :
PtrList<MRFZone> public PtrList<MRFZone>
{ {
private:
// Private Member Functions // Private Member Functions
//- Disallow default bitwise copy construct //- Disallow default bitwise copy construct
@ -186,6 +184,9 @@ public:
surfaceScalarField& phi surfaceScalarField& phi
) const; ) const;
//- Update MRFZone faces if the mesh topology changes
void update();
// I-O // I-O