39 #include "MapMeshes.H"
47 const word& optionName,
56 dictFile = dictFile/
"decomposeParDict";
64 decompositionModel::selectIO
71 IOobject::MUST_READ_IF_MODIFIED,
77 ).lookup(
"numberOfSubdomains")
82 void mapConsistentMesh
84 const fvMesh& meshSource,
85 const fvMesh& meshTarget,
86 const meshToMesh0::order& mapOrder,
92 MapConsistentMesh<minusEqOp>
101 MapConsistentMesh<eqOp>
113 const fvMesh& meshSource,
114 const fvMesh& meshTarget,
115 const HashTable<word>& patchMap,
117 const meshToMesh0::order& mapOrder,
123 MapSubMesh<minusEqOp>
146 void mapConsistentSubMesh
148 const fvMesh& meshSource,
149 const fvMesh& meshTarget,
150 const meshToMesh0::order& mapOrder,
156 MapConsistentSubMesh<minusEqOp>
165 MapConsistentSubMesh<eqOp>
177 const fvMesh& meshTarget,
182 HashTable<label> cuttingPatchTable;
185 cuttingPatchTable.insert(cuttingPatches[i], i);
190 if (isA<processorFvPatch>(meshTarget.boundary()[
patchi]))
194 !cuttingPatchTable.found
196 meshTarget.boundaryMesh()[
patchi].name()
200 cuttingPatchTable.insert
202 meshTarget.boundaryMesh()[
patchi].name(),
209 return cuttingPatchTable.toc();
215 int main(
int argc,
char *argv[])
219 "map volume fields from one mesh to another"
221 argList::noParallel();
222 argList::validArgs.append(
"sourceCase");
227 "scalar|'latestTime'",
228 "specify the source time"
234 "specify the source region"
240 "specify the target region"
242 argList::addBoolOption
245 "the source is decomposed"
247 argList::addBoolOption
250 "the target is decomposed"
252 argList::addBoolOption
255 "source and target geometry and boundary conditions identical"
261 "specify the mapping method"
263 argList::addBoolOption
266 "subtract mapped source from target"
270 "sourceDecomposeParDict",
272 "read decomposePar dictionary from specified location"
276 "targetDecomposeParDict",
278 "read decomposePar dictionary from specified location"
282 argList
args(argc, argv);
292 const fileName casePath =
args[1];
293 const fileName rootDirSource = casePath.
path();
294 const fileName caseDirSource = casePath.
name();
296 Info<<
"Source: " << rootDirSource <<
" " << caseDirSource <<
endl;
297 word sourceRegion = fvMesh::defaultRegion;
300 sourceRegion =
args[
"sourceRegion"];
301 Info<<
"Source region: " << sourceRegion <<
endl;
304 Info<<
"Target: " << rootDirTarget <<
" " << caseDirTarget <<
endl;
305 word targetRegion = fvMesh::defaultRegion;
308 targetRegion =
args[
"targetRegion"];
309 Info<<
"Target region: " << targetRegion <<
endl;
316 meshToMesh0::order mapOrder = meshToMesh0::INTERPOLATE;
319 const word mapMethod(
args[
"mapMethod"]);
320 if (mapMethod ==
"mapNearest")
322 mapOrder = meshToMesh0::MAP;
324 else if (mapMethod ==
"interpolate")
326 mapOrder = meshToMesh0::INTERPOLATE;
328 else if (mapMethod ==
"cellPointInterpolate")
330 mapOrder = meshToMesh0::CELL_POINT_INTERPOLATE;
335 <<
"Unknown mapMethod " << mapMethod <<
". Valid options are: "
336 <<
"mapNearest, interpolate and cellPointInterpolate"
340 Info<<
"Mapping method: " << mapMethod <<
endl;
346 Info<<
"Subtracting mapped source field from target" <<
endl;
350 #include "createTimes.H"
352 HashTable<word> patchMap;
357 IOdictionary mapFieldsDict
364 IOobject::MUST_READ_IF_MODIFIED,
370 mapFieldsDict.lookup(
"patchMap") >> patchMap;
371 mapFieldsDict.lookup(
"cuttingPatches") >> cuttingPatches;
374 if (parallelSource && !parallelTarget)
376 int nProcs = readNumProcs
379 "sourceDecomposeParDict",
383 Info<<
"Create target mesh\n" <<
endl;
395 Info<<
"Target mesh size: " << meshTarget.nCells() <<
endl;
397 for (
int procI=0; procI<nProcs; procI++)
399 Info<<
nl <<
"Source processor " << procI <<
endl;
403 Time::controlDictName,
405 caseDirSource/fileName(word(
"processor") +
name(procI))
408 #include "setTimeIndex.H"
420 Info<<
"mesh size: " << meshSource.nCells() <<
endl;
446 else if (!parallelSource && parallelTarget)
448 int nProcs = readNumProcs
451 "targetDecomposeParDict",
456 Info<<
"Create source mesh\n" <<
endl;
458 #include "setTimeIndex.H"
470 Info<<
"Source mesh size: " << meshSource.nCells() <<
endl;
472 for (
int procI=0; procI<nProcs; procI++)
474 Info<<
nl <<
"Target processor " << procI <<
endl;
478 Time::controlDictName,
480 caseDirTarget/fileName(word(
"processor") +
name(procI))
493 Info<<
"mesh size: " << meshTarget.nCells() <<
endl;
512 addProcessorPatches(meshTarget, cuttingPatches),
519 else if (parallelSource && parallelTarget)
521 int nProcsSource = readNumProcs
524 "sourceDecomposeParDict",
527 int nProcsTarget = readNumProcs
530 "targetDecomposeParDict",
537 for (
int procISource=0; procISource<nProcsSource; procISource++)
539 Info<<
nl <<
"Source processor " << procISource <<
endl;
543 Time::controlDictName,
545 caseDirSource/fileName(word(
"processor") +
name(procISource))
548 #include "setTimeIndex.H"
560 Info<<
"mesh size: " << meshSource.nCells() <<
endl;
562 boundBox bbSource(meshSource.bounds());
564 for (
int procITarget=0; procITarget<nProcsTarget; procITarget++)
568 !bbsTargetSet[procITarget]
570 bbsTargetSet[procITarget]
571 && bbsTarget[procITarget].overlaps(bbSource)
575 Info<<
nl <<
"Target processor " << procITarget <<
endl;
579 Time::controlDictName,
581 caseDirTarget/fileName(word(
"processor")
595 Info<<
"mesh size: " << meshTarget.nCells() <<
endl;
597 bbsTarget[procITarget] = meshTarget.bounds();
598 bbsTargetSet[procITarget] =
true;
600 if (bbsTarget[procITarget].overlaps(bbSource))
619 addProcessorPatches(meshTarget, cuttingPatches),
631 #include "setTimeIndex.H"
655 Info<<
"Source mesh size: " << meshSource.nCells() <<
tab
656 <<
"Target mesh size: " << meshTarget.nCells() <<
nl <<
endl;
660 mapConsistentMesh(meshSource, meshTarget, mapOrder,
subtract);