reconstructParMesh, fvMeshDistribute: Removed all geometric point merging
Geometric point merging has an inherent chance of failure that occurs
when a mesh contains valid distinct points that are closer together than
the supplied tolerance. It is beneficial to avoid such merging whenever
possible.
reconstructParMesh does not need explicit point merging any more. Points
may be duplicated temporarily when processor meshes are combined which
share points and edges but not faces. Ultimately, however,
reconstructParMesh reconstructs the entire mesh so everything eventually
gets face-connected and all point duplications get resolved.
fvMeshDistribute requires point-merging, as the entire mesh is not
constructed. However, since 5d4c8f5d, this process has been purely
topological and has not relied on any of the geometric merging processes
triggered by utilised code.
As such, all geometric point merging operations and tolerances have been
removed from these two implementations, as well as in lower level code
in faceCoupleInfo and polyMeshAdder. faceCoupleInfo has also had support
for face and edge splits removed as this was not being used. This change
will have improved the robustness of both reconstruction and
redistributuon and has greatly reduced the total amount of code
involved.
The only geometric tolerance-based matching still being performed by
either of these processes is as a result of coupled patch ordering in
fvMeshDistribute. It is possible that this is not necessary either
(though at present coupled patch ordering is certainly needed
elsewhere). This warrants further investigation.
This commit is contained in:
@ -2,7 +2,7 @@
|
||||
========= |
|
||||
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
|
||||
\\ / O peration | Website: https://openfoam.org
|
||||
\\ / A nd | Copyright (C) 2011-2019 OpenFOAM Foundation
|
||||
\\ / A nd | Copyright (C) 2011-2021 OpenFOAM Foundation
|
||||
\\/ M anipulation |
|
||||
-------------------------------------------------------------------------------
|
||||
License
|
||||
@ -58,65 +58,6 @@ Description
|
||||
|
||||
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
|
||||
|
||||
// Tolerance (as fraction of the bounding box). Needs to be fairly lax since
|
||||
// usually meshes get written with limited precision (6 digits)
|
||||
static const scalar defaultMergeTol = 1e-6;
|
||||
|
||||
|
||||
// Get merging distance when matching face centres
|
||||
scalar getMergeDistance
|
||||
(
|
||||
const argList& args,
|
||||
const Time& runTime,
|
||||
const boundBox& bb
|
||||
)
|
||||
{
|
||||
scalar mergeTol = defaultMergeTol;
|
||||
args.optionReadIfPresent("mergeTol", mergeTol);
|
||||
|
||||
scalar writeTol =
|
||||
Foam::pow(scalar(10.0), -scalar(IOstream::defaultPrecision()));
|
||||
|
||||
Info<< "Merge tolerance : " << mergeTol << nl
|
||||
<< "Write tolerance : " << writeTol << endl;
|
||||
|
||||
if (runTime.writeFormat() == IOstream::ASCII && mergeTol < writeTol)
|
||||
{
|
||||
FatalErrorInFunction
|
||||
<< "Your current settings specify ASCII writing with "
|
||||
<< IOstream::defaultPrecision() << " digits precision." << endl
|
||||
<< "Your merging tolerance (" << mergeTol << ") is finer than this."
|
||||
<< endl
|
||||
<< "Please change your writeFormat to binary"
|
||||
<< " or increase the writePrecision" << endl
|
||||
<< "or adjust the merge tolerance (-mergeTol)."
|
||||
<< exit(FatalError);
|
||||
}
|
||||
|
||||
scalar mergeDist = mergeTol * bb.mag();
|
||||
|
||||
Info<< "Overall meshes bounding box : " << bb << nl
|
||||
<< "Relative tolerance : " << mergeTol << nl
|
||||
<< "Absolute matching distance : " << mergeDist << nl
|
||||
<< endl;
|
||||
|
||||
return mergeDist;
|
||||
}
|
||||
|
||||
|
||||
//void printMeshData(Ostream& os, const polyMesh& mesh)
|
||||
//{
|
||||
// os << "Number of points: " << mesh.points().size() << nl
|
||||
// << " faces: " << mesh.faces().size() << nl
|
||||
// << " internal faces: " << mesh.faceNeighbour().size() << nl
|
||||
// << " cells: " << mesh.cells().size() << nl
|
||||
// << " boundary patches: " << mesh.boundaryMesh().size() << nl
|
||||
// << " point zones: " << mesh.pointZones().size() << nl
|
||||
// << " face zones: " << mesh.faceZones().size() << nl
|
||||
// << " cell zones: " << mesh.cellZones().size() << nl;
|
||||
//}
|
||||
|
||||
|
||||
void printMeshData(const polyMesh& mesh)
|
||||
{
|
||||
// Collect all data on master
|
||||
@ -365,72 +306,11 @@ void readFields
|
||||
}
|
||||
|
||||
|
||||
// Debugging: compare two fields.
|
||||
void compareFields
|
||||
(
|
||||
const scalar tolDim,
|
||||
const volVectorField& a,
|
||||
const volVectorField& b
|
||||
)
|
||||
{
|
||||
forAll(a, celli)
|
||||
{
|
||||
if (mag(b[celli] - a[celli]) > tolDim)
|
||||
{
|
||||
FatalErrorInFunction
|
||||
<< "Did not map volVectorField correctly:" << nl
|
||||
<< "cell:" << celli
|
||||
<< " transfer b:" << b[celli]
|
||||
<< " real cc:" << a[celli]
|
||||
<< abort(FatalError);
|
||||
}
|
||||
}
|
||||
forAll(a.boundaryField(), patchi)
|
||||
{
|
||||
// We have real mesh cellcentre and
|
||||
// mapped original cell centre.
|
||||
|
||||
const fvPatchVectorField& aBoundary =
|
||||
a.boundaryField()[patchi];
|
||||
|
||||
const fvPatchVectorField& bBoundary =
|
||||
b.boundaryField()[patchi];
|
||||
|
||||
if (!bBoundary.coupled())
|
||||
{
|
||||
forAll(aBoundary, i)
|
||||
{
|
||||
if (mag(aBoundary[i] - bBoundary[i]) > tolDim)
|
||||
{
|
||||
WarningInFunction
|
||||
<< "Did not map volVectorField correctly:"
|
||||
<< endl
|
||||
<< "patch:" << patchi << " patchFace:" << i
|
||||
<< " cc:" << endl
|
||||
<< " real :" << aBoundary[i] << endl
|
||||
<< " mapped :" << bBoundary[i] << endl
|
||||
<< "This might be just a precision entry"
|
||||
<< " on writing the mesh." << endl;
|
||||
//<< abort(FatalError);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
int main(int argc, char *argv[])
|
||||
{
|
||||
#include "addRegionOption.H"
|
||||
#include "addOverwriteOption.H"
|
||||
argList::addOption
|
||||
(
|
||||
"mergeTol",
|
||||
"scalar",
|
||||
"specify the merge distance relative to the bounding box size "
|
||||
"(default 1e-6)"
|
||||
);
|
||||
|
||||
// Include explicit constant options, have zero from time range
|
||||
timeSelector::addOptions();
|
||||
|
||||
@ -781,16 +661,8 @@ int main(int argc, char *argv[])
|
||||
// Used to test correctness of mapping
|
||||
// volVectorField mapCc("mapCc", 1*mesh.C());
|
||||
|
||||
// Global matching tolerance
|
||||
const scalar tolDim = getMergeDistance
|
||||
(
|
||||
args,
|
||||
runTime,
|
||||
mesh.bounds()
|
||||
);
|
||||
|
||||
// Mesh distribution engine
|
||||
fvMeshDistribute distributor(mesh, tolDim);
|
||||
fvMeshDistribute distributor(mesh);
|
||||
|
||||
// Pout<< "Wanted distribution:"
|
||||
// << distributor.countCells(finalDecomp) << nl << endl;
|
||||
@ -819,9 +691,6 @@ int main(int argc, char *argv[])
|
||||
mesh.write();
|
||||
|
||||
|
||||
// Debugging: test mapped cellcentre field.
|
||||
// compareFields(tolDim, mesh.C(), mapCc);
|
||||
|
||||
// Print nice message
|
||||
// ~~~~~~~~~~~~~~~~~~
|
||||
|
||||
|
||||
Reference in New Issue
Block a user