mirror of
https://develop.openfoam.com/Development/openfoam.git
synced 2025-11-28 03:28:01 +00:00
checkMesh, moveDynamicMesh: option -checkAMI writes the reconstructed AMI weights
Patch contributed by Mattijs Janssens
This commit is contained in:
@ -1,3 +1,4 @@
|
|||||||
|
#include "PatchTools.H"
|
||||||
#include "checkGeometry.H"
|
#include "checkGeometry.H"
|
||||||
#include "polyMesh.H"
|
#include "polyMesh.H"
|
||||||
#include "cellSet.H"
|
#include "cellSet.H"
|
||||||
@ -9,7 +10,9 @@
|
|||||||
#include "polyMeshTetDecomposition.H"
|
#include "polyMeshTetDecomposition.H"
|
||||||
#include "surfaceWriter.H"
|
#include "surfaceWriter.H"
|
||||||
#include "checkTools.H"
|
#include "checkTools.H"
|
||||||
|
#include "vtkSurfaceWriter.H"
|
||||||
|
#include "cyclicAMIPolyPatch.H"
|
||||||
|
#include "Time.H"
|
||||||
|
|
||||||
// Find wedge with opposite orientation. Note: does not actually check that
|
// Find wedge with opposite orientation. Note: does not actually check that
|
||||||
// it is opposite, only that it has opposite normal and same axis
|
// it is opposite, only that it has opposite normal and same axis
|
||||||
@ -925,5 +928,134 @@ Foam::label Foam::checkGeometry
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (allGeometry)
|
||||||
|
{
|
||||||
|
const polyBoundaryMesh& pbm = mesh.boundaryMesh();
|
||||||
|
|
||||||
|
const word tmName(mesh.time().timeName());
|
||||||
|
const word procAndTime(Foam::name(Pstream::myProcNo()) + "_" + tmName);
|
||||||
|
|
||||||
|
autoPtr<surfaceWriter> patchWriter;
|
||||||
|
if (!writer.valid())
|
||||||
|
{
|
||||||
|
patchWriter.reset(new vtkSurfaceWriter());
|
||||||
|
}
|
||||||
|
const surfaceWriter& wr = (writer.valid() ? writer() : patchWriter());
|
||||||
|
|
||||||
|
forAll(pbm, patchi)
|
||||||
|
{
|
||||||
|
if (isA<cyclicAMIPolyPatch>(pbm[patchi]))
|
||||||
|
{
|
||||||
|
const cyclicAMIPolyPatch& cpp =
|
||||||
|
refCast<const cyclicAMIPolyPatch>(pbm[patchi]);
|
||||||
|
|
||||||
|
if (cpp.owner())
|
||||||
|
{
|
||||||
|
Info<< "Calculating AMI weights between owner patch: "
|
||||||
|
<< cpp.name() << " and neighbour patch: "
|
||||||
|
<< cpp.neighbPatch().name() << endl;
|
||||||
|
|
||||||
|
const AMIPatchToPatchInterpolation& ami =
|
||||||
|
cpp.AMI();
|
||||||
|
|
||||||
|
{
|
||||||
|
// Collect geometry
|
||||||
|
labelList pointToGlobal;
|
||||||
|
labelList uniqueMeshPointLabels;
|
||||||
|
autoPtr<globalIndex> globalPoints;
|
||||||
|
autoPtr<globalIndex> globalFaces;
|
||||||
|
faceList mergedFaces;
|
||||||
|
pointField mergedPoints;
|
||||||
|
Foam::PatchTools::gatherAndMerge
|
||||||
|
(
|
||||||
|
mesh,
|
||||||
|
cpp.localFaces(),
|
||||||
|
cpp.meshPoints(),
|
||||||
|
cpp.meshPointMap(),
|
||||||
|
|
||||||
|
pointToGlobal,
|
||||||
|
uniqueMeshPointLabels,
|
||||||
|
globalPoints,
|
||||||
|
globalFaces,
|
||||||
|
|
||||||
|
mergedFaces,
|
||||||
|
mergedPoints
|
||||||
|
);
|
||||||
|
// Collect field
|
||||||
|
scalarField mergedWeights;
|
||||||
|
globalFaces().gather
|
||||||
|
(
|
||||||
|
UPstream::worldComm,
|
||||||
|
UPstream::procID(UPstream::worldComm),
|
||||||
|
ami.srcWeightsSum(),
|
||||||
|
mergedWeights
|
||||||
|
);
|
||||||
|
|
||||||
|
if (Pstream::master())
|
||||||
|
{
|
||||||
|
wr.write
|
||||||
|
(
|
||||||
|
"postProcessing",
|
||||||
|
"src_" + tmName,
|
||||||
|
mergedPoints,
|
||||||
|
mergedFaces,
|
||||||
|
"weightsSum",
|
||||||
|
mergedWeights,
|
||||||
|
false
|
||||||
|
);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
{
|
||||||
|
// Collect geometry
|
||||||
|
labelList pointToGlobal;
|
||||||
|
labelList uniqueMeshPointLabels;
|
||||||
|
autoPtr<globalIndex> globalPoints;
|
||||||
|
autoPtr<globalIndex> globalFaces;
|
||||||
|
faceList mergedFaces;
|
||||||
|
pointField mergedPoints;
|
||||||
|
Foam::PatchTools::gatherAndMerge
|
||||||
|
(
|
||||||
|
mesh,
|
||||||
|
cpp.neighbPatch().localFaces(),
|
||||||
|
cpp.neighbPatch().meshPoints(),
|
||||||
|
cpp.neighbPatch().meshPointMap(),
|
||||||
|
|
||||||
|
pointToGlobal,
|
||||||
|
uniqueMeshPointLabels,
|
||||||
|
globalPoints,
|
||||||
|
globalFaces,
|
||||||
|
|
||||||
|
mergedFaces,
|
||||||
|
mergedPoints
|
||||||
|
);
|
||||||
|
// Collect field
|
||||||
|
scalarField mergedWeights;
|
||||||
|
globalFaces().gather
|
||||||
|
(
|
||||||
|
UPstream::worldComm,
|
||||||
|
UPstream::procID(UPstream::worldComm),
|
||||||
|
ami.tgtWeightsSum(),
|
||||||
|
mergedWeights
|
||||||
|
);
|
||||||
|
|
||||||
|
if (Pstream::master())
|
||||||
|
{
|
||||||
|
wr.write
|
||||||
|
(
|
||||||
|
"postProcessing",
|
||||||
|
"tgt_" + tmName,
|
||||||
|
mergedPoints,
|
||||||
|
mergedFaces,
|
||||||
|
"weightsSum",
|
||||||
|
mergedWeights,
|
||||||
|
false
|
||||||
|
);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
return noFailedChecks;
|
return noFailedChecks;
|
||||||
}
|
}
|
||||||
|
|||||||
@ -35,6 +35,7 @@ Description
|
|||||||
#include "pimpleControl.H"
|
#include "pimpleControl.H"
|
||||||
#include "vtkSurfaceWriter.H"
|
#include "vtkSurfaceWriter.H"
|
||||||
#include "cyclicAMIPolyPatch.H"
|
#include "cyclicAMIPolyPatch.H"
|
||||||
|
#include "PatchTools.H"
|
||||||
|
|
||||||
using namespace Foam;
|
using namespace Foam;
|
||||||
|
|
||||||
@ -43,6 +44,7 @@ using namespace Foam;
|
|||||||
// Dump patch + weights to vtk file
|
// Dump patch + weights to vtk file
|
||||||
void writeWeights
|
void writeWeights
|
||||||
(
|
(
|
||||||
|
const polyMesh& mesh,
|
||||||
const scalarField& wghtSum,
|
const scalarField& wghtSum,
|
||||||
const primitivePatch& patch,
|
const primitivePatch& patch,
|
||||||
const fileName& directory,
|
const fileName& directory,
|
||||||
@ -52,17 +54,52 @@ void writeWeights
|
|||||||
{
|
{
|
||||||
vtkSurfaceWriter writer;
|
vtkSurfaceWriter writer;
|
||||||
|
|
||||||
|
// Collect geometry
|
||||||
|
labelList pointToGlobal;
|
||||||
|
labelList uniqueMeshPointLabels;
|
||||||
|
autoPtr<globalIndex> globalPoints;
|
||||||
|
autoPtr<globalIndex> globalFaces;
|
||||||
|
faceList mergedFaces;
|
||||||
|
pointField mergedPoints;
|
||||||
|
Foam::PatchTools::gatherAndMerge
|
||||||
|
(
|
||||||
|
mesh,
|
||||||
|
patch.localFaces(),
|
||||||
|
patch.meshPoints(),
|
||||||
|
patch.meshPointMap(),
|
||||||
|
|
||||||
|
pointToGlobal,
|
||||||
|
uniqueMeshPointLabels,
|
||||||
|
globalPoints,
|
||||||
|
globalFaces,
|
||||||
|
|
||||||
|
mergedFaces,
|
||||||
|
mergedPoints
|
||||||
|
);
|
||||||
|
// Collect field
|
||||||
|
scalarField mergedWeights;
|
||||||
|
globalFaces().gather
|
||||||
|
(
|
||||||
|
UPstream::worldComm,
|
||||||
|
UPstream::procID(UPstream::worldComm),
|
||||||
|
wghtSum,
|
||||||
|
mergedWeights
|
||||||
|
);
|
||||||
|
|
||||||
|
if (Pstream::master())
|
||||||
|
{
|
||||||
writer.write
|
writer.write
|
||||||
(
|
(
|
||||||
directory,
|
directory,
|
||||||
prefix + "_proc" + Foam::name(Pstream::myProcNo()) + "_" + timeName,
|
prefix + "_" + timeName,
|
||||||
patch.localPoints(),
|
mergedPoints,
|
||||||
patch.localFaces(),
|
mergedFaces,
|
||||||
"weightsSum",
|
"weightsSum",
|
||||||
wghtSum,
|
mergedWeights,
|
||||||
false
|
false
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
void writeWeights(const polyMesh& mesh)
|
void writeWeights(const polyMesh& mesh)
|
||||||
@ -89,6 +126,7 @@ void writeWeights(const polyMesh& mesh)
|
|||||||
|
|
||||||
writeWeights
|
writeWeights
|
||||||
(
|
(
|
||||||
|
mesh,
|
||||||
ami.tgtWeightsSum(),
|
ami.tgtWeightsSum(),
|
||||||
cpp.neighbPatch(),
|
cpp.neighbPatch(),
|
||||||
"postProcessing",
|
"postProcessing",
|
||||||
@ -97,6 +135,7 @@ void writeWeights(const polyMesh& mesh)
|
|||||||
);
|
);
|
||||||
writeWeights
|
writeWeights
|
||||||
(
|
(
|
||||||
|
mesh,
|
||||||
ami.srcWeightsSum(),
|
ami.srcWeightsSum(),
|
||||||
cpp,
|
cpp,
|
||||||
"postProcessing",
|
"postProcessing",
|
||||||
|
|||||||
@ -219,6 +219,12 @@ void Foam::PatchTools::gatherAndMerge
|
|||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
|
pointToGlobal = identity(meshPoints.size());
|
||||||
|
uniqueMeshPointLabels = pointToGlobal;
|
||||||
|
|
||||||
|
globalPointsPtr.reset(new globalIndex(meshPoints.size()));
|
||||||
|
globalFacesPtr.reset(new globalIndex(localFaces.size()));
|
||||||
|
|
||||||
mergedFaces = localFaces;
|
mergedFaces = localFaces;
|
||||||
mergedPoints = pointField(mesh.points(), meshPoints);
|
mergedPoints = pointField(mesh.points(), meshPoints);
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user