mirror of
https://develop.openfoam.com/Development/openfoam.git
synced 2025-11-28 03:28:01 +00:00
ENH: mirrorMesh: Added support for cellLevel and pointLevel to support dynamic mesh refinement
Patch contributed by Mattijs Janssens Resolves bug-report https://bugs.openfoam.org/view.php?id=2712
This commit is contained in:
committed by
Andrew Heather
parent
798ac98aef
commit
3e19185f10
@ -1,5 +1,7 @@
|
||||
EXE_INC = \
|
||||
-I$(LIB_SRC)/dynamicMesh/lnInclude \
|
||||
-I$(LIB_SRC)/finiteVolume/lnInclude
|
||||
|
||||
EXE_LIBS = \
|
||||
-ldynamicMesh \
|
||||
-lfiniteVolume
|
||||
|
||||
@ -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) 2017 OpenCFD Ltd.
|
||||
-------------------------------------------------------------------------------
|
||||
License
|
||||
@ -42,8 +42,7 @@ Foam::mirrorFvMesh::mirrorFvMesh(const IOobject& io)
|
||||
IOobject::MUST_READ_IF_MODIFIED,
|
||||
IOobject::NO_WRITE
|
||||
)
|
||||
),
|
||||
mirrorMeshPtr_(nullptr)
|
||||
)
|
||||
{
|
||||
plane mirrorPlane(mirrorMeshDict_);
|
||||
|
||||
@ -108,6 +107,21 @@ Foam::mirrorFvMesh::mirrorFvMesh(const IOobject& io)
|
||||
Info<< " New points: " << nNewPoints << endl;
|
||||
newPoints.setSize(nNewPoints);
|
||||
|
||||
// Construct new to old map
|
||||
pointMapPtr_.reset(new labelList(newPoints.size()));
|
||||
labelList& pointMap = pointMapPtr_();
|
||||
// Insert old points
|
||||
forAll(oldPoints, oldPointi)
|
||||
{
|
||||
pointMap[oldPointi] = oldPointi;
|
||||
}
|
||||
forAll(mirrorPointLookup, oldPointi)
|
||||
{
|
||||
pointMap[mirrorPointLookup[oldPointi]] = oldPointi;
|
||||
}
|
||||
|
||||
|
||||
|
||||
Info<< "Mirroring faces. Old faces: " << oldFaces.size();
|
||||
|
||||
// Algorithm:
|
||||
@ -317,6 +331,10 @@ Foam::mirrorFvMesh::mirrorFvMesh(const IOobject& io)
|
||||
cellList newCells(2*oldCells.size());
|
||||
label nNewCells = 0;
|
||||
|
||||
// Construct new to old cell map
|
||||
cellMapPtr_.reset(new labelList(newCells.size()));
|
||||
labelList& cellMap = cellMapPtr_();
|
||||
|
||||
// Grab the original cells. Take care of face renumbering.
|
||||
forAll(oldCells, celli)
|
||||
{
|
||||
@ -330,6 +348,8 @@ Foam::mirrorFvMesh::mirrorFvMesh(const IOobject& io)
|
||||
nc[i] = masterFaceLookup[oc[i]];
|
||||
}
|
||||
|
||||
cellMap[nNewCells] = celli;
|
||||
|
||||
nNewCells++;
|
||||
}
|
||||
|
||||
@ -346,6 +366,8 @@ Foam::mirrorFvMesh::mirrorFvMesh(const IOobject& io)
|
||||
nc[i] = mirrorFaceLookup[oc[i]];
|
||||
}
|
||||
|
||||
cellMap[nNewCells] = celli;
|
||||
|
||||
nNewCells++;
|
||||
}
|
||||
|
||||
@ -361,7 +383,7 @@ Foam::mirrorFvMesh::mirrorFvMesh(const IOobject& io)
|
||||
std::move(newCells)
|
||||
);
|
||||
|
||||
fvMesh& pMesh = *mirrorMeshPtr_;
|
||||
fvMesh& pMesh = mirrorMeshPtr_();
|
||||
|
||||
// Add the boundary patches
|
||||
List<polyPatch*> p(newPatchSizes.size());
|
||||
|
||||
@ -2,7 +2,7 @@
|
||||
========= |
|
||||
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
|
||||
\\ / O peration |
|
||||
\\ / A nd | Copyright (C) 2011 OpenFOAM Foundation
|
||||
\\ / A nd | Copyright (C) 2011-2017 OpenFOAM Foundation
|
||||
\\/ M anipulation |
|
||||
-------------------------------------------------------------------------------
|
||||
License
|
||||
@ -57,6 +57,12 @@ class mirrorFvMesh
|
||||
//- Mirrored mesh
|
||||
autoPtr<fvMesh> mirrorMeshPtr_;
|
||||
|
||||
//- Cell map
|
||||
autoPtr<labelList> cellMapPtr_;
|
||||
|
||||
//- Point map
|
||||
autoPtr<labelList> pointMapPtr_;
|
||||
|
||||
|
||||
// Private Member Functions
|
||||
|
||||
@ -84,7 +90,19 @@ public:
|
||||
//- Return reference to mirror mesh
|
||||
const fvMesh& mirrorMesh() const
|
||||
{
|
||||
return *mirrorMeshPtr_;
|
||||
return mirrorMeshPtr_();
|
||||
}
|
||||
|
||||
//- Mirrorred to original cell
|
||||
const labelList& cellMap() const
|
||||
{
|
||||
return cellMapPtr_();
|
||||
}
|
||||
|
||||
//- Mirrorred to original point
|
||||
const labelList& pointMap() const
|
||||
{
|
||||
return pointMapPtr_();
|
||||
}
|
||||
};
|
||||
|
||||
|
||||
@ -2,7 +2,7 @@
|
||||
========= |
|
||||
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
|
||||
\\ / O peration |
|
||||
\\ / A nd | Copyright (C) 2011-2015 OpenFOAM Foundation
|
||||
\\ / A nd | Copyright (C) 2011-2017 OpenFOAM Foundation
|
||||
\\/ M anipulation |
|
||||
-------------------------------------------------------------------------------
|
||||
License
|
||||
@ -35,6 +35,8 @@ Description
|
||||
#include "argList.H"
|
||||
#include "Time.H"
|
||||
#include "mirrorFvMesh.H"
|
||||
#include "mapPolyMesh.H"
|
||||
#include "hexRef8Data.H"
|
||||
|
||||
using namespace Foam;
|
||||
|
||||
@ -42,18 +44,12 @@ using namespace Foam;
|
||||
|
||||
int main(int argc, char *argv[])
|
||||
{
|
||||
|
||||
#include "addOverwriteOption.H"
|
||||
#include "setRootCase.H"
|
||||
#include "createTime.H"
|
||||
|
||||
const bool overwrite = args.found("overwrite");
|
||||
|
||||
if (!overwrite)
|
||||
{
|
||||
runTime++;
|
||||
}
|
||||
|
||||
mirrorFvMesh mesh
|
||||
(
|
||||
IOobject
|
||||
@ -64,11 +60,71 @@ int main(int argc, char *argv[])
|
||||
)
|
||||
);
|
||||
|
||||
hexRef8Data refData
|
||||
(
|
||||
IOobject
|
||||
(
|
||||
"dummy",
|
||||
mesh.facesInstance(),
|
||||
polyMesh::meshSubDir,
|
||||
mesh,
|
||||
IOobject::READ_IF_PRESENT,
|
||||
IOobject::NO_WRITE,
|
||||
false
|
||||
)
|
||||
);
|
||||
|
||||
if (!overwrite)
|
||||
{
|
||||
runTime++;
|
||||
mesh.setInstance(runTime.timeName());
|
||||
}
|
||||
|
||||
|
||||
// Set the precision of the points data to 10
|
||||
IOstream::defaultPrecision(max(10u, IOstream::defaultPrecision()));
|
||||
|
||||
// Generate the mirrorred mesh
|
||||
const fvMesh& mMesh = mesh.mirrorMesh();
|
||||
|
||||
const_cast<fvMesh&>(mMesh).setInstance(mesh.facesInstance());
|
||||
Info<< "Writing mirrored mesh" << endl;
|
||||
mesh.mirrorMesh().write();
|
||||
mMesh.write();
|
||||
|
||||
// Map the hexRef8 data
|
||||
mapPolyMesh map
|
||||
(
|
||||
mesh,
|
||||
mesh.nPoints(), //nOldPoints,
|
||||
mesh.nFaces(), //nOldFaces,
|
||||
mesh.nCells(), //nOldCells,
|
||||
mesh.pointMap(), //pointMap,
|
||||
List<objectMap>(0), // pointsFromPoints,
|
||||
labelList(0), //faceMap,
|
||||
List<objectMap>(0), //facesFromPoints,
|
||||
List<objectMap>(0), //facesFromEdges,
|
||||
List<objectMap>(0), //facesFromFaces,
|
||||
mesh.cellMap(), //cellMap,
|
||||
List<objectMap>(0), //cellsFromPoints,
|
||||
List<objectMap>(0), //cellsFromEdges,
|
||||
List<objectMap>(0), //cellsFromFaces,
|
||||
List<objectMap>(0), //cellsFromCells,
|
||||
labelList(0), //reversePointMap,
|
||||
labelList(0), //reverseFaceMap,
|
||||
labelList(0), //reverseCellMap,
|
||||
labelHashSet(0), //flipFaceFlux,
|
||||
labelListList(0), //patchPointMap,
|
||||
labelListList(0), //pointZoneMap,
|
||||
labelListList(0), //faceZonePointMap,
|
||||
labelListList(0), //faceZoneFaceMap,
|
||||
labelListList(0), //cellZoneMap,
|
||||
pointField(0), //preMotionPoints,
|
||||
labelList(0), //oldPatchStarts,
|
||||
labelList(0), //oldPatchNMeshPoints,
|
||||
autoPtr<scalarField>() //oldCellVolumesPtr
|
||||
);
|
||||
refData.updateMesh(map);
|
||||
refData.write();
|
||||
|
||||
Info<< "End" << nl << endl;
|
||||
|
||||
|
||||
@ -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
|
||||
@ -90,24 +90,27 @@ Foam::mapPolyMesh::mapPolyMesh
|
||||
oldPatchNMeshPoints_(oldPatchNMeshPoints),
|
||||
oldCellVolumesPtr_(oldCellVolumesPtr)
|
||||
{
|
||||
// Calculate old patch sizes
|
||||
for (label patchi = 0; patchi < oldPatchStarts_.size() - 1; patchi++)
|
||||
if (oldPatchStarts_.size())
|
||||
{
|
||||
oldPatchSizes_[patchi] =
|
||||
oldPatchStarts_[patchi + 1] - oldPatchStarts_[patchi];
|
||||
}
|
||||
|
||||
// Set the last one by hand
|
||||
const label lastPatchID = oldPatchStarts_.size() - 1;
|
||||
|
||||
oldPatchSizes_[lastPatchID] = nOldFaces_ - oldPatchStarts_[lastPatchID];
|
||||
|
||||
if (polyMesh::debug)
|
||||
{
|
||||
if (min(oldPatchSizes_) < 0)
|
||||
// Calculate old patch sizes
|
||||
for (label patchi = 0; patchi < oldPatchStarts_.size() - 1; patchi++)
|
||||
{
|
||||
FatalErrorInFunction
|
||||
<< abort(FatalError);
|
||||
oldPatchSizes_[patchi] =
|
||||
oldPatchStarts_[patchi + 1] - oldPatchStarts_[patchi];
|
||||
}
|
||||
|
||||
// Set the last one by hand
|
||||
const label lastPatchID = oldPatchStarts_.size() - 1;
|
||||
|
||||
oldPatchSizes_[lastPatchID] = nOldFaces_ - oldPatchStarts_[lastPatchID];
|
||||
|
||||
if (polyMesh::debug)
|
||||
{
|
||||
if (min(oldPatchSizes_) < 0)
|
||||
{
|
||||
FatalErrorInFunction
|
||||
<< abort(FatalError);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@ -326,7 +326,6 @@ void Foam::hexRef8Data::updateMesh(const mapPolyMesh& map)
|
||||
}
|
||||
|
||||
|
||||
|
||||
if (cellLevelPtr_.valid())
|
||||
{
|
||||
const labelList& cellMap = map.cellMap();
|
||||
@ -347,6 +346,7 @@ void Foam::hexRef8Data::updateMesh(const mapPolyMesh& map)
|
||||
}
|
||||
}
|
||||
cellLevel.transfer(newCellLevel);
|
||||
cellLevelPtr_().instance() = map.mesh().facesInstance();
|
||||
}
|
||||
if (pointLevelPtr_.valid())
|
||||
{
|
||||
@ -368,13 +368,14 @@ void Foam::hexRef8Data::updateMesh(const mapPolyMesh& map)
|
||||
}
|
||||
}
|
||||
pointLevel.transfer(newPointLevel);
|
||||
pointLevelPtr_().instance() = map.mesh().facesInstance();
|
||||
}
|
||||
|
||||
// No need to map the level0Edge
|
||||
|
||||
if (refHistoryPtr_.valid() && refHistoryPtr_().active())
|
||||
{
|
||||
refHistoryPtr_().updateMesh(map);
|
||||
refHistoryPtr_().instance() = map.mesh().facesInstance();
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user