ENH: 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
committed by Andrew Heather
parent c06f716555
commit be9d388a68
11 changed files with 176 additions and 129 deletions

View File

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

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

View File

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

View File

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

View File

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

View File

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

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

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 | 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();
}
}
// ************************************************************************* //

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