From ef6eb777129bc6859e118d64a5bc8b8a17dfcf68 Mon Sep 17 00:00:00 2001 From: Mark Olesen Date: Mon, 10 Dec 2018 11:26:11 +0100 Subject: [PATCH] ENH: use vtp output for AMIWeights function object - allows inclusion of the cyclicACMIPolyPatch mask in the same file --- .../field/AMIWeights/AMIWeights.C | 54 +++++++++---------- .../RAS/propeller/system/AMIWeights | 1 + 2 files changed, 28 insertions(+), 27 deletions(-) diff --git a/src/functionObjects/field/AMIWeights/AMIWeights.C b/src/functionObjects/field/AMIWeights/AMIWeights.C index 4f0952442c..8f85c1944e 100644 --- a/src/functionObjects/field/AMIWeights/AMIWeights.C +++ b/src/functionObjects/field/AMIWeights/AMIWeights.C @@ -25,7 +25,7 @@ License #include "AMIWeights.H" #include "fvMesh.H" -#include "vtkSurfaceWriter.H" +#include "foamVtkSurfaceWriter.H" #include "PatchTools.H" #include "cyclicACMIPolyPatch.H" #include "addToRunTimeSelectionTable.H" @@ -212,8 +212,6 @@ void Foam::functionObjects::AMIWeights::writeWeightField const word& side ) const { - vtkSurfaceWriter writer; - // Collect geometry labelList pointToGlobal; labelList uniqueMeshPointLabels; @@ -251,23 +249,13 @@ void Foam::functionObjects::AMIWeights::writeWeightField mergedWeights ); - if (Pstream::master()) - { - writer.write - ( - baseTimeDir(), - cpp.name() + "_" + side, - meshedSurfRef(mergedPoints, mergedFaces), - "weightsSum", - mergedWeights, - false - ); - } + const bool isACMI = isA(cpp); - if (isA(cpp)) + scalarField mergedMask; + if (isACMI) { const cyclicACMIPolyPatch& pp = refCast(cpp); - scalarField mergedMask; + globalFaces().gather ( UPstream::worldComm, @@ -279,18 +267,30 @@ void Foam::functionObjects::AMIWeights::writeWeightField pp.mask(), mergedMask ); + } - if (Pstream::master()) + if (Pstream::master()) + { + instant inst(mesh_.time().value(), mesh_.time().timeName()); + + vtk::surfaceWriter writer + ( + mergedPoints, + mergedFaces, + (baseTimeDir()/cpp.name() + "_" + side), + false // serial: master-only + ); + + writer.setTime(inst); + writer.writeTimeValue(); + writer.writeGeometry(); + + writer.beginCellData(1 + (isACMI ? 1 : 0)); + writer.write("weightsSum", mergedWeights); + + if (isACMI) { - writer.write - ( - baseTimeDir(), - cpp.name() + "_" + side, - meshedSurfRef(mergedPoints, mergedFaces), - "mask", - mergedMask, - false - ); + writer.write("mask", mergedMask); } } } diff --git a/tutorials/incompressible/pimpleFoam/RAS/propeller/system/AMIWeights b/tutorials/incompressible/pimpleFoam/RAS/propeller/system/AMIWeights index 10a3a902c0..dc9e5ec128 100644 --- a/tutorials/incompressible/pimpleFoam/RAS/propeller/system/AMIWeights +++ b/tutorials/incompressible/pimpleFoam/RAS/propeller/system/AMIWeights @@ -12,6 +12,7 @@ AMIWeights libs ("libfieldFunctionObjects.so"); writeControl writeTime; writeFields no; + // writeFields yes; } // ************************************************************************* //