Commit d8209254 authored by mattijs's avatar mattijs
Browse files

ENH: preservePatchTypes preserves whole patch dictionary, not just type.

parent 5158b331
......@@ -569,21 +569,31 @@ int main(int argc, char *argv[])
<< "as type patch. Please reset after mesh conversion as necessary."
<< endl;
wordList patchTypes(patchFaces.size(), polyPatch::typeName);
wordList patchPhysicalTypes(patchFaces.size());
PtrList<dictionary> patchDicts;
preservePatchTypes
(
runTime,
runTime.constant(),
polyMesh::defaultRegion,
polyMesh::meshSubDir,
patchNames,
patchTypes,
patchDicts,
defaultFacesName,
defaultFacesType,
patchPhysicalTypes
defaultFacesType
);
// Add information to dictionary
forAll(patchNames, patchI)
{
if (!patchDicts.set(patchI))
{
patchDicts.set(patchI, new dictionary());
}
// Add but not overwrite
patchDicts[patchI].add("type", polyPatch::typeName, false);
}
polyMesh pShapeMesh
(
IOobject
......@@ -596,10 +606,9 @@ int main(int argc, char *argv[])
cellShapes,
patchFaces,
patchNames,
patchTypes,
patchDicts,
defaultFacesName,
defaultFacesType,
patchPhysicalTypes
defaultFacesType
);
......
......@@ -578,7 +578,6 @@ int main(int argc, char *argv[])
wordList patchTypes(npatch);
word defaultFacesName = "defaultFaces";
word defaultFacesType = wallPolyPatch::typeName;
wordList patchPhysicalTypes(npatch);
label nCreatedPatches = 0;
......@@ -707,18 +706,30 @@ int main(int argc, char *argv[])
patchTypes.setSize(nCreatedPatches);
patchNames.setSize(nCreatedPatches);
PtrList<dictionary> patchDicts;
preservePatchTypes
(
runTime,
runTime.constant(),
polyMesh::defaultRegion,
polyMesh::meshSubDir,
patchNames,
patchTypes,
patchDicts,
defaultFacesName,
defaultFacesType,
patchPhysicalTypes
defaultFacesType
);
// Add information to dictionary
forAll(patchNames, patchI)
{
if (!patchDicts.set(patchI))
{
patchDicts.set(patchI, new dictionary());
}
// Add but not overwrite
patchDicts[patchI].add("type", patchTypes[patchI], false);
}
polyMesh pShapeMesh
(
IOobject
......@@ -731,10 +742,9 @@ int main(int argc, char *argv[])
cellShapes,
boundary,
patchNames,
patchTypes,
patchDicts,
defaultFacesName,
defaultFacesType,
patchPhysicalTypes
defaultFacesType
);
// Set the precision of the points data to 10
......
......@@ -45,7 +45,6 @@ Description
#include "emptyPolyPatch.H"
#include "wallPolyPatch.H"
#include "symmetryPolyPatch.H"
#include "preservePatchTypes.H"
#include "cellShape.H"
#include "faceSet.H"
#include "cellSet.H"
......@@ -1542,17 +1541,6 @@ int main(int argc, char *argv[])
}
repatcher.repatch();
preservePatchTypes
(
runTime,
runTime.constant(),
polyMesh::defaultRegion,
patchNames,
patchTypes,
defaultFacesName,
defaultFacesType,
patchPhysicalTypes
);
// Set the precision of the points data to 10
IOstream::defaultPrecision(10);
......
......@@ -818,24 +818,32 @@ int main(int argc, char *argv[])
// Scale points
points *= scaleFactor;
wordList patchTypes(boundary.size(), polyPatch::typeName);
PtrList<dictionary> patchDicts(boundary.size());
word defaultFacesName = "defaultFaces";
word defaultFacesType = emptyPolyPatch::typeName;
wordList patchPhysicalTypes(boundary.size());
preservePatchTypes
(
runTime,
runTime.constant(),
polyMesh::defaultRegion,
polyMesh::meshSubDir,
patchNames,
patchTypes,
patchDicts,
defaultFacesName,
defaultFacesType,
patchPhysicalTypes
defaultFacesType
);
// Mesh will auto-write on construction
// Add information to dictionary
forAll(patchNames, patchI)
{
if (!patchDicts.set(patchI))
{
patchDicts.set(patchI, new dictionary());
}
// Add but not overwrite
patchDicts[patchI].add("type", polyPatch::typeName, false);
}
polyMesh pShapeMesh
(
IOobject
......@@ -848,10 +856,9 @@ int main(int argc, char *argv[])
cells,
boundary,
patchNames,
patchTypes,
patchDicts,
defaultFacesName,
defaultFacesType,
patchPhysicalTypes
defaultFacesType
);
// Set the precision of the points data to 10
......
......@@ -459,7 +459,6 @@ wordList patchNames(nPatches);
wordList patchTypes(nPatches);
word defaultFacesName = "defaultFaces";
word defaultFacesType = emptyPolyPatch::typeName;
wordList patchPhysicalTypes(nPatches);
label nAddedPatches = 0;
......@@ -535,17 +534,27 @@ forAll(boundary, patchi)
}
}
PtrList<dictionary> patchDicts;
preservePatchTypes
(
runTime,
runTime.constant(),
polyMesh::defaultRegion,
polyMesh::meshSubDir,
patchNames,
patchTypes,
patchDicts,
defaultFacesName,
defaultFacesType,
patchPhysicalTypes
defaultFacesType
);
// Add information to dictionary
forAll(patchNames, patchI)
{
if (!patchDicts.set(patchI))
{
patchDicts.set(patchI, new dictionary());
}
// Add but not overwrite
patchDicts[patchI].add("type", patchTypes[patchI], false);
}
// Build the mesh and write it out
polyMesh pShapeMesh
......@@ -560,10 +569,9 @@ polyMesh pShapeMesh
cellShapes,
boundary,
patchNames,
patchTypes,
patchDicts,
defaultFacesName,
defaultFacesType,
patchPhysicalTypes
defaultFacesType
);
Info << "Writing polyMesh" << endl;
......
......@@ -43,7 +43,6 @@ Description
#include "polyMesh.H"
#include "wallPolyPatch.H"
#include "symmetryPolyPatch.H"
#include "preservePatchTypes.H"
#include "cellShape.H"
#include "cellModeller.H"
#include "mergePoints.H"
......
......@@ -230,17 +230,28 @@ void sammMesh::readBoundary()
patchPhysicalTypes_.setSize(patchTypes_.size());
PtrList<dictionary> patchDicts;
preservePatchTypes
(
runTime_,
runTime_.constant(),
polyMesh::defaultRegion,
polyMesh::meshSubDir,
patchNames_,
patchTypes_,
patchDicts,
defaultFacesName_,
defaultFacesType_,
patchPhysicalTypes_
defaultFacesType_
);
forAll(patchDicts, patchI)
{
if (patchDicts.set(patchI))
{
const dictionary& dict = patchDicts[patchI];
dict.readIfPresent("type", patchTypes_[patchI]);
dict.readIfPresent("physicalType", patchPhysicalTypes_[patchI]);
}
}
}
......
......@@ -228,17 +228,28 @@ void starMesh::readBoundary()
patchPhysicalTypes_.setSize(patchTypes_.size());
PtrList<dictionary> patchDicts;
preservePatchTypes
(
runTime_,
runTime_.constant(),
polyMesh::defaultRegion,
polyMesh::meshSubDir,
patchNames_,
patchTypes_,
patchDicts,
defaultFacesName_,
defaultFacesType_,
patchPhysicalTypes_
defaultFacesType_
);
forAll(patchDicts, patchI)
{
if (patchDicts.set(patchI))
{
const dictionary& dict = patchDicts[patchI];
dict.readIfPresent("type", patchTypes_[patchI]);
dict.readIfPresent("physicalType", patchPhysicalTypes_[patchI]);
}
}
}
......
......@@ -52,7 +52,6 @@ Usage
#include "blockMesh.H"
#include "attachPolyTopoChanger.H"
#include "preservePatchTypes.H"
#include "emptyPolyPatch.H"
#include "cellSet.H"
......@@ -219,6 +218,7 @@ int main(int argc, char *argv[])
xferCopy(blocks.points()), // could we re-use space?
blocks.cells(),
blocks.patches(),
blocks.patchNames(),
blocks.patchDicts(),
defaultFacesName,
defaultFacesType
......
......@@ -280,6 +280,7 @@ public:
const Xfer<pointField>& points,
const cellShapeList& shapes,
const faceListList& boundaryFaces,
const wordList& boundaryPatchNames,
const PtrList<dictionary>& boundaryDicts,
const word& defaultBoundaryPatchName,
const word& defaultBoundaryPatchType,
......
......@@ -698,6 +698,7 @@ Foam::polyMesh::polyMesh
const Xfer<pointField>& points,
const cellShapeList& cellsAsShapes,
const faceListList& boundaryFaces,
const wordList& boundaryPatchNames,
const PtrList<dictionary>& boundaryDicts,
const word& defaultBoundaryPatchName,
const word& defaultBoundaryPatchType,
......@@ -832,12 +833,6 @@ Foam::polyMesh::polyMesh
// Remove all of the old mesh files if they exist
removeFiles(instance());
wordList boundaryPatchNames(boundaryDicts.size());
forAll(boundaryDicts, patchI)
{
boundaryDicts[patchI].lookup("name") >> boundaryPatchNames[patchI];
}
// Calculate faces and cells
labelList patchSizes;
labelList patchStarts;
......@@ -858,7 +853,7 @@ Foam::polyMesh::polyMesh
// Warning: Patches can only be added once the face list is
// completed, as they hold a subList of the face list
forAll(boundaryFaces, patchI)
forAll(boundaryDicts, patchI)
{
dictionary patchDict(boundaryDicts[patchI]);
......
......@@ -25,7 +25,6 @@ License
#include "preservePatchTypes.H"
#include "polyBoundaryMeshEntries.H"
#include "dictionary.H"
// * * * * * * * * * * * * * * * Global Functions * * * * * * * * * * * * * //
......@@ -35,14 +34,16 @@ void Foam::preservePatchTypes
const word& meshInstance,
const fileName& meshDir,
const wordList& patchNames,
wordList& patchTypes,
PtrList<dictionary>& patchDicts,
const word& defaultFacesName,
word& defaultFacesType,
wordList& patchPhysicalTypes
word& defaultFacesType
)
{
patchDicts.setSize(patchNames.size());
dictionary patchDictionary;
// Read boundary file as single dictionary
{
IOobject patchEntriesHeader
(
......@@ -67,33 +68,25 @@ void Foam::preservePatchTypes
}
}
if (patchDictionary.size())
forAll(patchNames, patchi)
{
forAll(patchNames, patchi)
if (patchDictionary.found(patchNames[patchi]))
{
if (patchDictionary.found(patchNames[patchi]))
{
const dictionary& patchDict =
patchDictionary.subDict(patchNames[patchi]);
patchDict.lookup("type") >> patchTypes[patchi];
const dictionary& patchDict =
patchDictionary.subDict(patchNames[patchi]);
patchDict.readIfPresent("geometricType", patchTypes[patchi]);
patchDict.readIfPresent
(
"physicalType",
patchPhysicalTypes[patchi]
);
}
patchDicts.set(patchi, patchDict.clone());
patchDicts[patchi].remove("nFaces");
patchDicts[patchi].remove("startFace");
}
}
if (patchDictionary.found(defaultFacesName))
{
const dictionary& patchDict =
patchDictionary.subDict(defaultFacesName);
if (patchDictionary.found(defaultFacesName))
{
const dictionary& patchDict =
patchDictionary.subDict(defaultFacesName);
patchDict.readIfPresent("geometricType", defaultFacesType);
}
patchDict.readIfPresent("geometricType", defaultFacesType);
}
Info<< nl << "Default patch type set to " << defaultFacesType << endl;
......
......@@ -37,6 +37,7 @@ SourceFiles
#include "fileName.H"
#include "wordList.H"
#include "dictionary.H"
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
......@@ -52,10 +53,9 @@ void preservePatchTypes
const word& meshInstance,
const fileName& meshDir,
const wordList& patchNames,
wordList& patchTypes,
PtrList<dictionary>& patchDicts,
const word& defaultFacesName,
word& defaultFacesType,
wordList& patchPhysicalTypes
word& defaultFacesType
);
} // End namespace Foam
......
......@@ -412,6 +412,8 @@ Foam::meshReader::polyBoundaryPatches(const polyMesh& mesh)
List<polyPatch*> p(nPatches);
// All patch dictionaries
PtrList<dictionary> patchDicts(patchNames_.size());
// Default boundary patch types
word defaultFacesType(emptyPolyPatch::typeName);
......@@ -422,20 +424,37 @@ Foam::meshReader::polyBoundaryPatches(const polyMesh& mesh)
mesh.instance(),
mesh.meshDir(),
patchNames_,
patchTypes_,
patchDicts,
"defaultFaces",
defaultFacesType,
patchPhysicalTypes_
defaultFacesType
);
forAll(patchDicts, patchI)
{
if (!patchDicts.set(patchI))
{
patchDicts.set(patchI, new dictionary());
}
dictionary& patchDict = patchDicts[patchI];
// add but not overwrite type
patchDict.add("type", patchTypes_[patchI], false);
if (patchPhysicalTypes_.size() && patchPhysicalTypes_[patchI].size())
{
patchDict.add("startFace", patchPhysicalTypes_[patchI], false);
}
// overwrite sizes and start
patchDict.add("nFaces", patchSizes_[patchI], true);
patchDict.add("startFace", patchStarts_[patchI], true);
}
forAll(patchStarts_, patchI)
{
p[patchI] = polyPatch::New
(
patchTypes_[patchI],
patchNames_[patchI],
patchSizes_[patchI],
patchStarts_[patchI],
patchDicts[patchI],
patchI,
mesh.boundaryMesh()
).ptr();
......
......@@ -89,7 +89,6 @@ Foam::PtrList<Foam::dictionary> Foam::blockMesh::patchDicts() const
patchTopologies[patchI].write(os);
IStringStream is(os.str());
patchDicts.set(patchI, new dictionary(is));
patchDicts[patchI].set("name", patchTopologies[patchI].name());
}
return patchDicts;
}
......@@ -134,12 +133,12 @@ const Foam::faceListList& Foam::blockMesh::patches() const
}
//Foam::wordList Foam::blockMesh::patchNames() const
//{
// return topology().boundaryMesh().names();
//}
//
//
Foam::wordList Foam::blockMesh::patchNames() const
{
return topology().boundaryMesh().names();
}
//Foam::wordList Foam::blockMesh::patchTypes() const
//{
// return topology().boundaryMesh().types();
......
......@@ -121,6 +121,7 @@ class blockMesh
bool readBoundary
(
const dictionary& meshDescription,
wordList& patchNames,
faceListList& tmpBlocksPatches,
PtrList<dictionary>& patchDicts
);
......@@ -185,8 +186,8 @@ public:
//- Get patch information from the topology mesh
PtrList<dictionary> patchDicts() const;
// wordList patchNames() const;
//
wordList patchNames() const;
// wordList patchTypes() const;
//
// wordList patchPhysicalTypes() const;
......
......@@ -189,6 +189,7 @@ bool Foam::blockMesh::readPatches
bool Foam::blockMesh::readBoundary
(
const dictionary& meshDescription,
wordList& patchNames,
faceListList& tmpBlocksPatches,
PtrList<dictionary>& patchDicts
)
......@@ -201,6 +202,7 @@ bool Foam::blockMesh::readBoundary
meshDescription.lookup("boundary")
);
patchNames.setSize(patchesInfo.size());
tmpBlocksPatches.setSize(patchesInfo.size());
patchDicts.setSize(patchesInfo.size());
......@@ -215,9 +217,9 @@ bool Foam::blockMesh::readBoundary
<< " valid dictionary." << exit(FatalIOError);
}
// Construct dictionary and add name
patchNames[patchI] = patchInfo.keyword();
// Construct dictionary
patchDicts.set(patchI, new dictionary(patchInfo.dict()));
patchDicts[patchI].set("name", patchInfo.keyword());
// Read block faces
patchDicts[patchI].lookup("faces") >> tmpBlocksPatches[patchI];
......@@ -472,7 +474,8 @@ Foam::polyMesh* Foam::blockMesh::createTopology(IOdictionary& meshDescription)
Info<< nl << "Reading physicalType from existing boundary file" << endl;
wordList patchPhysicalTypes(tmpBlocksPatches.size());
PtrList<dictionary> patchDicts(patchNames.size());
word defaultFacesType;
preservePatchTypes
(
......@@ -480,31 +483,29 @@ Foam::polyMesh* Foam::blockMesh::createTopology(IOdictionary& meshDescription)
meshDescription.time().constant(),
polyMesh::meshSubDir,
patchNames,
patchTypes,
patchDicts,
defaultPatchName,
defaultPatchType,