Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 3 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
@@ -1,4 +1,6 @@
## Adaptive mesh refinement in OpenFoam-v1812 for 2-dimensional problems
## The [original code](https://github.com/krajit/dynamicRefine2DFvMesh) is ported to OpenFOAM-v2306 with minimum modifications

## Adaptive mesh refinement in OpenFOAM-v2306 for 2-dimensional problems

Standard OpenFOAM-v1812 has a module called dynamicRefineFvMesh. This adaptive mesh refinement tool does not seem to be
applicable for two dimensional problems. [Shonibare](https://www.academia.edu/16217705/Two-dimensional_adaptive_meshing_in_OpenFOAM) and [Ahmad Baniabedalruhman](https://digitalcommons.mtu.edu/cgi/viewcontent.cgi?referer=&httpsredir=1&article=2008&context=etds)
Expand Down
64 changes: 0 additions & 64 deletions src/Make/linux64GccDPInt32Debug/options

This file was deleted.

5 changes: 0 additions & 5 deletions src/Make/linux64GccDPInt32Debug/sourceFiles

This file was deleted.

1 change: 0 additions & 1 deletion src/Make/linux64GccDPInt32Debug/variables

This file was deleted.

64 changes: 0 additions & 64 deletions src/Make/linux64GccDPInt32Opt/options

This file was deleted.

5 changes: 0 additions & 5 deletions src/Make/linux64GccDPInt32Opt/sourceFiles

This file was deleted.

1 change: 0 additions & 1 deletion src/Make/linux64GccDPInt32Opt/variables

This file was deleted.

8 changes: 4 additions & 4 deletions src/Make/options
Original file line number Diff line number Diff line change
Expand Up @@ -3,12 +3,12 @@ EXE_INC = \
-I$(LIB_SRC)/surfMesh/lnInclude \
-I$(LIB_SRC)/meshTools/lnInclude \
-I$(LIB_SRC)/mesh/extrudeModel/lnInclude \
-I$(LIB_SRC)/dynamicMesh/lnInclude \
-I$(LIB_SRC)/dynamicFvMesh/lnInclude
-I$(LIB_SRC)/dynamicMesh/lnInclude \
-I$(LIB_SRC)/dynamicFvMesh/lnInclude

LIB_LIBS = \
-lfiniteVolume \
-lsurfMesh \
-lextrudeModel \
-ldynamicMesh \
-ldynamicFvMesh
-ldynamicMesh \
-ldynamicFvMesh
28 changes: 15 additions & 13 deletions src/dynamicRefine2DFvMesh/dynamicRefine2DFvMesh.C
Original file line number Diff line number Diff line change
Expand Up @@ -296,12 +296,12 @@ autoPtr<mapPolyMesh> dynamicRefine2DFvMesh::refine
(
lookupObject<surfaceScalarField>(correctFluxes_[i][0])
);
surfaceScalarField phiU =
surfaceScalarField phiU(
fvc::interpolate
(
lookupObject<volVectorField>(correctFluxes_[i][1])
)
& Sf();
& Sf());

// Recalculate new internal faces.
for (label faceI = 0; faceI < nInternalFaces(); faceI++)
Expand Down Expand Up @@ -487,12 +487,12 @@ autoPtr<mapPolyMesh> dynamicRefine2DFvMesh::unrefine
(
lookupObject<surfaceScalarField>(correctFluxes_[i][0])
);
surfaceScalarField phiU =
surfaceScalarField phiU(
fvc::interpolate
(
lookupObject<volVectorField>(correctFluxes_[i][1])
)
& Sf();
& Sf());

forAllConstIter(Map<label>, faceToSplitPoint, iter)
{
Expand Down Expand Up @@ -1238,18 +1238,19 @@ bool dynamicRefine2DFvMesh::update()

bool dynamicRefine2DFvMesh::writeObject
(
IOstream::streamFormat fmt,
IOstream::versionNumber ver,
IOstream::compressionType cmp,
const bool valid
IOstreamOption streamOpt,
const bool writeOnProc

) const
{
// Force refinement data to go to the current time directory.
const_cast<hexRef2D&>(meshCutter_).setInstance(time().timeName());

bool writeOk =
dynamicFvMesh::writeObject(fmt, ver, cmp, valid)
&& meshCutter_.write();
(
dynamicFvMesh::writeObject(streamOpt, writeOnProc)
&& meshCutter_.write()
);

if (dumpLevel_)
{
Expand All @@ -1261,11 +1262,12 @@ bool dynamicRefine2DFvMesh::writeObject
time().timeName(),
*this,
IOobject::NO_READ,
IOobject::AUTO_WRITE,
false
IOobject::NO_WRITE,
IOobject::NO_REGISTER
),
*this,
dimensionedScalar("level", dimless, 0)
dimensionedScalar(dimless, Zero)

);

const labelList& cellLevel = meshCutter_.cellLevel();
Expand Down
7 changes: 3 additions & 4 deletions src/dynamicRefine2DFvMesh/dynamicRefine2DFvMesh.H
Original file line number Diff line number Diff line change
Expand Up @@ -175,10 +175,9 @@ class dynamicRefine2DFvMesh

//- Write using given format, version and compression
virtual bool writeObject(
IOstream::streamFormat fmt,
IOstream::versionNumber ver,
IOstream::compressionType cmp,
const bool valid) const;
IOstreamOption streamOpt,
const bool writeOnProc
) const;
};

// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
Expand Down
26 changes: 13 additions & 13 deletions src/hexRef2D/hexRef2D.C
Original file line number Diff line number Diff line change
Expand Up @@ -529,7 +529,7 @@ Foam::label Foam::hexRef2D::getAnchorCell

if (cellAnchorPoints[cellI].size() > 0)
{
label index = findIndex(cellAnchorPoints[cellI], pointI);
label index = cellAnchorPoints[cellI].find(pointI);

if (index != -1)
{
Expand All @@ -552,7 +552,7 @@ Foam::label Foam::hexRef2D::getAnchorCell

forAll(f, fp)
{
label index = findIndex(cellAnchorPoints[cellI], f[fp]);
label index = cellAnchorPoints[cellI].find(f[fp]);

if (index != -1)
{
Expand Down Expand Up @@ -801,9 +801,9 @@ void Foam::hexRef2D::checkInternalOrientation
)
{
face compactFace(identity(newFace.size()));
pointField compactPoints(IndirectList<point>(meshMod.points(), newFace)());
pointField compactPoints(meshMod.points(), newFace);

vector n(compactFace.normal(compactPoints));
vector n(compactFace.areaNormal(compactPoints));

vector dir(neiPt - ownPt);

Expand Down Expand Up @@ -847,9 +847,9 @@ void Foam::hexRef2D::checkBoundaryOrientation
)
{
face compactFace(identity(newFace.size()));
pointField compactPoints(IndirectList<point>(meshMod.points(), newFace)());
pointField compactPoints(meshMod.points(), newFace);

vector n(compactFace.normal(compactPoints));
vector n(compactFace.areaNormal(compactPoints));

vector dir(boundaryPt - ownPt);

Expand Down Expand Up @@ -983,13 +983,13 @@ Foam::label Foam::hexRef2D::storeMidPointInfo
}

const edge& anchors = midPointToAnchors[edgeMidPointI];
label index = findIndex(cellAnchorPoints[cellI], anchorPointI);
label index = cellAnchorPoints[cellI].find(anchorPointI);

if (findIndex(cellAnchorPoints[cellI], anchorPointI) == 0)
if (cellAnchorPoints[cellI].find(anchorPointI) == 0)
{
index = 4;
}
if (findIndex(cellAnchorPoints[cellI], anchorPointI) == 4)
if (cellAnchorPoints[cellI].find(anchorPointI) == 4)
{
index = 8;
}
Expand All @@ -1004,7 +1004,7 @@ Foam::label Foam::hexRef2D::storeMidPointInfo

if (faceOrder == (mesh_.faceOwner()[faceI] == cellI))
{
label anch = findIndex(f, point1);
label anch = f.find(point1);

if (pointLevel_[f[f.rcIndex(anch)]] <= cellLevel_[cellI])
{
Expand Down Expand Up @@ -1043,7 +1043,7 @@ Foam::label Foam::hexRef2D::storeMidPointInfo
}
else
{
label anch = findIndex(f, point1);
label anch = f.find(point1);

if (pointLevel_[f[f.fcIndex(anch)]] <= cellLevel_[cellI])
{
Expand Down Expand Up @@ -4464,7 +4464,7 @@ void Foam::hexRef2D::subset

cellLevel_.transfer(newCellLevel);

if (findIndex(cellLevel_, -1) != -1)
if (cellLevel_.find(-1) != -1)
{
FatalErrorIn("hexRef2D::subset(..)")
<< "Problem : "
Expand All @@ -4485,7 +4485,7 @@ void Foam::hexRef2D::subset

pointLevel_.transfer(newPointLevel);

if (findIndex(pointLevel_, -1) != -1)
if (pointLevel_.find(-1) != -1)
{
FatalErrorIn("hexRef2D::subset(..)")
<< "Problem : "
Expand Down