BUG: vtkCloud suppresses output for empty clouds (closes #866)

- the original intention was to avoid vtp output when the clouds are
  empty anyhow. However, it is useful for post-processing to have
  clouds with zero parcels (eg, before the start of injection).

  Pruning of empty clouds is now an option in the vtkCloud dictionary
  controls, with the default being false (no pruning). This represents
  a non-breaking change in behaviour since it generates more output
  than previously.

  Example,
  {
      type    vtkCloud;
      //- Suppress writing of empty clouds (default: false)
      prune   true;
  }
This commit is contained in:
Mark Olesen
2018-07-11 07:53:51 +02:00
parent baba0069d4
commit 1b76ff6001
6 changed files with 62 additions and 5 deletions

View File

@ -139,7 +139,7 @@ bool Foam::functionObjects::vtkCloud::writeCloud
label nTotParcels = pointsPtr->size();
reduce(nTotParcels, sumOp<label>());
if (!nTotParcels)
if (pruneEmpty_ && !nTotParcels)
{
return false;
}
@ -331,6 +331,7 @@ Foam::functionObjects::vtkCloud::vtkCloud
writeOpts_(vtk::formatType::INLINE_BASE64),
printf_(),
useVerts_(false),
pruneEmpty_(false),
selectClouds_(),
selectFields_(),
dirName_("VTK"),
@ -396,6 +397,7 @@ bool Foam::functionObjects::vtkCloud::read(const dictionary& dict)
// useTimeName_ = dict.lookupOrDefault<bool>("useTimeName", false);
useVerts_ = dict.lookupOrDefault<bool>("cellData", false);
pruneEmpty_ = dict.lookupOrDefault<bool>("prune", false);
//

View File

@ -59,6 +59,7 @@ Usage
directory | The output directory name | no | VTK
width | Padding width for file name | no | 8
format | ascii or binary format | no | binary
prune | suppress writing of empty clouds | no | false
writePrecision | write precision in ascii | no | same as IOstream
\endtable
@ -125,6 +126,9 @@ class vtkCloud
//- Write lagrangian as cell data (verts) instead of point data
bool useVerts_;
//- Suppress writing of empty clouds
bool pruneEmpty_;
//- Requested names of clouds to process
wordRes selectClouds_;

View File

@ -0,0 +1,19 @@
#!/bin/sh
cd ${0%/*} || exit 1 # Run from this directory
. $WM_PROJECT_DIR/bin/tools/RunFunctions # Tutorial run functions
restore0Dir
runApplication blockMesh
runApplication topoSet
runApplication createBaffles -overwrite
runApplication decomposePar
runParallel $(getApplication)
runApplication reconstructPar
#------------------------------------------------------------------------------

View File

@ -51,5 +51,9 @@ maxCo 1.0;
maxDeltaT 1;
functions
{
#include "vtkCloud"
}
// ************************************************************************* //

View File

@ -27,9 +27,6 @@ preserveFaceZones
coeffs
{
n (2 2 1);
//delta 0.001; // default=0.001
//order xyz; // default=xzy
dataFile "";
}
// ************************************************************************* //

View File

@ -0,0 +1,31 @@
// -*- C++ -*-
cloudWrite
{
type vtkCloud;
libs ("liblagrangianFunctionObjects.so");
log true;
writeControl writeTime;
// cloud reactingCloud1;
clouds ( ".*" );
// Fields to output (words or regex)
fields ( U T d "Y.*" );
//- Output format (ascii | binary) - default = binary
// format binary;
// format ascii;
// writePrecision 12;
//- Suppress writing of empty clouds - default = false
// prune true;
//- Output directory name - default = "VTK"
// directory "VTK";
}
// ************************************************************************* //