mirror of
https://github.com/OpenFOAM/OpenFOAM-6.git
synced 2025-12-08 06:57:46 +00:00
blockMesh: Simplify reading of curvedEdges
This commit is contained in:
@ -112,7 +112,7 @@ void Foam::blockMesh::readPatches
|
|||||||
{
|
{
|
||||||
ITstream& patchStream(meshDescription.lookup("patches"));
|
ITstream& patchStream(meshDescription.lookup("patches"));
|
||||||
|
|
||||||
// read number of patches in mesh
|
// Read number of patches in mesh
|
||||||
label nPatches = 0;
|
label nPatches = 0;
|
||||||
|
|
||||||
token firstToken(patchStream);
|
token firstToken(patchStream);
|
||||||
@ -213,6 +213,7 @@ void Foam::blockMesh::readPatches
|
|||||||
// Update halfA info
|
// Update halfA info
|
||||||
patchNames[nPatches-1] = halfA;
|
patchNames[nPatches-1] = halfA;
|
||||||
nbrPatchNames[nPatches-1] = halfB;
|
nbrPatchNames[nPatches-1] = halfB;
|
||||||
|
|
||||||
// Update halfB info
|
// Update halfB info
|
||||||
patchTypes[nPatches] = patchTypes[nPatches-1];
|
patchTypes[nPatches] = patchTypes[nPatches-1];
|
||||||
patchNames[nPatches] = halfB;
|
patchNames[nPatches] = halfB;
|
||||||
@ -326,7 +327,7 @@ Foam::polyMesh* Foam::blockMesh::createTopology
|
|||||||
word defaultPatchName = "defaultFaces";
|
word defaultPatchName = "defaultFaces";
|
||||||
word defaultPatchType = emptyPolyPatch::typeName;
|
word defaultPatchType = emptyPolyPatch::typeName;
|
||||||
|
|
||||||
// get names/types for the unassigned patch faces
|
// Read the names/types for the unassigned patch faces
|
||||||
// this is a bit heavy handed (and ugly), but there is currently
|
// this is a bit heavy handed (and ugly), but there is currently
|
||||||
// no easy way to rename polyMesh patches subsequently
|
// no easy way to rename polyMesh patches subsequently
|
||||||
if (const dictionary* dictPtr = meshDescription.subDictPtr("defaultPatch"))
|
if (const dictionary* dictPtr = meshDescription.subDictPtr("defaultPatch"))
|
||||||
@ -335,85 +336,36 @@ Foam::polyMesh* Foam::blockMesh::createTopology
|
|||||||
dictPtr->readIfPresent("type", defaultPatchType);
|
dictPtr->readIfPresent("type", defaultPatchType);
|
||||||
}
|
}
|
||||||
|
|
||||||
// optional 'convertToMeters' or 'scale' scaling factor
|
// Optional 'convertToMeters' or 'scale' scaling factor
|
||||||
if (!meshDescription.readIfPresent("convertToMeters", scaleFactor_))
|
if (!meshDescription.readIfPresent("convertToMeters", scaleFactor_))
|
||||||
{
|
{
|
||||||
meshDescription.readIfPresent("scale", scaleFactor_);
|
meshDescription.readIfPresent("scale", scaleFactor_);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
//
|
// Read the block edges
|
||||||
// get the non-linear edges in mesh
|
|
||||||
//
|
|
||||||
if (meshDescription.found("edges"))
|
if (meshDescription.found("edges"))
|
||||||
{
|
{
|
||||||
if (verboseOutput)
|
if (verboseOutput)
|
||||||
{
|
{
|
||||||
Info<< "Creating curved edges" << endl;
|
Info<< "Creating block edges" << endl;
|
||||||
}
|
}
|
||||||
|
|
||||||
ITstream& is(meshDescription.lookup("edges"));
|
curvedEdgeList blockEdges
|
||||||
|
|
||||||
// read number of edges in mesh
|
|
||||||
label nEdges = 0;
|
|
||||||
|
|
||||||
token firstToken(is);
|
|
||||||
|
|
||||||
if (firstToken.isLabel())
|
|
||||||
{
|
|
||||||
nEdges = firstToken.labelToken();
|
|
||||||
edges_.setSize(nEdges);
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
is.putBack(firstToken);
|
|
||||||
}
|
|
||||||
|
|
||||||
// Read beginning of edges
|
|
||||||
is.readBegin("edges");
|
|
||||||
|
|
||||||
nEdges = 0;
|
|
||||||
|
|
||||||
token lastToken(is);
|
|
||||||
while
|
|
||||||
(
|
(
|
||||||
!(
|
meshDescription.lookup("edges"),
|
||||||
lastToken.isPunctuation()
|
curvedEdge::iNew(blockPointField_)
|
||||||
&& lastToken.pToken() == token::END_LIST
|
);
|
||||||
)
|
|
||||||
)
|
|
||||||
{
|
|
||||||
if (edges_.size() <= nEdges)
|
|
||||||
{
|
|
||||||
edges_.setSize(nEdges + 1);
|
|
||||||
}
|
|
||||||
|
|
||||||
is.putBack(lastToken);
|
edges_.transfer(blockEdges);
|
||||||
|
|
||||||
edges_.set
|
|
||||||
(
|
|
||||||
nEdges,
|
|
||||||
curvedEdge::New(blockPointField_, is)
|
|
||||||
);
|
|
||||||
|
|
||||||
nEdges++;
|
|
||||||
|
|
||||||
is >> lastToken;
|
|
||||||
}
|
|
||||||
is.putBack(lastToken);
|
|
||||||
|
|
||||||
// Read end of edges
|
|
||||||
is.readEnd("edges");
|
|
||||||
}
|
}
|
||||||
else if (verboseOutput)
|
else if (verboseOutput)
|
||||||
{
|
{
|
||||||
Info<< "No non-linear edges defined" << endl;
|
Info<< "No non-linear block edges defined" << endl;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
//
|
|
||||||
// Create the blocks
|
// Create the blocks
|
||||||
//
|
|
||||||
if (verboseOutput)
|
if (verboseOutput)
|
||||||
{
|
{
|
||||||
Info<< "Creating topology blocks" << endl;
|
Info<< "Creating topology blocks" << endl;
|
||||||
@ -422,7 +374,7 @@ Foam::polyMesh* Foam::blockMesh::createTopology
|
|||||||
{
|
{
|
||||||
ITstream& is(meshDescription.lookup("blocks"));
|
ITstream& is(meshDescription.lookup("blocks"));
|
||||||
|
|
||||||
// read number of blocks in mesh
|
// Read number of blocks in mesh
|
||||||
label nBlocks = 0;
|
label nBlocks = 0;
|
||||||
|
|
||||||
token firstToken(is);
|
token firstToken(is);
|
||||||
@ -482,9 +434,8 @@ Foam::polyMesh* Foam::blockMesh::createTopology
|
|||||||
|
|
||||||
polyMesh* blockMeshPtr = nullptr;
|
polyMesh* blockMeshPtr = nullptr;
|
||||||
|
|
||||||
//
|
|
||||||
// Create the patches
|
// Create the patches
|
||||||
//
|
|
||||||
if (verboseOutput)
|
if (verboseOutput)
|
||||||
{
|
{
|
||||||
Info<< "Creating topology patches" << endl;
|
Info<< "Creating topology patches" << endl;
|
||||||
@ -574,7 +525,7 @@ Foam::polyMesh* Foam::blockMesh::createTopology
|
|||||||
IOobject::NO_WRITE,
|
IOobject::NO_WRITE,
|
||||||
false
|
false
|
||||||
),
|
),
|
||||||
xferCopy(blockPointField_), // copy these points, do NOT move
|
xferCopy(blockPointField_), // Copy these points, do NOT move
|
||||||
tmpBlockCells,
|
tmpBlockCells,
|
||||||
tmpBlocksPatches,
|
tmpBlocksPatches,
|
||||||
patchNames,
|
patchNames,
|
||||||
@ -613,7 +564,7 @@ Foam::polyMesh* Foam::blockMesh::createTopology
|
|||||||
IOobject::NO_WRITE,
|
IOobject::NO_WRITE,
|
||||||
false
|
false
|
||||||
),
|
),
|
||||||
xferCopy(blockPointField_), // copy these points, do NOT move
|
xferCopy(blockPointField_), // Copy these points, do NOT move
|
||||||
tmpBlockCells,
|
tmpBlockCells,
|
||||||
tmpBlocksPatches,
|
tmpBlocksPatches,
|
||||||
patchNames,
|
patchNames,
|
||||||
|
|||||||
@ -123,6 +123,25 @@ public:
|
|||||||
//- New function which constructs and returns pointer to a curvedEdge
|
//- New function which constructs and returns pointer to a curvedEdge
|
||||||
static autoPtr<curvedEdge> New(const pointField&, Istream&);
|
static autoPtr<curvedEdge> New(const pointField&, Istream&);
|
||||||
|
|
||||||
|
//- Class used for the read-construction of
|
||||||
|
// PtrLists of curvedEdge
|
||||||
|
class iNew
|
||||||
|
{
|
||||||
|
const pointField& points_;
|
||||||
|
|
||||||
|
public:
|
||||||
|
|
||||||
|
iNew(const pointField& points)
|
||||||
|
:
|
||||||
|
points_(points)
|
||||||
|
{}
|
||||||
|
|
||||||
|
autoPtr<curvedEdge> operator()(Istream& is) const
|
||||||
|
{
|
||||||
|
return curvedEdge::New(points_, is);
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
|
|
||||||
//- Destructor
|
//- Destructor
|
||||||
virtual ~curvedEdge(){}
|
virtual ~curvedEdge(){}
|
||||||
|
|||||||
Reference in New Issue
Block a user