Merge remote branch 'OpenCFD/master' into olesenm

Conflicts:
	src/finiteVolume/fields/fvPatchFields/derived/timeVaryingMappedFixedValue/timeVaryingMappedFixedValueFvPatchField.C
This commit is contained in:
Mark Olesen
2010-05-31 11:50:56 +02:00
1421 changed files with 21173 additions and 9427 deletions

View File

@ -487,8 +487,7 @@ Foam::labelList Foam::autoLayerDriver::collectFaces
(
mesh,
selected,
orEqOp<bool>(), // combine operator
false // separation
orEqOp<bool>() // combine operator
);
labelList selectedFaces(findIndices(selected, true));
@ -534,8 +533,7 @@ Foam::labelList Foam::autoLayerDriver::growFaceCellFace
(
mesh,
selected,
orEqOp<bool>(), // combine operator
false // separation
orEqOp<bool>() // combine operator
);
return findIndices(selected, true);
}
@ -1015,8 +1013,7 @@ void Foam::autoLayerDriver::handleFeatureAngle
mesh,
edgeNormal,
nomalsCombine(),
point::max, // null value
false // no separation
point::max // null value
);
label vertI = 0;
@ -1307,8 +1304,7 @@ void Foam::autoLayerDriver::setNumLayers
pp.meshPoints(),
maxLayers,
maxEqOp<label>(),
labelMin, // null value
false // no separation
labelMin // null value
);
syncTools::syncPointList
(
@ -1316,8 +1312,7 @@ void Foam::autoLayerDriver::setNumLayers
pp.meshPoints(),
minLayers,
minEqOp<label>(),
labelMax, // null value
false // no separation
labelMax // null value
);
// Unmark any point with different min and max
@ -1434,8 +1429,7 @@ void Foam::autoLayerDriver::growNoExtrusion
pp.meshPoints(),
status,
minEqOp<label>(),
labelMax, // null value
false // no separation
labelMax // null value
);
forAll(status, i)
{
@ -1528,8 +1522,7 @@ void Foam::autoLayerDriver::calculateLayerThickness
pp.meshPoints(),
expansionRatio,
minEqOp<scalar>(),
GREAT, // null value
false // no separation
GREAT // null value
);
syncTools::syncPointList
(
@ -1537,8 +1530,7 @@ void Foam::autoLayerDriver::calculateLayerThickness
pp.meshPoints(),
thickness,
minEqOp<scalar>(),
GREAT, // null value
false // no separation
GREAT // null value
);
syncTools::syncPointList
(
@ -1546,8 +1538,7 @@ void Foam::autoLayerDriver::calculateLayerThickness
pp.meshPoints(),
minThickness,
minEqOp<scalar>(),
GREAT, // null value
false // no separation
GREAT // null value
);
@ -1594,8 +1585,7 @@ void Foam::autoLayerDriver::calculateLayerThickness
pp.meshPoints(),
maxPointLevel,
maxEqOp<label>(),
labelMin, // null value
false // no separation
labelMin // null value
);
@ -1664,8 +1654,7 @@ void Foam::autoLayerDriver::syncPatchDisplacement
meshPoints,
patchDisp,
minEqOp<vector>(),
point::max, // null value
false // no separation
point::max // null value
);
// Unmark if displacement too small
@ -1697,8 +1686,7 @@ void Foam::autoLayerDriver::syncPatchDisplacement
meshPoints,
syncPatchNLayers,
minEqOp<label>(),
labelMax, // null value
false // no separation
labelMax // null value
);
// Reset if differs
@ -1728,8 +1716,7 @@ void Foam::autoLayerDriver::syncPatchDisplacement
meshPoints,
syncPatchNLayers,
maxEqOp<label>(),
labelMin, // null value
false // no separation
labelMin // null value
);
// Reset if differs
@ -1815,8 +1802,7 @@ void Foam::autoLayerDriver::getPatchDisplacement
meshPoints,
pointNormals,
plusEqOp<vector>(),
vector::zero, // null value
false // no separation
vector::zero // null value
);
syncTools::syncPointList
@ -1825,8 +1811,7 @@ void Foam::autoLayerDriver::getPatchDisplacement
meshPoints,
nPointFaces,
plusEqOp<label>(),
0, // null value
false // no separation
0 // null value
);
forAll(pointNormals, i)
@ -2258,8 +2243,7 @@ void Foam::autoLayerDriver::setupLayerInfoTruncation
pp.meshPoints(),
foundNeighbour,
orEqOp<bool>(),
false, // null value
false // no separation
false // null value
);
forAll(pp.meshPoints(), patchPointI)
@ -2318,8 +2302,7 @@ void Foam::autoLayerDriver::setupLayerInfoTruncation
pp.meshPoints(),
nPatchPointLayers,
maxEqOp<label>(),
0, // null value
false // no separation
0 // null value
);
}
}

View File

@ -67,8 +67,7 @@ void Foam::autoLayerDriver::sumWeights
meshPoints,
invSumWeight,
plusEqOp<scalar>(),
scalar(0.0), // null value
false // no separation
scalar(0.0) // null value
);
forAll(invSumWeight, pointI)
@ -521,8 +520,7 @@ void Foam::autoLayerDriver::findIsolatedRegions
pp.meshPoints(),
keptPoints,
orEqOp<bool>(),
false, // null value
false // no separation
false // null value
);
label nChanged = 0;
@ -589,8 +587,7 @@ void Foam::autoLayerDriver::findIsolatedRegions
pp.meshPoints(),
isolatedPoint,
plusEqOp<label>(),
0, // null value
false // no separation
0 // null value
);
// stop layer growth on isolated faces
@ -724,8 +721,7 @@ void Foam::autoLayerDriver::medialAxisSmoothingInfo
meshPoints,
pointNormals,
plusEqOp<vector>(),
vector::zero, // null value
false // no separation
vector::zero // null value
);
syncTools::syncPointList
@ -734,8 +730,7 @@ void Foam::autoLayerDriver::medialAxisSmoothingInfo
meshPoints,
nPointFaces,
plusEqOp<label>(),
0, // null value
false // no separation
0 // null value
);
forAll(pointNormals, i)

View File

@ -64,8 +64,7 @@ void Foam::autoLayerDriver::averageNeighbours
meshPoints,
average,
plusEqOp<Type>(),
pTraits<Type>::zero, // null value
false // no separation
pTraits<Type>::zero // null value
);
average *= invSumWeight;

View File

@ -274,8 +274,7 @@ Foam::pointField Foam::autoSnapDriver::smoothPatchDisplacement
pp.meshPoints(),
avgBoundary,
plusEqOp<point>(), // combine op
vector::zero, // null value
false // no separation
vector::zero // null value
);
syncTools::syncPointList
(
@ -283,8 +282,7 @@ Foam::pointField Foam::autoSnapDriver::smoothPatchDisplacement
pp.meshPoints(),
nBoundary,
plusEqOp<label>(), // combine op
0, // null value
false // no separation
0 // null value
);
forAll(avgBoundary, i)
@ -322,36 +320,18 @@ Foam::pointField Foam::autoSnapDriver::smoothPatchDisplacement
forAll(patches, patchI)
{
if (Pstream::parRun() && isA<processorPolyPatch>(patches[patchI]))
if
(
patches[patchI].coupled()
&& refCast<const coupledPolyPatch>(patches[patchI]).owner()
)
{
const processorPolyPatch& pp =
refCast<const processorPolyPatch>(patches[patchI]);
if (pp.myProcNo() < pp.neighbProcNo())
{
const vectorField::subField faceCentres = pp.faceCentres();
forAll(pp, i)
{
const face& f = pp[i];
const point& fc = faceCentres[i];
forAll(f, fp)
{
globalSum[f[fp]] += fc;
globalNum[f[fp]]++;
}
}
}
}
else if (isA<cyclicPolyPatch>(patches[patchI]))
{
const cyclicPolyPatch& pp =
refCast<const cyclicPolyPatch>(patches[patchI]);
const coupledPolyPatch& pp =
refCast<const coupledPolyPatch>(patches[patchI]);
const vectorField::subField faceCentres = pp.faceCentres();
for (label i = 0; i < pp.size()/2; i++)
forAll(pp, i)
{
const face& f = pp[i];
const point& fc = faceCentres[i];
@ -370,16 +350,14 @@ Foam::pointField Foam::autoSnapDriver::smoothPatchDisplacement
mesh,
globalSum,
plusEqOp<vector>(), // combine op
vector::zero, // null value
false // no separation
vector::zero // null value
);
syncTools::syncPointList
(
mesh,
globalNum,
plusEqOp<label>(), // combine op
0, // null value
false // no separation
0 // null value
);
avgInternal.setSize(meshPoints.size());
@ -815,8 +793,7 @@ Foam::scalarField Foam::autoSnapDriver::calcSnapDistance
pp.meshPoints(),
maxEdgeLen,
maxEqOp<scalar>(), // combine op
-GREAT, // null value
false // no separation
-GREAT // null value
);
return snapParams.snapTol()*maxEdgeLen;
@ -1123,8 +1100,7 @@ Foam::vectorField Foam::autoSnapDriver::calcNearestSurface
pp.meshPoints(),
patchDisp,
minMagEqOp(), // combine op
vector(GREAT, GREAT, GREAT), // null value
false // no separation
vector(GREAT, GREAT, GREAT) // null value
);
@ -1178,7 +1154,7 @@ void Foam::autoSnapDriver::smoothDisplacement
}
pointVectorField oldDisp(disp);
meshMover.smooth(oldDisp, edgeGamma, false, disp);
meshMover.smooth(oldDisp, edgeGamma, disp);
}
Info<< "Displacement smoothed in = "
<< mesh.time().cpuTimeIncrement() << " s\n" << nl << endl;

View File

@ -146,8 +146,8 @@ void Foam::meshRefinement::calcNeighbourData
}
// Swap coupled boundaries. Apply separation to cc since is coordinate.
syncTools::swapBoundaryFaceList(mesh_, neiCc, true);
syncTools::swapBoundaryFaceList(mesh_, neiLevel, false);
syncTools::swapBoundaryFacePositions(mesh_, neiCc);
syncTools::swapBoundaryFaceList(mesh_, neiLevel);
}
@ -235,7 +235,7 @@ void Foam::meshRefinement::updateIntersections(const labelList& changedFaces)
// Make sure both sides have same information. This should be
// case in general since same vectors but just to make sure.
syncTools::syncFaceList(mesh_, surfaceIndex_, maxEqOp<label>(), false);
syncTools::syncFaceList(mesh_, surfaceIndex_, maxEqOp<label>());
label nHits = countHits();
label nTotHits = returnReduce(nHits, sumOp<label>());
@ -275,11 +275,11 @@ void Foam::meshRefinement::checkData()
// Get neighbouring face centres
pointField neiBoundaryFc(boundaryFc);
syncTools::swapBoundaryFaceList
syncTools::syncBoundaryFacePositions
(
mesh_,
neiBoundaryFc,
true
eqOp<point>()
);
// Compare
@ -339,7 +339,7 @@ void Foam::meshRefinement::checkData()
mesh_.nInternalFaces()
)
);
syncTools::swapBoundaryFaceList(mesh_, neiHit, false);
syncTools::swapBoundaryFaceList(mesh_, neiHit);
// Check
forAll(surfaceHit, faceI)
@ -390,8 +390,7 @@ void Foam::meshRefinement::checkData()
syncTools::swapBoundaryFaceList
(
mesh_,
neiBoundarySurface,
false
neiBoundarySurface
);
// Compare
@ -1158,8 +1157,7 @@ Foam::autoPtr<Foam::mapDistributePolyMesh> Foam::meshRefinement::balance
(
mesh_,
blockedFace,
andEqOp<bool>(), // combine operator
false // separation
andEqOp<bool>() // combine operator
);
}
reduce(nUnblocked, sumOp<label>());
@ -1527,7 +1525,7 @@ void Foam::meshRefinement::checkCoupledFaceZones(const polyMesh& mesh)
}
labelList neiFaceToZone(faceToZone);
syncTools::swapBoundaryFaceList(mesh, neiFaceToZone, false);
syncTools::swapBoundaryFaceList(mesh, neiFaceToZone);
forAll(faceToZone, i)
{

View File

@ -354,8 +354,8 @@ void Foam::meshRefinement::getBafflePatches
// might not be owner on the other processor but the neighbour is
// not used when creating baffles from proc faces.
// - tolerances issues occasionally crop up.
syncTools::syncFaceList(mesh_, ownPatch, maxEqOp<label>(), false);
syncTools::syncFaceList(mesh_, neiPatch, maxEqOp<label>(), false);
syncTools::syncFaceList(mesh_, ownPatch, maxEqOp<label>());
syncTools::syncFaceList(mesh_, neiPatch, maxEqOp<label>());
}
@ -386,9 +386,9 @@ Foam::autoPtr<Foam::mapPolyMesh> Foam::meshRefinement::createBaffles
if (debug)
{
labelList syncedOwnPatch(ownPatch);
syncTools::syncFaceList(mesh_, syncedOwnPatch, maxEqOp<label>(), false);
syncTools::syncFaceList(mesh_, syncedOwnPatch, maxEqOp<label>());
labelList syncedNeiPatch(neiPatch);
syncTools::syncFaceList(mesh_, syncedNeiPatch, maxEqOp<label>(), false);
syncTools::syncFaceList(mesh_, syncedNeiPatch, maxEqOp<label>());
forAll(syncedOwnPatch, faceI)
{
@ -669,8 +669,7 @@ Foam::List<Foam::labelPair> Foam::meshRefinement::filterDuplicateFaces
mesh_,
nBafflesPerEdge,
plusEqOp<label>(), // in-place add
0, // initial value
false // no separation
0 // initial value
);
@ -1030,7 +1029,7 @@ void Foam::meshRefinement::findCellZoneGeometric
}
}
}
syncTools::swapBoundaryFaceList(mesh_, neiCellZone, false);
syncTools::swapBoundaryFaceList(mesh_, neiCellZone);
forAll(patches, patchI)
{
@ -1058,13 +1057,7 @@ void Foam::meshRefinement::findCellZoneGeometric
}
// Sync
syncTools::syncFaceList
(
mesh_,
namedSurfaceIndex,
maxEqOp<label>(),
false
);
syncTools::syncFaceList(mesh_, namedSurfaceIndex, maxEqOp<label>());
}
//XXXXXXXXX
void Foam::meshRefinement::findCellZoneInsideWalk
@ -1371,7 +1364,7 @@ void Foam::meshRefinement::findCellZoneTopo
}
}
}
syncTools::swapBoundaryFaceList(mesh_, neiCellRegion, false);
syncTools::swapBoundaryFaceList(mesh_, neiCellRegion);
// Calculate region to zone from cellRegions on either side of coupled
// face.
@ -1492,7 +1485,7 @@ void Foam::meshRefinement::makeConsistentFaceIndex
}
}
}
syncTools::swapBoundaryFaceList(mesh_, neiCellZone, false);
syncTools::swapBoundaryFaceList(mesh_, neiCellZone);
// Use coupled cellZone to do check
forAll(patches, patchI)
@ -1812,7 +1805,7 @@ Foam::autoPtr<Foam::mapPolyMesh> Foam::meshRefinement::splitMesh
blockedFace[faceI] = true;
}
}
syncTools::syncFaceList(mesh_, blockedFace, orEqOp<bool>(), false);
syncTools::syncFaceList(mesh_, blockedFace, orEqOp<bool>());
// Set region per cell based on walking
regionSplit cellRegion(mesh_, blockedFace);
@ -1924,8 +1917,7 @@ Foam::autoPtr<Foam::mapPolyMesh> Foam::meshRefinement::splitMesh
mesh_,
pointBaffle,
maxEqOp<label>(),
-1, // null value
false // no separation
-1 // null value
);
@ -1950,7 +1942,7 @@ Foam::autoPtr<Foam::mapPolyMesh> Foam::meshRefinement::splitMesh
}
}
}
syncTools::syncFaceList(mesh_, ownPatch, maxEqOp<label>(), false);
syncTools::syncFaceList(mesh_, ownPatch, maxEqOp<label>());
// 3. From faces to cells (cellRegion) and back to faces (ownPatch)
@ -1999,7 +1991,7 @@ Foam::autoPtr<Foam::mapPolyMesh> Foam::meshRefinement::splitMesh
ownPatch.transfer(newOwnPatch);
syncTools::syncFaceList(mesh_, ownPatch, maxEqOp<label>(), false);
syncTools::syncFaceList(mesh_, ownPatch, maxEqOp<label>());
}
@ -2376,8 +2368,7 @@ Foam::autoPtr<Foam::mapPolyMesh> Foam::meshRefinement::zonify
(
mesh_,
namedSurfaceIndex,
maxEqOp<label>(),
false
maxEqOp<label>()
);
// Print a bit
@ -2541,7 +2532,7 @@ Foam::autoPtr<Foam::mapPolyMesh> Foam::meshRefinement::zonify
}
}
}
syncTools::swapBoundaryFaceList(mesh_, neiCellZone, false);
syncTools::swapBoundaryFaceList(mesh_, neiCellZone);
// Get per face whether is it master (of a coupled set of faces)
PackedBoolList isMasterFace(syncTools::getMasterFaces(mesh_));

View File

@ -496,8 +496,7 @@ Foam::labelList Foam::meshRefinement::markFacesOnProblemCells
mesh_,
isBoundaryPoint,
orEqOp<bool>(),
false, // null value
false // no separation
false // null value
);
syncTools::syncEdgeList
@ -505,16 +504,14 @@ Foam::labelList Foam::meshRefinement::markFacesOnProblemCells
mesh_,
isBoundaryEdge,
orEqOp<bool>(),
false, // null value
false // no separation
false // null value
);
syncTools::syncFaceList
(
mesh_,
isBoundaryFace,
orEqOp<bool>(),
false // no separation
orEqOp<bool>()
);
@ -805,8 +802,7 @@ Foam::labelList Foam::meshRefinement::markFacesOnProblemCells
mesh_,
isBoundaryPoint,
orEqOp<bool>(),
false, // null value
false // no separation
false // null value
);
syncTools::syncEdgeList
@ -814,16 +810,14 @@ Foam::labelList Foam::meshRefinement::markFacesOnProblemCells
mesh_,
isBoundaryEdge,
orEqOp<bool>(),
false, // null value
false // no separation
false // null value
);
syncTools::syncFaceList
(
mesh_,
isBoundaryFace,
orEqOp<bool>(),
false // no separation
orEqOp<bool>()
);
@ -1107,8 +1101,7 @@ Foam::labelList Foam::meshRefinement::markFacesOnProblemCells
// (
// mesh_,
// facePatch,
// maxEqOp<label>(),
// false // no separation
// maxEqOp<label>()
// );
//
// return facePatch;

View File

@ -133,8 +133,7 @@ Foam::labelList Foam::meshRefinement::getChangedFaces
(
mesh,
refinedBoundaryFace,
orEqOp<bool>(),
false
orEqOp<bool>()
);
@ -176,8 +175,7 @@ Foam::labelList Foam::meshRefinement::getChangedFaces
(
mesh,
changedFace,
orEqOp<bool>(),
false
orEqOp<bool>()
);
@ -925,8 +923,8 @@ Foam::label Foam::meshRefinement::markSurfaceCurvatureRefinement
neiBndMaxLevel[bFaceI] = cellMaxLevel[own];
neiBndMaxNormal[bFaceI] = cellMaxNormal[own];
}
syncTools::swapBoundaryFaceList(mesh_, neiBndMaxLevel, false);
syncTools::swapBoundaryFaceList(mesh_, neiBndMaxNormal, false);
syncTools::swapBoundaryFaceList(mesh_, neiBndMaxLevel);
syncTools::swapBoundaryFaceList(mesh_, neiBndMaxNormal);
// Loop over all faces. Could only be checkFaces.. except if they're coupled

View File

@ -77,6 +77,24 @@ const Foam::polyMesh& Foam::blockMesh::topology() const
}
Foam::PtrList<Foam::dictionary> Foam::blockMesh::patchDicts() const
{
const polyPatchList& patchTopologies = topology().boundaryMesh();
PtrList<dictionary> patchDicts(patchTopologies.size());
forAll(patchTopologies, patchI)
{
OStringStream os;
patchTopologies[patchI].write(os);
IStringStream is(os.str());
patchDicts.set(patchI, new dictionary(is));
patchDicts[patchI].set("name", patchTopologies[patchI].name());
}
return patchDicts;
}
Foam::scalar Foam::blockMesh::scaleFactor() const
{
return scaleFactor_;
@ -116,22 +134,22 @@ const Foam::faceListList& Foam::blockMesh::patches() const
}
Foam::wordList Foam::blockMesh::patchNames() const
{
return topology().boundaryMesh().names();
}
Foam::wordList Foam::blockMesh::patchTypes() const
{
return topology().boundaryMesh().types();
}
Foam::wordList Foam::blockMesh::patchPhysicalTypes() const
{
return topology().boundaryMesh().physicalTypes();
}
//Foam::wordList Foam::blockMesh::patchNames() const
//{
// return topology().boundaryMesh().names();
//}
//
//
//Foam::wordList Foam::blockMesh::patchTypes() const
//{
// return topology().boundaryMesh().types();
//}
//
//
//Foam::wordList Foam::blockMesh::patchPhysicalTypes() const
//{
// return topology().boundaryMesh().physicalTypes();
//}
Foam::label Foam::blockMesh::numZonedBlocks() const

View File

@ -109,6 +109,24 @@ class blockMesh
const faceList& patchShapes
) const;
bool readPatches
(
const dictionary& meshDescription,
faceListList& tmpBlocksPatches,
wordList& patchNames,
wordList& patchTypes,
wordList& nbrPatchNames
);
bool readBoundary
(
const dictionary& meshDescription,
faceListList& tmpBlocksPatches,
PtrList<dictionary>& patchDicts
);
void createCellShapes(cellShapeList& tmpBlockCells);
polyMesh* createTopology(IOdictionary&);
void checkBlockMesh(const polyMesh&) const;
@ -163,11 +181,15 @@ public:
const faceListList& patches() const;
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;

View File

@ -27,11 +27,232 @@ License
#include "Time.H"
#include "preservePatchTypes.H"
#include "emptyPolyPatch.H"
#include "cyclicPolyPatch.H"
bool Foam::blockMesh::readPatches
(
const dictionary& meshDescription,
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 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,
blockPointField_,
tmpBlocksPatches[nPatches]
);
nPatches++;
// Split old style cyclics
if (patchTypes[nPatches-1] == cyclicPolyPatch::typeName)
{
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 'boundary' dictionary syntax."
<< endl;
// Add extra patch
if (tmpBlocksPatches.size() <= nPatches)
{
tmpBlocksPatches.setSize(nPatches + 1);
patchNames.setSize(nPatches + 1);
patchTypes.setSize(nPatches + 1);
nbrPatchNames.setSize(nPatches + 1);
}
// Update halfA info
patchNames[nPatches-1] = halfA;
nbrPatchNames[nPatches-1] = halfB;
// Update halfB info
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,
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,
blockPointField_,
tmpBlocksPatches[patchI]
);
}
return topologyOK;
}
void Foam::blockMesh::createCellShapes
(
cellShapeList& tmpBlockCells
)
{
const blockMesh& blocks = *this;
tmpBlockCells.setSize(blocks.size());
forAll(blocks, blockI)
{
tmpBlockCells[blockI] = cellShape(blocks[blockI].blockShape());
if (tmpBlockCells[blockI].mag(blockPointField_) < 0.0)
{
WarningIn
(
"blockMesh::createTopology(IOdictionary&)"
) << "negative volume block : " << blockI
<< ", probably defined inside-out" << endl;
}
}
}
// * * * * * * * * * * * * * Private Member Functions * * * * * * * * * * * //
Foam::polyMesh* Foam::blockMesh::createTopology(IOdictionary& dict)
Foam::polyMesh* Foam::blockMesh::createTopology(IOdictionary& meshDescription)
{
bool topologyOK = true;
@ -43,30 +264,30 @@ Foam::polyMesh* Foam::blockMesh::createTopology(IOdictionary& dict)
// get names/types for the unassigned patch faces
// this is a bit heavy handed (and ugly), but there is currently
// no easy way to rename polyMesh patches subsequently
if (const dictionary* dictPtr = dict.subDictPtr("defaultPatch"))
if (const dictionary* dictPtr = meshDescription.subDictPtr("defaultPatch"))
{
dictPtr->readIfPresent("name", defaultPatchName);
dictPtr->readIfPresent("type", defaultPatchType);
}
// optional 'convertToMeters' or 'scale' scaling factor
if (!dict.readIfPresent("convertToMeters", scaleFactor_))
if (!meshDescription.readIfPresent("convertToMeters", scaleFactor_))
{
dict.readIfPresent("scale", scaleFactor_);
meshDescription.readIfPresent("scale", scaleFactor_);
}
//
// get the non-linear edges in mesh
//
if (dict.found("edges"))
if (meshDescription.found("edges"))
{
if (verboseOutput)
{
Info<< "Creating curved edges" << endl;
}
ITstream& is(dict.lookup("edges"));
ITstream& is(meshDescription.lookup("edges"));
// read number of edges in mesh
label nEdges = 0;
@ -134,7 +355,7 @@ Foam::polyMesh* Foam::blockMesh::createTopology(IOdictionary& dict)
}
{
ITstream& is(dict.lookup("blocks"));
ITstream& is(meshDescription.lookup("blocks"));
// read number of blocks in mesh
label nBlocks = 0;
@ -201,6 +422,8 @@ Foam::polyMesh* Foam::blockMesh::createTopology(IOdictionary& dict)
}
polyMesh* blockMeshPtr = NULL;
//
// Create the patches
//
@ -209,160 +432,140 @@ Foam::polyMesh* Foam::blockMesh::createTopology(IOdictionary& dict)
Info<< "Creating topology patches" << endl;
}
faceListList tmpBlocksPatches;
wordList patchNames;
wordList patchTypes;
if (meshDescription.found("patches"))
{
ITstream& is(dict.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(is);
if (firstToken.isLabel())
{
nPatches = firstToken.labelToken();
tmpBlocksPatches.setSize(nPatches);
patchNames.setSize(nPatches);
patchTypes.setSize(nPatches);
}
else
{
is.putBack(firstToken);
}
// Read beginning of blocks
is.readBegin("patches");
nPatches = 0;
token lastToken(is);
while
topologyOK = topologyOK && readPatches
(
!(
lastToken.isPunctuation()
&& lastToken.pToken() == token::END_LIST
)
)
meshDescription,
tmpBlocksPatches,
patchNames,
patchTypes,
nbrPatchNames
);
if (!topologyOK)
{
if (tmpBlocksPatches.size() <= nPatches)
{
tmpBlocksPatches.setSize(nPatches + 1);
patchNames.setSize(nPatches + 1);
patchTypes.setSize(nPatches + 1);
}
is.putBack(lastToken);
is
>> 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 " << is.lineNumber()
<< ". Exiting !" << nl
<< exit(FatalError);
}
}
topologyOK = topologyOK && patchLabelsOK
(
nPatches,
blockPointField_,
tmpBlocksPatches[nPatches]
);
nPatches++;
is >> lastToken;
FatalErrorIn("blockMesh::createTopology(IOdictionary&)")
<< "Cannot create mesh due to errors in topology, exiting !"
<< nl << exit(FatalError);
}
is.putBack(lastToken);
// Read end of blocks
is.readEnd("patches");
}
Info<< nl << "Creating block mesh topology" << endl;
cellShapeList tmpBlockCells(blocks.size());
createCellShapes(tmpBlockCells);
if (!topologyOK)
{
FatalErrorIn("blockMesh::createTopology(IOdictionary&)")
<< "Cannot create mesh due to errors in topology, exiting !" << nl
<< exit(FatalError);
}
Info<< nl << "Reading physicalType from existing boundary file" << endl;
wordList patchPhysicalTypes(tmpBlocksPatches.size());
//
// Create the topology
//
if (verboseOutput)
{
Info<< "Creating topology mesh" << endl;
}
cellShapeList tmpBlockShapes(blocks.size());
forAll(blocks, blockI)
{
tmpBlockShapes[blockI] = cellShape(blocks[blockI].blockShape());
if (tmpBlockShapes[blockI].mag(blockPointField_) < 0.0)
{
WarningIn
(
"blockMesh::createTopology(IOdictionary&)"
) << "negative volume block : " << blockI
<< ", probably defined inside-out" << endl;
}
}
wordList patchPhysicalTypes(tmpBlocksPatches.size());
preservePatchTypes
(
dict.time(),
dict.time().constant(),
polyMesh::meshSubDir,
patchNames,
patchTypes,
defaultPatchName,
defaultPatchType,
patchPhysicalTypes
);
// construct the topology as its own mesh
polyMesh* blockMeshPtr = new polyMesh
(
IOobject
preservePatchTypes
(
"blockMesh",
dict.time().constant(),
dict.time(),
IOobject::NO_READ,
IOobject::NO_WRITE,
false
),
xferCopy(blockPointField_), // copy these points, do NOT move
tmpBlockShapes,
tmpBlocksPatches,
patchNames,
patchTypes,
defaultPatchName,
defaultPatchType,
patchPhysicalTypes
);
meshDescription.time(),
meshDescription.time().constant(),
polyMesh::meshSubDir,
patchNames,
patchTypes,
defaultPatchName,
defaultPatchType,
patchPhysicalTypes
);
// Convert into dictionary
PtrList<dictionary> patchDicts(patchNames.size());
forAll(patchDicts, patchI)
{
patchDicts.set(patchI, new dictionary());
patchDicts[patchI].set("name", patchNames[patchI]);
patchDicts[patchI].set("type", patchTypes[patchI]);
if (nbrPatchNames[patchI] != word::null)
{
patchDicts[patchI].set("neighbourPatch", nbrPatchNames[patchI]);
}
if (patchPhysicalTypes[patchI] != word::null)
{
patchDicts[patchI].set
(
"physicalType",
patchPhysicalTypes[patchI]
);
}
}
blockMeshPtr = new polyMesh
(
IOobject
(
"blockMesh",
meshDescription.time().constant(),
meshDescription.time(),
IOobject::NO_READ,
IOobject::NO_WRITE,
false
),
xferCopy(blockPointField_), // copy these points, do NOT move
tmpBlockCells,
tmpBlocksPatches,
patchDicts,
defaultPatchName,
defaultPatchType
);
}
else if (meshDescription.found("boundary"))
{
faceListList tmpBlocksPatches;
PtrList<dictionary> patchDicts;
topologyOK = topologyOK && readBoundary
(
meshDescription,
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;
cellShapeList tmpBlockCells(blocks.size());
createCellShapes(tmpBlockCells);
blockMeshPtr = new polyMesh
(
IOobject
(
"blockMesh",
meshDescription.time().constant(),
meshDescription.time(),
IOobject::NO_READ,
IOobject::NO_WRITE,
false
),
xferCopy(blockPointField_), // copy these points, do NOT move
tmpBlockCells,
tmpBlocksPatches,
patchDicts,
defaultPatchName,
defaultPatchType
);
}
checkBlockMesh(*blockMeshPtr);