ENH: mapFields FO - continuation of commit 46faebf783

- cuttingPatches now automatically constructed when createPatchMap is true
This commit is contained in:
Andrew Heather
2023-11-14 15:19:09 +00:00
parent 46faebf783
commit 9ac7982d64
2 changed files with 55 additions and 26 deletions

View File

@ -135,38 +135,59 @@ void Foam::functionObjects::mapFields::createInterpolation
const polyBoundaryMesh& pbm = mesh_.boundaryMesh(); const polyBoundaryMesh& pbm = mesh_.boundaryMesh();
const polyBoundaryMesh& pbmT = mapRegion.boundaryMesh(); const polyBoundaryMesh& pbmT = mapRegion.boundaryMesh();
DynamicList<label> cuttingIndices;
if (createPatchMap) if (createPatchMap)
{ {
Info<< " Creating patchMap" << endl; Info<< " Creating patchMap and cuttingPatches" << endl;
if (dict.found("cuttingPatches"))
{
WarningInFunction
<< "Ignoring user supplied cuttingPatches when "
<< "createPatchMap option is active"
<< endl;
}
forAll(pbmT, patchiT) forAll(pbmT, patchiT)
{ {
const polyPatch& pp = pbmT[patchiT]; const polyPatch& ppT = pbmT[patchiT];
if (!polyPatch::constraintType(pp.type())) if (!polyPatch::constraintType(ppT.type()))
{ {
const word& patchName = pp.name(); const word& patchNameT = ppT.name();
const label patchi = pbm.findPatchID(patchName); const label patchi = pbm.findPatchID(patchNameT);
const label patchSize =
returnReduce(pp.size(), sumOp<label>());
if (patchi != -1 && patchSize > 0) if (patchi == -1)
{ {
Info<< " Adding patch:" << pp.name() << endl; Info<< " Adding to cuttingPatches: "
patchMap.set(patchName, patchName); << ppT.name() << endl;
cuttingIndices.push_back(ppT.index());
}
else
{
if (returnReduce(ppT.size(), sumOp<label>()) > 0)
{
Info<< " Adding to patchMap: " << ppT.name()
<< endl;
patchMap.set(patchNameT, patchNameT);
}
} }
} }
} }
} }
else else
{ {
// Read patch map
patchMap = HashTable<word>(ePtr->stream()); patchMap = HashTable<word>(ePtr->stream());
// Read cutting patches using wordRe's
const wordRes cuttingPatchRes = dict.get<wordRes>("cuttingPatches");
cuttingIndices.push_back(pbmT.indices(cuttingPatchRes));
} }
// Cutting patches specified using wordRe's
const wordRes cuttingPatchRes = dict.get<wordRes>("cuttingPatches");
const labelList cuttingIndices = pbmT.indices(cuttingPatchRes);
const wordList cuttingPatches(pbmT.names(), cuttingIndices); const wordList cuttingPatches(pbmT.names(), cuttingIndices);
// Checks // Checks
@ -174,16 +195,16 @@ void Foam::functionObjects::mapFields::createInterpolation
// Find patch names that exist on target mesh that are not included // Find patch names that exist on target mesh that are not included
// in the patchMap // in the patchMap
wordHashSet unknownPatchNames; wordHashSet unknownPatchNames;
for (const auto& pp : pbmT) for (const auto& ppT : pbmT)
{ {
if if
( (
!polyPatch::constraintType(pp.type()) !polyPatch::constraintType(ppT.type())
&& !patchMap.found(pp.name()) && !patchMap.found(ppT.name())
&& returnReduce(pp.size(), sumOp<label>()) > 0 && returnReduce(ppT.size(), sumOp<label>()) > 0
) )
{ {
unknownPatchNames.insert(pp.name()); unknownPatchNames.insert(ppT.name());
} }
} }
@ -195,8 +216,8 @@ void Foam::functionObjects::mapFields::createInterpolation
if (patchMap.found(patchName)) if (patchMap.found(patchName))
{ {
Info<< " Removing cutting patch:" << patchName Info<< " Removing cutting patch from patchMap: "
<< endl; << patchName << endl;
patchMap.erase(patchName); patchMap.erase(patchName);
} }

View File

@ -5,7 +5,7 @@
\\ / A nd | www.openfoam.com \\ / A nd | www.openfoam.com
\\/ M anipulation | \\/ M anipulation |
------------------------------------------------------------------------------- -------------------------------------------------------------------------------
Copyright (C) 2016-2020 OpenCFD Ltd. Copyright (C) 2016-2023 OpenCFD Ltd.
------------------------------------------------------------------------------- -------------------------------------------------------------------------------
License License
This file is part of OpenFOAM. This file is part of OpenFOAM.
@ -61,9 +61,15 @@ Usage
// Optional entries (runtime modifiable) // Optional entries (runtime modifiable)
// patchMapMethod direct; // AMI-related entry // patchMapMethod direct; // AMI-related entry
// enabled if consistent=false
// patchMap (<patchSrc> <patchTgt>); // When consistent=false
// cuttingPatches (<patchTgt1> <patchTgt2> ... <patchTgtN>);
// Manual: createPatchMap false;
// patchMap (<patchSrc> <patchTgt>);
// cuttingPatches (<patchTgt1> <patchTgt2> ... <patchTgtN>);
// Automatic: createPatchMap true;
// Creates the patchMap and cuttingPatches automatically
// Optional (inherited) entries // Optional (inherited) entries
... ...
@ -80,8 +86,10 @@ Usage
mapMethod | Mapping method | word | yes | - mapMethod | Mapping method | word | yes | -
consistent | Mapping meshes have consistent boundaries | bool | yes | - consistent | Mapping meshes have consistent boundaries | bool | yes | -
patchMapMethod | Patch mapping method for AMI cases | word | no | - patchMapMethod | Patch mapping method for AMI cases | word | no | -
patchMap | Coincident source/target patches in two cases <!-- createPatchMap | Automatically create patchMap and cuttingPatches| <!--
--> | wordHashTable | no | - --> | bool | no | -
patchMap | Mapping between coincident source and target patches <!--
--> | wordHashTable | no | -
cuttingPatches | Target patches cutting the source domain <!-- cuttingPatches | Target patches cutting the source domain <!--
--> | wordList | no | - --> | wordList | no | -
\endtable \endtable