51 template <
class Container,
class T>
52 void Foam::fvMeshDistribute::exchange
54 const List<Container >& sendBufs,
55 List<Container >& recvBufs,
65 "Pstream::exchange(..)"
73 "Pstream::exchange(..)"
74 ) <<
"Size of list:" << sendBufs.size()
75 <<
" does not equal the number of processors:"
86 nsTransPs[procI] = sendBufs[procI].size();
95 recvBufs.setSize(sendBufs.size());
102 recvBufs[procI].setSize(nRecv);
107 reinterpret_cast<char*>(recvBufs[procI].begin()),
127 reinterpret_cast<const char*>(sendBufs[procI].begin()),
128 sendBufs[procI].size()*
sizeof(
T)
133 <<
"Cannot send outgoing message. "
134 <<
"to:" << procI <<
" nBytes:"
135 << label(sendBufs[procI].size()*
sizeof(
T))
154 template<
class GeoField>
159 mesh.objectRegistry::lookupClass<GeoField>()
169 const GeoField& fld = *iter();
171 Pout<<
"Field:" << iter.key() <<
" internalsize:" << fld.size()
175 forAll(fld.boundaryField(), patchI)
178 <<
' ' << fld.boundaryField()[patchI].patch().
name()
179 <<
' ' << fld.boundaryField()[patchI].
type()
180 <<
' ' << fld.boundaryField()[patchI].size()
187 template<
class GeoField>
188 void Foam::fvMeshDistribute::addPatchFields(
const word& patchFieldType)
192 mesh_.objectRegistry::lookupClass<GeoField>()
202 const GeoField& fld = *iter();
204 typename GeoField::GeometricBoundaryField& bfld =
205 const_cast<typename GeoField::GeometricBoundaryField&
>
210 label sz = bfld.size();
211 bfld.setSize(sz + 1);
215 GeoField::PatchFieldType::New
218 mesh_.boundary()[sz],
219 fld.dimensionedInternalField()
227 template<
class GeoField>
228 void Foam::fvMeshDistribute::deleteTrailingPatchFields()
230 HashTable<const GeoField*> flds
232 mesh_.objectRegistry::lookupClass<GeoField>()
237 typename HashTable<const GeoField*>::const_iterator iter = flds.begin();
242 const GeoField& fld = *iter();
244 typename GeoField::GeometricBoundaryField& bfld =
245 const_cast<typename GeoField::GeometricBoundaryField&
>
251 bfld.setSize(bfld.size() - 1);
257 template <
class T,
class Mesh>
258 void Foam::fvMeshDistribute::saveBoundaryFields
260 PtrList<FieldField<fvsPatchField, T> >& bflds
263 typedef GeometricField<T, fvsPatchField, Mesh> fldType;
265 HashTable<const fldType*> flds
267 mesh_.objectRegistry::lookupClass<fldType>()
270 bflds.setSize(flds.size());
276 typename HashTable<const fldType*>::const_iterator iter = flds.begin();
281 const fldType& fld = *iter();
283 bflds.set(i, fld.boundaryField().clone().ptr());
291 template <
class T,
class Mesh>
292 void Foam::fvMeshDistribute::mapBoundaryFields
294 const mapPolyMesh& map,
295 const PtrList<FieldField<fvsPatchField, T> >& oldBflds
298 const labelList& oldPatchStarts = map.oldPatchStarts();
299 const labelList& faceMap = map.faceMap();
301 typedef GeometricField<T, fvsPatchField, Mesh> fldType;
303 HashTable<const fldType*> flds
305 mesh_.objectRegistry::lookupClass<fldType>()
308 if (flds.size() != oldBflds.size())
310 FatalErrorIn(
"fvMeshDistribute::mapBoundaryFields(..)") <<
"problem"
318 typename HashTable<const fldType*>::const_iterator iter = flds.begin();
323 const fldType& fld = *iter();
324 typename fldType::GeometricBoundaryField& bfld =
325 const_cast<typename fldType::GeometricBoundaryField&
>
331 const FieldField<fvsPatchField, T>& oldBfld = oldBflds[fieldI++];
337 fvsPatchField<T>& patchFld = bfld[patchI];
338 label faceI = patchFld.patch().patch().start();
342 label oldFaceI = faceMap[faceI++];
345 forAll(oldPatchStarts, oldPatchI)
347 label oldLocalI = oldFaceI - oldPatchStarts[oldPatchI];
349 if (oldLocalI >= 0 && oldLocalI < oldBfld[oldPatchI].size())
351 patchFld[i] = oldBfld[oldPatchI][oldLocalI];
361 template<
class GeoField,
class PatchFieldType>
362 void Foam::fvMeshDistribute::initPatchFields
364 const typename GeoField::value_type& initVal
367 HashTable<const GeoField*> flds
369 mesh_.objectRegistry::lookupClass<GeoField>()
374 typename HashTable<const GeoField*>::const_iterator iter = flds.begin();
379 const GeoField& fld = *iter();
381 typename GeoField::GeometricBoundaryField& bfld =
382 const_cast<typename GeoField::GeometricBoundaryField&
>
389 if (isA<PatchFieldType>(bfld[patchI]))
391 bfld[patchI] == initVal;
416 template<
class GeoField>
417 void Foam::fvMeshDistribute::sendFields
421 const fvMeshSubset& subsetter,
430 Pout<<
"Subsetting field " << fieldNames[i]
431 <<
" for domain:" << domain <<
endl;
436 const GeoField& fld =
437 subsetter.baseMesh().objectRegistry::lookupObject<GeoField>(fieldNames[i]);
439 tmp<GeoField> tsubfld = subsetter.interpolate(fld);
451 template<
class GeoField>
452 void Foam::fvMeshDistribute::receiveFields
457 PtrList<GeoField>&
fields,
458 const dictionary& fieldDicts
463 Pout<<
"Receiving fields " << fieldNames
464 <<
" from domain:" << domain <<
endl;
467 fields.setSize(fieldNames.size());
473 Pout<<
"Constructing field " << fieldNames[i]
474 <<
" from domain:" << domain <<
endl;
485 mesh.time().timeName(),
491 fieldDicts.subDict(fieldNames[i])