mirror of
https://develop.openfoam.com/Development/openfoam.git
synced 2025-11-28 03:28:01 +00:00
ENH: provide separate geometry description per region/patch (issue #278)
- Also fixed bug noted in issue #269 - Previous implementation had all faces together, which made it difficult (impossible) for external applications to figure out which geometry was being referred to. - Provide separate region/patches as follows: // Patch: <regionName> <patchName> For example, // Group: coupleGroup // Patch: heater minY 8( ... ) The region-name is always present, even if there is only one region. - This change is a partial reversion to the behaviour in 2.4.x, except that we can now also handle multi-region geometries. Changing the leading comment from "# " to "// " facilitates parsing of the files with OpenFOAM itself if necessary.
This commit is contained in:
@ -49,7 +49,7 @@ namespace Foam
|
|||||||
|
|
||||||
Foam::word Foam::externalCoupledFunctionObject::lockName = "OpenFOAM";
|
Foam::word Foam::externalCoupledFunctionObject::lockName = "OpenFOAM";
|
||||||
|
|
||||||
Foam::string Foam::externalCoupledFunctionObject::patchKey = "# Patch: ";
|
Foam::string Foam::externalCoupledFunctionObject::patchKey = "// Patch:";
|
||||||
|
|
||||||
template<>
|
template<>
|
||||||
const char* Foam::NamedEnum
|
const char* Foam::NamedEnum
|
||||||
@ -431,11 +431,6 @@ void Foam::externalCoupledFunctionObject::writeGeometry
|
|||||||
|
|
||||||
fileName dir(groupDir(commsDir, compositeName(regionNames), groupName));
|
fileName dir(groupDir(commsDir, compositeName(regionNames), groupName));
|
||||||
|
|
||||||
//if (log_)
|
|
||||||
{
|
|
||||||
Info<< typeName << ": writing geometry to " << dir << endl;
|
|
||||||
}
|
|
||||||
|
|
||||||
autoPtr<OFstream> osPointsPtr;
|
autoPtr<OFstream> osPointsPtr;
|
||||||
autoPtr<OFstream> osFacesPtr;
|
autoPtr<OFstream> osFacesPtr;
|
||||||
if (Pstream::master())
|
if (Pstream::master())
|
||||||
@ -443,12 +438,20 @@ void Foam::externalCoupledFunctionObject::writeGeometry
|
|||||||
mkDir(dir);
|
mkDir(dir);
|
||||||
osPointsPtr.reset(new OFstream(dir/"patchPoints"));
|
osPointsPtr.reset(new OFstream(dir/"patchPoints"));
|
||||||
osFacesPtr.reset(new OFstream(dir/"patchFaces"));
|
osFacesPtr.reset(new OFstream(dir/"patchFaces"));
|
||||||
|
|
||||||
|
osPointsPtr() << "// Group: " << groupName << endl;
|
||||||
|
osFacesPtr() << "// Group: " << groupName << endl;
|
||||||
|
|
||||||
|
Info<< typeName << ": writing geometry to " << dir << endl;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Individual region/patch entries
|
||||||
|
|
||||||
DynamicList<face> allMeshesFaces;
|
DynamicList<face> allFaces;
|
||||||
DynamicField<point> allMeshesPoints;
|
DynamicField<point> allPoints;
|
||||||
|
|
||||||
|
labelList pointToGlobal;
|
||||||
|
labelList uniquePointIDs;
|
||||||
forAll(meshes, meshI)
|
forAll(meshes, meshI)
|
||||||
{
|
{
|
||||||
const fvMesh& mesh = meshes[meshI];
|
const fvMesh& mesh = meshes[meshI];
|
||||||
@ -461,38 +464,14 @@ void Foam::externalCoupledFunctionObject::writeGeometry
|
|||||||
).sortedToc()
|
).sortedToc()
|
||||||
);
|
);
|
||||||
|
|
||||||
// Count faces
|
|
||||||
label nFaces = 0;
|
|
||||||
forAll(patchIDs, i)
|
|
||||||
{
|
|
||||||
nFaces += mesh.boundaryMesh()[patchIDs[i]].size();
|
|
||||||
}
|
|
||||||
|
|
||||||
// Collect faces
|
|
||||||
DynamicList<label> allFaceIDs(nFaces);
|
|
||||||
forAll(patchIDs, i)
|
forAll(patchIDs, i)
|
||||||
{
|
{
|
||||||
const polyPatch& p = mesh.boundaryMesh()[patchIDs[i]];
|
const polyPatch& p = mesh.boundaryMesh()[patchIDs[i]];
|
||||||
|
|
||||||
forAll(p, pI)
|
|
||||||
{
|
|
||||||
allFaceIDs.append(p.start()+pI);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
// Construct overall patch
|
|
||||||
indirectPrimitivePatch allPatch
|
|
||||||
(
|
|
||||||
IndirectList<face>(mesh.faces(), allFaceIDs),
|
|
||||||
mesh.points()
|
|
||||||
);
|
|
||||||
|
|
||||||
labelList pointToGlobal;
|
|
||||||
labelList uniquePointIDs;
|
|
||||||
mesh.globalData().mergePoints
|
mesh.globalData().mergePoints
|
||||||
(
|
(
|
||||||
allPatch.meshPoints(),
|
p.meshPoints(),
|
||||||
allPatch.meshPointMap(),
|
p.meshPointMap(),
|
||||||
pointToGlobal,
|
pointToGlobal,
|
||||||
uniquePointIDs
|
uniquePointIDs
|
||||||
);
|
);
|
||||||
@ -505,7 +484,7 @@ void Foam::externalCoupledFunctionObject::writeGeometry
|
|||||||
|
|
||||||
List<faceList> collectedFaces(Pstream::nProcs());
|
List<faceList> collectedFaces(Pstream::nProcs());
|
||||||
faceList& patchFaces = collectedFaces[procI];
|
faceList& patchFaces = collectedFaces[procI];
|
||||||
patchFaces = allPatch.localFaces();
|
patchFaces = p.localFaces();
|
||||||
forAll(patchFaces, faceI)
|
forAll(patchFaces, faceI)
|
||||||
{
|
{
|
||||||
inplaceRenumber(pointToGlobal, patchFaces[faceI]);
|
inplaceRenumber(pointToGlobal, patchFaces[faceI]);
|
||||||
@ -514,56 +493,37 @@ void Foam::externalCoupledFunctionObject::writeGeometry
|
|||||||
|
|
||||||
if (Pstream::master())
|
if (Pstream::master())
|
||||||
{
|
{
|
||||||
// Append and renumber
|
allPoints.clear();
|
||||||
label nPoints = allMeshesPoints.size();
|
allFaces.clear();
|
||||||
|
|
||||||
forAll(collectedPoints, procI)
|
for (label procI=0; procI < Pstream::nProcs(); ++procI)
|
||||||
{
|
{
|
||||||
allMeshesPoints.append(collectedPoints[procI]);
|
allPoints.append(collectedPoints[procI]);
|
||||||
|
allFaces.append(collectedFaces[procI]);
|
||||||
}
|
|
||||||
face newFace;
|
|
||||||
forAll(collectedFaces, procI)
|
|
||||||
{
|
|
||||||
const faceList& procFaces = collectedFaces[procI];
|
|
||||||
|
|
||||||
forAll(procFaces, faceI)
|
|
||||||
{
|
|
||||||
const face& f = procFaces[faceI];
|
|
||||||
|
|
||||||
newFace.setSize(f.size());
|
|
||||||
forAll(f, fp)
|
|
||||||
{
|
|
||||||
newFace[fp] = f[fp]+nPoints;
|
|
||||||
}
|
|
||||||
allMeshesFaces.append(newFace);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
nPoints += collectedPoints[procI].size();
|
Info<< typeName << ": mesh " << mesh.name()
|
||||||
}
|
<< ", patch " << p.name()
|
||||||
}
|
<< ": writing " << allPoints.size() << " points to "
|
||||||
|
<< osPointsPtr().name() << nl
|
||||||
//if (log_)
|
<< typeName << ": mesh " << mesh.name()
|
||||||
{
|
<< ", patch " << p.name()
|
||||||
Info<< typeName << ": for mesh " << mesh.name()
|
<< ": writing " << allFaces.size() << " faces to "
|
||||||
<< " writing " << allMeshesPoints.size() << " points to "
|
|
||||||
<< osPointsPtr().name() << endl;
|
|
||||||
Info<< typeName << ": for mesh " << mesh.name()
|
|
||||||
<< " writing " << allMeshesFaces.size() << " faces to "
|
|
||||||
<< osFacesPtr().name() << endl;
|
<< osFacesPtr().name() << endl;
|
||||||
}
|
|
||||||
}
|
// The entry name (region / patch)
|
||||||
|
const string entryHeader =
|
||||||
|
patchKey + ' ' + mesh.name() + ' ' + p.name();
|
||||||
|
|
||||||
// Write points
|
// Write points
|
||||||
if (osPointsPtr.valid())
|
osPointsPtr()
|
||||||
{
|
<< entryHeader.c_str() << nl << allPoints << nl << endl;
|
||||||
osPointsPtr() << allMeshesPoints << endl;
|
|
||||||
}
|
|
||||||
|
|
||||||
// Write faces
|
// Write faces
|
||||||
if (osFacesPtr.valid())
|
osFacesPtr()
|
||||||
{
|
<< entryHeader.c_str() << nl << allFaces << nl << endl;
|
||||||
osFacesPtr() << allMeshesFaces << endl;
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@ -2,7 +2,7 @@
|
|||||||
========= |
|
========= |
|
||||||
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
|
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
|
||||||
\\ / O peration |
|
\\ / O peration |
|
||||||
\\ / A nd | Copyright (C) 2015 OpenCFD Ltd.
|
\\ / A nd | Copyright (C) 2015-2016 OpenCFD Ltd.
|
||||||
\\/ M anipulation |
|
\\/ M anipulation |
|
||||||
-------------------------------------------------------------------------------
|
-------------------------------------------------------------------------------
|
||||||
License
|
License
|
||||||
@ -319,10 +319,10 @@ public:
|
|||||||
//- Runtime type information
|
//- Runtime type information
|
||||||
TypeName("externalCoupled");
|
TypeName("externalCoupled");
|
||||||
|
|
||||||
//- Name of lock file
|
//- Name of lock file (normally 'OpenFOAM.lock')
|
||||||
static word lockName;
|
static word lockName;
|
||||||
|
|
||||||
//- Name of patch key, e.g. '# Patch:' when looking for start of patch data
|
//- Name of patch key, e.g. '// Patch:' when looking for start of patch data
|
||||||
static string patchKey;
|
static string patchKey;
|
||||||
|
|
||||||
|
|
||||||
@ -391,7 +391,7 @@ public:
|
|||||||
// separated by '_'
|
// separated by '_'
|
||||||
static word compositeName(const wordList&);
|
static word compositeName(const wordList&);
|
||||||
|
|
||||||
//- Write geometry for the group/patch
|
//- Write geometry for the group as region/patch
|
||||||
static void writeGeometry
|
static void writeGeometry
|
||||||
(
|
(
|
||||||
const UPtrList<const fvMesh>& meshes,
|
const UPtrList<const fvMesh>& meshes,
|
||||||
|
|||||||
Reference in New Issue
Block a user