35 namespace cellsToCellss
43 const Foam::scalar Foam::cellsToCellss::intersection::tolerance_ = 1
e-6;
48 bool Foam::cellsToCellss::intersection::intersect
50 const polyMesh& srcMesh,
51 const polyMesh& tgtMesh,
57 tetOverlapVolume().cellCellOverlapMinDecomp
63 treeBoundBox(tgtMesh.points(), tgtMesh.cellPoints()[tgtCelli]),
64 tolerance_*srcMesh.cellVolumes()[srcCelli]
69 Foam::scalar Foam::cellsToCellss::intersection::interVol
71 const polyMesh& srcMesh,
72 const polyMesh& tgtMesh,
78 tetOverlapVolume().cellCellOverlapVolumeMinDecomp
84 treeBoundBox(tgtMesh.points(), tgtMesh.cellPoints()[tgtCelli])
89 bool Foam::cellsToCellss::intersection::findInitialSeeds
91 const polyMesh& srcMesh,
92 const polyMesh& tgtMesh,
95 const label startSeedI,
100 const cellList& srcCells = srcMesh.cells();
101 const faceList& srcFaces = srcMesh.faces();
106 for (
label i = startSeedI; i < srcCellIDs.size(); i++)
108 const label srcI = srcCellIDs[i];
114 tgtSearchEngine.cellTree().findBox
116 treeBoundBox(srcCells[srcI].bb(srcPts, srcFaces))
122 const label tgtI = tgtIDs[j];
124 if (intersect(srcMesh, tgtMesh, srcI, tgtI))
137 Pout<<
"could not find starting seed" <<
endl;
144 Foam::scalar Foam::cellsToCellss::intersection::calculateAddressing
146 const polyMesh& srcMesh,
147 const polyMesh& tgtMesh,
152 const label srcSeedI,
153 const label tgtSeedI,
161 label srcCelli = srcSeedI;
162 label tgtCelli = tgtSeedI;
171 DynamicList<label> nbrTgtCells(10);
174 DynamicList<label> visitedTgtCells(10);
177 labelList seedCells(srcMesh.nCells(), -1);
178 seedCells[srcCelli] = tgtCelli;
185 visitedTgtCells.clear();
188 nbrTgtCells.append(tgtCelli);
189 appendNbrCells(tgtCelli, tgtMesh, visitedTgtCells, nbrTgtCells);
193 tgtCelli = nbrTgtCells.remove();
194 visitedTgtCells.append(tgtCelli);
196 scalar vol = interVol(srcMesh, tgtMesh, srcCelli, tgtCelli);
199 if (vol/srcVol[srcCelli] > tolerance_)
202 srcToTgtAddr[srcCelli].append(tgtCelli);
203 srcToTgtWght[srcCelli].append(vol);
205 tgtToSrcAddr[tgtCelli].append(srcCelli);
206 tgtToSrcWght[tgtCelli].append(vol);
208 appendNbrCells(tgtCelli, tgtMesh, visitedTgtCells, nbrTgtCells);
214 while (!nbrTgtCells.empty());
216 mapFlag[srcCelli] =
false;
232 while (srcCelli != -1);
235 forAll(srcToTgtCellAddr, i)
237 srcToTgtCellAddr[i].transfer(srcToTgtAddr[i]);
238 srcToTgtCellWght[i].transfer(srcToTgtWght[i]);
241 forAll(tgtToSrcCellAddr, i)
243 tgtToSrcCellAddr[i].transfer(tgtToSrcAddr[i]);
244 tgtToSrcCellWght[i].transfer(tgtToSrcWght[i]);
251 void Foam::cellsToCellss::intersection::setNextCells
253 const polyMesh& srcMesh,
254 const polyMesh& tgtMesh,
260 const DynamicList<label>& visitedCells,
264 const labelList& srcNbrCells = srcMesh.cellCells()[srcCelli];
268 bool valuesSet =
false;
271 label cellS = srcNbrCells[i];
273 if (mapFlag[cellS] && seedCells[cellS] == -1)
277 label cellT = visitedCells[j];
279 if (intersect(srcMesh, tgtMesh, cellS, cellT))
281 seedCells[cellS] = cellT;
302 bool foundNextSeed =
false;
303 for (
label i = startSeedI; i < srcCellIDs.size(); i++)
305 label cellS = srcCellIDs[i];
312 foundNextSeed =
true;
315 if (seedCells[cellS] != -1)
318 tgtCelli = seedCells[cellS];
328 Pout<<
"Advancing front stalled: searching for new "
329 <<
"target cell" <<
endl;
365 initialise(srcMesh, tgtMesh);
368 const labelList srcCellIDs(maskCells(srcMesh, tgtMesh));
377 label startSeedI = 0;
424 forAll(srcToTgtWght, srcCelli)
428 forAll(srcToTgtWght[srcCelli], i)
430 srcToTgtWght[srcCelli][i] /= v;
#define forAll(list, i)
Loop across all elements in list.
Macros for easy insertion into run-time selection tables.
void clear()
Clear the list, i.e. set size to zero.
A List with indirect addressing.
Class to calculate interpolative addressing and weights between the cells of two overlapping meshes.
Intersection-based cells-to-cells interpolation class. Volume conservative.
virtual scalar calculate(const polyMesh &srcMesh, const polyMesh &tgtMesh)
Calculate the addressing and weights.
virtual ~intersection()
Destructor.
virtual void normalise(const polyMesh &mesh, labelListList &localOtherCells, scalarListList &weights) const
Normalise the weights for a given mesh.
intersection()
Construct null.
static const meshSearch & New(const polyMesh &mesh, const pointInCellShapes=pointInCellShapes::tets)
Lookup or construct from mesh and cell decomposition option.
Motion of the mesh specified as a list of pointMeshMovers.
Mesh consisting of general polyhedral cells.
Calculates the overlap volume of two cells using tetrahedral decomposition.
scalar cellVolumeMinDecomp(const primitiveMesh &mesh, const label celli) const
Calculates the cell volume.
A class for handling words, derived from string.
defineTypeNameAndDebug(intersection, 0)
addToRunTimeSelectionTable(cellsToCells, intersection, word)
const dimensionedScalar e
Elementary charge.
List< scalarList > scalarListList
List< label > labelList
A List of labels.
intWM_LABEL_SIZE_t label
A label is an int32_t or int64_t as specified by the pre-processor macro WM_LABEL_SIZE.
List< cell > cellList
list of cells
Ostream & endl(Ostream &os)
Add newline and flush stream.
vectorField pointField
pointField is a vectorField.
List< bool > boolList
Bool container classes.
Field< scalar > scalarField
Specialisation of Field<T> for scalar.
List< labelList > labelListList
A List of labelList.
prefixOSstream Pout(cout, "Pout")