37void Foam::fvMeshAdder::MapVolField
39 const mapAddedPolyMesh& meshMap,
41 GeometricField<Type, fvPatchField, volMesh>&
fld,
42 const GeometricField<Type, fvPatchField, volMesh>& fldToAdd,
43 const bool fullyMapped
46 const fvMesh&
mesh =
fld.mesh();
53 const Field<Type> oldInternalField(
fld.primitiveField());
56 Field<Type>& intFld =
fld.primitiveFieldRef();
60 intFld.rmap(oldInternalField, meshMap.oldCellMap());
61 intFld.rmap(fldToAdd.primitiveField(), meshMap.addedCellMap());
68 auto& bfld =
fld.boundaryFieldRef();
71 const labelList& oldPatchMap = meshMap.oldPatchMap();
72 const labelList& oldPatchStarts = meshMap.oldPatchStarts();
73 const labelList& oldPatchSizes = meshMap.oldPatchSizes();
77 label unusedPatchi = 0;
79 forAll(oldPatchMap, patchi)
81 label newPatchi = oldPatchMap[patchi];
89 label nUsedPatches = unusedPatchi;
94 forAll(oldPatchMap, patchi)
96 const label newPatchi = oldPatchMap[patchi];
100 oldToNew[patchi] = newPatchi;
104 oldToNew[patchi] = unusedPatchi++;
110 bfld.reorder(oldToNew);
116 label newPatchi = nUsedPatches;
117 newPatchi < bfld.size();
121 bfld.set(newPatchi,
nullptr);
128 forAll(oldPatchMap, patchi)
130 const label newPatchi = oldPatchMap[patchi];
138 oldPatchStarts[patchi],
139 oldPatchSizes[patchi],
140 meshMap.oldFaceMap(),
152 patchMapper.hasUnmapped() =
false;
183 const labelList& addedPatchMap = meshMap.addedPatchMap();
186 forAll(addedPatchMap, patchi)
188 const label newPatchi = addedPatchMap[patchi];
193 const polyPatch& oldPatch =
196 if (!bfld(newPatchi))
208 meshMap.addedFaceMap(),
220 patchMapper.hasUnmapped() =
false;
228 fldToAdd.boundaryField()[patchi],
240 labelList addedToNew(oldPatch.size(), -1);
243 label addedFacei = oldPatch.start()+i;
244 label newFacei = meshMap.addedFaceMap()[addedFacei];
245 label patchFacei = newFacei-newPatch.start();
246 if (patchFacei >= 0 && patchFacei < newPatch.size())
248 addedToNew[i] = patchFacei;
254 fldToAdd.boundaryField()[patchi],
270 const bool fullyMapped
277 mesh.objectRegistry::lookupClass<fldType>()
282 meshToAdd.objectRegistry::lookupClass<fldType>()
292 fldType&
fld =
const_cast<fldType&
>(*fieldIter());
295 <<
"MapVolFields : Storing old time for " <<
fld.name() <<
endl;
303 fldType&
fld =
const_cast<fldType&
>(*fieldIter());
307 const fldType& fldToAdd = *fieldsToAdd[
fld.name()];
310 <<
"MapVolFields : mapping " <<
fld.name()
311 <<
" and " << fldToAdd.name() <<
endl;
313 MapVolField<Type>(meshMap,
fld, fldToAdd, fullyMapped);
318 <<
"Not mapping field " <<
fld.name()
319 <<
" since not present on mesh to add" <<
endl;
326void Foam::fvMeshAdder::MapSurfaceField
332 const bool fullyMapped
338 auto& bfld =
fld.boundaryFieldRef();
363 label start = oldPatchStarts[patchi];
367 label newFacei = meshMap.
oldFaceMap()[start + i];
371 intFld[newFacei] = pf[i];
387 label unusedPatchi = 0;
389 forAll(oldPatchMap, patchi)
391 const label newPatchi = oldPatchMap[patchi];
399 label nUsedPatches = unusedPatchi;
404 forAll(oldPatchMap, patchi)
406 const label newPatchi = oldPatchMap[patchi];
410 oldToNew[patchi] = newPatchi;
414 oldToNew[patchi] = unusedPatchi++;
420 bfld.reorder(oldToNew);
426 label newPatchi = nUsedPatches;
427 newPatchi < bfld.size();
431 bfld.set(newPatchi,
nullptr);
438 forAll(oldPatchMap, patchi)
440 const label newPatchi = oldPatchMap[patchi];
448 oldPatchStarts[patchi],
449 oldPatchSizes[patchi],
462 patchMapper.hasUnmapped() =
false;
496 forAll(addedPatchMap, patchi)
498 const label newPatchi = addedPatchMap[patchi];
503 const polyPatch& oldPatch =
504 fldToAdd.
mesh().boundaryMesh()[patchi];
506 if (!bfld(newPatchi))
530 patchMapper.hasUnmapped() =
false;
550 labelList addedToNew(oldPatch.size(), -1);
553 label addedFacei = oldPatch.start()+i;
555 label patchFacei = newFacei-newPatch.start();
556 if (patchFacei >= 0 && patchFacei < newPatch.size())
558 addedToNew[i] = patchFacei;
580 const bool fullyMapped
587 mesh.objectRegistry::lookupClass<fldType>()
592 meshToAdd.objectRegistry::lookupClass<fldType>()
602 fldType&
fld =
const_cast<fldType&
>(*fieldIter());
605 <<
"MapSurfaceFields : Storing old time for " <<
fld.name() <<
endl;
613 fldType&
fld =
const_cast<fldType&
>(*fieldIter());
617 const fldType& fldToAdd = *fieldsToAdd[
fld.name()];
620 <<
"MapSurfaceFields : mapping " <<
fld.name()
621 <<
" and " << fldToAdd.name() <<
endl;
623 MapSurfaceField<Type>(meshMap,
fld, fldToAdd, fullyMapped);
628 <<
"Not mapping field " <<
fld.name()
629 <<
" since not present on mesh to add" <<
endl;
636void Foam::fvMeshAdder::MapDimField
670 mesh.objectRegistry::lookupClass<fldType>(
true)
675 meshToAdd.objectRegistry::lookupClass<fldType>(
true)
680 fldType&
fld =
const_cast<fldType&
>(*fieldIter());
684 const fldType& fldToAdd = *fieldsToAdd[
fld.name()];
687 <<
"MapDimFields : mapping " <<
fld.name()
688 <<
" and " << fldToAdd.name() <<
endl;
690 MapDimField<Type>(meshMap,
fld, fldToAdd);
695 <<
"Not mapping field " <<
fld.name()
696 <<
" since not present on mesh to add" <<
endl;
705void Foam::fvMeshAdder::MapDimField
709 const bool fullyMapped
719 || cellProcAddressing.
size() != flds.size()
740 intFld.
rmap(oldInternalField, cellProcAddressing[0]);
742 for (label meshi = 1; meshi < flds.size(); meshi++)
747 intFld.
rmap(addFld, cellProcAddressing[meshi]);
755void Foam::fvMeshAdder::MapVolField
763 const bool fullyMapped
769 if (flds.size() == 0 || !flds.set(0))
781 const Field<Type> oldInternalField(flds[0].primitiveField());
789 intFld.
rmap(oldInternalField, cellProcAddressing[0]);
791 for (label meshi = 1; meshi < flds.size(); meshi++)
795 const Field<Type>& addFld = flds[meshi].primitiveFieldRef();
796 intFld.
rmap(addFld, cellProcAddressing[meshi]);
805 auto& bfld0 = flds[0].boundaryFieldRef();
820 oldPatchStarts0[patchi],
821 oldPatchSizes0[patchi],
822 faceProcAddressing[0],
823 bfld0[patchi].patch().patch(),
837 bfld0[patchi].autoMap(patchMapper);
840 for (label meshi = 1; meshi < flds.size(); meshi++)
844 const auto& bfld = flds[meshi].boundaryFieldRef();
846 const labelList& patchMap = patchProcAddressing[meshi];
848 forAll(patchMap, oldPatchi)
850 const auto& fvp = bfld[oldPatchi].patch();
851 const label newPatchi = patchMap[oldPatchi];
856 if (newPatchi >= 0 && newPatchi < bfld0.size())
858 const auto& fvp0 = bfld0[newPatchi].patch();
859 labelList addedToNew(bfld[oldPatchi].size(), -1);
862 const label newFacei =
863 faceProcAddressing[meshi][fvp.start()+i];
864 const label patchFacei = newFacei-fvp0.start();
868 && patchFacei < fvp0.size()
871 addedToNew[i] = patchFacei;
875 bfld0[newPatchi].rmap(bfld[oldPatchi], addedToNew);
880 << bfld[oldPatchi].patch().name() <<
" on field "
881 << flds[meshi].name() <<
endl;
890void Foam::fvMeshAdder::MapSurfaceField
899 const bool fullyMapped
905 if (flds.size() == 0 || !flds.set(0))
911 const fvMesh& mesh0 = flds[0].mesh();
919 const Field<Type> oldInternalField(flds[0].primitiveField());
933 const auto&
fld = flds[meshi];
948 const auto& bfld = flds[meshi].boundaryField();
963 const label oldFacei =
964 oldPatchStarts0[oldPatchi]+patchFacei;
965 newFacei = faceProcAddressing[meshi][oldFacei];
966 const label oldOwn = oldFaceOwner0[oldFacei];
967 newOwn = cellProcAddressing[meshi][oldOwn];
978 const label oldFacei =
980 newFacei = faceProcAddressing[meshi][oldFacei];
982 fld.mesh().faceOwner()[oldFacei];
983 newOwn = cellProcAddressing[meshi][oldOwn];
997 && (newOwn == mesh0.
faceOwner()[newFacei])
1000 intFld[newFacei] = pf[patchFacei];
1021 auto& bfld0 = flds[0].boundaryFieldRef();
1028 oldPatchStarts0[patchi],
1029 oldPatchSizes0[patchi],
1030 faceProcAddressing[0],
1031 bfld0[patchi].patch().patch(),
1045 bfld0[patchi].autoMap(patchMapper);
1048 for (label meshi = 1; meshi < flds.size(); meshi++)
1050 if (flds.set(meshi))
1052 const auto& bfld = flds[meshi].boundaryFieldRef();
1054 const labelList& patchMap = patchProcAddressing[meshi];
1056 forAll(patchMap, oldPatchi)
1058 const auto& fvp = bfld[oldPatchi].patch();
1059 const label newPatchi = patchMap[oldPatchi];
1060 if (newPatchi >= 0 && newPatchi < bfld0.size())
1062 const auto& fvp0 = bfld0[newPatchi].patch();
1063 labelList addedToNew(bfld[oldPatchi].size(), -1);
1066 const label newFacei =
1067 faceProcAddressing[meshi][fvp.start()+i];
1068 const label patchFacei = newFacei-fvp0.start();
1072 && patchFacei < fvp0.size()
1075 addedToNew[i] = patchFacei;
1079 bfld0[newPatchi].rmap(bfld[oldPatchi], addedToNew);
1084 << bfld[oldPatchi].patch().name() <<
" on field "
1085 << flds[meshi].name() <<
endl;
1103 const bool fullyMapped
1117 mesh0.objectRegistry::lookupClass<fldType>()
1129 <<
"MapVolFields : Storing old time for " <<
fld->name()
1132 const_cast<fldType&
>(*fld).storeOldTimes();
1138 const word& name0 =
fld->name();
1141 <<
"MapVolFields : mapping " << name0 <<
endl;
1148 auto& meshFld =
meshes[meshi].
1149 objectRegistry::lookupObjectRef<fldType>(name0);
1150 meshToField.
set(meshi, &meshFld);
1159 patchProcAddressing,
1173 const bool fullyMapped
1188 mesh0.objectRegistry::lookupClass<fldType>()
1194 if (!isA<excludeType>(*
fld))
1196 const word& name0 =
fld->name();
1199 <<
"MapDimFields : mapping " << name0 <<
endl;
1206 auto& meshFld =
meshes[meshi].
1207 objectRegistry::lookupObjectRef<fldType>(name0);
1208 meshToField.
set(meshi, &meshFld);
1212 MapDimField(meshToField, cellProcAddressing, fullyMapped);
1217 <<
"MapDimFields : ignoring " <<
fld->name() <<
endl;
1234 const bool fullyMapped
1244 const auto& mesh0 =
meshes[0];
1248 mesh0.objectRegistry::lookupClass<fldType>()
1260 <<
"MapSurfaceFields : Storing old time for " <<
fld->name()
1263 const_cast<fldType&
>(*fld).storeOldTimes();
1269 const word& name0 =
fld->name();
1272 <<
"MapSurfaceFields : Mapping " <<
fld->name() <<
endl;
1279 auto& meshFld =
meshes[meshi].
1280 objectRegistry::lookupObjectRef<fldType>(name0);
1281 meshToField.
set(meshi, &meshFld);
1291 patchProcAddressing,
Info<< nl<< "Wrote faMesh in vtk format: "<< writer.output().name()<< nl;}{ vtk::lineWriter writer(aMesh.points(), aMesh.edges(), fileName(aMesh.mesh().time().globalPath()/"finiteArea-edges"));writer.writeGeometry();writer.beginCellData(4);writer.writeProcIDs();{ Field< scalar > fld(faMeshTools::flattenEdgeField(aMesh.magLe(), true))
Field with dimensions and associated with geometry type GeoMesh which is used to size the field and a...
const Mesh & mesh() const
Return mesh.
A templated direct mapper for the given FieldMapper type.
virtual bool hasUnmapped() const
Any unmapped values?
Generic templated field type.
void rmap(const UList< Type > &mapF, const labelUList &mapAddressing)
1 to 1 reverse-map from the given field
Generic GeometricField class.
const Boundary & boundaryField() const
Return const-reference to the boundary field.
A HashTable similar to std::unordered_map.
bool found(const Key &key) const
Return true if hashed entry is found in table.
void setSize(const label n)
Alias for resize()
const T * set(const label i) const
static autoPtr< Time > New()
Construct (dummy) Time - no functionObjects or libraries.
void size(const label n)
Older name for setAddressableSize.
A list of pointers to objects of type <T>, without allocation/deallocation management of the pointers...
const T * set(const label i) const
label size() const noexcept
The number of elements in the list.
static void MapSurfaceFields(const mapAddedPolyMesh &, const fvMesh &mesh, const fvMesh &meshToAdd, const bool fullyMapped=false)
Map all surfaceFields of Type.
static void MapDimFields(const mapAddedPolyMesh &, const fvMesh &mesh, const fvMesh &meshToAdd)
Map all DimensionedFields of Type.
static void MapVolFields(const mapAddedPolyMesh &, const fvMesh &mesh, const fvMesh &meshToAdd, const bool fullyMapped=false)
Map all volFields of Type.
Mesh data needed to do the Finite Volume discretisation.
const fvBoundaryMesh & boundary() const
Return reference to boundary mesh.
virtual label start() const
Return start label of this patch in the polyMesh face list.
An abstract base class with a fat-interface to all derived classes covering all possible ways in whic...
const fvPatch & patch() const
Return patch.
Class containing mesh-to-mesh mapping information after a mesh addition where we add a mesh ('added m...
const labelList & oldPatchStarts() const
Return list of the old patch start labels.
const labelList & oldCellMap() const
const labelList & addedCellMap() const
const labelList & addedPatchMap() const
From added mesh patch index to new patch index or -1 if.
const labelList & oldPatchMap() const
From old patch index to new patch index or -1 if patch.
const labelList & oldFaceMap() const
const labelList & oldPatchSizes() const
Return list of the old patch sizes.
const labelList & addedFaceMap() const
const polyMesh & mesh() const noexcept
Return the mesh reference.
virtual const labelList & faceOwner() const
Return face owner.
const polyBoundaryMesh & boundaryMesh() const
Return boundary mesh.
label nInternalFaces() const noexcept
Number of internal faces.
label nCells() const noexcept
Number of mesh cells.
A class for handling words, derived from Foam::string.
Foam::PtrList< Foam::fvMesh > meshes(regionNames.size())
#define FatalErrorInFunction
Report an error message using Foam::FatalError.
#define WarningInFunction
Report a warning using Foam::Warning.
#define DebugPout
Report an information message using Foam::Pout.
DirectFieldMapper< fvPatchFieldMapper > directFvPatchFieldMapper
A fvPatchFieldMapper with direct mapping.
Pair< int > faceMap(const label facePi, const face &faceP, const label faceNi, const face &faceN)
List< label > labelList
A List of labels.
Ostream & endl(Ostream &os)
Add newline and flush stream.
errorManipArg< error, int > exit(error &err, const int errNo=1)
multivariateSurfaceInterpolationScheme< scalar >::fieldTable fields
#define forAll(list, i)
Loop across all elements in list.
#define forAllIters(container, iter)
Iterate across all elements in the container object.