33 template<
class GeoField>
38 mesh.objectRegistry::lookupClass<GeoField>()
43 const GeoField&
fld = *iter();
45 Pout<<
"Field:" << iter.key() <<
" internalsize:" <<
fld.size()
49 for (
const auto& patchFld :
fld.boundaryField())
51 Pout<<
" " << patchFld.patch().index()
52 <<
' ' << patchFld.patch().
name()
53 <<
' ' << patchFld.
type()
54 <<
' ' << patchFld.size()
61 template<
class T,
class Mesh>
62 void Foam::fvMeshDistribute::saveBoundaryFields
73 mesh_.objectRegistry::lookupClass<
const fldType>()
76 bflds.setSize(flds.size());
81 const fldType&
fld = *iter();
83 bflds.set(i,
fld.boundaryField().clone().ptr());
90 template<
class T,
class Mesh>
91 void Foam::fvMeshDistribute::mapBoundaryFields
93 const mapPolyMesh& map,
94 const PtrList<FieldField<fvsPatchField, T>>& oldBflds
99 const labelList& oldPatchStarts = map.oldPatchStarts();
102 typedef GeometricField<T, fvsPatchField, Mesh> fldType;
104 HashTable<fldType*> flds
106 mesh_.objectRegistry::lookupClass<fldType>()
109 if (flds.size() != oldBflds.size())
119 fldType&
fld = *iter();
120 auto& bfld =
fld.boundaryFieldRef();
122 const FieldField<fvsPatchField, T>& oldBfld = oldBflds[fieldi++];
128 fvsPatchField<T>& patchFld = bfld[patchi];
129 label facei = patchFld.patch().start();
133 label oldFacei =
faceMap[facei++];
136 forAll(oldPatchStarts, oldPatchi)
138 label oldLocalI = oldFacei - oldPatchStarts[oldPatchi];
140 if (oldLocalI >= 0 && oldLocalI < oldBfld[oldPatchi].size())
142 patchFld[i] = oldBfld[oldPatchi][oldLocalI];
152 void Foam::fvMeshDistribute::saveInternalFields
154 PtrList<Field<T>>& iflds
157 typedef GeometricField<T, fvsPatchField, surfaceMesh> fldType;
159 HashTable<const fldType*> flds
161 mesh_.objectRegistry::lookupClass<
const fldType>()
164 iflds.setSize(flds.size());
170 const fldType&
fld = *iter();
172 iflds.set(i,
fld.primitiveField().clone());
180 void Foam::fvMeshDistribute::mapExposedFaces
182 const mapPolyMesh& map,
183 const PtrList<Field<T>>& oldFlds
190 typedef GeometricField<T, fvsPatchField, surfaceMesh> fldType;
192 HashTable<fldType*> flds
194 mesh_.objectRegistry::lookupClass<fldType>()
197 if (flds.size() != oldFlds.size())
209 fldType&
fld = *iter();
210 const bool oriented =
fld.oriented()();
212 typename fldType::Boundary& bfld =
fld.boundaryFieldRef();
214 const Field<T>& oldInternal = oldFlds[fieldI++];
220 fvsPatchField<T>& patchFld = bfld[patchi];
224 const label faceI = patchFld.patch().start()+i;
226 label oldFaceI =
faceMap[faceI];
228 if (oldFaceI < oldInternal.size())
230 patchFld[i] = oldInternal[oldFaceI];
232 if (oriented && map.flipFaceFlux().found(faceI))
234 patchFld[i] = flipOp()(patchFld[i]);
243 template<
class GeoField,
class PatchFieldType>
244 void Foam::fvMeshDistribute::initPatchFields
246 const typename GeoField::value_type& initVal
251 HashTable<GeoField*> flds
253 mesh_.objectRegistry::lookupClass<GeoField>()
258 GeoField&
fld = *iter();
260 auto& bfld =
fld.boundaryFieldRef();
264 if (isA<PatchFieldType>(bfld[patchi]))
266 bfld[patchi] == initVal;
273 template<
class GeoField>
274 void Foam::fvMeshDistribute::correctBoundaryConditions()
278 HashTable<GeoField*> flds
280 mesh_.objectRegistry::lookupClass<GeoField>()
285 GeoField&
fld = *iter();
286 fld.correctBoundaryConditions();
291 template<
class GeoField>
292 void Foam::fvMeshDistribute::getFieldNames
295 HashTable<wordList>& allFieldNames,
299 wordList& list = allFieldNames(GeoField::typeName);
312 if (allNames[proci] != allNames[0])
315 <<
"When checking for equal "
316 << GeoField::typeName
318 <<
"processor0 has:" << allNames[0] <<
endl
319 <<
"processor" << proci <<
" has:" << allNames[proci] <<
nl
320 << GeoField::typeName
321 <<
" need to be synchronised on all processors."
329 template<
class GeoField>
330 void Foam::fvMeshDistribute::sendFields
333 const HashTable<wordList>& allFieldNames,
334 const fvMeshSubset& subsetter,
362 for (
const word& fieldName : fieldNames)
366 Pout<<
"Subsetting field " << fieldName
367 <<
" for domain:" << domain <<
endl;
372 const GeoField&
fld =
373 subsetter.baseMesh().lookupObject<GeoField>(fieldName);
377 tmp<GeoField> tsubfld = subsetter.interpolate(
fld,
true);
388 template<
class GeoField>
389 void Foam::fvMeshDistribute::receiveFields
392 const HashTable<wordList>& allFieldNames,
394 PtrList<GeoField>&
fields,
395 const dictionary& allFieldsDict
403 const dictionary& fieldDicts =
404 allFieldsDict.subDict(GeoField::typeName);
409 Pout<<
"Receiving fields " << fieldNames
410 <<
" from domain:" << domain <<
endl;
413 fields.resize(fieldNames.size());
416 for (
const word& fieldName : fieldNames)
420 Pout<<
"Constructing field " << fieldName
421 <<
" from domain:" << domain <<
endl;