ENH: Adding extrudePatchMesh, re-location of extrudeModel and

createShellMesh and introducing io::READ_IF_PRESENT option
in polyMesh constructor from components
This commit is contained in:
sergio
2012-04-19 14:07:51 +01:00
parent 2738c6b917
commit 9d6def688f
40 changed files with 620 additions and 32 deletions

View File

@ -10,7 +10,6 @@ EXE_INC = \
${EXE_NDEBUG} \
${CGAL_INC} \
-I$(FOAM_APP)/utilities/mesh/generation/extrude2DMesh/extrude2DMesh/lnInclude \
-I$(FOAM_APP)/utilities/mesh/generation/extrude/extrudeModel/lnInclude \
-IconformalVoronoi2DMesh/lnInclude \
-I$(FOAM_APP)/utilities/mesh/generation/cvMesh/conformalVoronoiMesh/lnInclude \
-I$(LIB_SRC)/finiteVolume/lnInclude \
@ -18,6 +17,7 @@ EXE_INC = \
-I$(LIB_SRC)/surfMesh/lnInclude \
-I$(LIB_SRC)/edgeMesh/lnInclude \
-I$(LIB_SRC)/dynamicMesh/lnInclude \
-I$(LIB_SRC)/mesh/extrudeModel/lnInclude \
-I$(LIB_SRC)/triSurface/lnInclude
EXE_LIBS = \

View File

@ -2,7 +2,6 @@
cd ${0%/*} || exit 1 # run from this directory
set -x
wclean libso extrudeModel
wclean extrudeMesh
wclean extrudeToRegionMesh

View File

@ -2,10 +2,7 @@
cd ${0%/*} || exit 1 # run from this directory
set -x
wmake libso extrudeModel
wmake extrudeMesh
wmake libso extrudeToRegionMesh/createShellMesh
wmake extrudeToRegionMesh

View File

@ -1,10 +1,10 @@
EXE_INC = \
-IextrudedMesh \
-I../extrudeModel/lnInclude \
-I$(LIB_SRC)/finiteVolume/lnInclude \
-I$(LIB_SRC)/surfMesh/lnInclude \
-I$(LIB_SRC)/meshTools/lnInclude \
-I$(LIB_SRC)/dynamicMesh/lnInclude
-I$(LIB_SRC)/dynamicMesh/lnInclude \
-I$(LIB_SRC)/mesh/extrudeModel/lnInclude
EXE_LIBS = \
-lfiniteVolume \

View File

@ -1,13 +1,11 @@
EXE_INC = \
-I../extrudeModel/lnInclude \
-IcreateShellMesh/lnInclude \
-I$(LIB_SRC)/finiteVolume/lnInclude \
-I$(LIB_SRC)/meshTools/lnInclude \
-I$(LIB_SRC)/dynamicMesh/lnInclude
-I$(LIB_SRC)/dynamicMesh/lnInclude \
-I$(LIB_SRC)/mesh/extrudeModel/lnInclude
EXE_LIBS = \
-lextrudeModel \
-lcreateShellMesh \
-lfiniteVolume \
-lmeshTools \
-ldynamicMesh
-ldynamicMesh \
-lextrudeModel

View File

@ -3,7 +3,7 @@ EXE_INC = \
-I$(LIB_SRC)/surfMesh/lnInclude \
-I$(LIB_SRC)/dynamicMesh/lnInclude \
-Iextrude2DMesh/lnInclude \
-I../extrude/extrudeModel/lnInclude
-I$(LIB_SRC)/mesh/extrudeModel/lnInclude
EXE_LIBS = \
-lsurfMesh \

View File

@ -4,7 +4,7 @@ EXE_INC = \
-I$(LIB_SRC)/dynamicMesh/lnInclude \
-I$(LIB_SRC)/finiteVolume/lnInclude \
-I$(LIB_SRC)/surfMesh/lnInclude \
-I$(FOAM_APP)/utilities/mesh/generation/extrude/extrudeModel/lnInclude
-I$(LIB_SRC)/mesh/extrudeModel/lnInclude
LIB_LIBS = \
-lmeshTools \

View File

@ -52,6 +52,8 @@ wmake $makeType conversion
wmake $makeType sampling
wmake $makeType mesh/extrudeModel
wmake $makeType dynamicMesh
wmake $makeType dynamicFvMesh
wmake $makeType topoChangerFvMesh

View File

@ -130,6 +130,7 @@ Foam::solution::solution
obr,
(
obr.readOpt() == IOobject::MUST_READ
|| obr.readOpt() == IOobject::READ_IF_PRESENT
? IOobject::MUST_READ_IF_MODIFIED
: obr.readOpt()
),
@ -148,6 +149,7 @@ Foam::solution::solution
(
readOpt() == IOobject::MUST_READ
|| readOpt() == IOobject::MUST_READ_IF_MODIFIED
|| (readOpt() == IOobject::READ_IF_PRESENT && headerOk())
)
{
read(solutionDict());

View File

@ -132,6 +132,84 @@ Foam::polyBoundaryMesh::polyBoundaryMesh
{}
Foam::polyBoundaryMesh::polyBoundaryMesh
(
const IOobject& io,
const polyMesh& pm,
const polyPatchList& ppl
)
:
polyPatchList(),
regIOobject(io),
mesh_(pm)
{
if
(
(this->readOpt() == IOobject::READ_IF_PRESENT && this->headerOk())
|| this->readOpt() == IOobject::MUST_READ
|| this->readOpt() == IOobject::MUST_READ_IF_MODIFIED
)
{
if (readOpt() == IOobject::MUST_READ_IF_MODIFIED)
{
WarningIn
(
"polyBoundaryMesh::polyBoundaryMesh\n"
"(\n"
" const IOobject&,\n"
" const polyMesh&\n"
" const polyPatchList&\n"
")"
) << "Specified IOobject::MUST_READ_IF_MODIFIED but class"
<< " does not support automatic rereading."
<< endl;
}
polyPatchList& patches = *this;
// Read polyPatchList
Istream& is = readStream(typeName);
PtrList<entry> patchEntries(is);
patches.setSize(patchEntries.size());
forAll(patches, patchI)
{
patches.set
(
patchI,
polyPatch::New
(
patchEntries[patchI].keyword(),
patchEntries[patchI].dict(),
patchI,
*this
)
);
}
// Check state of IOstream
is.check
(
"polyBoundaryMesh::polyBoundaryMesh"
"(const IOobject&, const polyMesh&, const polyPatchList&)"
);
close();
}
else
{
polyPatchList& patches = *this;
patches.setSize(ppl.size());
forAll (patches, patchI)
{
patches.set(patchI, ppl[patchI].clone(*this).ptr());
}
}
}
// * * * * * * * * * * * * * * * * Destructor * * * * * * * * * * * * * * * //
Foam::polyBoundaryMesh::~polyBoundaryMesh()

View File

@ -119,6 +119,14 @@ public:
const label size
);
//- Construct given polyPatchList
polyBoundaryMesh
(
const IOobject&,
const polyMesh&,
const polyPatchList&
);
//- Destructor
~polyBoundaryMesh();

View File

@ -338,7 +338,7 @@ Foam::polyMesh::polyMesh
instance(),
meshSubDir,
*this,
IOobject::NO_READ,
io.readOpt(),
IOobject::AUTO_WRITE
),
points
@ -351,7 +351,7 @@ Foam::polyMesh::polyMesh
instance(),
meshSubDir,
*this,
IOobject::NO_READ,
io.readOpt(),
IOobject::AUTO_WRITE
),
faces
@ -364,7 +364,7 @@ Foam::polyMesh::polyMesh
instance(),
meshSubDir,
*this,
IOobject::NO_READ,
io.readOpt(),
IOobject::AUTO_WRITE
),
owner
@ -377,7 +377,7 @@ Foam::polyMesh::polyMesh
instance(),
meshSubDir,
*this,
IOobject::NO_READ,
io.readOpt(),
IOobject::AUTO_WRITE
),
neighbour
@ -391,11 +391,11 @@ Foam::polyMesh::polyMesh
instance(),
meshSubDir,
*this,
IOobject::NO_READ,
io.readOpt(),
IOobject::AUTO_WRITE
),
*this,
0
polyPatchList()
),
bounds_(points_, syncPar),
geometricD_(Vector<label>::zero),
@ -410,11 +410,11 @@ Foam::polyMesh::polyMesh
instance(),
meshSubDir,
*this,
IOobject::NO_READ,
io.readOpt(),
IOobject::NO_WRITE
),
*this,
0
PtrList<pointZone>()
),
faceZones_
(
@ -424,11 +424,11 @@ Foam::polyMesh::polyMesh
instance(),
meshSubDir,
*this,
IOobject::NO_READ,
io.readOpt(),
IOobject::NO_WRITE
),
*this,
0
PtrList<faceZone>()
),
cellZones_
(
@ -438,11 +438,11 @@ Foam::polyMesh::polyMesh
instance(),
meshSubDir,
*this,
IOobject::NO_READ,
io.readOpt(),
IOobject::NO_WRITE
),
*this,
0
PtrList<cellZone>()
),
globalMeshDataPtr_(NULL),
moving_(false),

View File

@ -162,6 +162,32 @@ Foam::ZoneMesh<ZoneType, MeshType>::ZoneMesh
{}
template<class ZoneType, class MeshType>
Foam::ZoneMesh<ZoneType, MeshType>::ZoneMesh
(
const IOobject& io ,
const MeshType& mesh,
const PtrList<ZoneType>& pzm
)
:
PtrList<ZoneType>(),
regIOobject(io),
mesh_(mesh),
zoneMapPtr_(NULL)
{
ZoneMesh<ZoneType, MeshType>(io, mesh);
if (this->size() == 0)
{
PtrList<ZoneType>& zones = *this;
zones.setSize(pzm.size());
forAll (zones, zoneI)
{
zones.set(zoneI, pzm[zoneI].clone(*this).ptr());
}
}
}
// * * * * * * * * * * * * * * * * Destructor * * * * * * * * * * * * * * * //
template<class ZoneType, class MeshType>

View File

@ -106,6 +106,15 @@ public:
const label size
);
//- Construct given a PtrList
ZoneMesh
(
const IOobject&,
const MeshType&,
const PtrList<ZoneType>&
);
//- Destructor
~ZoneMesh();

View File

@ -86,4 +86,9 @@ motionSmoother/polyMeshGeometry/polyMeshGeometry.C
motionSolver/motionSolver.C
createShellMesh/createShellMesh.C
extrudePatchMesh/extrudePatchMesh.C
LIB = $(FOAM_LIBBIN)/libdynamicMesh

View File

@ -1,8 +1,10 @@
EXE_INC = \
-I$(LIB_SRC)/finiteVolume/lnInclude \
-I$(LIB_SRC)/meshTools/lnInclude \
-I$(LIB_SRC)/triSurface/lnInclude
-I$(LIB_SRC)/triSurface/lnInclude \
-I$(LIB_SRC)/mesh/extrudeModel/lnInclude
LIB_LIBS = \
-lfiniteVolume \
-ltriSurface
-ltriSurface \
-lextrudeModel

View File

@ -0,0 +1,283 @@
/*---------------------------------------------------------------------------*\
========= |
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
\\ / O peration |
\\ / A nd | Copyright (C) 2012-2012 OpenCFD Ltd.
\\/ M anipulation |
-------------------------------------------------------------------------------
License
This file is part of OpenFOAM.
OpenFOAM is free software: you can redistribute it and/or modify it
under the terms of the GNU General Public License as published by
the Free Software Foundation, either version 3 of the License, or
(at your option) any later version.
OpenFOAM is distributed in the hope that it will be useful, but WITHOUT
ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
for more details.
You should have received a copy of the GNU General Public License
along with OpenFOAM. If not, see <http://www.gnu.org/licenses/>.
\*---------------------------------------------------------------------------*/
#include "extrudePatchMesh.H"
#include "createShellMesh.H"
#include "polyTopoChange.H"
#include "wallPolyPatch.H"
#include "emptyPolyPatch.H"
#include "wedgePolyPatch.H"
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
namespace Foam
{
// * * * * * * * * * * * * * * Static Data Members * * * * * * * * * * * * * //
defineTypeNameAndDebug(extrudePatchMesh, 0);
// * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * //
extrudePatchMesh::extrudePatchMesh
(
const fvMesh& mesh,
const fvPatch& patch,
const dictionary& dict
)
:
fvMesh
(
IOobject
(
dict.lookup("region"),
mesh.facesInstance(),
mesh,
IOobject::READ_IF_PRESENT,
IOobject::NO_WRITE,
true
),
xferCopy(pointField()),
xferCopy(faceList()),
xferCopy(labelList()),
xferCopy(labelList()),
false
),
extrudedPatch_(patch.patch())
{
if (this->boundaryMesh().size() == 0)
{
bool columnCells = readBool(dict.lookup("columnCells"));
PackedBoolList nonManifoldEdge(extrudedPatch_.nEdges());
for (label edgeI = 0; edgeI < extrudedPatch_.nInternalEdges(); edgeI++)
{
if (columnCells)
{
nonManifoldEdge[edgeI] = true;
}
}
autoPtr<extrudeModel> model_(extrudeModel::New(dict));
faceList pointGlobalRegions;
faceList pointLocalRegions;
labelList localToGlobalRegion;
const primitiveFacePatch pp
(
extrudedPatch_, extrudedPatch_.points()
);
createShellMesh::calcPointRegions
(
this->globalData(),
pp,
nonManifoldEdge,
false,
pointGlobalRegions,
pointLocalRegions,
localToGlobalRegion
);
// Per local region an originating point
labelList localRegionPoints(localToGlobalRegion.size());
forAll(pointLocalRegions, faceI)
{
const face& f = extrudedPatch_.localFaces()[faceI];
const face& pRegions = pointLocalRegions[faceI];
forAll(pRegions, fp)
{
localRegionPoints[pRegions[fp]] = f[fp];
}
}
// Calculate region normals by reducing local region normals
pointField localRegionNormals(localToGlobalRegion.size());
{
pointField localSum(localToGlobalRegion.size(), vector::zero);
forAll(pointLocalRegions, faceI)
{
const face& pRegions = pointLocalRegions[faceI];
forAll(pRegions, fp)
{
label localRegionI = pRegions[fp];
localSum[localRegionI] +=
extrudedPatch_.faceNormals()[faceI];
}
}
Map<point> globalSum(2*localToGlobalRegion.size());
forAll(localSum, localRegionI)
{
label globalRegionI = localToGlobalRegion[localRegionI];
globalSum.insert(globalRegionI, localSum[localRegionI]);
}
// Reduce
Pstream::mapCombineGather(globalSum, plusEqOp<point>());
Pstream::mapCombineScatter(globalSum);
forAll(localToGlobalRegion, localRegionI)
{
label globalRegionI = localToGlobalRegion[localRegionI];
localRegionNormals[localRegionI] = globalSum[globalRegionI];
}
localRegionNormals /= mag(localRegionNormals);
}
// Per local region an extrusion direction
vectorField firstDisp(localToGlobalRegion.size());
forAll(firstDisp, regionI)
{
//const point& regionPt = regionCentres[regionI];
const point& regionPt = extrudedPatch_.points()
[
extrudedPatch_.meshPoints()
[
localRegionPoints[regionI]
]
];
const vector& n = localRegionNormals[regionI];
firstDisp[regionI] = model_()(regionPt, n, 1) - regionPt;
}
// Extrude engine
createShellMesh extruder
(
pp,
pointLocalRegions,
localRegionPoints
);
List<polyPatch*> regionPatches(3);
List<word> patchNames(regionPatches.size());
List<word> patchTypes(regionPatches.size());
PtrList<dictionary> dicts(regionPatches.size());
forAll (dicts, patchI)
{
if (!dicts.set(patchI))
{
dicts.set(patchI, new dictionary());
}
}
dicts[bottomPatchID] = dict.subDict("bottomCoeffs");
dicts[sidePatchID] = dict.subDict("sideCoeffs");
dicts[topPatchID] = dict.subDict("topCoeffs");
forAll (dicts, patchI)
{
dicts[patchI].lookup("name") >> patchNames[patchI];
dicts[patchI].lookup("type") >> patchTypes[patchI];
}
forAll (regionPatches, patchI)
{
dictionary& patchDict = dicts[patchI];
patchDict.set("nFaces", 0);
patchDict.set("startFace", 0);
regionPatches[patchI] = polyPatch::New
(
patchNames[patchI],
patchDict,
patchI,
mesh.boundaryMesh()
).ptr();
}
this->clearOut();
this->removeFvBoundary();
this->addFvPatches(regionPatches, true);
// At this point we have a valid mesh with 3 patches and zero cells.
// Determine:
// - per face the top and bottom patch (topPatchID, bottomPatchID)
// - per edge, per face on edge the side patch (edgePatches)
labelListList edgePatches(extrudedPatch_.nEdges());
forAll(edgePatches, edgeI)
{
const labelList& eFaces = extrudedPatch_.edgeFaces()[edgeI];
if (eFaces.size() != 2 || nonManifoldEdge[edgeI])
{
edgePatches[edgeI].setSize(eFaces.size(), sidePatchID);
}
}
polyTopoChange meshMod(regionPatches.size());
extruder.setRefinement
(
firstDisp, // first displacement
model_().expansionRatio(),
model_().nLayers(), // nLayers
labelList(extrudedPatch_.size(), topPatchID),
labelList(extrudedPatch_.size(), bottomPatchID),
edgePatches,
meshMod
);
autoPtr<mapPolyMesh> map = meshMod.changeMesh
(
*this, // mesh to change
false // inflate
);
// Update numbering on extruder.
extruder.updateMesh(map);
this->setInstance(this->thisDb().time().constant());
this->write();
}
}
// * * * * * * * * * * * * * * * * Destructor * * * * * * * * * * * * * * * //
extrudePatchMesh::~extrudePatchMesh()
{}
// * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * //
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
} // End namespace Foam
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //

View File

@ -0,0 +1,177 @@
/*---------------------------------------------------------------------------*\
========= |
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
\\ / O peration |
\\ / A nd | Copyright (C) 2012-2012 OpenCFD Ltd.
\\/ M anipulation |
-------------------------------------------------------------------------------
License
This file is part of OpenFOAM.
OpenFOAM is free software: you can redistribute it and/or modify it
under the terms of the GNU General Public License as published by
the Free Software Foundation, either version 3 of the License, or
(at your option) any later version.
OpenFOAM is distributed in the hope that it will be useful, but WITHOUT
ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
for more details.
You should have received a copy of the GNU General Public License
along with OpenFOAM. If not, see <http://www.gnu.org/licenses/>.
Class
extrudePatchMesh
Description
Mesh at a patch created on the fly. The following entried should be used
on the field boundary dictionary:
// New Shell mesh data
region "regionMesh";
extrudeModel linearNormal;
linearNormalCoeffs
{
thickness 40e-6;
}
nLayers 50;
expansionRatio 1;
columnCells true;
// Patch information
bottomCoeffs
{
name "bottom";
type mappedWall;
sampleMode nearestPatchFace;
samplePatch fixedWalls;
offsetMode uniform;
offset (0 0 0);
}
topCoeffs
{
name "top";
type patch;
}
sideCoeffs
{
name "side";
type empty;
}
\*---------------------------------------------------------------------------*/
#ifndef extrudePatchMesh_H
#define extrudePatchMesh_H
#include "extrudeModel.H"
#include "autoPtr.H"
#include "fvMesh.H"
#include "Time.H"
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
namespace Foam
{
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
/*---------------------------------------------------------------------------*\
Class extrudePatchMesh Declaration
\*---------------------------------------------------------------------------*/
class extrudePatchMesh
:
public fvMesh
{
private:
// Private data
//- Enumeration of patch IDs
enum patchID
{
bottomPatchID,
topPatchID,
sidePatchID
};
//- Const reference to the patch from which this mesh is extruded
const polyPatch& extrudedPatch_;
public:
//- Runtime type information
TypeName("extrudePatchMesh");
// Constructors
//- Construct from mesh, patch and dictionary
extrudePatchMesh
(
const fvMesh&,
const fvPatch&,
const dictionary&
);
//- Destructor
virtual ~extrudePatchMesh();
// Member functions
// Access functions
//- Return region mesh
const fvMesh& regionMesh() const
{
return *this;
}
//- Return bottom patch
const polyPatch& bottomPatch() const
{
return this->boundaryMesh()[bottomPatchID];
}
//- Return top patch
const polyPatch& topPatch() const
{
return this->boundaryMesh()[topPatchID];
}
//- Return sides patch
const polyPatch& sidesPatch() const
{
return this->boundaryMesh()[sidePatchID];
}
//- Return extruded patch
const polyPatch& extrudedPatch() const
{
return extrudedPatch_;
}
};
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
} // End namespace Foam
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
#endif
// ************************************************************************* //

View File

@ -258,6 +258,7 @@ Foam::fvSchemes::fvSchemes(const objectRegistry& obr)
obr,
(
obr.readOpt() == IOobject::MUST_READ
|| obr.readOpt() == IOobject::READ_IF_PRESENT
? IOobject::MUST_READ_IF_MODIFIED
: obr.readOpt()
),
@ -372,6 +373,7 @@ Foam::fvSchemes::fvSchemes(const objectRegistry& obr)
(
readOpt() == IOobject::MUST_READ
|| readOpt() == IOobject::MUST_READ_IF_MODIFIED
|| (readOpt() == IOobject::READ_IF_PRESENT && headerOk())
)
{
read(schemesDict());

View File

@ -295,7 +295,7 @@ Foam::fvMesh::fvMesh
fvSchemes(static_cast<const objectRegistry&>(*this)),
fvSolution(static_cast<const objectRegistry&>(*this)),
data(static_cast<const objectRegistry&>(*this)),
boundary_(*this),
boundary_(*this, boundaryMesh()),
lduPtr_(NULL),
curTimeIndex_(time().timeIndex()),
VPtr_(NULL),

View File

@ -5,5 +5,6 @@ set -x
wmake $makeType autoMesh
wmake $makeType blockMesh
wmake $makeType extrudeModel
# ----------------------------------------------------------------- end-of-file

View File

@ -3,5 +3,4 @@ EXE_INC = \
-I$(LIB_SRC)/dynamicMesh/lnInclude
LIB_LIBS = \
-lmeshTools \
-ldynamicMesh
-lmeshTools