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
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;

View File

@ -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
@ -93,21 +93,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"

View File

@ -75,20 +75,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

View File

@ -94,23 +94,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"

View File

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

View File

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

View File

@ -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
@ -109,22 +109,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"
}
}
}

View File

@ -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
@ -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
\\ / 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<fvsPatchField, scalar>& 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<scalar>& 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<fvsPatchField, scalar>& 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<scalar>& 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

View File

@ -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<<

View File

@ -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<MRFZone>
public PtrList<MRFZone>
{
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