Skip to content
Snippets Groups Projects

Compare revisions

Changes are shown as if the source revision was being merged into the target revision. Learn more about comparing revisions.

Source

Select target project
No results found

Target

Select target project
No results found
Show changes
Commits on Source (6)
Showing
with 547 additions and 124 deletions
......@@ -84,8 +84,8 @@ The cmake configuration possibilities are functional, but still very
## Authors
- Mark Olesen | <Mark.Olesen@esi-group.com> | (ESI-OpenCFD)
- Simone Bna | <Simone.Bna@cineca.it> | (CINECA)
- Mark Olesen | <mark.olesen@esi-group.com> | (ESI-OpenCFD)
- Simone Bna | <simone.bna@cineca.it> | (CINECA)
## License
......
include(${PARAVIEW_USE_FILE})
include_directories(
$ENV{WM_PROJECT_DIR}/src/OpenFOAM/lnInclude
$ENV{WM_PROJECT_DIR}/src/OSspecific/$ENV{WM_OSTYPE}/lnInclude
$ENV{WM_PROJECT_DIR}/src/finiteArea/lnInclude
$ENV{WM_PROJECT_DIR}/src/finiteVolume/lnInclude
$ENV{WM_PROJECT_DIR}/src/fileFormats/lnInclude
$ENV{WM_PROJECT_DIR}/src/conversion/lnInclude
$ENV{WM_PROJECT_DIR}/src/meshTools/lnInclude
$ENV{WM_PROJECT_DIR}/src/lagrangian/basic/lnInclude
$ENV{WM_PROJECT_DIR}/src/overset/lnInclude
${CMAKE_CURRENT_SOURCE_DIR}
${CMAKE_CURRENT_BINARY_DIR}
)
link_directories(
$ENV{FOAM_LIBBIN}
$ENV{FOAM_LIBBIN}/dummy
)
add_definitions(
-DWM_$ENV{WM_PRECISION_OPTION} -DWM_LABEL_SIZE=$ENV{WM_LABEL_SIZE}
-DNoRepository
)
set(CMAKE_BUILD_TYPE Release)
#------------------------------------------------------------------------------
set(CMAKE_CXX_FLAGS_DEBUG
"-g -O0 -std=c++11 -Wall -Wextra -Wno-unused-parameter -Wnon-virtual-dtor -Wno-overloaded-virtual"
)
set(CMAKE_CXX_FLAGS_RELEASE
"-O3 -std=c++11 -Wall -Wextra -Wno-unused-parameter -Wnon-virtual-dtor -Wno-overloaded-virtual"
)
include(${PARAVIEW_USE_FILE})
# Some characteristics
# ----------------------------------------------------------------------
# Test some characteristics
set(test_file ${CMAKE_CURRENT_BINARY_DIR}/check_initialize.cxx)
file(WRITE ${test_file}
"#include <vtkCPProcessor.h>\n"
......@@ -55,6 +25,29 @@ else()
message(WARNING "==== CAUTION: ParaView Catalyst without chdir capability ====")
endif()
# ----------------------------------------------------------------------
include_directories(
${LIB_SRC}/OpenFOAM/lnInclude
${LIB_SRC}/OSspecific/${WM_OSTYPE}/lnInclude
${LIB_SRC}/finiteArea/lnInclude
${LIB_SRC}/finiteVolume/lnInclude
${LIB_SRC}/fileFormats/lnInclude
${LIB_SRC}/conversion/lnInclude
${LIB_SRC}/meshTools/lnInclude
${LIB_SRC}/lagrangian/basic/lnInclude
${LIB_SRC}/overset/lnInclude
${CMAKE_CURRENT_SOURCE_DIR}
${CMAKE_CURRENT_BINARY_DIR}
)
link_directories(
$ENV{FOAM_LIBBIN}
$ENV{FOAM_LIBBIN}/dummy
)
set(CMAKE_BUILD_TYPE Release)
set(LIBRARY_OUTPUT_PATH ${CMAKE_LIBRARY_OUTPUT_DIRECTORY}
CACHE INTERNAL
......
#------------------------------------------------------------------------------
# Standard definitions when using OpenFOAM
if (NOT EXISTS "$ENV{WM_PROJECT_DIR}")
message(FATAL_ERROR "WM_PROJECT_DIR not set - no OpenFOAM??")
endif()
# WM_OSTYPE env variable is optional (only POSIX anyhow)
if (EXISTS "$ENV{WM_OSTYPE}")
set(WM_OSTYPE "$ENV{WM_OSTYPE}")
else()
set(WM_OSTYPE "POSIX")
endif()
# Convenience name, as per wmake internals
set(LIB_SRC "$ENV{WM_PROJECT_DIR}/src")
# Needed for internal label-size, scalar-size, templates
add_definitions(
-DWM_$ENV{WM_PRECISION_OPTION}
-DWM_LABEL_SIZE=$ENV{WM_LABEL_SIZE}
-DNoRepository
)
set(CMAKE_CXX_FLAGS_DEBUG
"-g -O0 -std=c++11 -Wall -Wextra -Wno-unused-parameter -Wnon-virtual-dtor -Wno-overloaded-virtual"
)
set(CMAKE_CXX_FLAGS_RELEASE
"-O3 -std=c++11 -Wall -Wextra -Wno-unused-parameter -Wnon-virtual-dtor -Wno-overloaded-virtual"
)
#-----------------------------------------------------------------------------
......@@ -14,13 +14,11 @@ project(catalyst)
cmake_policy(SET CMP0002 OLD)
include(CMakeLists-OpenFOAM.txt)
#------------------------------------------------------------------------------
# Simple sanity checks
if (NOT EXISTS "$ENV{WM_PROJECT_DIR}")
message(FATAL_ERROR "WM_PROJECT_DIR not set")
endif()
if (EXISTS "$ENV{ParaView_DIR}")
find_package(ParaView REQUIRED COMPONENTS vtkPVPythonCatalyst)
else()
......@@ -53,6 +51,6 @@ message("================")
#-----------------------------------------------------------------------------
include(CMakeLists-Common.txt)
include(CMakeLists-Catalyst.txt)
#-----------------------------------------------------------------------------
......@@ -62,13 +62,17 @@ void Foam::catalyst::faMeshInput::update()
forAllConstIters(meshes_, iter)
{
if (!backends_.found(iter.key()))
const word& areaName(iter.key());
if (!backends_.found(areaName))
{
backends_.set
(
iter.key(),
new Foam::vtk::faMeshAdaptor(*(iter.object()))
);
auto backend =
autoPtr<Foam::vtk::faMeshAdaptor>::New(*(iter.object()));
// Apply any configuration options
// ...
backends_.set(areaName, backend);
}
}
}
......@@ -215,7 +219,6 @@ bool Foam::catalyst::faMeshInput::convert
{
auto dataset = backends_[areaName]->output(selectFields_);
// Existing or new
vtkSmartPointer<vtkMultiBlockDataSet> block =
outputs.lookup
......
......@@ -19,7 +19,6 @@ catalyst
scripts
(
// "<etc>/caseDicts/insitu/catalyst/printChannels.py"
"<etc>/caseDicts/insitu/catalyst/writeAll.py"
);
......@@ -39,6 +38,9 @@ catalyst
// Emit internal mesh/fields
internal true;
// Restrict boundary conversion to specific patches
patches (walls "*.top");
// Selected fields (words or regex)
fields (T U p);
}
......
......@@ -336,7 +336,15 @@ bool Foam::functionObjects::catalystFunctionObject::execute()
if (outputs.size())
{
Log << type() << ": send data" << nl;
if (log)
{
Info<< type() << ": send data (";
for (const word& channelName : outputs.sortedToc())
{
Info<< ' ' << channelName;
}
Info<< " )" << nl;
}
adaptor_().process(dataq, outputs);
}
......@@ -373,6 +381,8 @@ bool Foam::functionObjects::catalystFunctionObject::end()
}
adaptor_.clear();
inputs_.clear();
return true;
}
......
......@@ -139,7 +139,6 @@ bool Foam::catalyst::cloudInput::convert
auto dataset =
vtk::cloudAdaptor(fvm).getCloud(cloudName, selectFields_);
// Existing or new
vtkSmartPointer<vtkMultiBlockDataSet> block =
outputs.lookup
......
......@@ -60,13 +60,22 @@ void Foam::catalyst::fvMeshInput::update()
forAllConstIters(meshes_, iter)
{
if (!backends_.found(iter.key()))
const word& regionName = iter.key();
if (!backends_.found(regionName))
{
backends_.set
(
iter.key(),
new Foam::vtk::fvMeshAdaptor(*(iter.object()), decomposeOpt_)
);
auto backend =
autoPtr<Foam::vtk::fvMeshAdaptor>::New
(
*(iter.object()),
channelOpt_,
selectPatches_
);
// Special polyhedral treatment?
backend->setDecompose(decomposeOpt_);
backends_.set(regionName, backend);
}
}
}
......@@ -86,6 +95,7 @@ Foam::catalyst::fvMeshInput::fvMeshInput
channelOpt_(channelType::DEFAULT),
decomposeOpt_(false),
selectRegions_(),
selectPatches_(),
selectFields_(),
meshes_(),
backends_()
......@@ -102,8 +112,9 @@ bool Foam::catalyst::fvMeshInput::read(const dictionary& dict)
meshes_.clear();
backends_.clear();
selectFields_.clear();
selectRegions_.clear();
selectPatches_.clear();
selectFields_.clear();
decomposeOpt_ = dict.lookupOrDefault("decompose", false);
unsigned selected(channelType::NONE);
......@@ -132,6 +143,7 @@ bool Foam::catalyst::fvMeshInput::read(const dictionary& dict)
// All possible meshes
meshes_ = time_.lookupClass<fvMesh>();
dict.readIfPresent("patches", selectPatches_);
dict.readIfPresent("regions", selectRegions_);
if (selectRegions_.empty())
......@@ -226,12 +238,8 @@ bool Foam::catalyst::fvMeshInput::convert
for (const word& regionName : regionNames)
{
// Define/redefine output channels (caching)
backends_[regionName]->channels(channelOpt_);
auto dataset = backends_[regionName]->output(selectFields_);
// Existing or new
vtkSmartPointer<vtkMultiBlockDataSet> block =
outputs.lookup
......
......@@ -50,6 +50,7 @@ Usage
type | input type: \c default | no | default
region | name for a single region | no | region0
regions | wordRe list of regions | no |
patches | explicit wordRe list of patches | no |
fields | wordRe list of fields | yes |
boundary | convert boundary fields | no | true
internal | convert internal fields | no | true
......@@ -83,6 +84,10 @@ Usage
Note
The channel name is that of the defining dictionary.
If the \c patches entry is missing or an empty list,
all non-processor patches will be used for the boundary.
When it is non-empty, only the explicitly specified (non-processor)
patch names will be used.
See also
Foam::vtk::fvMeshAdaptor
......@@ -135,6 +140,9 @@ protected:
//- Requested names of regions to process
wordRes selectRegions_;
//- Requested names of patches to process
wordRes selectPatches_;
//- Names of fields to process
wordRes selectFields_;
......
......@@ -59,26 +59,70 @@ Foam::vtk::fvMeshAdaptor::channelNames
};
// * * * * * * * * * * * * * Private Member Functions * * * * * * * * * * * //
void Foam::vtk::fvMeshAdaptor::definePatchIds()
{
// Generate or update the list of patchIds
patchIds_.clear();
if (!usingBoundary())
{
return;
}
// General patch information
// Restrict to non-processor patches.
// This value is invariant across all processors.
const polyBoundaryMesh& patches = mesh_.boundaryMesh();
const label nNonProcessor = patches.nNonProcessor();
if (patchPatterns_.empty())
{
patchIds_ = identity(nNonProcessor);
}
else
{
// Don't warn if not found, use patch groups
labelHashSet ids(patches.patchSet(patchPatterns_, false, true));
// Restricted to non-processor patches
ids.filterKeys
(
[nNonProcessor](label i){ return i < nNonProcessor; }
);
// MUST be sorted. Other internal logic relies upon this!
patchIds_ = ids.sortedToc();
}
}
// * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * //
Foam::vtk::fvMeshAdaptor::fvMeshAdaptor
(
const fvMesh& mesh,
const bool decompose
const channelType channelsOpt,
const wordRes& patchSelection
)
:
mesh_(mesh),
channels_(ALL),
patchPatterns_(patchSelection),
patchIds_(),
channels_(channelsOpt),
interpFields_(true),
extrapPatches_(false),
decomposePoly_(decompose),
decomposePoly_(false),
meshState_(polyMesh::TOPO_CHANGE)
{}
// * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * //
void Foam::vtk::fvMeshAdaptor::channels(const wordList& chanNames)
void Foam::vtk::fvMeshAdaptor::setChannels(const wordList& chanNames)
{
unsigned chanIds = 0;
for (const word& chan : chanNames)
......@@ -89,11 +133,11 @@ void Foam::vtk::fvMeshAdaptor::channels(const wordList& chanNames)
}
}
channels(chanIds);
setChannels(chanIds);
}
void Foam::vtk::fvMeshAdaptor::channels(enum channelType chanIds)
void Foam::vtk::fvMeshAdaptor::setChannels(enum channelType chanIds)
{
channels_ = chanIds;
......@@ -105,11 +149,12 @@ void Foam::vtk::fvMeshAdaptor::channels(enum channelType chanIds)
if (!usingBoundary())
{
cachedVtp_.clear();
patchIds_.clear();
}
}
void Foam::vtk::fvMeshAdaptor::channels(unsigned chanIds)
void Foam::vtk::fvMeshAdaptor::setChannels(unsigned chanIds)
{
channels_ = (chanIds & 0x3);
......@@ -121,6 +166,17 @@ void Foam::vtk::fvMeshAdaptor::channels(unsigned chanIds)
if (!usingBoundary())
{
cachedVtp_.clear();
patchIds_.clear();
}
}
void Foam::vtk::fvMeshAdaptor::setDecompose(const bool val)
{
if (usingInternal() && val != decomposePoly_)
{
cachedVtu_.clear();
decomposePoly_ = val;
}
}
......@@ -143,17 +199,9 @@ bool Foam::vtk::fvMeshAdaptor::usingBoundary() const
}
Foam::label Foam::vtk::fvMeshAdaptor::nPatches() const
const Foam::labelList& Foam::vtk::fvMeshAdaptor::patchIds() const
{
// Restrict to non-processor patches.
// This value is invariant across all processors.
if (usingBoundary())
{
return mesh_.boundaryMesh().nNonProcessor();
}
return 0;
return patchIds_;
}
......@@ -161,6 +209,14 @@ void Foam::vtk::fvMeshAdaptor::updateContent(const wordRes& selectFields)
{
const bool oldDecomp = decomposePoly_;
// General patch information
// Restrict to non-processor patches.
// This value is invariant across all processors.
const polyBoundaryMesh& patches = mesh_.boundaryMesh();
const label nNonProcessor = patches.nNonProcessor();
// Update cached, saved, unneed values.
HashSet<string> nowActive;
......@@ -171,18 +227,15 @@ void Foam::vtk::fvMeshAdaptor::updateContent(const wordRes& selectFields)
nowActive.insert(internalName());
}
// BOUNDARY
// Restrict to non-processor patches.
// This value is invariant across all processors.
const polyBoundaryMesh& patches = mesh_.boundaryMesh();
const label npatches = this->nPatches();
for (label patchId=0; patchId < npatches; ++patchId)
// BOUNDARY
if (usingBoundary())
{
const polyPatch& pp = patches[patchId];
nowActive.insert(pp.name());
for (label patchId=0; patchId < nNonProcessor; ++patchId)
{
const polyPatch& pp = patches[patchId];
nowActive.insert(pp.name());
}
}
// Dispose of unneeded components
......@@ -206,6 +259,8 @@ void Foam::vtk::fvMeshAdaptor::updateContent(const wordRes& selectFields)
iter.object().clearGeom();
iter.object().clear();
}
definePatchIds();
}
else if (oldDecomp != decomposePoly_)
{
......@@ -281,8 +336,7 @@ Foam::vtk::fvMeshAdaptor::output(const wordRes& select)
}
// BOUNDARY
const label npatches = this->nPatches();
if (npatches)
if (!patchIds_.empty())
{
unsigned int subBlockNo = 0;
......@@ -290,7 +344,7 @@ Foam::vtk::fvMeshAdaptor::output(const wordRes& select)
const polyBoundaryMesh& patches = mesh_.boundaryMesh();
for (label patchId=0; patchId < npatches; ++patchId)
for (const label patchId : patchIds_)
{
const polyPatch& pp = patches[patchId];
const word& longName = pp.name();
......
......@@ -170,6 +170,12 @@ private:
//- OpenFOAM mesh
const fvMesh& mesh_;
//- In non-empty, restrict to these selected patches only
wordRes patchPatterns_;
//- Cached values for selected patches. *Always* in sorted order.
labelList patchIds_;
//- Selected output channels
unsigned channels_;
......@@ -195,6 +201,9 @@ private:
// Mesh Conversion
//- Define patch ids
void definePatchIds();
//- Convert internal
void convertGeometryInternal();
......@@ -293,7 +302,12 @@ public:
// Constructors
//- Construct from components
fvMeshAdaptor(const fvMesh& mesh, const bool decompose=false);
fvMeshAdaptor
(
const fvMesh& mesh,
const channelType channelsOpt = channelType::DEFAULT,
const wordRes& patchSelection = wordRes()
);
//- Destructor
......@@ -303,13 +317,17 @@ public:
// Member Functions
//- Define the output channels by name
void channels(const wordList& chanNames);
void setChannels(const wordList& chanNames);
//- Define the output channels by enum
void channels(enum channelType chanIds);
void setChannels(enum channelType chanIds);
//- Define the output channels by value
void channels(unsigned chanIds);
void setChannels(unsigned chanIds);
//- Define polyhedral decomposition treatment
void setDecompose(const bool on);
//- Return the selected output channel ids
label channels() const;
......@@ -320,9 +338,9 @@ public:
//- True if BOUNDARY channel is being used
bool usingBoundary() const;
//- Number of non-processor patches, when the BOUNDARY channel is being
//- used - otherwise 0.
label nPatches() const;
//- Selected (non-processor) patch ids, when the BOUNDARY channel
//- is being used. Empty otherwise.
const labelList& patchIds() const;
//- Return the names of known (supported) fields
wordHashSet knownFields(const wordRes& selectFields) const;
......
......@@ -69,9 +69,7 @@ void Foam::vtk::fvMeshAdaptor::convertVolField
convertVolFieldInternal(fld, ptfPtr);
// BOUNDARY
const label npatches = this->nPatches();
for (label patchId=0; patchId < npatches; ++patchId)
for (const label patchId : patchIds_)
{
const polyPatch& pp = patches[patchId];
const word& longName = pp.name();
......@@ -125,7 +123,11 @@ void Foam::vtk::fvMeshAdaptor::convertVolField
transcribeFloatData(cdata, tpptf());
if (interpFields_ && patchId < patchInterpList.size())
if
(
patchId < patchInterpList.size()
&& patchInterpList.set(patchId)
)
{
pdata = vtk::Tools::convertFieldToVTK
(
......@@ -138,7 +140,11 @@ void Foam::vtk::fvMeshAdaptor::convertVolField
{
transcribeFloatData(cdata, ptf);
if (interpFields_ && patchId < patchInterpList.size())
if
(
patchId < patchInterpList.size()
&& patchInterpList.set(patchId)
)
{
pdata = vtk::Tools::convertFieldToVTK
(
......
......@@ -105,21 +105,23 @@ void Foam::vtk::fvMeshAdaptor::convertVolFields
PtrList<patchInterpolator> interpLst;
if (interpFields_)
if (interpFields_ && patchIds_.size())
{
// NOTE: this will be broken with processor patches, but
// for the catalyst adaptor we explicitly restrict ourselves
// to non-processor patches
interpLst.setSize(this->nPatches());
// NOTE: this would be broken with processor patches,
// but we don't allow them for the catalyst adaptor anyhow
forAll(interpLst, i)
// patchIds_ are sorted, so the last one is also the max
interpLst.setSize(patchIds_.last() + 1);
for (const label patchId : patchIds_)
{
interpLst.set
(
i,
patchId,
new PrimitivePatchInterpolation<primitivePatch>
(
mesh_.boundaryMesh()[i]
mesh_.boundaryMesh()[patchId]
)
);
}
......
......@@ -90,9 +90,8 @@ void Foam::vtk::fvMeshAdaptor::convertGeometryBoundary()
// BOUNDARY
const polyBoundaryMesh& patches = mesh_.boundaryMesh();
const label npatches = this->nPatches();
for (label patchId=0; patchId < npatches; ++patchId)
for (const label patchId : patchIds_)
{
const polyPatch& pp = patches[patchId];
const word& longName = pp.name();
......@@ -233,9 +232,8 @@ void Foam::vtk::fvMeshAdaptor::applyGhostingBoundary(const labelUList& types)
}
const polyBoundaryMesh& patches = mesh_.boundaryMesh();
const label npatches = this->nPatches();
for (label patchId=0; patchId < npatches; ++patchId)
for (const label patchId : patchIds_)
{
const polyPatch& pp = patches[patchId];
const word& longName = pp.name();
......
......@@ -7,7 +7,7 @@ catalyst
scripts
(
"<system>/scripts/slice1.py"
// "<etc>/caseDicts/insitu/catalyst/printChannels.py"
// "<system>/scripts/showT.py"
// "<etc>/caseDicts/insitu/catalyst/writeAll.py"
);
......@@ -22,7 +22,19 @@ catalyst
boundary false;
// Selected fields (words or regex)
fields (T U p);
fields (T U p);
}
// Solid walls only
walls
{
internal false;
regions ( heater "(?i).*solid" );
patches ( "(?i).*solid_to.*" "heater.*(Air|Water)" );
fields (T);
}
}
}
......
from paraview.simple import *
from paraview import coprocessing
#--------------------------------------------------------------
# Code generated from cpstate.py to create the CoProcessor.
# paraview version 5.5.2
#--------------------------------------------------------------
# Global screenshot output options
imageFileNamePadding=6
rescale_lookuptable=False
# ----------------------- CoProcessor definition -----------------------
def CreateCoProcessor():
def _CreatePipeline(coprocessor, datadescription):
class Pipeline:
# state file generated using paraview version 5.5.2
# ----------------------------------------------------------------
# setup views used in the visualization
# ----------------------------------------------------------------
# trace generated using paraview version 5.5.2
#### disable automatic camera reset on 'Show'
paraview.simple._DisableFirstRenderCameraReset()
# Create a new 'Render View'
renderView1 = CreateView('RenderView')
renderView1.ViewSize = [1227, 756]
renderView1.AxesGrid = 'GridAxes3DActor'
renderView1.OrientationAxesVisibility = 0
renderView1.CenterOfRotation = [0.0, -0.0159999993629754, 0.0]
renderView1.StereoType = 0
renderView1.CameraPosition = [-0.22987670461473275, 0.027908517670887454, 0.37475316483990634]
renderView1.CameraFocalPoint = [0.00145289821931723, -0.013255103910183037, 0.0005962967658004288]
renderView1.CameraViewUp = [0.20896067334705018, 0.9776847628875804, 0.0216319534902209]
renderView1.CameraParallelScale = 0.0945044135920057
renderView1.CameraParallelProjection = 1
renderView1.Background = [0.32, 0.34, 0.43]
# init the 'GridAxes3DActor' selected for 'AxesGrid'
renderView1.AxesGrid.XTitleFontFile = ''
renderView1.AxesGrid.YTitleFontFile = ''
renderView1.AxesGrid.ZTitleFontFile = ''
renderView1.AxesGrid.XLabelFontFile = ''
renderView1.AxesGrid.YLabelFontFile = ''
renderView1.AxesGrid.ZLabelFontFile = ''
# register the view with coprocessor
# and provide it with information such as the filename to use,
# how frequently to write the images, etc.
coprocessor.RegisterView(renderView1,
filename='image_%t.png', freq=1, fittoscreen=0, magnification=1, width=1227, height=756, cinema={})
renderView1.ViewTime = datadescription.GetTime()
# ----------------------------------------------------------------
# restore active view
SetActiveView(renderView1)
# ----------------------------------------------------------------
# ----------------------------------------------------------------
# setup the data processing pipelines
# ----------------------------------------------------------------
# create a new 'XML MultiBlock Data Reader'
# create a producer from a simulation input
region = coprocessor.CreateProducer(datadescription, 'region')
# create a new 'XML MultiBlock Data Reader'
# create a producer from a simulation input
walls = coprocessor.CreateProducer(datadescription, 'walls')
# create a new 'Slice'
slice1 = Slice(Input=region)
slice1.SliceType = 'Plane'
slice1.SliceOffsetValues = [0.0]
# init the 'Plane' selected for 'SliceType'
slice1.SliceType.Normal = [0.0, 0.0, 1.0]
# ----------------------------------------------------------------
# setup the visualization in view 'renderView1'
# ----------------------------------------------------------------
# show data from walls
wallsDisplay = Show(walls, renderView1)
# get color transfer function/color map for 'T'
tLUT = GetColorTransferFunction('T')
tLUT.RGBPoints = [300.0, 0.231373, 0.298039, 0.752941, 400.0, 0.865003, 0.865003, 0.865003, 500.0, 0.705882, 0.0156863, 0.14902]
tLUT.ScalarRangeInitialized = 1.0
# trace defaults for the display properties.
wallsDisplay.Representation = 'Surface'
wallsDisplay.ColorArrayName = ['POINTS', 'T']
wallsDisplay.LookupTable = tLUT
wallsDisplay.Opacity = 0.4
wallsDisplay.OSPRayScaleArray = 'T'
wallsDisplay.OSPRayScaleFunction = 'PiecewiseFunction'
wallsDisplay.SelectOrientationVectors = 'None'
wallsDisplay.ScaleFactor = 0.0200000002980232
wallsDisplay.SelectScaleArray = 'None'
wallsDisplay.GlyphType = 'Arrow'
wallsDisplay.GlyphTableIndexArray = 'None'
wallsDisplay.GaussianRadius = 0.00100000001490116
wallsDisplay.SetScaleArray = ['POINTS', 'T']
wallsDisplay.ScaleTransferFunction = 'PiecewiseFunction'
wallsDisplay.OpacityArray = ['POINTS', 'T']
wallsDisplay.OpacityTransferFunction = 'PiecewiseFunction'
wallsDisplay.DataAxesGrid = 'GridAxesRepresentation'
wallsDisplay.SelectionCellLabelFontFile = ''
wallsDisplay.SelectionPointLabelFontFile = ''
wallsDisplay.PolarAxes = 'PolarAxesRepresentation'
# init the 'PiecewiseFunction' selected for 'ScaleTransferFunction'
wallsDisplay.ScaleTransferFunction.Points = [300.0, 0.0, 0.5, 0.0, 451.4297180175781, 1.0, 0.5, 0.0]
# init the 'PiecewiseFunction' selected for 'OpacityTransferFunction'
wallsDisplay.OpacityTransferFunction.Points = [300.0, 0.0, 0.5, 0.0, 451.4297180175781, 1.0, 0.5, 0.0]
# init the 'GridAxesRepresentation' selected for 'DataAxesGrid'
wallsDisplay.DataAxesGrid.XTitleFontFile = ''
wallsDisplay.DataAxesGrid.YTitleFontFile = ''
wallsDisplay.DataAxesGrid.ZTitleFontFile = ''
wallsDisplay.DataAxesGrid.XLabelFontFile = ''
wallsDisplay.DataAxesGrid.YLabelFontFile = ''
wallsDisplay.DataAxesGrid.ZLabelFontFile = ''
# init the 'PolarAxesRepresentation' selected for 'PolarAxes'
wallsDisplay.PolarAxes.PolarAxisTitleFontFile = ''
wallsDisplay.PolarAxes.PolarAxisLabelFontFile = ''
wallsDisplay.PolarAxes.LastRadialAxisTextFontFile = ''
wallsDisplay.PolarAxes.SecondaryRadialAxesTextFontFile = ''
# show data from slice1
slice1Display = Show(slice1, renderView1)
# trace defaults for the display properties.
slice1Display.Representation = 'Surface'
slice1Display.ColorArrayName = ['POINTS', 'T']
slice1Display.LookupTable = tLUT
slice1Display.Opacity = 0.8
slice1Display.OSPRayScaleArray = 'T'
slice1Display.OSPRayScaleFunction = 'PiecewiseFunction'
slice1Display.SelectOrientationVectors = 'None'
slice1Display.ScaleFactor = 0.0100000001490116
slice1Display.SelectScaleArray = 'None'
slice1Display.GlyphType = 'Arrow'
slice1Display.GlyphTableIndexArray = 'None'
slice1Display.GaussianRadius = 0.000500000007450581
slice1Display.SetScaleArray = ['POINTS', 'T']
slice1Display.ScaleTransferFunction = 'PiecewiseFunction'
slice1Display.OpacityArray = ['POINTS', 'T']
slice1Display.OpacityTransferFunction = 'PiecewiseFunction'
slice1Display.DataAxesGrid = 'GridAxesRepresentation'
slice1Display.SelectionCellLabelFontFile = ''
slice1Display.SelectionPointLabelFontFile = ''
slice1Display.PolarAxes = 'PolarAxesRepresentation'
# init the 'PiecewiseFunction' selected for 'ScaleTransferFunction'
slice1Display.ScaleTransferFunction.Points = [300.0, 0.0, 0.5, 0.0, 500.0, 1.0, 0.5, 0.0]
# init the 'PiecewiseFunction' selected for 'OpacityTransferFunction'
slice1Display.OpacityTransferFunction.Points = [300.0, 0.0, 0.5, 0.0, 500.0, 1.0, 0.5, 0.0]
# init the 'GridAxesRepresentation' selected for 'DataAxesGrid'
slice1Display.DataAxesGrid.XTitleFontFile = ''
slice1Display.DataAxesGrid.YTitleFontFile = ''
slice1Display.DataAxesGrid.ZTitleFontFile = ''
slice1Display.DataAxesGrid.XLabelFontFile = ''
slice1Display.DataAxesGrid.YLabelFontFile = ''
slice1Display.DataAxesGrid.ZLabelFontFile = ''
# init the 'PolarAxesRepresentation' selected for 'PolarAxes'
slice1Display.PolarAxes.PolarAxisTitleFontFile = ''
slice1Display.PolarAxes.PolarAxisLabelFontFile = ''
slice1Display.PolarAxes.LastRadialAxisTextFontFile = ''
slice1Display.PolarAxes.SecondaryRadialAxesTextFontFile = ''
# setup the color legend parameters for each legend in this view
# get color legend/bar for tLUT in view renderView1
tLUTColorBar = GetScalarBar(tLUT, renderView1)
tLUTColorBar.Title = 'T'
tLUTColorBar.ComponentTitle = ''
tLUTColorBar.TitleFontFile = ''
tLUTColorBar.LabelFontFile = ''
# set color bar visibility
tLUTColorBar.Visibility = 1
# show color legend
wallsDisplay.SetScalarBarVisibility(renderView1, True)
# show color legend
slice1Display.SetScalarBarVisibility(renderView1, True)
# ----------------------------------------------------------------
# setup color maps and opacity mapes used in the visualization
# note: the Get..() functions create a new object, if needed
# ----------------------------------------------------------------
# get opacity transfer function/opacity map for 'T'
tPWF = GetOpacityTransferFunction('T')
tPWF.Points = [300.0, 0.0, 0.5, 0.0, 500.0, 1.0, 0.5, 0.0]
tPWF.ScalarRangeInitialized = 1
# ----------------------------------------------------------------
# finally, restore active source
SetActiveSource(walls)
# ----------------------------------------------------------------
return Pipeline()
class CoProcessor(coprocessing.CoProcessor):
def CreatePipeline(self, datadescription):
self.Pipeline = _CreatePipeline(self, datadescription)
coprocessor = CoProcessor()
# these are the frequencies at which the coprocessor updates.
freqs = {'walls': [1], 'region': [1, 1]}
coprocessor.SetUpdateFrequencies(freqs)
return coprocessor
#--------------------------------------------------------------
# Global variable that will hold the pipeline for each timestep
# Creating the CoProcessor object, doesn't actually create the ParaView pipeline.
# It will be automatically setup when coprocessor.UpdateProducers() is called the
# first time.
coprocessor = CreateCoProcessor()
#--------------------------------------------------------------
# Enable Live-Visualizaton with ParaView and the update frequency
coprocessor.EnableLiveVisualization(False, 1)
# ---------------------- Data Selection method ----------------------
def RequestDataDescription(datadescription):
"Callback to populate the request for current timestep"
global coprocessor
if datadescription.GetForceOutput() == True:
# We are just going to request all fields and meshes from the simulation
# code/adaptor.
for i in range(datadescription.GetNumberOfInputDescriptions()):
datadescription.GetInputDescription(i).AllFieldsOn()
datadescription.GetInputDescription(i).GenerateMeshOn()
return
# setup requests for all inputs based on the requirements of the
# pipeline.
coprocessor.LoadRequestedData(datadescription)
# ------------------------ Processing method ------------------------
def DoCoProcessing(datadescription):
"Callback to do co-processing for current timestep"
global coprocessor
# Update the coprocessor by providing it the newly generated simulation data.
# If the pipeline hasn't been setup yet, this will setup the pipeline.
coprocessor.UpdateProducers(datadescription)
# Write output data, if appropriate.
coprocessor.WriteData(datadescription);
# Write image capture (Last arg: rescale lookup table), if appropriate.
coprocessor.WriteImages(datadescription, rescale_lookuptable=rescale_lookuptable,
image_quality=0, padding_amount=imageFileNamePadding)
# Live Visualization, if enabled.
coprocessor.DoLiveVisualization(datadescription, "localhost", 22222)
......@@ -9,17 +9,21 @@ def CreateCoProcessor():
def _CreatePipeline(coprocessor, datadescription):
class Pipeline:
region = coprocessor.CreateProducer(datadescription, 'region')
walls = coprocessor.CreateProducer(datadescription, 'walls')
slice1 = Slice(Input=region, guiName="Slice1", SliceOffsetValues=[0.0], Triangulatetheslice=1, SliceType="Plane")
slice1.SliceType.Offset = 0.0
slice1.SliceType.Origin = [0, 0, 0]
slice1 = Slice(Input=region)
slice1.SliceType = 'Plane'
slice1.SliceOffsetValues = [0.0]
slice1.SliceType.Normal = [0, 0, 1]
sliceWriter = servermanager.writers.XMLMultiBlockDataWriter(Input=slice1)
coprocessor.RegisterWriter(sliceWriter, filename='slice_%t.vtm', freq=10, paddingamount=fileNamePadding)
meshWriter = servermanager.writers.XMLMultiBlockDataWriter(Input=region)
coprocessor.RegisterWriter(meshWriter, filename='region_%t.vtm', freq=100, paddingamount=fileNamePadding)
regionWriter = servermanager.writers.XMLMultiBlockDataWriter(Input=region)
coprocessor.RegisterWriter(regionWriter, filename='region_%t.vtm', freq=100, paddingamount=fileNamePadding)
wallsWriter = servermanager.writers.XMLMultiBlockDataWriter(Input=walls)
coprocessor.RegisterWriter(wallsWriter, filename='walls_%t.vtm', freq=25, paddingamount=fileNamePadding)
return Pipeline()
......@@ -28,7 +32,7 @@ def CreateCoProcessor():
self.Pipeline = _CreatePipeline(self, datadescription)
coprocessor = CoProcessor()
freqs = {'region': [10, 100]}
freqs = {'region': [10, 100], 'walls': [25]}
coprocessor.SetUpdateFrequencies(freqs)
return coprocessor
......