ENH: adjust/update debugSurfaceWriter flags

- removed gatherv control.
  The globalIndex information is cached on the merged surface
  and thus not triggered often.

- strip out debug mergeField method which was a precursor to
  what is now within surfaceWriter itself.

- add 'merge' true/false handling to allow testing without
  parallel merging (implies no writing)
This commit is contained in:
Mark Olesen 2023-07-05 20:40:18 +02:00
parent 63753605a0
commit 69dae2e008
2 changed files with 45 additions and 73 deletions

View File

@ -5,7 +5,7 @@
\\ / A nd | www.openfoam.com
\\/ M anipulation |
-------------------------------------------------------------------------------
Copyright (C) 2022 OpenCFD Ltd.
Copyright (C) 2022-2023 OpenCFD Ltd.
-------------------------------------------------------------------------------
License
This file is part of OpenFOAM.
@ -60,69 +60,8 @@ Foam::surfaceWriters::debugWriter::mergeField
const Field<Type>& fld
) const
{
addProfiling
(
merge,
"debugWriter::merge-field"
);
if (parallel_ && Pstream::parRun())
{
// Ensure geometry is also merged
merge();
// Gather all values
auto tfield = tmp<Field<Type>>::New();
auto& allFld = tfield.ref();
if (mpiGatherv_)
{
globalIndex::mpiGatherOp
(
fld,
allFld,
UPstream::worldComm,
commType_
);
}
else
{
const globalIndex& globIndex =
(
this->isPointData()
? mergedSurf_.pointGlobalIndex()
: mergedSurf_.faceGlobalIndex()
);
globIndex.gather
(
fld,
allFld,
UPstream::msgType(),
commType_,
UPstream::worldComm
);
}
// Renumber (point data) to correspond to merged points
if
(
Pstream::master()
&& this->isPointData()
&& mergedSurf_.pointsMap().size()
)
{
inplaceReorder(mergedSurf_.pointsMap(), allFld);
allFld.resize(mergedSurf_.points().size());
}
return tfield;
}
// Mark that any geometry changes have been taken care of
upToDate_ = true;
return fld;
addProfiling(merge, "debugWriter::merge-field");
return surfaceWriter::mergeField(fld);
}
@ -131,7 +70,7 @@ Foam::surfaceWriters::debugWriter::mergeField
Foam::surfaceWriters::debugWriter::debugWriter()
:
surfaceWriter(),
mpiGatherv_(false),
enableMerge_(true),
enableWrite_(false),
header_(true),
streamOpt_(IOstreamOption::BINARY)
@ -144,7 +83,7 @@ Foam::surfaceWriters::debugWriter::debugWriter
)
:
surfaceWriter(options),
mpiGatherv_(options.getOrDefault("gatherv", false)),
enableMerge_(options.getOrDefault("merge", true)),
enableWrite_(options.getOrDefault("write", false)),
header_(true),
streamOpt_(IOstreamOption::BINARY)
@ -152,7 +91,7 @@ Foam::surfaceWriters::debugWriter::debugWriter
Info<< "Using debug surface writer ("
<< (this->isPointData() ? "point" : "face") << " data):"
<< " commsType=" << UPstream::commsTypeNames[commType_]
<< " gatherv=" << Switch::name(mpiGatherv_)
<< " merge=" << Switch::name(enableMerge_)
<< " write=" << Switch::name(enableWrite_) << endl;
}
@ -252,6 +191,19 @@ Foam::fileName Foam::surfaceWriters::debugWriter::write()
fileName surfaceDir = outputPath_;
if (parallel_ && !enableMerge_)
{
if (verbose_)
{
Info<< "Not merging or writing" << nl;
}
// Pretend to have succeeded
wroteGeom_ = true;
return surfaceDir;
}
const meshedSurf& surf = surface();
// const meshedSurfRef& surf = adjustSurface();
@ -314,6 +266,19 @@ Foam::fileName Foam::surfaceWriters::debugWriter::writeTemplate
const fileName outputFile(surfaceDir/timeName()/fieldName);
if (parallel_ && !enableMerge_)
{
if (verbose_)
{
Info<< "Not merging or writing" << nl;
}
// Pretend to have succeeded
wroteGeom_ = true;
return surfaceDir;
}
// Implicit geometry merge()
tmp<Field<Type>> tfield = mergeField(localValues);

View File

@ -5,7 +5,7 @@
\\ / A nd | www.openfoam.com
\\/ M anipulation |
-------------------------------------------------------------------------------
Copyright (C) 2022 OpenCFD Ltd.
Copyright (C) 2022-2023 OpenCFD Ltd.
-------------------------------------------------------------------------------
License
This file is part of OpenFOAM.
@ -35,7 +35,8 @@ Description
{
debug
{
write true;
merge true;
write true;
}
}
\endverbatim
@ -44,10 +45,16 @@ Description
\table
Property | Description | Required | Default
commsType | blocking/nonBlocking/scheduled | no | scheduled
gatherv | Use MPI gatherv when merging | no | false
write | Write boundaryData (binary + header) | no | false
merge | Enable geometry/field merging | no | true
write | Write file(s) | no | false
\endtable
Note
Disabling geometry/field merging (in parallel) implicitly deactivates
writing as well.
Output files (if any) are written as boundaryData (binary + header).
SourceFiles
debugSurfaceWriter.C
@ -79,8 +86,8 @@ class debugWriter
{
// Private Data
//- Use MPI gatherv in globalIndex gathering
bool mpiGatherv_;
//- Enable/disable all merging in parallel
bool enableMerge_;
//- Output writing?
bool enableWrite_;