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>
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
148 mesh_.objectRegistry::lookupClass<
const fldType>()
151 bflds.setSize(flds.size());
156 const fldType&
fld = *iter();
158 bflds.set(i,
fld.boundaryField().clone().ptr());
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.setSize(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.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);
407 if (allNames[proci] != allNames[0])
410 <<
"When checking for equal "
411 << GeoField::typeName
413 <<
"processor0 has:" << allNames[0] <<
endl
414 <<
"processor" << proci <<
" has:" << allNames[proci] <<
nl
415 << GeoField::typeName
416 <<
" need to be synchronised on all processors."
424 template<
class GeoField>
425 void Foam::fvMeshDistribute::sendFields
428 const HashTable<wordList>& allFieldNames,
429 const fvMeshSubset& subsetter,
461 Pout<<
"Subsetting " << GeoField::typeName
462 <<
" field " << fieldName
463 <<
" for domain:" << domain <<
endl;
468 const GeoField&
fld =
469 subsetter.baseMesh().lookupObject<GeoField>(fieldName);
473 tmp<GeoField> tsubfld = subsetter.interpolate(
fld,
true);
484 template<
class GeoField>
485 void Foam::fvMeshDistribute::receiveFields
488 const HashTable<wordList>& allFieldNames,
490 PtrList<GeoField>&
fields,
491 const dictionary& allFieldsDict
499 const dictionary& fieldDicts =
500 allFieldsDict.subDict(GeoField::typeName);
505 Pout<<
"Receiving:" << GeoField::typeName
507 <<
" from domain:" << domain <<
endl;
517 Pout<<
"Constructing type:" << GeoField::typeName
518 <<
" field:" << fieldName
519 <<
" from domain:" << domain <<
endl;