33template<
class ZoneMesh>
34void Foam::fvMeshDistribute::reorderZones
36 const wordList& zoneNames,
40 zones.clearAddressing();
45 PtrList<zone_type>& oldPtrs = zones;
46 PtrList<zone_type> newPtrs(zoneNames.size());
50 if (!zones.get(zonei))
53 <<
"Problem with zone[" << zonei <<
"] " << zones.names()
61 auto ptr = oldPtrs.release(zonei);
65 <<
"Problem with zone[" << zonei <<
"] == nullptr" <<
nl
69 const label newIndex = zoneNames.find(ptr->name());
71 ptr->index() = newIndex;
72 newPtrs.set(newIndex, std::move(ptr));
80 newPtrs.emplace_set(i, zoneNames[i], i, zones);
85 oldPtrs = std::move(newPtrs);
89template<
class GeoField>
94 typename GeoField::value_type,
99 for (
const GeoField&
field :
mesh.objectRegistry::csorted<GeoField>())
111template<
class GeoField>
114 for (
const GeoField&
field :
mesh.objectRegistry::csorted<GeoField>())
120 for (
const auto& patchFld :
field.boundaryField())
122 Pout<<
" " << patchFld.patch().index()
123 <<
' ' << patchFld.patch().name()
124 <<
' ' << patchFld.type()
125 <<
' ' << patchFld.size()
132template<
class T,
class Mesh>
133void Foam::fvMeshDistribute::saveBoundaryFields
144 mesh_.objectRegistry::csorted<fldType>()
147 bflds.resize_null(flds.size());
150 for (
const fldType&
fld : flds)
152 bflds.set(fieldi,
fld.boundaryField().clone());
159template<
class T,
class Mesh>
160void Foam::fvMeshDistribute::mapBoundaryFields
168 const labelList& oldPatchStarts = map.oldPatchStarts();
175 mesh_.objectRegistry::sorted<fldType>()
178 if (flds.size() != oldBflds.size())
186 auto& bfld = flds[fieldi].boundaryFieldRef();
187 const auto& oldBfld = oldBflds[fieldi];
198 label oldFacei =
faceMap[facei++];
201 forAll(oldPatchStarts, oldPatchi)
203 label oldLocalI = oldFacei - oldPatchStarts[oldPatchi];
205 if (oldLocalI >= 0 && oldLocalI < oldBfld[oldPatchi].size())
207 patchFld[i] = oldBfld[oldPatchi][oldLocalI];
217void Foam::fvMeshDistribute::saveInternalFields
226 mesh_.objectRegistry::csorted<fldType>()
229 iflds.resize_null(
fields.size());
244void Foam::fvMeshDistribute::mapExposedFaces
258 mesh_.objectRegistry::sorted<fldType>()
261 if (flds.size() != oldFlds.size())
271 auto&
fld = flds[fieldi];
272 const auto& oldInternal = oldFlds[fieldi];
274 const bool oriented =
fld.is_oriented();
276 auto& bfld =
fld.boundaryFieldRef();
287 const label faceI = patchFld.
patch().
start()+i;
289 label oldFaceI =
faceMap[faceI];
291 if (oldFaceI < oldInternal.size())
293 patchFld[i] = oldInternal[oldFaceI];
295 if (oriented && map.flipFaceFlux().found(faceI))
297 patchFld[i] =
flipOp()(patchFld[i]);
306template<
class GeoField,
class PatchFieldType>
307void Foam::fvMeshDistribute::initPatchFields
309 const typename GeoField::value_type& initVal
315 for (GeoField&
fld : mesh_.objectRegistry::objects<GeoField>())
317 auto& bfld =
fld.boundaryFieldRef();
323 bfld[patchi] == initVal;
342template<
class GeoField>
343void Foam::fvMeshDistribute::getFieldNames
347 const word& excludeType,
351 wordList& list = allFieldNames(GeoField::typeName);
354 if (!excludeType.empty())
359 if (!excludeList.empty())
362 for (
const auto&
name : list)
364 if (!excludeList.contains(
name))
366 newList.push_back(
name);
369 if (newList.size() < list.size())
371 list = std::move(newList);
385 const wordList allNames(procAddr.gather(list));
388 for (
const int proci : procAddr.subProcs())
390 const auto procNames(allNames.slice(procAddr.range(proci)));
392 if (procNames != list)
395 <<
"When checking for equal " << GeoField::typeName
397 <<
"processor0 has:" << list <<
nl
398 <<
"processor" << proci <<
" has:" << procNames <<
nl
399 << GeoField::typeName
400 <<
" need to be synchronised on all processors."
409template<
class GeoField>
410void Foam::fvMeshDistribute::sendFields
442 for (
const word& fieldName : fieldNames)
446 Pout<<
"Subsetting " << GeoField::typeName
447 <<
" field " << fieldName
448 <<
" for domain:" << domain <<
endl;
453 const GeoField&
fld =
454 subsetter.baseMesh().lookupObject<GeoField>(fieldName);
469template<
class GeoField>
470void Foam::fvMeshDistribute::receiveFields
485 allFieldsDict.
subDict(GeoField::typeName);
490 Pout<<
"Receiving:" << GeoField::typeName
491 <<
" fields:" << fieldNames
492 <<
" from domain:" << domain <<
endl;
495 fields.resize(fieldNames.size());
498 for (
const word& fieldName : fieldNames)
502 Pout<<
"Constructing type:" << GeoField::typeName
503 <<
" field:" << fieldName
504 <<
" from domain:" << domain <<
endl;
Info<< nl;Info<< "Write faMesh in vtk format:"<< nl;{ vtk::uindirectPatchWriter writer(aMesh.patch(), fileName(aMesh.time().globalPath()/vtkBaseFileName));writer.writeGeometry();globalIndex procAddr(aMesh.nFaces());labelList cellIDs;if(UPstream::master()) { cellIDs.resize(procAddr.totalSize());for(const labelRange &range :procAddr.ranges()) { auto slice=cellIDs.slice(range);slice=identity(range);} } writer.beginCellData(4);writer.writeProcIDs();writer.write("cellID", cellIDs);writer.write("area", aMesh.S().field());writer.write("normal", aMesh.faceAreaNormals());writer.beginPointData(1);writer.write("normal", aMesh.pointAreaNormals());Info<< " "<< writer.output().name()<< nl;}{ vtk::lineWriter writer(aMesh.points(), aMesh.edges(), fileName(aMesh.time().globalPath()/(vtkBaseFileName+"-edges")));writer.writeGeometry();writer.beginCellData(4);writer.writeProcIDs();{ Field< scalar > fld(faMeshTools::flattenEdgeField(aMesh.magLe(), true))
A 1D vector of objects of type <T> that resizes itself as necessary to accept the new objects.
A field of fields is a PtrList of fields with reference counting.
Generic templated field type that is much like a Foam::List except that it is expected to hold numeri...
Generic GeometricField class.
A HashTable similar to std::unordered_map.
@ NO_READ
Nothing to be read.
@ AUTO_WRITE
Automatically write from objectRegistry::writeObject().
Defines the attributes of an object for which implicit objectRegistry management is supported,...
static const List< word > & null() noexcept
An Ostream is an abstract base class for all output systems (streams, files, token lists,...
A list of pointers to objects of type <T>, with allocation/deallocation management of the pointers....
static word timeName(const scalar t, const int precision=precision_)
Return a time name for the given scalar time value formatted with the given precision.
static bool parRun(const bool on) noexcept
Set as parallel run on/off.
A list of pointers to objects of type <T>, without allocation/deallocation management of the pointers...
ZoneType zone_type
The zone type. Same as PtrList<ZoneType>::value_type.
A list of keyword definitions, which are a keyword followed by a number of values (eg,...
const dictionary & subDict(const word &keyword, enum keyType::option matchOpt=keyType::REGEX) const
Find and return a sub-dictionary.
static void printIntFieldInfo(const fvMesh &)
Print some field info.
static void printFieldInfo(const fvMesh &)
Print some field info.
Holds a reference to the original mesh (the baseMesh) and optionally to a subset of that mesh (the su...
Mesh data needed to do the Finite Volume discretisation.
const Time & time() const
Return the top-level database.
Abstract base class with a fat-interface to all derived classes covering all possible ways in which t...
label start() const noexcept
The patch start within the polyMesh face list.
const fvPatch & patch() const noexcept
Return the patch.
An abstract base class with a fat-interface to all derived classes covering all possible ways in whic...
Calculates a non-overlapping list of offsets based on an input size (eg, number of cells) from differ...
Class containing mesh-to-mesh mapping information after a change in polyMesh topology.
wordList sortedNames() const
The sorted names of all objects.
A class for managing temporary objects.
@ BEGIN_BLOCK
Begin block [isseparator].
@ END_BLOCK
End block [isseparator].
Mesh data needed to do the Finite Volume discretisation.
A class for handling words, derived from Foam::string.
#define FatalErrorInFunction
Report an error message using Foam::FatalError.
Namespace for handling debugging switches.
Pair< int > faceMap(const label facePi, const face &faceP, const label faceNi, const face &faceN)
List< word > wordList
List of word.
List< label > labelList
A List of labels.
Ostream & endl(Ostream &os)
Add newline and flush stream.
const Type * isA(const U &obj)
Attempt dynamic_cast to Type.
errorManip< error > abort(error &err)
error FatalError
Error stream (stdout output on all processes), with additional 'FOAM FATAL ERROR' header text and sta...
word name(const expressions::valueTypeCode typeCode)
A word representation of a valueTypeCode. Empty for expressions::valueTypeCode::INVALID.
prefixOSstream Pout
OSstream wrapped stdout (std::cout) with parallel prefix.
errorManipArg< error, int > exit(error &err, const int errNo=1)
constexpr char nl
The newline '\n' character (0x0a).
multivariateSurfaceInterpolationScheme< scalar >::fieldTable fields
#define forAll(list, i)
Loop across all elements in list.
Functor to negate primitives. Dummy for most other types.
Dispatch tag: Construct 'one-sided' from the non-master local sizes using gather but no broadcast.