AMRFoam class is a standalone adaptive mesh refinement application that uses polyMesh as its base and provides useful interface for use of different solvers and mesh formats. More...
Initially the supported refinement criterias would be size field defined over mesh as well as a gradient field of any simulation quantity.
Any object/pointer created for this class in C++ runtime will act as finiteVolume mesh of OpenFOAM.
Public Member Functions | |
AMRFoam (const Foam::IOobject &iomesh) | |
Standard constructor. More... | |
~AMRFoam () | |
Class destructor. More... | |
bool | updateAMR (const int &refineInterval, const int &maxRefinement, volScalarField &vFld, const double &lowerRefineLevel, const double &upperRefineLevel, const double &unrefineAbove, const double &unrefineBelow, const int &nBufferLayers, const int &maxCells) |
updateAMR is a master method for this process. More... | |
bool | updateAMRML (const int &refineInterval, const int &maxRefinement, const int &nBufferLayers, const int &maxCells, volScalarField &vFld) |
New method for machine learning ML. More... | |
void | solveMotion () |
A mesh motion solver. More... | |
Foam::scalarField | cell2Pt (const scalarField &vFld) |
Converts volume field to point field. More... | |
void | writeHistory () |
Writes refinement history in current time directory. More... | |
const polyMesh & | getMesh () |
Access to current mesh at every time step. More... | |
void | writeMesh () |
Ability to write current mesh into current time directory. More... | |
void | disableMotion () |
Ability to explicitely disable motion. More... | |
pointScalarField | readIncomingPtField (const std::string &inName, const std::string &outName) |
Converts incoming size-field/solution-field into pointScalarField defined over all points of mesh. More... | |
volScalarField | pF2vF (const pointScalarField &pntF, const std::string &outName) |
Converts pointScalarField to volScalarField. More... | |
volScalarField | readInitialField (const std::string &fldName) |
Reads the refinement field and registers it. More... | |
pointScalarField | initPntSField (const std::string &fldName) |
Creates an empty pointScalarField based on current mesh. More... | |
volScalarField | initScalarField (const std::string &fldName) |
Creates an empty volScalarField based on current mesh. More... | |
volScalarField | initGradientField (const std::string &fldName) |
Creates an empty volScalarField for gradient magnitude. More... | |
volScalarField | assignToVolScalarField (const std::vector< int > &vec) |
Converts vector to volScalarField for refinement/unrefinement. More... | |
void | enableUpdatedField () |
Access to updated field at every time step. More... | |
void | enableRefHistoryData () |
Access to refinement history data. More... | |
void | enableMeshWriting () |
Access to mesh data. More... | |
volScalarField | readIncomingCellField (const std::string &inName, const std::string &outName) |
reads incoming field and converts to volScalarField More... | |
void | transformField (volScalarField &inField) |
Transforms incoming scalar field into refinement levels understood by OpenFOAM environement. More... | |
volScalarField | getGradient (const volScalarField &fldGrd) |
Returns a gradient of scalar field over mesh param fldGrd Scalar Field for Gradient Calculation. More... | |
virtual bool | update () |
const hexRef8 & | meshCutter () const |
const bitSet & | protectedCell () const |
bitSet & | protectedCell () |
bool | writeObjectAMR (const bool valid) const |
virtual void | mapFields (const mapPolyMesh &mpm) |
Public Attributes | |
std::vector< double > | lowerRefLvl |
Vector to store lower refinement levels. More... | |
std::vector< double > | upperRefLvl |
Vector to store upper refinement levels. More... | |
std::vector< double > | unrefAboveLvl |
Vector to store unrefine levels. More... | |
std::vector< double > | unrefBelowLvl |
Vector to store unrefine levels. More... | |
int | stepSz = 1 |
Step size for one time refinement. More... | |
bool | enableMotion {false} |
Boolean to check if mesh motion is needed. More... | |
autoPtr< motionSolver > | motionPtr_ |
Protected Member Functions | |
void | checkForMotion () |
Checks for availability of mesh motion keywords in dictionary. More... | |
void | calcProtectedCells () |
Calculates and stores non-hex cells in protected cells catagory to avoid their refinement. More... | |
virtual Foam::autoPtr< Foam::mapPolyMesh > | refine (const labelList &) |
Unrefines selected cells in a mesh. More... | |
virtual Foam::autoPtr< Foam::mapPolyMesh > | unrefine (const labelList &) |
Refines selected cells in a mesh. More... | |
void | calculateProtectedCells (bitSet &unrefineableCell) const |
void | readDict () |
scalar | getRefineLevel (const label maxCells, const label maxRefinement, const scalar refineLevel, const scalarField &) const |
scalarField | maxPointField (const scalarField &) const |
scalarField | maxCellField (const volScalarField &) const |
scalarField | cellToPoint (const scalarField &vFld) const |
scalarField | error (const scalarField &fld, const scalar minLevel, const scalar maxLevel) const |
virtual void | selectRefineCandidates (const scalar lowerRefineLevel, const scalar upperRefineLevel, const scalarField &vFld, bitSet &candidateCell) const |
virtual labelList | selectRefineCells (const label maxCells, const label maxRefinement, const bitSet &candidateCell) const |
virtual labelList | selectUnrefinePoints (const scalar unrefineAbove, const scalar unrefineBelow, const bitSet &markedCell, const scalarField &pFld) const |
Marked the cells to unrefine based on user defined levels. More... | |
void | extendMarkedCells (bitSet &markedCell) const |
void | checkEightAnchorPoints (bitSet &protectedCell) const |
template<class T > | |
void | mapNewInternalFaces (const labelList &faceMap, GeometricField< T, fvsPatchField, surfaceMesh > &) |
template<class T > | |
void | mapNewInternalFaces (const labelList &faceMap) |
template<class T > | |
void | mapNewInternalFaces (const surfaceVectorField &Sf, const surfaceScalarField &magSf, const labelList &faceMap) |
Protected Attributes | |
hexRef8 | meshCutter_ |
bool | dumpLevel_ |
HashTable< word > | correctFluxes_ |
label | nRefinementIterations_ |
bitSet | protectedCell_ |
Private Attributes | |
bool | writeField {false} |
Boolean to enable writing of updated solution field every timestep. More... | |
bool | writeRefHistory {false} |
Boolean to enable writing of refinement history. More... | |
bool | writeMeshData {false} |
Boolean to enable writing of mesh. More... | |
std::vector< double > | incomingField |
Vector to store user defined vector. More... | |
Inherits dynamicFvMesh.
Foam::AMRFoam::AMRFoam | ( | const Foam::IOobject & | iomesh | ) |
Accepts polyMesh object for initialization. It needs dynamicMeshDict present in constant folder. Method for same is available in MeshManipulationFoam class as "createDynamicMeshDict"
iomesh | A polyMesh input object |
Definition at line 62 of file AMRFoam.C.
References calcProtectedCells(), and checkForMotion().
|
inline |
Definition at line 65 of file AMRFoam.H.
References assignToVolScalarField(), cell2Pt(), disableMotion(), enableMeshWriting(), enableRefHistoryData(), enableUpdatedField(), getGradient(), getMesh(), initGradientField(), initPntSField(), initScalarField(), pF2vF(), readIncomingCellField(), readIncomingPtField(), readInitialField(), solveMotion(), transformField(), updateAMR(), updateAMRML(), writeHistory(), and writeMesh().
volScalarField Foam::AMRFoam::assignToVolScalarField | ( | const std::vector< int > & | vec | ) |
vec | Incoming vector |
Definition at line 750 of file AMRFoam.C.
References initScalarField().
Referenced by NEM::DRV::FoamRefineDriver::execute(), and ~AMRFoam().
|
protected |
Definition at line 86 of file AMRFoam.C.
References checkEightAnchorPoints(), enableMotion, meshCutter_, and protectedCell_.
Referenced by AMRFoam().
|
protected |
Definition at line 847 of file AMRFoam.C.
References meshCutter_, and protectedCell_.
Referenced by selectRefineCells().
scalarField Foam::AMRFoam::cell2Pt | ( | const scalarField & | vFld | ) |
vFld | Volume Field. |
Definition at line 680 of file AMRFoam.C.
Referenced by ~AMRFoam().
|
protected |
Definition at line 1286 of file AMRFoam.C.
Referenced by selectRefineCandidates().
|
protected |
Definition at line 1401 of file AMRFoam.C.
References meshCutter_.
Referenced by calcProtectedCells().
|
protected |
Definition at line 72 of file AMRFoam.C.
References enableMotion, motionPtr_, and NEM::MSH::New().
Referenced by AMRFoam().
void Foam::AMRFoam::disableMotion | ( | ) |
Definition at line 84 of file AMRFoam.C.
References enableMotion.
Referenced by ~AMRFoam().
void Foam::AMRFoam::enableMeshWriting | ( | ) |
Definition at line 832 of file AMRFoam.C.
References writeMeshData.
Referenced by ~AMRFoam().
void Foam::AMRFoam::enableRefHistoryData | ( | ) |
Definition at line 828 of file AMRFoam.C.
References writeRefHistory.
Referenced by ~AMRFoam().
void Foam::AMRFoam::enableUpdatedField | ( | ) |
Definition at line 830 of file AMRFoam.C.
References writeField.
Referenced by ~AMRFoam().
|
protected |
Definition at line 1299 of file AMRFoam.C.
Referenced by selectRefineCandidates().
|
protected |
volScalarField Foam::AMRFoam::getGradient | ( | const volScalarField & | fldGrd | ) |
Definition at line 834 of file AMRFoam.C.
References initGradientField().
Referenced by ~AMRFoam().
const polyMesh & Foam::AMRFoam::getMesh | ( | ) |
Definition at line 702 of file AMRFoam.C.
References meshCutter_.
Referenced by ~AMRFoam().
|
protected |
volScalarField Foam::AMRFoam::initGradientField | ( | const std::string & | fldName | ) |
fldName | Name of field to create in current runTime directory |
Definition at line 806 of file AMRFoam.C.
Referenced by getGradient(), and ~AMRFoam().
pointScalarField Foam::AMRFoam::initPntSField | ( | const std::string & | fldName | ) |
fldName | Name of field to create in current runTime directory |
Definition at line 814 of file AMRFoam.C.
Referenced by readIncomingPtField(), and ~AMRFoam().
volScalarField Foam::AMRFoam::initScalarField | ( | const std::string & | fldName | ) |
fldName | Name of field to create in current runTime directory |
Definition at line 798 of file AMRFoam.C.
Referenced by assignToVolScalarField(), pF2vF(), readIncomingCellField(), and ~AMRFoam().
|
virtual |
|
protected |
|
protected |
Definition at line 1510 of file AMRFoam.C.
References mapNewInternalFaces().
|
protected |
Definition at line 1534 of file AMRFoam.C.
References mapNewInternalFaces().
|
protected |
Definition at line 1273 of file AMRFoam.C.
Referenced by update(), updateAMR(), and updateAMRML().
|
protected |
Definition at line 1260 of file AMRFoam.C.
Referenced by selectRefineCandidates().
|
inline |
Definition at line 370 of file AMRFoam.H.
References meshCutter_.
Referenced by update(), updateAMR(), and updateAMRML().
volScalarField Foam::AMRFoam::pF2vF | ( | const pointScalarField & | pntF, |
const std::string & | outName | ||
) |
pntF | A point field defined on mesh points |
outName | Object name for output scalar |
Definition at line 792 of file AMRFoam.C.
References initScalarField().
Referenced by ~AMRFoam().
|
inline |
|
inline |
Definition at line 376 of file AMRFoam.H.
References mapFields(), protectedCell_, and writeObjectAMR().
|
protected |
volScalarField Foam::AMRFoam::readIncomingCellField | ( | const std::string & | inName, |
const std::string & | outName | ||
) |
inName | Input file name |
outName | Object name for volScalarField |
Definition at line 723 of file AMRFoam.C.
References incomingField, initScalarField(), and nemAux::strToChar().
Referenced by ~AMRFoam().
pointScalarField Foam::AMRFoam::readIncomingPtField | ( | const std::string & | inName, |
const std::string & | outName | ||
) |
inName |
Definition at line 756 of file AMRFoam.C.
References incomingField, initPntSField(), and nemAux::strToChar().
Referenced by ~AMRFoam().
volScalarField Foam::AMRFoam::readInitialField | ( | const std::string & | fldName | ) |
fldName | Name of field present in current runTime directory |
Definition at line 784 of file AMRFoam.C.
Referenced by ~AMRFoam().
|
protectedvirtual |
splitPoints | Selected hanging nodes that can be erased to unrefine previously refined cells. Selection is performed using criteria and protected cells are excluded. |
Definition at line 1082 of file AMRFoam.C.
References enableMotion, meshCutter_, motionPtr_, and protectedCell_.
Referenced by update(), updateAMR(), and updateAMRML().
|
protectedvirtual |
Definition at line 1310 of file AMRFoam.C.
References cellToPoint(), error(), and maxPointField().
Referenced by update(), updateAMR(), and updateAMRML().
|
protectedvirtual |
Definition at line 1325 of file AMRFoam.C.
References calculateProtectedCells(), and meshCutter_.
Referenced by update(), updateAMR(), and updateAMRML().
|
protectedvirtual |
unrefineAbove | Unrefine cells above this thresold. |
unrefineBelow | Unrefine cells below this thresold. |
markedCell | Unrefinable cells list |
pFld | PointField at current runTime |
Definition at line 616 of file AMRFoam.C.
References meshCutter_, and protectedCell_.
Referenced by update(), updateAMR(), and updateAMRML().
void Foam::AMRFoam::solveMotion | ( | ) |
This method allows solving of mesh motion along with mesh refinment. Flux correction takes place after motion and refinement operations are performed. Experimental method.
Definition at line 1449 of file AMRFoam.C.
References motionPtr_.
Referenced by update(), updateAMR(), and ~AMRFoam().
void Foam::AMRFoam::transformField | ( | volScalarField & | inField | ) |
Appends this information to lower, upper and unrefine level vectors for AMR
Definition at line 708 of file AMRFoam.C.
Referenced by ~AMRFoam().
|
protectedvirtual |
cellsToRefine | Cell list selected for refinement. |
Definition at line 1138 of file AMRFoam.C.
References correctFluxes_, enableMotion, meshCutter_, motionPtr_, and protectedCell_.
Referenced by update(), updateAMR(), and updateAMRML().
|
virtual |
Definition at line 233 of file AMRFoam.C.
References nemAux::cellsToRefine(), correctFluxes_, dumpLevel_, enableMotion, extendMarkedCells(), maxCellField(), meshCutter(), nRefinementIterations_, refine(), selectRefineCandidates(), selectRefineCells(), selectUnrefinePoints(), solveMotion(), unrefine(), writeHistory(), and writeMesh().
bool Foam::AMRFoam::updateAMR | ( | const int & | refineInterval, |
const int & | maxRefinement, | ||
volScalarField & | vFld, | ||
const double & | lowerRefineLevel, | ||
const double & | upperRefineLevel, | ||
const double & | unrefineAbove, | ||
const double & | unrefineBelow, | ||
const int & | nBufferLayers, | ||
const int & | maxCells | ||
) |
It drives the refinement and unrefinement procedure between any two given timesteps.
refineInterval | Refinement interval/frequency |
maxRefinement | Maximum refinement allowed by user |
vFld | A scalar field of refinement criteria quantity |
lowerRefineLevel | Lower refinement level (Based on vFld) |
upperRefineLevel | Upper refinement level (Based on vFld) |
unrefineAbove | Criteria for unrefinement above this value |
unrefineBelow | Criteria for unrefinement below this value |
nBufferLayers | Buffer layers for slower than 2:1 refinement |
maxCells | Maximum number of cells allowed in mesh. Once this level is reached, refinement will be stopped. |
Definition at line 386 of file AMRFoam.C.
References nemAux::cellsToRefine(), enableMotion, extendMarkedCells(), maxCellField(), meshCutter(), nRefinementIterations_, refine(), selectRefineCandidates(), selectRefineCells(), selectUnrefinePoints(), solveMotion(), unrefine(), writeField, writeHistory(), writeMesh(), writeMeshData, and writeRefHistory.
Referenced by ~AMRFoam().
bool Foam::AMRFoam::updateAMRML | ( | const int & | refineInterval, |
const int & | maxRefinement, | ||
const int & | nBufferLayers, | ||
const int & | maxCells, | ||
volScalarField & | vFld | ||
) |
Takes output from ML model and performs refinement/unrefinement.
refineInterval | Refinement interval/frequency |
maxRefinement | Maximum refinement allowed by user |
nBufferLayers | Buffer layers for slower than 2:1 refinement |
maxCells | Maximum number of cells allowed in mesh. Once this level is reached, refinement will be stopped. |
vFld | Machine learning model output vector |
Definition at line 510 of file AMRFoam.C.
References nemAux::cellsToRefine(), extendMarkedCells(), maxCellField(), meshCutter(), nRefinementIterations_, refine(), selectRefineCandidates(), selectRefineCells(), selectUnrefinePoints(), and unrefine().
Referenced by NEM::DRV::FoamRefineDriver::execute(), and ~AMRFoam().
void Foam::AMRFoam::writeHistory | ( | ) |
Definition at line 696 of file AMRFoam.C.
References meshCutter_.
Referenced by update(), updateAMR(), and ~AMRFoam().
void Foam::AMRFoam::writeMesh | ( | ) |
Definition at line 704 of file AMRFoam.C.
References writeObjectAMR().
Referenced by update(), updateAMR(), and ~AMRFoam().
bool Foam::AMRFoam::writeObjectAMR | ( | const bool | valid | ) | const |
Definition at line 1425 of file AMRFoam.C.
References dumpLevel_, and meshCutter_.
Referenced by protectedCell(), and writeMesh().
|
protected |
Definition at line 259 of file AMRFoam.H.
Referenced by mapFields(), readDict(), unrefine(), and update().
|
protected |
Definition at line 256 of file AMRFoam.H.
Referenced by readDict(), update(), and writeObjectAMR().
bool Foam::AMRFoam::enableMotion {false} |
Definition at line 231 of file AMRFoam.H.
Referenced by calcProtectedCells(), checkForMotion(), disableMotion(), refine(), unrefine(), update(), and updateAMR().
|
private |
Definition at line 249 of file AMRFoam.H.
Referenced by readIncomingCellField(), and readIncomingPtField().
|
protected |
Definition at line 253 of file AMRFoam.H.
Referenced by calcProtectedCells(), calculateProtectedCells(), checkEightAnchorPoints(), getMesh(), meshCutter(), refine(), selectRefineCells(), selectUnrefinePoints(), unrefine(), writeHistory(), and writeObjectAMR().
autoPtr<motionSolver> Foam::AMRFoam::motionPtr_ |
Definition at line 365 of file AMRFoam.H.
Referenced by checkForMotion(), refine(), solveMotion(), and unrefine().
|
protected |
Definition at line 262 of file AMRFoam.H.
Referenced by update(), updateAMR(), and updateAMRML().
|
protected |
Definition at line 265 of file AMRFoam.H.
Referenced by calcProtectedCells(), calculateProtectedCells(), protectedCell(), refine(), selectUnrefinePoints(), and unrefine().
|
private |
Definition at line 237 of file AMRFoam.H.
Referenced by enableUpdatedField(), and updateAMR().
|
private |
Definition at line 245 of file AMRFoam.H.
Referenced by enableMeshWriting(), and updateAMR().
|
private |
Definition at line 241 of file AMRFoam.H.
Referenced by enableRefHistoryData(), and updateAMR().