blockMesh tweaks

- convertToMeters optional, also allow 'scale'
This commit is contained in:
Mark Olesen
2008-10-25 17:55:56 +02:00
parent cd199d599e
commit 4c3c2385ed
17 changed files with 68 additions and 195 deletions

View File

@ -1,4 +0,0 @@
argList::noParallel();
argList::validOptions.insert("blockTopology", "");
argList::validOptions.insert("dict", "dictionary");
# include "addRegionOption.H"

View File

@ -27,7 +27,6 @@ Description
\*---------------------------------------------------------------------------*/ \*---------------------------------------------------------------------------*/
#include "error.H" #include "error.H"
#include "block.H" #include "block.H"
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //

View File

@ -28,18 +28,12 @@ Description
\*---------------------------------------------------------------------------*/ \*---------------------------------------------------------------------------*/
#include "error.H" #include "error.H"
#include "block.H" #include "block.H"
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
namespace Foam
{
// * * * * * * * * * * * * * Private Member Functions * * * * * * * * * * * // // * * * * * * * * * * * * * Private Member Functions * * * * * * * * * * * //
void Foam::block::blockBoundary()
void block::blockBoundary()
{ {
label ni = blockDef_.n().x(); label ni = blockDef_.n().x();
label nj = blockDef_.n().y(); label nj = blockDef_.n().y();
@ -212,9 +206,4 @@ void block::blockBoundary()
} }
} }
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
} // End namespace Foam
// ************************************************************************* // // ************************************************************************* //

View File

@ -28,18 +28,11 @@ Description
\*---------------------------------------------------------------------------*/ \*---------------------------------------------------------------------------*/
#include "error.H" #include "error.H"
#include "block.H" #include "block.H"
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
namespace Foam
{
// * * * * * * * * * * * * * Private Member Functions * * * * * * * * * * * // // * * * * * * * * * * * * * Private Member Functions * * * * * * * * * * * //
void Foam::block::blockCells()
void block::blockCells()
{ {
label ni = blockDef_.n().x(); label ni = blockDef_.n().x();
label nj = blockDef_.n().y(); label nj = blockDef_.n().y();
@ -69,9 +62,4 @@ void block::blockCells()
} }
} }
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
} // End namespace Foam
// ************************************************************************* // // ************************************************************************* //

View File

@ -32,21 +32,16 @@ Description
#include "blockMesh.H" #include "blockMesh.H"
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
namespace Foam
{
// * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * // // * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * //
// Construct from IOdictionary // Construct from IOdictionary
blockMesh::blockMesh(IOdictionary& meshDescription) Foam::blockMesh::blockMesh(IOdictionary& meshDescription)
: :
topologyPtr_(createTopology(meshDescription)), topologyPtr_(createTopology(meshDescription)),
scale_(readScalar(meshDescription.lookup("convertToMeters"))),
blockOffsets_(createBlockOffsets()), blockOffsets_(createBlockOffsets()),
mergeList_(createMergeList()), mergeList_(createMergeList()),
points_(createPoints()), points_(createPoints(meshDescription)),
cells_(createCells()), cells_(createCells()),
patches_(createPatches()) patches_(createPatches())
{} {}
@ -54,7 +49,7 @@ blockMesh::blockMesh(IOdictionary& meshDescription)
// * * * * * * * * * * * * * * * * Destructor * * * * * * * * * * * * * * * // // * * * * * * * * * * * * * * * * Destructor * * * * * * * * * * * * * * * //
blockMesh::~blockMesh() Foam::blockMesh::~blockMesh()
{ {
delete topologyPtr_; delete topologyPtr_;
} }
@ -62,7 +57,7 @@ blockMesh::~blockMesh()
// * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * // // * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * //
const polyMesh& blockMesh::topology() const const Foam::polyMesh& Foam::blockMesh::topology() const
{ {
if (!topologyPtr_) if (!topologyPtr_)
{ {
@ -75,13 +70,7 @@ const polyMesh& blockMesh::topology() const
} }
const curvedEdgeList& blockMesh::edges() const Foam::wordList Foam::blockMesh::patchNames() const
{
return edges_;
}
wordList blockMesh::patchNames() const
{ {
const polyPatchList& patchTopologies = topology().boundaryMesh(); const polyPatchList& patchTopologies = topology().boundaryMesh();
wordList names(patchTopologies.size()); wordList names(patchTopologies.size());
@ -95,7 +84,7 @@ wordList blockMesh::patchNames() const
} }
wordList blockMesh::patchTypes() const Foam::wordList Foam::blockMesh::patchTypes() const
{ {
const polyPatchList& patchTopologies = topology().boundaryMesh(); const polyPatchList& patchTopologies = topology().boundaryMesh();
wordList types(patchTopologies.size()); wordList types(patchTopologies.size());
@ -109,7 +98,7 @@ wordList blockMesh::patchTypes() const
} }
wordList blockMesh::patchPhysicalTypes() const Foam::wordList Foam::blockMesh::patchPhysicalTypes() const
{ {
const polyPatchList& patchTopologies = topology().boundaryMesh(); const polyPatchList& patchTopologies = topology().boundaryMesh();
wordList physicalTypes(patchTopologies.size()); wordList physicalTypes(patchTopologies.size());
@ -123,7 +112,7 @@ wordList blockMesh::patchPhysicalTypes() const
} }
label blockMesh::numZonedBlocks() const Foam::label Foam::blockMesh::numZonedBlocks() const
{ {
label num = 0; label num = 0;
@ -139,7 +128,7 @@ label blockMesh::numZonedBlocks() const
} }
void blockMesh::writeTopology(Ostream& os) const void Foam::blockMesh::writeTopology(Ostream& os) const
{ {
const pointField& pts = topology().points(); const pointField& pts = topology().points();
@ -160,9 +149,4 @@ void blockMesh::writeTopology(Ostream& os) const
} }
} }
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
} // End namespace Foam
// ************************************************************************* // // ************************************************************************* //

View File

@ -62,8 +62,6 @@ class blockMesh
polyMesh* topologyPtr_; polyMesh* topologyPtr_;
scalar scale_;
labelList blockOffsets_; labelList blockOffsets_;
labelList mergeList_; labelList mergeList_;
@ -94,7 +92,7 @@ class blockMesh
labelList createBlockOffsets(); labelList createBlockOffsets();
labelList createMergeList(); labelList createMergeList();
pointField createPoints(); pointField createPoints(const dictionary&);
cellShapeList createCells(); cellShapeList createCells();
faceList createPatchFaces(const polyPatch& patchTopologyFaces); faceList createPatchFaces(const polyPatch& patchTopologyFaces);
@ -123,7 +121,10 @@ public:
const polyMesh& topology() const; const polyMesh& topology() const;
const curvedEdgeList& edges() const; const curvedEdgeList& edges() const
{
return edges_;
}
const pointField& points() const const pointField& points() const
{ {

View File

@ -72,11 +72,11 @@ using namespace Foam;
int main(int argc, char *argv[]) int main(int argc, char *argv[])
{ {
argList::noParallel(); argList::noParallel();
argList::validOptions.insert("blockTopology", "");
# include "addOptions.H" argList::validOptions.insert("dict", "dictionary");
# include "addRegionOption.H"
# include "setRootCase.H" # include "setRootCase.H"
# include "createTime.H" # include "createTime.H"
# include "checkOptions.H"
word regionName; word regionName;
fileName polyMeshDir; fileName polyMeshDir;
@ -117,6 +117,7 @@ int main(int argc, char *argv[])
} }
} }
bool writeTopo = args.options().found("blockTopology");
IOobject meshDictIo IOobject meshDictIo
( (
@ -139,7 +140,7 @@ int main(int argc, char *argv[])
} }
Info<< nl << "Creating block mesh from\n " Info<< nl << "Creating block mesh from\n "
<< meshDictIo.objectPath() << endl; << meshDictIo.objectPath() << nl << endl;
IOdictionary meshDict(meshDictIo); IOdictionary meshDict(meshDictIo);
@ -242,7 +243,7 @@ int main(int argc, char *argv[])
<< exit(FatalError); << exit(FatalError);
} }
//#include "mergePatchPairs.H" //// #include "mergePatchPairs.H"
} }
else else
{ {
@ -316,7 +317,7 @@ int main(int argc, char *argv[])
{ {
label zoneI = iter(); label zoneI = iter();
cz[zoneI]= new cellZone cz[zoneI] = new cellZone
( (
iter.key(), iter.key(),
zoneCells[zoneI].shrink(), zoneCells[zoneI].shrink(),
@ -339,7 +340,7 @@ int main(int argc, char *argv[])
IOstream::defaultPrecision(10); IOstream::defaultPrecision(10);
Info << nl << "Writing polyMesh" << endl; Info << nl << "Writing polyMesh" << endl;
mesh.removeFiles(mesh.instance()); mesh.removeFiles();
if (!mesh.write()) if (!mesh.write())
{ {
FatalErrorIn(args.executable()) FatalErrorIn(args.executable())

View File

@ -28,17 +28,11 @@ Description
\*---------------------------------------------------------------------------*/ \*---------------------------------------------------------------------------*/
#include "error.H" #include "error.H"
#include "block.H" #include "block.H"
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
namespace Foam
{
// * * * * * * * * * * * * * Private Member Functions * * * * * * * * * * * // // * * * * * * * * * * * * * Private Member Functions * * * * * * * * * * * //
void block::blockPoints() void Foam::block::blockPoints()
{ {
// set local variables for mesh specification // set local variables for mesh specification
label ni = blockDef_.n().x(); label ni = blockDef_.n().x();
@ -291,9 +285,4 @@ void block::blockPoints()
} }
} }
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
} // End namespace Foam
// ************************************************************************* // // ************************************************************************* //

View File

@ -28,16 +28,10 @@ Description
#include "blockMesh.H" #include "blockMesh.H"
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
namespace Foam
{
// * * * * * * * * * * * * * Private Member Functions * * * * * * * * * * * // // * * * * * * * * * * * * * Private Member Functions * * * * * * * * * * * //
// Check the blockMesh topology // Check the blockMesh topology
void Foam::blockMesh::checkBlockMesh(const polyMesh& bm)
void blockMesh::checkBlockMesh(const polyMesh& bm)
{ {
Info<< nl << "Check block mesh topology" << endl; Info<< nl << "Check block mesh topology" << endl;
@ -148,9 +142,4 @@ void blockMesh::checkBlockMesh(const polyMesh& bm)
} }
} }
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
} // End namespace Foam
// ************************************************************************* // // ************************************************************************* //

View File

@ -1 +0,0 @@
bool writeTopo = args.options().found("blockTopology");

View File

@ -27,17 +27,11 @@ Description
\*---------------------------------------------------------------------------*/ \*---------------------------------------------------------------------------*/
#include "error.H" #include "error.H"
#include "blockMesh.H" #include "blockMesh.H"
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
namespace Foam
{
// * * * * * * * * * * * * * Private Member Functions * * * * * * * * * * * // // * * * * * * * * * * * * * Private Member Functions * * * * * * * * * * * //
labelList blockMesh::createBlockOffsets() Foam::labelList Foam::blockMesh::createBlockOffsets()
{ {
Info<< nl << "Creating block offsets" << endl; Info<< nl << "Creating block offsets" << endl;
@ -63,10 +57,4 @@ labelList blockMesh::createBlockOffsets()
return BlockOffsets; return BlockOffsets;
} }
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
} // End namespace Foam
// ************************************************************************* // // ************************************************************************* //

View File

@ -29,14 +29,9 @@ License
#include "blockMesh.H" #include "blockMesh.H"
#include "cellModeller.H" #include "cellModeller.H"
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
namespace Foam
{
// * * * * * * * * * * * * * Private Member Functions * * * * * * * * * * * // // * * * * * * * * * * * * * Private Member Functions * * * * * * * * * * * //
cellShapeList blockMesh::createCells() Foam::cellShapeList Foam::blockMesh::createCells()
{ {
Info<< nl << "Creating cells" << endl; Info<< nl << "Creating cells" << endl;
@ -76,10 +71,4 @@ cellShapeList blockMesh::createCells()
return cells; return cells;
} }
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
} // End namespace Foam
// ************************************************************************* // // ************************************************************************* //

View File

@ -26,14 +26,9 @@ License
#include "blockMesh.H" #include "blockMesh.H"
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
namespace Foam
{
// * * * * * * * * * * * * * Private Member Functions * * * * * * * * * * * // // * * * * * * * * * * * * * Private Member Functions * * * * * * * * * * * //
labelList blockMesh::createMergeList() Foam::labelList Foam::blockMesh::createMergeList()
{ {
Info<< nl << "Creating merge list " << flush; Info<< nl << "Creating merge list " << flush;
@ -561,9 +556,4 @@ labelList blockMesh::createMergeList()
return MergeList; return MergeList;
} }
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
} // End namespace Foam
// ************************************************************************* // // ************************************************************************* //

View File

@ -29,14 +29,9 @@ Description
#include "blockMesh.H" #include "blockMesh.H"
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
namespace Foam
{
// * * * * * * * * * * * * * Private Member Functions * * * * * * * * * * * // // * * * * * * * * * * * * * Private Member Functions * * * * * * * * * * * //
faceList blockMesh::createPatchFaces Foam::faceList Foam::blockMesh::createPatchFaces
( (
const polyPatch& patchTopologyFaces const polyPatch& patchTopologyFaces
) )
@ -157,7 +152,7 @@ faceList blockMesh::createPatchFaces
} }
faceListList blockMesh::createPatches() Foam::faceListList Foam::blockMesh::createPatches()
{ {
Info<< "\nCreating patches\n"; Info<< "\nCreating patches\n";
@ -173,9 +168,4 @@ faceListList blockMesh::createPatches()
return patches; return patches;
} }
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
} // End namespace Foam
// ************************************************************************* // // ************************************************************************* //

View File

@ -28,24 +28,26 @@ Description
\*---------------------------------------------------------------------------*/ \*---------------------------------------------------------------------------*/
#include "error.H" #include "error.H"
#include "blockMesh.H" #include "blockMesh.H"
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
namespace Foam
{
// * * * * * * * * * * * * * Private Member Functions * * * * * * * * * * * // // * * * * * * * * * * * * * Private Member Functions * * * * * * * * * * * //
pointField blockMesh::createPoints() Foam::pointField Foam::blockMesh::createPoints(const dictionary& dict)
{ {
Info<< nl << "Creating points" << endl; blockMesh& blocks = *this;
scalar scaleFactor = 1.0;
// optional 'convertToMeters' (or 'scale'?)
if (!dict.readIfPresent("convertToMeters", scaleFactor))
{
dict.readIfPresent("scale", scaleFactor);
}
Info<< nl << "Creating points with scale " << scaleFactor << endl;
pointField points(nPoints_); pointField points(nPoints_);
blockMesh& blocks = *this;
forAll(blocks, blockLabel) forAll(blocks, blockLabel)
{ {
const pointField& blockPoints = blocks[blockLabel].points(); const pointField& blockPoints = blocks[blockLabel].points();
@ -59,17 +61,11 @@ pointField blockMesh::createPoints()
blockPointLabel blockPointLabel
+ blockOffsets_[blockLabel] + blockOffsets_[blockLabel]
] ]
] = scale_*blockPoints[blockPointLabel]; ] = scaleFactor * blockPoints[blockPointLabel];
} }
} }
return points; return points;
} }
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
} // End namespace Foam
// ************************************************************************* // // ************************************************************************* //

View File

@ -40,9 +40,9 @@ bool Foam::blockMesh::blockLabelsOK
{ {
bool ok = true; bool ok = true;
for (int i=0; i<blockShape.size(); i++) forAll(blockShape, blockI)
{ {
if (blockShape[i] < 0) if (blockShape[blockI] < 0)
{ {
ok = false; ok = false;
@ -52,10 +52,10 @@ bool Foam::blockMesh::blockLabelsOK
"(const label blockLabel, const pointField& points, " "(const label blockLabel, const pointField& points, "
"const cellShape& blockShape)" "const cellShape& blockShape)"
) << "block " << blockLabel ) << "block " << blockLabel
<< " point label " << blockShape[i] << " point label " << blockShape[blockI]
<< " less than zero" << endl; << " less than zero" << endl;
} }
else if (blockShape[i] >= points.size()) else if (blockShape[blockI] >= points.size())
{ {
ok = false; ok = false;
@ -65,7 +65,7 @@ bool Foam::blockMesh::blockLabelsOK
"(const label blockLabel, const pointField& points, " "(const label blockLabel, const pointField& points, "
"const cellShape& blockShape)" "const cellShape& blockShape)"
) << "block " << blockLabel ) << "block " << blockLabel
<< " point label " << blockShape[i] << " point label " << blockShape[blockI]
<< " larger than " << points.size() - 1 << " larger than " << points.size() - 1
<< " the largest defined point label" << endl; << " the largest defined point label" << endl;
} }
@ -84,38 +84,34 @@ bool Foam::blockMesh::patchLabelsOK
{ {
bool ok = true; bool ok = true;
for (label facei=0; facei<patchFaces.size(); facei++) forAll(patchFaces, faceI)
{ {
const labelList& labels = patchFaces[facei]; const labelList& f = patchFaces[faceI];
for (int i=0; i<labels.size(); i++) forAll(f, fp)
{ {
if (labels[i] < 0) if (f[fp] < 0)
{ {
ok = false; ok = false;
WarningIn WarningIn
( (
"bool Foam::blockMesh::patchLabelsOK" "bool Foam::blockMesh::patchLabelsOK(...)"
"(const label patchLabel, const pointField& points, "
"const faceList& patchFaces)"
) << "patch " << patchLabel ) << "patch " << patchLabel
<< " face " << facei << " face " << faceI
<< " point label " << labels[i] << " point label " << f[fp]
<< " less than zero" << endl; << " less than zero" << endl;
} }
else if (labels[i] >= points.size()) else if (f[fp] >= points.size())
{ {
ok = false; ok = false;
WarningIn WarningIn
( (
"bool Foam::blockMesh::patchLabelsOK" "bool Foam::blockMesh::patchLabelsOK(...)"
"(const label patchLabel, const pointField& points, "
"const faceList& patchFaces)"
) << "patch " << patchLabel ) << "patch " << patchLabel
<< " face " << facei << " face " << faceI
<< " point label " << labels[i] << " point label " << f[fp]
<< " larger than " << points.size() - 1 << " larger than " << points.size() - 1
<< " the largest defined point label" << endl; << " the largest defined point label" << endl;
} }
@ -137,23 +133,13 @@ Foam::polyMesh* Foam::blockMesh::createTopology(IOdictionary& meshDescription)
word defaultPatchName = "defaultFaces"; word defaultPatchName = "defaultFaces";
word defaultPatchType = emptyPolyPatch::typeName; word defaultPatchType = emptyPolyPatch::typeName;
// get names and types for the unassigned patch faces // get names/types for the unassigned patch faces
if (meshDescription.found("defaultPatch")) // this is a bit heavy handed (and ugly), but there is currently
// no easy way to rename polyMesh patches subsequently
if (const dictionary* dictPtr = meshDescription.subDictPtr("defaultPatch"))
{ {
const dictionary& defaultPatch = dictPtr->readIfPresent("name", defaultPatchName);
meshDescription.subDict("defaultPatch"); dictPtr->readIfPresent("type", defaultPatchType);
// this is a bit heavy handed (and ugly), but there is currently
// no easy way to rename polyMesh patches subsequently
if (defaultPatch.found("name"))
{
defaultPatch.lookup("name") >> defaultPatchName;
}
if (defaultPatch.found("type"))
{
defaultPatch.lookup("type") >> defaultPatchType;
}
} }
Info<< nl << "Creating blockCorners" << endl; Info<< nl << "Creating blockCorners" << endl;
@ -456,4 +442,3 @@ Foam::polyMesh* Foam::blockMesh::createTopology(IOdictionary& meshDescription)
// ************************************************************************* // // ************************************************************************* //

View File

@ -1,4 +1,4 @@
Info<< nl << "Creating merge patch pairs" << nl << endl; Info<< "Creating merge patch pairs" << nl << endl;
if (mergePatchPairs.size() > 0) if (mergePatchPairs.size() > 0)
{ {