mirror of
https://develop.openfoam.com/Development/openfoam.git
synced 2025-11-28 03:28:01 +00:00
Initial set of changes.
This commit is contained in:
@ -5,4 +5,4 @@ EXE_INC = \
|
||||
|
||||
EXE_LIBS = \
|
||||
-lmeshTools \
|
||||
-ldynamicMesh
|
||||
/* -ldynamicMesh */
|
||||
|
||||
@ -81,45 +81,21 @@ const curvedEdgeList& blockMesh::edges() const
|
||||
}
|
||||
|
||||
|
||||
wordList blockMesh::patchNames() const
|
||||
PtrList<dictionary> blockMesh::patchDicts() const
|
||||
{
|
||||
const polyPatchList& patchTopologies = topology().boundaryMesh();
|
||||
wordList names(patchTopologies.size());
|
||||
|
||||
forAll (names, patchI)
|
||||
PtrList<dictionary> patchDicts(patchTopologies.size());
|
||||
|
||||
forAll(patchTopologies, patchI)
|
||||
{
|
||||
names[patchI] = patchTopologies[patchI].name();
|
||||
OStringStream os;
|
||||
patchTopologies[patchI].write(os);
|
||||
IStringStream is(os.str());
|
||||
patchDicts.set(patchI, new dictionary(is));
|
||||
patchDicts[patchI].set("name", patchTopologies[patchI].name());
|
||||
}
|
||||
|
||||
return names;
|
||||
}
|
||||
|
||||
|
||||
wordList blockMesh::patchTypes() const
|
||||
{
|
||||
const polyPatchList& patchTopologies = topology().boundaryMesh();
|
||||
wordList types(patchTopologies.size());
|
||||
|
||||
forAll (types, patchI)
|
||||
{
|
||||
types[patchI] = patchTopologies[patchI].type();
|
||||
}
|
||||
|
||||
return types;
|
||||
}
|
||||
|
||||
|
||||
wordList blockMesh::patchPhysicalTypes() const
|
||||
{
|
||||
const polyPatchList& patchTopologies = topology().boundaryMesh();
|
||||
wordList physicalTypes(patchTopologies.size());
|
||||
|
||||
forAll (physicalTypes, patchI)
|
||||
{
|
||||
physicalTypes[patchI] = patchTopologies[patchI].physicalType();
|
||||
}
|
||||
|
||||
return physicalTypes;
|
||||
return patchDicts;
|
||||
}
|
||||
|
||||
|
||||
|
||||
@ -88,6 +88,30 @@ class blockMesh
|
||||
const faceList& patchShapes
|
||||
);
|
||||
|
||||
bool readPatches
|
||||
(
|
||||
const dictionary& meshDescription,
|
||||
const pointField& tmpBlockPoints,
|
||||
faceListList& tmpBlocksPatches,
|
||||
wordList& patchNames,
|
||||
wordList& patchTypes,
|
||||
wordList& nbrPatchNames
|
||||
);
|
||||
|
||||
bool readBoundary
|
||||
(
|
||||
const dictionary& meshDescription,
|
||||
const pointField& tmpBlockPoints,
|
||||
faceListList& tmpBlocksPatches,
|
||||
PtrList<dictionary>& patchDicts
|
||||
);
|
||||
|
||||
void createCellShapes
|
||||
(
|
||||
const pointField& tmpBlockPoints,
|
||||
PtrList<cellShape>& tmpBlockCells
|
||||
);
|
||||
|
||||
polyMesh* createTopology(IOdictionary&);
|
||||
void checkBlockMesh(const polyMesh&);
|
||||
|
||||
@ -140,11 +164,15 @@ public:
|
||||
return patches_;
|
||||
}
|
||||
|
||||
wordList patchNames() const;
|
||||
|
||||
wordList patchTypes() const;
|
||||
//- Get patch information from the topology mesh
|
||||
PtrList<dictionary> patchDicts() const;
|
||||
|
||||
wordList patchPhysicalTypes() const;
|
||||
// wordList patchNames() const;
|
||||
//
|
||||
// wordList patchTypes() const;
|
||||
//
|
||||
// wordList patchPhysicalTypes() const;
|
||||
|
||||
//- Number of blocks with specified zones
|
||||
label numZonedBlocks() const;
|
||||
|
||||
@ -190,23 +190,8 @@ int main(int argc, char *argv[])
|
||||
|
||||
Info<< nl << "Creating mesh from block mesh" << endl;
|
||||
|
||||
wordList patchNames = blocks.patchNames();
|
||||
wordList patchTypes = blocks.patchTypes();
|
||||
word defaultFacesName = "defaultFaces";
|
||||
word defaultFacesType = emptyPolyPatch::typeName;
|
||||
wordList patchPhysicalTypes = blocks.patchPhysicalTypes();
|
||||
|
||||
preservePatchTypes
|
||||
(
|
||||
runTime,
|
||||
runTime.constant(),
|
||||
polyMeshDir,
|
||||
patchNames,
|
||||
patchTypes,
|
||||
defaultFacesName,
|
||||
defaultFacesType,
|
||||
patchPhysicalTypes
|
||||
);
|
||||
|
||||
polyMesh mesh
|
||||
(
|
||||
@ -219,11 +204,9 @@ int main(int argc, char *argv[])
|
||||
blocks.points(),
|
||||
blocks.cells(),
|
||||
blocks.patches(),
|
||||
patchNames,
|
||||
patchTypes,
|
||||
blocks.patchDicts(),
|
||||
defaultFacesName,
|
||||
defaultFacesType,
|
||||
patchPhysicalTypes
|
||||
defaultFacesType
|
||||
);
|
||||
|
||||
|
||||
|
||||
@ -28,6 +28,7 @@ License
|
||||
#include "Time.H"
|
||||
#include "preservePatchTypes.H"
|
||||
#include "emptyPolyPatch.H"
|
||||
#include "cyclicPolyPatch.H"
|
||||
|
||||
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
|
||||
|
||||
@ -126,6 +127,248 @@ bool Foam::blockMesh::patchLabelsOK
|
||||
}
|
||||
|
||||
|
||||
bool Foam::blockMesh::readPatches
|
||||
(
|
||||
const dictionary& meshDescription,
|
||||
const pointField& tmpBlockPoints,
|
||||
faceListList& tmpBlocksPatches,
|
||||
wordList& patchNames,
|
||||
wordList& patchTypes,
|
||||
wordList& nbrPatchNames
|
||||
)
|
||||
{
|
||||
bool topologyOK = true;
|
||||
|
||||
ITstream& patchStream(meshDescription.lookup("patches"));
|
||||
|
||||
// read number of patches in mesh
|
||||
label nPatches = 0;
|
||||
|
||||
token firstToken(patchStream);
|
||||
|
||||
if (firstToken.isLabel())
|
||||
{
|
||||
nPatches = firstToken.labelToken();
|
||||
|
||||
tmpBlocksPatches.setSize(nPatches);
|
||||
patchNames.setSize(nPatches);
|
||||
patchTypes.setSize(nPatches);
|
||||
nbrPatchNames.setSize(nPatches);
|
||||
}
|
||||
else
|
||||
{
|
||||
patchStream.putBack(firstToken);
|
||||
}
|
||||
|
||||
// Read beginning of blocks
|
||||
patchStream.readBegin("patches");
|
||||
|
||||
nPatches = 0;
|
||||
|
||||
token lastToken(patchStream);
|
||||
while
|
||||
(
|
||||
!(
|
||||
lastToken.isPunctuation()
|
||||
&& lastToken.pToken() == token::END_LIST
|
||||
)
|
||||
)
|
||||
{
|
||||
if (tmpBlocksPatches.size() <= nPatches)
|
||||
{
|
||||
tmpBlocksPatches.setSize(nPatches + 1);
|
||||
patchNames.setSize(nPatches + 1);
|
||||
patchTypes.setSize(nPatches + 1);
|
||||
nbrPatchNames.setSize(nPatches + 1);
|
||||
}
|
||||
|
||||
patchStream.putBack(lastToken);
|
||||
|
||||
patchStream
|
||||
>> patchTypes[nPatches]
|
||||
>> patchNames[nPatches];
|
||||
|
||||
// Read optional neighbour patch name
|
||||
if (patchTypes[nPatches] == cyclicPolyPatch::typeName)
|
||||
{
|
||||
patchStream >> lastToken;
|
||||
if (lastToken.isWord())
|
||||
{
|
||||
nbrPatchNames[nPatches] = lastToken.wordToken();
|
||||
}
|
||||
else
|
||||
{
|
||||
patchStream.putBack(lastToken);
|
||||
}
|
||||
}
|
||||
|
||||
// Read patch faces
|
||||
patchStream >> tmpBlocksPatches[nPatches];
|
||||
|
||||
|
||||
// Catch multiple patches asap.
|
||||
for (label i = 0; i < nPatches; i++)
|
||||
{
|
||||
if (patchNames[nPatches] == patchNames[i])
|
||||
{
|
||||
FatalErrorIn
|
||||
(
|
||||
"blockMesh::createTopology(IOdictionary&)"
|
||||
) << "Duplicate patch " << patchNames[nPatches]
|
||||
<< " at line " << patchStream.lineNumber()
|
||||
<< ". Exiting !" << nl
|
||||
<< exit(FatalError);
|
||||
}
|
||||
}
|
||||
|
||||
topologyOK = topologyOK && patchLabelsOK
|
||||
(
|
||||
nPatches,
|
||||
tmpBlockPoints,
|
||||
tmpBlocksPatches[nPatches]
|
||||
);
|
||||
|
||||
nPatches++;
|
||||
|
||||
|
||||
// Split old style cyclics
|
||||
|
||||
if (patchTypes[nPatches-1] == cyclicPolyPatch::typeName)
|
||||
{
|
||||
if (nbrPatchNames[nPatches] == word::null)
|
||||
{
|
||||
word halfA = patchNames[nPatches-1] + "_half0";
|
||||
word halfB = patchNames[nPatches-1] + "_half1";
|
||||
|
||||
WarningIn("blockMesh::createTopology(IOdictionary&)")
|
||||
<< "Old-style cyclic definition."
|
||||
<< " Splitting patch "
|
||||
<< patchNames[nPatches-1] << " into two halves "
|
||||
<< halfA << " and " << halfB << endl
|
||||
<< " Alternatively use new syntax "
|
||||
<< " cyclic <name> <neighbourname> <faces>" << endl;
|
||||
|
||||
// Add extra patch
|
||||
if (tmpBlocksPatches.size() <= nPatches)
|
||||
{
|
||||
tmpBlocksPatches.setSize(nPatches + 1);
|
||||
patchNames.setSize(nPatches + 1);
|
||||
patchTypes.setSize(nPatches + 1);
|
||||
nbrPatchNames.setSize(nPatches + 1);
|
||||
}
|
||||
|
||||
patchNames[nPatches-1] = halfA;
|
||||
nbrPatchNames[nPatches-1] = halfB;
|
||||
patchTypes[nPatches] = patchTypes[nPatches-1];
|
||||
patchNames[nPatches] = halfB;
|
||||
nbrPatchNames[nPatches] = halfA;
|
||||
|
||||
// Split faces
|
||||
if ((tmpBlocksPatches[nPatches-1].size() % 2) != 0)
|
||||
{
|
||||
FatalErrorIn
|
||||
(
|
||||
"blockMesh::createTopology(IOdictionary&)"
|
||||
) << "Size of cyclic faces is not a multiple of 2 :"
|
||||
<< tmpBlocksPatches[nPatches-1]
|
||||
<< exit(FatalError);
|
||||
}
|
||||
label sz = tmpBlocksPatches[nPatches-1].size()/2;
|
||||
faceList unsplitFaces(tmpBlocksPatches[nPatches-1], true);
|
||||
tmpBlocksPatches[nPatches-1] = faceList
|
||||
(
|
||||
SubList<face>(unsplitFaces, sz)
|
||||
);
|
||||
tmpBlocksPatches[nPatches] = faceList
|
||||
(
|
||||
SubList<face>(unsplitFaces, sz, sz)
|
||||
);
|
||||
|
||||
nPatches++;
|
||||
}
|
||||
}
|
||||
|
||||
patchStream >> lastToken;
|
||||
}
|
||||
patchStream.putBack(lastToken);
|
||||
|
||||
// Read end of blocks
|
||||
patchStream.readEnd("patches");
|
||||
|
||||
return topologyOK;
|
||||
}
|
||||
|
||||
|
||||
bool Foam::blockMesh::readBoundary
|
||||
(
|
||||
const dictionary& meshDescription,
|
||||
const pointField& tmpBlockPoints,
|
||||
faceListList& tmpBlocksPatches,
|
||||
PtrList<dictionary>& patchDicts
|
||||
)
|
||||
{
|
||||
bool topologyOK = true;
|
||||
|
||||
// Read like boundary file
|
||||
const PtrList<entry> patchesInfo
|
||||
(
|
||||
meshDescription.lookup("boundary")
|
||||
);
|
||||
|
||||
tmpBlocksPatches.setSize(patchesInfo.size());
|
||||
patchDicts.setSize(patchesInfo.size());
|
||||
|
||||
forAll(tmpBlocksPatches, patchI)
|
||||
{
|
||||
const entry& patchInfo = patchesInfo[patchI];
|
||||
|
||||
// Construct dictionary and add name
|
||||
patchDicts.set(patchI, new dictionary(patchInfo.dict()));
|
||||
patchDicts[patchI].set("name", patchInfo.keyword());
|
||||
// Read block faces
|
||||
patchDicts[patchI].lookup("faces") >> tmpBlocksPatches[patchI];
|
||||
|
||||
topologyOK = topologyOK && patchLabelsOK
|
||||
(
|
||||
patchI,
|
||||
tmpBlockPoints,
|
||||
tmpBlocksPatches[patchI]
|
||||
);
|
||||
}
|
||||
|
||||
return topologyOK;
|
||||
}
|
||||
|
||||
|
||||
void Foam::blockMesh::createCellShapes
|
||||
(
|
||||
const pointField& tmpBlockPoints,
|
||||
PtrList<cellShape>& tmpBlockCells
|
||||
)
|
||||
{
|
||||
const blockMesh& blocks = *this;
|
||||
|
||||
tmpBlockCells.setSize(blocks.size());
|
||||
forAll(blocks, blockLabel)
|
||||
{
|
||||
tmpBlockCells.set
|
||||
(
|
||||
blockLabel,
|
||||
new cellShape(blocks[blockLabel].blockDef().blockShape())
|
||||
);
|
||||
|
||||
if (tmpBlockCells[blockLabel].mag(tmpBlockPoints) < 0.0)
|
||||
{
|
||||
WarningIn
|
||||
(
|
||||
"blockMesh::createTopology(IOdictionary&)"
|
||||
) << "negative volume block : " << blockLabel
|
||||
<< ", probably defined inside-out" << endl;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
// * * * * * * * * * * * * * Private Member Functions * * * * * * * * * * * //
|
||||
|
||||
Foam::polyMesh* Foam::blockMesh::createTopology(IOdictionary& meshDescription)
|
||||
@ -296,158 +539,127 @@ Foam::polyMesh* Foam::blockMesh::createTopology(IOdictionary& meshDescription)
|
||||
}
|
||||
|
||||
|
||||
polyMesh* blockMeshPtr = NULL;
|
||||
|
||||
Info<< nl << "Creating patches" << endl;
|
||||
|
||||
faceListList tmpBlocksPatches;
|
||||
wordList patchNames;
|
||||
wordList patchTypes;
|
||||
|
||||
if (meshDescription.found("patches"))
|
||||
{
|
||||
ITstream& patchStream(meshDescription.lookup("patches"));
|
||||
Info<< nl << "Reading patches section" << endl;
|
||||
|
||||
// read number of patches in mesh
|
||||
label nPatches = 0;
|
||||
faceListList tmpBlocksPatches;
|
||||
wordList patchNames;
|
||||
wordList patchTypes;
|
||||
wordList nbrPatchNames;
|
||||
|
||||
token firstToken(patchStream);
|
||||
|
||||
if (firstToken.isLabel())
|
||||
{
|
||||
nPatches = firstToken.labelToken();
|
||||
|
||||
tmpBlocksPatches.setSize(nPatches);
|
||||
patchNames.setSize(nPatches);
|
||||
patchTypes.setSize(nPatches);
|
||||
}
|
||||
else
|
||||
{
|
||||
patchStream.putBack(firstToken);
|
||||
}
|
||||
|
||||
// Read beginning of blocks
|
||||
patchStream.readBegin("patches");
|
||||
|
||||
nPatches = 0;
|
||||
|
||||
token lastToken(patchStream);
|
||||
while
|
||||
topologyOK = topologyOK && readPatches
|
||||
(
|
||||
!(
|
||||
lastToken.isPunctuation()
|
||||
&& lastToken.pToken() == token::END_LIST
|
||||
)
|
||||
)
|
||||
{
|
||||
if (tmpBlocksPatches.size() <= nPatches)
|
||||
{
|
||||
tmpBlocksPatches.setSize(nPatches + 1);
|
||||
patchNames.setSize(nPatches + 1);
|
||||
patchTypes.setSize(nPatches + 1);
|
||||
}
|
||||
|
||||
patchStream.putBack(lastToken);
|
||||
|
||||
patchStream
|
||||
>> patchTypes[nPatches]
|
||||
>> patchNames[nPatches]
|
||||
>> tmpBlocksPatches[nPatches];
|
||||
|
||||
|
||||
// Catch multiple patches asap.
|
||||
for (label i = 0; i < nPatches; i++)
|
||||
{
|
||||
if (patchNames[nPatches] == patchNames[i])
|
||||
{
|
||||
FatalErrorIn
|
||||
(
|
||||
"blockMesh::createTopology(IOdictionary&)"
|
||||
) << "Duplicate patch " << patchNames[nPatches]
|
||||
<< " at line " << patchStream.lineNumber()
|
||||
<< ". Exiting !" << nl
|
||||
<< exit(FatalError);
|
||||
}
|
||||
}
|
||||
|
||||
topologyOK = topologyOK && patchLabelsOK
|
||||
(
|
||||
nPatches,
|
||||
tmpBlockPoints,
|
||||
tmpBlocksPatches[nPatches]
|
||||
);
|
||||
|
||||
nPatches++;
|
||||
|
||||
patchStream >> lastToken;
|
||||
}
|
||||
patchStream.putBack(lastToken);
|
||||
|
||||
// Read end of blocks
|
||||
patchStream.readEnd("patches");
|
||||
}
|
||||
|
||||
|
||||
if (!topologyOK)
|
||||
{
|
||||
FatalErrorIn("blockMesh::createTopology(IOdictionary&)")
|
||||
<< "Cannot create mesh due to errors in topology, exiting !" << nl
|
||||
<< exit(FatalError);
|
||||
}
|
||||
|
||||
|
||||
Info<< nl << "Creating block mesh topology" << endl;
|
||||
|
||||
PtrList<cellShape> tmpBlockCells(blocks.size());
|
||||
forAll(blocks, blockLabel)
|
||||
{
|
||||
tmpBlockCells.set
|
||||
(
|
||||
blockLabel,
|
||||
new cellShape(blocks[blockLabel].blockDef().blockShape())
|
||||
meshDescription,
|
||||
tmpBlockPoints,
|
||||
tmpBlocksPatches,
|
||||
patchNames,
|
||||
patchTypes,
|
||||
nbrPatchNames
|
||||
);
|
||||
|
||||
if (tmpBlockCells[blockLabel].mag(tmpBlockPoints) < 0.0)
|
||||
if (!topologyOK)
|
||||
{
|
||||
WarningIn
|
||||
(
|
||||
"blockMesh::createTopology(IOdictionary&)"
|
||||
) << "negative volume block : " << blockLabel
|
||||
<< ", probably defined inside-out" << endl;
|
||||
FatalErrorIn("blockMesh::createTopology(IOdictionary&)")
|
||||
<< "Cannot create mesh due to errors in topology, exiting !"
|
||||
<< nl << exit(FatalError);
|
||||
}
|
||||
|
||||
|
||||
Info<< nl << "Creating block mesh topology" << endl;
|
||||
|
||||
PtrList<cellShape> tmpBlockCells(blocks.size());
|
||||
createCellShapes(tmpBlockPoints, tmpBlockCells);
|
||||
|
||||
|
||||
Info<< nl << "Reading physicalType from existing boundary file" << endl;
|
||||
|
||||
wordList patchPhysicalTypes(tmpBlocksPatches.size());
|
||||
|
||||
preservePatchTypes
|
||||
(
|
||||
meshDescription.time(),
|
||||
meshDescription.time().constant(),
|
||||
polyMesh::meshSubDir,
|
||||
patchNames,
|
||||
patchTypes,
|
||||
defaultPatchName,
|
||||
defaultPatchType,
|
||||
patchPhysicalTypes
|
||||
);
|
||||
|
||||
blockMeshPtr = new polyMesh
|
||||
(
|
||||
IOobject
|
||||
(
|
||||
"blockMesh",
|
||||
meshDescription.time().constant(),
|
||||
meshDescription.time(),
|
||||
IOobject::NO_READ,
|
||||
IOobject::NO_WRITE,
|
||||
false
|
||||
),
|
||||
tmpBlockPoints,
|
||||
tmpBlockCells,
|
||||
tmpBlocksPatches,
|
||||
patchNames,
|
||||
patchTypes,
|
||||
defaultPatchName,
|
||||
defaultPatchType,
|
||||
patchPhysicalTypes
|
||||
);
|
||||
}
|
||||
else if (meshDescription.found("boundary"))
|
||||
{
|
||||
faceListList tmpBlocksPatches;
|
||||
PtrList<dictionary> patchDicts;
|
||||
|
||||
topologyOK = topologyOK && readBoundary
|
||||
(
|
||||
meshDescription,
|
||||
tmpBlockPoints,
|
||||
tmpBlocksPatches,
|
||||
patchDicts
|
||||
);
|
||||
|
||||
if (!topologyOK)
|
||||
{
|
||||
FatalErrorIn("blockMesh::createTopology(IOdictionary&)")
|
||||
<< "Cannot create mesh due to errors in topology, exiting !"
|
||||
<< nl << exit(FatalError);
|
||||
}
|
||||
|
||||
|
||||
Info<< nl << "Creating block mesh topology" << endl;
|
||||
|
||||
PtrList<cellShape> tmpBlockCells(blocks.size());
|
||||
createCellShapes(tmpBlockPoints, tmpBlockCells);
|
||||
|
||||
|
||||
blockMeshPtr = new polyMesh
|
||||
(
|
||||
IOobject
|
||||
(
|
||||
"blockMesh",
|
||||
meshDescription.time().constant(),
|
||||
meshDescription.time(),
|
||||
IOobject::NO_READ,
|
||||
IOobject::NO_WRITE,
|
||||
false
|
||||
),
|
||||
tmpBlockPoints,
|
||||
tmpBlockCells,
|
||||
tmpBlocksPatches,
|
||||
patchDicts,
|
||||
defaultPatchName,
|
||||
defaultPatchType
|
||||
);
|
||||
}
|
||||
|
||||
wordList patchPhysicalTypes(tmpBlocksPatches.size());
|
||||
|
||||
preservePatchTypes
|
||||
(
|
||||
meshDescription.time(),
|
||||
meshDescription.time().constant(),
|
||||
polyMesh::meshSubDir,
|
||||
patchNames,
|
||||
patchTypes,
|
||||
defaultPatchName,
|
||||
defaultPatchType,
|
||||
patchPhysicalTypes
|
||||
);
|
||||
|
||||
polyMesh* blockMeshPtr = new polyMesh
|
||||
(
|
||||
IOobject
|
||||
(
|
||||
"blockMesh",
|
||||
meshDescription.time().constant(),
|
||||
meshDescription.time(),
|
||||
IOobject::NO_READ,
|
||||
IOobject::NO_WRITE,
|
||||
false
|
||||
),
|
||||
tmpBlockPoints,
|
||||
tmpBlockCells,
|
||||
tmpBlocksPatches,
|
||||
patchNames,
|
||||
patchTypes,
|
||||
defaultPatchName,
|
||||
defaultPatchType,
|
||||
patchPhysicalTypes
|
||||
);
|
||||
|
||||
checkBlockMesh(*blockMeshPtr);
|
||||
|
||||
|
||||
Reference in New Issue
Block a user