33 template<
class ZoneType,
class ZoneMesh>
34 void Foam::fvMeshDistribute::reorderZones
40 zones.clearAddressing();
43 UPtrList<ZoneType> newZonePtrs(zoneNames.size());
46 auto* zonePtr = zones.get(zonei);
52 const label newIndex = zoneNames.find(zonePtr->name());
53 zonePtr->index() = newIndex;
54 newZonePtrs.set(newIndex, zonePtr);
60 if (!newZonePtrs.get(i))
76 zones.swap(newZonePtrs);
80 template<
class GeoField>
85 typename GeoField::value_type,
90 for (
const GeoField&
field :
mesh.objectRegistry::csorted<GeoField>())
92 if (!isA<excludeType>(
field))
102 template<
class GeoField>
105 for (
const GeoField&
field :
mesh.objectRegistry::csorted<GeoField>())
111 for (
const auto& patchFld :
field.boundaryField())
113 Pout<<
" " << patchFld.patch().index()
114 <<
' ' << patchFld.patch().
name()
115 <<
' ' << patchFld.
type()
116 <<
' ' << patchFld.size()
123 template<
class T,
class Mesh>
124 void Foam::fvMeshDistribute::saveBoundaryFields
126 PtrList<FieldField<fvsPatchField, T>>& bflds
131 typedef GeometricField<T, fvsPatchField, Mesh> fldType;
133 const UPtrList<const fldType> flds
135 mesh_.objectRegistry::csorted<fldType>()
138 bflds.resize_null(flds.size());
141 for (
const fldType&
fld : flds)
143 bflds.set(fieldi,
fld.boundaryField().clone());
150 template<
class T,
class Mesh>
151 void Foam::fvMeshDistribute::mapBoundaryFields
153 const mapPolyMesh& map,
154 const PtrList<FieldField<fvsPatchField, T>>& oldBflds
159 const labelList& oldPatchStarts = map.oldPatchStarts();
162 typedef GeometricField<T, fvsPatchField, Mesh> fldType;
164 UPtrList<fldType> flds
166 mesh_.objectRegistry::sorted<fldType>()
169 if (flds.size() != oldBflds.size())
177 auto& bfld = flds[fieldi].boundaryFieldRef();
178 const auto& oldBfld = oldBflds[fieldi];
184 fvsPatchField<T>& patchFld = bfld[patchi];
185 label facei = patchFld.patch().start();
189 label oldFacei =
faceMap[facei++];
192 forAll(oldPatchStarts, oldPatchi)
194 label oldLocalI = oldFacei - oldPatchStarts[oldPatchi];
196 if (oldLocalI >= 0 && oldLocalI < oldBfld[oldPatchi].size())
198 patchFld[i] = oldBfld[oldPatchi][oldLocalI];
208 void Foam::fvMeshDistribute::saveInternalFields
210 PtrList<Field<T>>& iflds
213 typedef GeometricField<T, fvsPatchField, surfaceMesh> fldType;
215 const UPtrList<const fldType>
fields 217 mesh_.objectRegistry::csorted<fldType>()
220 iflds.resize_null(
fields.size());
224 iflds.set(fieldi,
fields[fieldi].primitiveField().clone());
230 void Foam::fvMeshDistribute::mapExposedFaces
232 const mapPolyMesh& map,
233 const PtrList<Field<T>>& oldFlds
240 typedef GeometricField<T, fvsPatchField, surfaceMesh> fldType;
242 UPtrList<fldType> flds
244 mesh_.objectRegistry::sorted<fldType>()
247 if (flds.size() != oldFlds.size())
257 auto&
fld = flds[fieldi];
258 const auto& oldInternal = oldFlds[fieldi];
260 const bool oriented =
fld.is_oriented();
262 auto& bfld =
fld.boundaryFieldRef();
269 fvsPatchField<T>& patchFld = bfld[patchi];
273 const label faceI = patchFld.patch().start()+i;
275 label oldFaceI =
faceMap[faceI];
277 if (oldFaceI < oldInternal.size())
279 patchFld[i] = oldInternal[oldFaceI];
281 if (oriented && map.flipFaceFlux().found(faceI))
283 patchFld[i] = flipOp()(patchFld[i]);
292 template<
class GeoField,
class PatchFieldType>
293 void Foam::fvMeshDistribute::initPatchFields
295 const typename GeoField::value_type& initVal
301 for (GeoField&
fld : mesh_.objectRegistry::objects<GeoField>())
303 auto& bfld =
fld.boundaryFieldRef();
307 if (isA<PatchFieldType>(bfld[patchi]))
309 bfld[patchi] == initVal;
328 template<
class GeoField>
329 void Foam::fvMeshDistribute::getFieldNames
332 HashTable<wordList>& allFieldNames,
333 const word& excludeType,
337 wordList& list = allFieldNames(GeoField::typeName);
340 if (!excludeType.empty())
345 if (!excludeList.empty())
347 DynamicList<word> newList(list.size());
348 for (
const auto&
name : list)
350 if (!excludeList.contains(
name))
355 if (newList.size() < list.size())
357 list = std::move(newList);
369 const globalIndex
procAddr(globalIndex::gatherNonLocal{}, list.size());
378 if (procNames != list)
381 <<
"When checking for equal " << GeoField::typeName
383 <<
"processor0 has:" << list <<
nl 384 <<
"processor" << proci <<
" has:" << procNames <<
nl 385 << GeoField::typeName
386 <<
" need to be synchronised on all processors." 395 template<
class GeoField>
396 void Foam::fvMeshDistribute::sendFields
399 const HashTable<wordList>& allFieldNames,
400 const fvMeshSubset& subsetter,
428 for (
const word& fieldName : fieldNames)
432 Pout<<
"Subsetting " << GeoField::typeName
433 <<
" field " << fieldName
434 <<
" for domain:" << domain <<
endl;
439 const GeoField&
fld =
440 subsetter.baseMesh().lookupObject<GeoField>(fieldName);
444 tmp<GeoField> tsubfld = subsetter.interpolate(
fld,
true);
455 template<
class GeoField>
456 void Foam::fvMeshDistribute::receiveFields
459 const HashTable<wordList>& allFieldNames,
461 PtrList<GeoField>&
fields,
462 const dictionary& allFieldsDict
471 allFieldsDict.subDict(GeoField::typeName);
476 Pout<<
"Receiving:" << GeoField::typeName
477 <<
" fields:" << fieldNames
478 <<
" from domain:" << domain <<
endl;
481 fields.resize(fieldNames.size());
484 for (
const word& fieldName : fieldNames)
488 Pout<<
"Constructing type:" << GeoField::typeName
489 <<
" field:" << fieldName
490 <<
" from domain:" << domain <<
endl;
Begin block [isseparator].
labelRange range(const label proci) const
Return start/size range of proci data.
errorManipArg< error, int > exit(error &err, const int errNo=1)
error FatalError
Error stream (stdout output on all processes), with additional 'FOAM FATAL ERROR' header text and sta...
#define FatalErrorInFunction
Report an error message using Foam::FatalError.
constexpr char nl
The newline '\n' character (0x0a)
Type type(bool followLink=true, bool checkGzip=false) const
Return the directory entry type: UNDEFINED, FILE, DIRECTORY (or SYMLINK).
Ostream & endl(Ostream &os)
Add newline and flush stream.
static bool & parRun() noexcept
Test if this a parallel run.
Abstract base class with a fat-interface to all derived classes covering all possible ways in which t...
Generic GeometricField class.
const Time & time() const
Return the top-level database.
virtual const fileName & name() const override
Get the name of the output serial stream. (eg, the name of the Fstream file name) ...
void push_back(const T &val)
Append an element at the end of the list.
const dictionary & subDict(const word &keyword, enum keyType::option matchOpt=keyType::REGEX) const
Find and return a sub-dictionary.
Pair< int > faceMap(const label facePi, const face &faceP, const label faceNi, const face &faceN)
multivariateSurfaceInterpolationScheme< scalar >::fieldTable fields
#define forAll(list, i)
Loop across all elements in list.
Mesh data needed to do the Finite Volume discretisation.
word name(const expressions::valueTypeCode typeCode)
A word representation of a valueTypeCode. Empty for expressions::valueTypeCode::INVALID.
wordList sortedNames() const
The sorted names of all objects.
errorManip< error > abort(error &err)
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 void printFieldInfo(const fvMesh &)
Print some field info.
int debug
Static debugging option.
labelRange subProcs() const noexcept
Range of process indices for addressed sub-offsets (processes)
gmvFile<< "tracers "<< particles.size()<< nl;for(const passiveParticle &p :particles){ gmvFile<< p.position().x()<< ' ';}gmvFile<< nl;for(const passiveParticle &p :particles){ gmvFile<< p.position().y()<< ' ';}gmvFile<< nl;for(const passiveParticle &p :particles){ gmvFile<< p.position().z()<< ' ';}gmvFile<< nl;for(const word &name :lagrangianScalarNames){ IOField< scalar > fld(IOobject(name, runTime.timeName(), cloud::prefix, mesh, IOobject::MUST_READ, IOobject::NO_WRITE))
List< word > wordList
List of word.
globalIndex procAddr(aMesh.nFaces())
Mesh data needed to do the Finite Volume discretisation.
Automatically write from objectRegistry::writeObject()
static void gather(const labelUList &offsets, const label comm, const ProcIDsContainer &procIDs, const UList< Type > &fld, List< Type > &allFld, const int tag=UPstream::msgType(), const UPstream::commsTypes=UPstream::commsTypes::nonBlocking)
Collect data in processor order on master (== procIDs[0]).
List< label > labelList
A List of labels.
static const List< word > & null() noexcept
Return a null List (reference to a nullObject). Behaves like an empty List.
prefixOSstream Pout
OSstream wrapped stdout (std::cout) with parallel prefix.
static void printIntFieldInfo(const fvMesh &)
Print some field info.