Added a rudimentary inverse-distance mapper
This commit is contained in:
parent
b10f0e3942
commit
d3f032c73d
4 changed files with 172 additions and 9 deletions
|
@ -3293,11 +3293,11 @@ void dynamicTopoFvMesh::mapFields(const mapPolyMesh& meshMap) const
|
|||
// Set the mapPolyMesh object in the mapper
|
||||
fieldMapper.setMapper(meshMap);
|
||||
|
||||
// Conservatively map scalar/vector volFields
|
||||
fieldMapper.conservativeMapVolFields<scalar>();
|
||||
fieldMapper.conservativeMapVolFields<vector>();
|
||||
|
||||
// Map all the volFields in the objectRegistry
|
||||
MapGeometricFields<scalar,fvPatchField,topoMapper,volMesh>
|
||||
(fieldMapper);
|
||||
MapGeometricFields<vector,fvPatchField,topoMapper,volMesh>
|
||||
(fieldMapper);
|
||||
MapGeometricFields<sphericalTensor,fvPatchField,topoMapper,volMesh>
|
||||
(fieldMapper);
|
||||
MapGeometricFields<symmTensor,fvPatchField,topoMapper,volMesh>
|
||||
|
@ -3305,11 +3305,11 @@ void dynamicTopoFvMesh::mapFields(const mapPolyMesh& meshMap) const
|
|||
MapGeometricFields<tensor,fvPatchField,topoMapper,volMesh>
|
||||
(fieldMapper);
|
||||
|
||||
// Conservatively map scalar/vector surfaceFields
|
||||
fieldMapper.conservativeMapSurfaceFields<scalar>();
|
||||
fieldMapper.conservativeMapSurfaceFields<vector>();
|
||||
|
||||
// Map all the surfaceFields in the objectRegistry
|
||||
MapGeometricFields<scalar,fvsPatchField,topoMapper,surfaceMesh>
|
||||
(fieldMapper);
|
||||
MapGeometricFields<vector,fvsPatchField,topoMapper,surfaceMesh>
|
||||
(fieldMapper);
|
||||
MapGeometricFields<sphericalTensor,fvsPatchField,topoMapper,surfaceMesh>
|
||||
(fieldMapper);
|
||||
MapGeometricFields<symmTensor,fvsPatchField,topoMapper,surfaceMesh>
|
||||
|
|
|
@ -257,6 +257,17 @@ class dynamicTopoFvMesh
|
|||
// Static equivalent for multiThreading
|
||||
static void computeMappingThread(void *argument);
|
||||
|
||||
// Compute parents for inverse-distance weighting
|
||||
void computeParents
|
||||
(
|
||||
const label index,
|
||||
const labelList& mapCandidates,
|
||||
const labelListList& oldNeighbourList,
|
||||
const vectorField& oldCentres,
|
||||
const label dimension,
|
||||
labelList& parents
|
||||
) const;
|
||||
|
||||
// Routine to invoke threaded mapping
|
||||
void threadedMapping(scalar matchTol, bool skipMapping);
|
||||
|
||||
|
|
|
@ -72,6 +72,19 @@ void dynamicTopoFvMesh::computeMapping
|
|||
cellWeights_[cellI].setSize(mo.size(), (1.0/(mo.size() + VSMALL)));
|
||||
cellCentres_[cellI].setSize(mo.size(), vector::zero);
|
||||
}
|
||||
else
|
||||
{
|
||||
// Compute master objects for inverse-distance weighting
|
||||
computeParents
|
||||
(
|
||||
cIndex,
|
||||
cellParents_[cIndex],
|
||||
polyMesh::cellCells(),
|
||||
polyMesh::cellCentres(),
|
||||
3,
|
||||
cellsFromCells_[cellI].masterObjects()
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
// Compute face mapping
|
||||
|
@ -98,6 +111,19 @@ void dynamicTopoFvMesh::computeMapping
|
|||
faceWeights_[faceI].setSize(mo.size(), (1.0/(mo.size() + VSMALL)));
|
||||
faceCentres_[faceI].setSize(mo.size(), vector::zero);
|
||||
}
|
||||
else
|
||||
{
|
||||
// Compute master objects for inverse-distance weighting
|
||||
computeParents
|
||||
(
|
||||
fIndex,
|
||||
faceParents_[fIndex],
|
||||
boundaryMesh()[patchIndex].faceFaces(),
|
||||
boundaryMesh()[patchIndex].faceCentres(),
|
||||
2,
|
||||
facesFromFaces_[faceI].masterObjects()
|
||||
);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -236,12 +262,14 @@ void dynamicTopoFvMesh::threadedMapping
|
|||
// force calculation of demand-driven data.
|
||||
polyMesh::cells();
|
||||
primitiveMesh::cellCells();
|
||||
primitiveMesh::cellCentres();
|
||||
|
||||
const polyBoundaryMesh& boundary = boundaryMesh();
|
||||
|
||||
forAll(boundary, patchI)
|
||||
{
|
||||
boundary[patchI].faceFaces();
|
||||
boundary[patchI].faceCentres();
|
||||
}
|
||||
|
||||
// Execute threads in linear sequence
|
||||
|
@ -249,6 +277,130 @@ void dynamicTopoFvMesh::threadedMapping
|
|||
}
|
||||
|
||||
|
||||
// Compute parents for inverse-distance weighting
|
||||
void dynamicTopoFvMesh::computeParents
|
||||
(
|
||||
const label index,
|
||||
const labelList& mapCandidates,
|
||||
const labelListList& oldNeighbourList,
|
||||
const vectorField& oldCentres,
|
||||
const label dimension,
|
||||
labelList& parents
|
||||
) const
|
||||
{
|
||||
if (parents.size())
|
||||
{
|
||||
FatalErrorIn
|
||||
(
|
||||
"\n\n"
|
||||
"void dynamicTopoFvMesh::computeParents\n"
|
||||
"(\n"
|
||||
" const label index,\n"
|
||||
" const labelList& mapCandidates,\n"
|
||||
" const labelListList& oldNeighbourList,\n"
|
||||
" const vectorField& oldCentres,\n"
|
||||
" const label dimension,\n"
|
||||
" labelList& parents\n"
|
||||
") const\n"
|
||||
)
|
||||
<< " Addressing has already been calculated." << nl
|
||||
<< " Index: " << index << nl
|
||||
<< " Type: " << (dimension == 2 ? "Face" : "Cell") << nl
|
||||
<< " mapCandidates: " << mapCandidates << nl
|
||||
<< " Parents: " << parents << nl
|
||||
<< abort(FatalError);
|
||||
}
|
||||
|
||||
// Figure out the patch offset and centre
|
||||
label offset = -1;
|
||||
vector centre = vector::zero;
|
||||
|
||||
if (dimension == 2)
|
||||
{
|
||||
offset = boundaryMesh()[whichPatch(index)].start();
|
||||
|
||||
meshOps::faceCentre(faces_[index], oldPoints_, centre);
|
||||
}
|
||||
else
|
||||
if (dimension == 3)
|
||||
{
|
||||
offset = 0;
|
||||
scalar dummyVol = 0.0;
|
||||
|
||||
meshOps::cellCentreAndVolume
|
||||
(
|
||||
index,
|
||||
oldPoints_,
|
||||
faces_,
|
||||
cells_,
|
||||
owner_,
|
||||
centre,
|
||||
dummyVol
|
||||
);
|
||||
}
|
||||
|
||||
// Maintain a check-list
|
||||
labelHashSet checked;
|
||||
|
||||
// Insert candidates first
|
||||
forAll(mapCandidates, indexI)
|
||||
{
|
||||
checked.insert(mapCandidates[indexI] - offset);
|
||||
}
|
||||
|
||||
// Loop for three outward levels from candidates
|
||||
for (label i = 0; i < 3; i++)
|
||||
{
|
||||
// Fetch the set of candidates
|
||||
const labelList checkList = checked.toc();
|
||||
|
||||
forAll(checkList, indexI)
|
||||
{
|
||||
const labelList& oldNei = oldNeighbourList[checkList[indexI]];
|
||||
|
||||
forAll(oldNei, entityI)
|
||||
{
|
||||
if (!checked.found(oldNei[entityI]))
|
||||
{
|
||||
checked.insert(oldNei[entityI]);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// Loop through accumulated candidates and fetch the nearest one.
|
||||
scalar minDist = GREAT;
|
||||
label minLocation = -1;
|
||||
|
||||
const labelList checkList = checked.toc();
|
||||
|
||||
forAll(checkList, indexI)
|
||||
{
|
||||
scalar dist = magSqr(oldCentres[checkList[indexI]] - centre);
|
||||
|
||||
if (dist < minDist)
|
||||
{
|
||||
minDist = dist;
|
||||
minLocation = checkList[indexI];
|
||||
}
|
||||
}
|
||||
|
||||
// Set the final list
|
||||
const labelList& neiList = oldNeighbourList[minLocation];
|
||||
|
||||
parents.setSize(neiList.size() + 1, -1);
|
||||
|
||||
// Fill indices
|
||||
forAll(neiList, indexI)
|
||||
{
|
||||
parents[indexI] = neiList[indexI] + offset;
|
||||
}
|
||||
|
||||
// Set final index
|
||||
parents[neiList.size()] = minLocation + offset;
|
||||
}
|
||||
|
||||
|
||||
// Set fill-in mapping information for a particular cell
|
||||
void dynamicTopoFvMesh::setCellMapping
|
||||
(
|
||||
|
|
|
@ -135,7 +135,7 @@ dynamicTopoFvMesh
|
|||
|
||||
//- Skip mapping step. Useful while using
|
||||
//- this tool as a pre-processor
|
||||
skipMapping true;
|
||||
// skipMapping true;
|
||||
|
||||
// Toggle edgeRefinement on/off
|
||||
edgeRefinement yes;
|
||||
|
|
Reference in a new issue