From 7240fdd5f86364eeac5ad6f777473ec303de080a Mon Sep 17 00:00:00 2001 From: mattijs Date: Tue, 7 Aug 2012 17:39:24 +0100 Subject: [PATCH] ENH: moveDynamicMesh: added option to dump AMI weights --- .../moveDynamicMesh/moveDynamicMesh.C | 86 ++++++++++++++++++- 1 file changed, 85 insertions(+), 1 deletion(-) diff --git a/applications/utilities/mesh/manipulation/moveDynamicMesh/moveDynamicMesh.C b/applications/utilities/mesh/manipulation/moveDynamicMesh/moveDynamicMesh.C index 47f1dba097..00c97614de 100644 --- a/applications/utilities/mesh/manipulation/moveDynamicMesh/moveDynamicMesh.C +++ b/applications/utilities/mesh/manipulation/moveDynamicMesh/moveDynamicMesh.C @@ -2,7 +2,7 @@ ========= | \\ / F ield | OpenFOAM: The Open Source CFD Toolbox \\ / O peration | - \\ / A nd | Copyright (C) 2011 OpenFOAM Foundation + \\ / A nd | Copyright (C) 2011-2012 OpenFOAM Foundation \\/ M anipulation | ------------------------------------------------------------------------------- License @@ -32,19 +32,98 @@ Description #include "argList.H" #include "Time.H" #include "dynamicFvMesh.H" +#include "vtkSurfaceWriter.H" +#include "cyclicAMIPolyPatch.H" using namespace Foam; // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // + +// Dump patch + weights to vtk file +void writeWeights +( + const scalarField& wghtSum, + const primitivePatch& patch, + const fileName& folder, + const fileName& prefix, + const word& timeName +) +{ + vtkSurfaceWriter writer; + + writer.write + ( + folder, + prefix + "_proc" + Foam::name(Pstream::myProcNo()) + "_" + timeName, + patch.localPoints(), + patch.localFaces(), + "weightsSum", + wghtSum, + false + ); +} + + +void writeWeights(const polyMesh& mesh) +{ + const polyBoundaryMesh& pbm = mesh.boundaryMesh(); + + const word tmName(mesh.time().timeName()); + + forAll(pbm, patchI) + { + if (isA(pbm[patchI])) + { + const cyclicAMIPolyPatch& cpp = + refCast(pbm[patchI]); + + if (cpp.owner()) + { + const AMIPatchToPatchInterpolation& ami = + cpp.AMI(); + writeWeights + ( + ami.tgtWeightsSum(), + cpp.neighbPatch(), + "output", + "tgt", + tmName + ); + writeWeights + ( + ami.srcWeightsSum(), + cpp, + "output", + "src", + tmName + ); + } + } + } +} + + // Main program: int main(int argc, char *argv[]) { + argList::addBoolOption + ( + "checkAMI", + "check AMI weights" + ); # include "setRootCase.H" # include "createTime.H" # include "createDynamicFvMesh.H" + const bool checkAMI = args.optionFound("checkAMI"); + + if (checkAMI) + { + Info<< "Writing VTK files with weights of AMI patches." << nl << endl; + } + while (runTime.loop()) { Info<< "Time = " << runTime.timeName() << endl; @@ -52,6 +131,11 @@ int main(int argc, char *argv[]) mesh.update(); mesh.checkMesh(true); + if (checkAMI) + { + writeWeights(mesh); + } + runTime.write(); Info<< "ExecutionTime = " << runTime.elapsedCpuTime() << " s"