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,
92 mesh.objectRegistry::lookupClass<GeoField>()
97 const GeoField&
fld = *iter();
98 if (!isA<excludeType>(
fld))
100 Pout<<
"Field:" << iter.key() <<
" internalsize:" <<
fld.size()
108 template<
class GeoField>
111 const HashTable<const GeoField*> flds
113 mesh.objectRegistry::lookupClass<GeoField>()
118 const GeoField&
fld = *iter();
120 Pout<<
"Field:" << iter.key() <<
" internalsize:" <<
fld.size()
124 for (
const auto& patchFld :
fld.boundaryField())
126 Pout<<
" " << patchFld.patch().index()
127 <<
' ' << patchFld.patch().
name()
128 <<
' ' << patchFld.
type()
129 <<
' ' << patchFld.size()
136 template<
class T,
class Mesh>
137 void Foam::fvMeshDistribute::saveBoundaryFields
139 PtrList<FieldField<fvsPatchField, T>>& bflds
144 typedef GeometricField<T, fvsPatchField, Mesh> fldType;
146 HashTable<const fldType*> flds
148 mesh_.objectRegistry::lookupClass<
const fldType>()
151 bflds.resize(flds.size());
156 const fldType&
fld = *iter();
158 bflds.set(i,
fld.boundaryField().clone());
165 template<
class T,
class Mesh>
166 void Foam::fvMeshDistribute::mapBoundaryFields
168 const mapPolyMesh& map,
169 const PtrList<FieldField<fvsPatchField, T>>& oldBflds
174 const labelList& oldPatchStarts = map.oldPatchStarts();
177 typedef GeometricField<T, fvsPatchField, Mesh> fldType;
179 HashTable<fldType*> flds
181 mesh_.objectRegistry::lookupClass<fldType>()
184 if (flds.size() != oldBflds.size())
194 fldType&
fld = *iter();
195 auto& bfld =
fld.boundaryFieldRef();
197 const FieldField<fvsPatchField, T>& oldBfld = oldBflds[fieldi++];
203 fvsPatchField<T>& patchFld = bfld[patchi];
204 label facei = patchFld.patch().start();
208 label oldFacei =
faceMap[facei++];
211 forAll(oldPatchStarts, oldPatchi)
213 label oldLocalI = oldFacei - oldPatchStarts[oldPatchi];
215 if (oldLocalI >= 0 && oldLocalI < oldBfld[oldPatchi].size())
217 patchFld[i] = oldBfld[oldPatchi][oldLocalI];
227 void Foam::fvMeshDistribute::saveInternalFields
229 PtrList<Field<T>>& iflds
232 typedef GeometricField<T, fvsPatchField, surfaceMesh> fldType;
234 HashTable<const fldType*> flds
236 mesh_.objectRegistry::lookupClass<
const fldType>()
239 iflds.resize(flds.size());
245 const fldType&
fld = *iter();
247 iflds.set(i,
fld.primitiveField().clone());
255 void Foam::fvMeshDistribute::mapExposedFaces
257 const mapPolyMesh& map,
258 const PtrList<Field<T>>& oldFlds
265 typedef GeometricField<T, fvsPatchField, surfaceMesh> fldType;
267 HashTable<fldType*> flds
269 mesh_.objectRegistry::lookupClass<fldType>()
272 if (flds.size() != oldFlds.size())
284 fldType&
fld = *iter();
285 const bool oriented =
fld.is_oriented();
287 typename fldType::Boundary& bfld =
fld.boundaryFieldRef();
289 const Field<T>& oldInternal = oldFlds[fieldI++];
295 fvsPatchField<T>& patchFld = bfld[patchi];
299 const label faceI = patchFld.patch().start()+i;
301 label oldFaceI =
faceMap[faceI];
303 if (oldFaceI < oldInternal.size())
305 patchFld[i] = oldInternal[oldFaceI];
307 if (oriented && map.flipFaceFlux().found(faceI))
309 patchFld[i] = flipOp()(patchFld[i]);
318 template<
class GeoField,
class PatchFieldType>
319 void Foam::fvMeshDistribute::initPatchFields
321 const typename GeoField::value_type& initVal
326 HashTable<GeoField*> flds
328 mesh_.objectRegistry::lookupClass<GeoField>()
333 GeoField&
fld = *iter();
335 auto& bfld =
fld.boundaryFieldRef();
339 if (isA<PatchFieldType>(bfld[patchi]))
341 bfld[patchi] == initVal;
366 template<
class GeoField>
367 void Foam::fvMeshDistribute::getFieldNames
370 HashTable<wordList>& allFieldNames,
371 const word& excludeType,
375 wordList& list = allFieldNames(GeoField::typeName);
378 if (!excludeType.empty())
380 const wordList& excludeList = allFieldNames(excludeType);
382 DynamicList<word> newList(list.size());
383 for(
const auto&
name : list)
385 if (!excludeList.found(
name))
387 newList.append(
name);
390 if (newList.size() < list.size())
392 list = std::move(newList);
403 const globalIndex
procAddr(globalIndex::gatherNonLocal{}, list.size());
412 if (procNames != list)
415 <<
"When checking for equal " << GeoField::typeName
417 <<
"processor0 has:" << list <<
nl 418 <<
"processor" << proci <<
" has:" << procNames <<
nl 419 << GeoField::typeName
420 <<
" need to be synchronised on all processors." 429 template<
class GeoField>
430 void Foam::fvMeshDistribute::sendFields
433 const HashTable<wordList>& allFieldNames,
434 const fvMeshSubset& subsetter,
462 for (
const word& fieldName : fieldNames)
466 Pout<<
"Subsetting " << GeoField::typeName
467 <<
" field " << fieldName
468 <<
" for domain:" << domain <<
endl;
473 const GeoField&
fld =
474 subsetter.baseMesh().lookupObject<GeoField>(fieldName);
478 tmp<GeoField> tsubfld = subsetter.interpolate(
fld,
true);
489 template<
class GeoField>
490 void Foam::fvMeshDistribute::receiveFields
493 const HashTable<wordList>& allFieldNames,
495 PtrList<GeoField>&
fields,
496 const dictionary& allFieldsDict
504 const dictionary& fieldDicts =
505 allFieldsDict.subDict(GeoField::typeName);
510 Pout<<
"Receiving:" << GeoField::typeName
511 <<
" fields:" << fieldNames
512 <<
" from domain:" << domain <<
endl;
515 fields.resize(fieldNames.size());
518 for (
const word& fieldName : fieldNames)
522 Pout<<
"Constructing type:" << GeoField::typeName
523 <<
" field:" << fieldName
524 <<
" from domain:" << domain <<
endl;
Begin block [isseparator].
virtual const fileName & name() const
Get the name of the output serial stream. (eg, the name of the Fstream file name) ...
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.
static const List< word > & null()
Return a null List.
const Time & time() const
Return the top-level database.
const dictionary & subDict(const word &keyword, enum keyType::option matchOpt=keyType::REGEX) const
Find and return a sub-dictionary.
labelRange range() const
Return start/size range of local processor data.
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 INVALID.
wordList sortedNames() const
The sorted names of all objects.
#define forAllIters(container, iter)
Iterate across all elements in the container object.
A HashTable similar to std::unordered_map.
errorManip< error > abort(error &err)
static word timeName(const scalar t, const int precision=precision_)
Return time name of given scalar time 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
A List of words.
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.
prefixOSstream Pout
OSstream wrapped stdout (std::cout) with parallel prefix.
static void printIntFieldInfo(const fvMesh &)
Print some field info.
forAllConstIters(mixture.phases(), phase)