Dear Andy Bauer,
For the color map issue, I think ParaView 5.4.1 resolved it. But, I
could not figure out annotate time filter issue. may be it is just
simple problem but I am not sure. Coprocess routine is as follows and
python script is attached.
It would be appreciated if you make some advice.
void CoProcess(Foam::fvMesh& mesh, Foam::Time& runTime)
{
vtkNew<vtkCPDataDescription> dataDescription;
dataDescription->AddInput("input");
const double time = runTime.value();
const unsigned int timeStep = runTime.timeIndex();
dataDescription->SetTimeData(time, timeStep);
if (runTime.end())
{
// assume that we want to all the pipelines to execute
// if it is the last time step
dataDescription->ForceOutputOn();
}
if
(Processor->RequestDataDescription(dataDescription.GetPointer()) != 0)
{
Foam::polyMesh::readUpdateState meshState = mesh.readUpdate();
if(meshState != Foam::polyMesh::UNCHANGED)
{
// mesh moved? or mesh topology changed?
BuildVTKGrid(mesh, true);
}
UpdateVTKAttributes(mesh);
dataDescription->GetInputDescriptionByName("input")->
SetGrid(multiBlockDataSet);
Processor->CoProcess(dataDescription.GetPointer());
}
}
Regards.
SeongMo
SeongMo Yeon, Ph.D, Senior Engineer
Offshore Hydrodynamics Research
SAMSUNG HEAVY INDUSTRIES CO., LTD.
Central Research Institute
E-mail : seongmo.y...@gmail.com
Tel :
--------------------------------------------------------
Fluctuat nec mergitur
On 01/25/2018 06:56 AM, Andy Bauer wrote:
Hi Seongmo,
Please keep the conversations on the mailing list so that anyone can
follow along or participate. Also, these types of things often get
lost in my inbox when they don't make it back to the ParaView mailing
list.
What version of ParaView Catalyst are you using? I think the annotate
time filter should work with Catalyst but I haven't verified that. I
vaguely remember others using that filter with Catalyst though. Also,
I think the colormap bug was fixed. If you have a way of sharing a
sample that demonstrates either of those bugs I can try taking a look
at the issue.
Best,
Andy
On Thu, Jan 18, 2018 at 6:40 PM, Seong Mo Yeon <seongmo.y...@gmail.com
<mailto:seongmo.y...@gmail.com>> wrote:
Dear Andy Bauer
I have a quick question.
Is it possible to have annotate time filter processed in catalyst
adaptor? Current my code cannot that filter.
BTW, image extracted from catalyst looks different from render
view of paraview at the time of writing a script. e.g., pressure
colormap legend is missing.
Regards
Seongmo
On 2018년 1월 18일 AM 1:17 +0900, Andy Bauer <andy.ba...@kitware.com
<mailto:andy.ba...@kitware.com>>, wrote:
Hi,
My guess is that the TimeStep isn't getting set properly in the
adaptor (though it looks like it should be in
"dataDescription->SetTimeData(runTime.value(),
runTime.deltaTValue());"). My suggestion would be to add in the
following to either the RequestDataDescription() or
DoCoProcessing() methods in the python script to see what
Catalyst thinks the time step is:
print("In script2.py, the data time step is ",
datadescription.GetTimeStep())
On Wed, Jan 17, 2018 at 9:57 AM, SeongMo <seongmo.y...@gmail.com
<mailto:seongmo.y...@gmail.com>> wrote:
Hi,
I wrote a OpenFOAM adaptor for Catalyst.
In the ParaView, the connection is made good and shows
filtered flow field as written in the python script.
However, filename_%t and image_%t is not expanded as time
marching but just write filename_0 and image_0.png.
As far as I know, %t should be replaced with current time as
given in dataDescription->SetTimeData.
Any help would be appreciated.
FYI, python script is attached and snippet of my OpenFOAM
Adaptor code for Catalyst is as follows:
// icoFoam.C
#ifdef USE_CATALYST
Foam::HashTable<string> options = args.options();
IStringStream is(options["scriptList"]);
wordList scriptList = readList<word>(is);
OFAdaptor::Initialize(scriptList, mesh);
#endif
while (runTime.loop())
{
runTime.write();
#ifdef USE_CATALYST
OFAdaptor::CoProcess(mesh, runTime);
#endif
}
#ifdef USE_CATALYST
OFAdaptor::Finalize();
#endif
// OFAdaptor.C
void CoProcess(Foam::fvMesh& mesh, Foam::Time& runTime)
{
vtkNew<vtkCPDataDescription> dataDescription;
dataDescription->AddInput("input");
dataDescription->SetTimeData(runTime.value(),
runTime.deltaTValue());
if (runTime.end())
{
// assume that we want to all the pipelines to execute
// if it is the last time step
dataDescription->ForceOutputOn();
}
if
(Processor->RequestDataDescription(dataDescription.GetPointer())
!= 0)
{
Foam::polyMesh::readUpdateState meshState = mesh.readUpdate();
if(meshState != Foam::polyMesh::UNCHANGED)
{
BuildVTKGrid(mesh);
}
UpdateVTKAttributes(mesh);
dataDescription->GetInputDescriptionByName("input")->SetGrid(multiBlockDataSet);
Processor->CoProcess(dataDescription.GetPointer());
}
}
--
SeongMo Yeon, Ph.D, Senior Engineer
Offshore Hydrodynamics Research
SAMSUNG HEAVY INDUSTRIES CO., LTD.
Central Research Institute
E-mail : seongmo.y...@gmail.com <mailto:seongmo.y...@gmail.com>
Tel :
--------------------------------------------------------
Fluctuat nec mergitur
_______________________________________________
Powered by www.kitware.com <http://www.kitware.com>
Visit other Kitware open-source projects at
http://www.kitware.com/opensource/opensource.html
<http://www.kitware.com/opensource/opensource.html>
Please keep messages on-topic and check the ParaView Wiki at:
http://paraview.org/Wiki/ParaView
<http://paraview.org/Wiki/ParaView>
Search the list archives at:
http://markmail.org/search/?q=ParaView
<http://markmail.org/search/?q=ParaView>
Follow this link to subscribe/unsubscribe:
https://paraview.org/mailman/listinfo/paraview
<https://paraview.org/mailman/listinfo/paraview>
from paraview.simple import *
from paraview import coprocessing
#--------------------------------------------------------------
# Code generated from cpstate.py to create the CoProcessor.
# ParaView 5.4.1 64 bits
#--------------------------------------------------------------
# Global screenshot output options
imageFileNamePadding=0
rescale_lookuptable=False
# ----------------------- CoProcessor definition -----------------------
def CreateCoProcessor():
def _CreatePipeline(coprocessor, datadescription):
class Pipeline:
# state file generated using paraview version 5.4.1
# ----------------------------------------------------------------
# setup views used in the visualization
# ----------------------------------------------------------------
#### disable automatic camera reset on 'Show'
paraview.simple._DisableFirstRenderCameraReset()
# Create a new 'Render View'
renderView1 = CreateView('RenderView')
renderView1.ViewSize = [1612, 808]
renderView1.AxesGrid = 'GridAxes3DActor'
renderView1.CenterOfRotation = [0.05000000074505806, 0.05000000074505806, 0.004999999888241291]
renderView1.StereoType = 0
renderView1.CameraPosition = [0.05000000074505806, 0.05000000074505806, 0.33884290240632653]
renderView1.CameraFocalPoint = [0.05000000074505806, 0.05000000074505806, 0.004999999888241291]
renderView1.CameraParallelScale = 0.0874130940050772
renderView1.Background = [0.32, 0.34, 0.43]
# 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=1, magnification=1, width=1612, height=808, cinema={})
renderView1.ViewTime = datadescription.GetTime()
# ----------------------------------------------------------------
# setup the data processing pipelines
# ----------------------------------------------------------------
# create a new 'OpenFOAMReader'
# create a producer from a simulation input
cavityfoam = coprocessor.CreateProducer(datadescription, 'input')
# create a new 'Parallel MultiBlockDataSet Writer'
parallelMultiBlockDataSetWriter1 = servermanager.writers.XMLMultiBlockDataWriter(Input=cavityfoam)
# register the writer with coprocessor
# and provide it with information such as the filename to use,
# how frequently to write the data, etc.
coprocessor.RegisterWriter(parallelMultiBlockDataSetWriter1, filename='filename_%t.vtm', freq=1, paddingamount=0)
# create a new 'Annotate Time'
annotateTime1 = AnnotateTime()
# create a new 'Stream Tracer'
streamTracer1 = StreamTracer(Input=cavityfoam,
SeedType='High Resolution Line Source')
streamTracer1.Vectors = ['POINTS', 'U']
streamTracer1.MaximumStreamlineLength = 0.10000000149011612
# init the 'High Resolution Line Source' selected for 'SeedType'
streamTracer1.SeedType.Point2 = [0.10000000149011612, 0.10000000149011612, 0.009999999776482582]
streamTracer1.SeedType.Resolution = 20
# create a new 'Tube'
tube1 = Tube(Input=streamTracer1)
tube1.Scalars = ['POINTS', 'p']
tube1.Vectors = ['POINTS', 'Normals']
tube1.Radius = 0.001024018581956625
# ----------------------------------------------------------------
# setup color maps and opacity mapes used in the visualization
# note: the Get..() functions create a new object, if needed
# ----------------------------------------------------------------
# get color transfer function/color map for 'p'
pLUT = GetColorTransferFunction('p')
pLUT.RGBPoints = [-4.36667013168335, 0.231373, 0.298039, 0.752941, 0.240919828414917, 0.865003, 0.865003, 0.865003, 4.848509788513184, 0.705882, 0.0156863, 0.14902]
pLUT.ScalarRangeInitialized = 1.0
# get opacity transfer function/opacity map for 'p'
pPWF = GetOpacityTransferFunction('p')
pPWF.Points = [-4.36667013168335, 0.0, 0.5, 0.0, 4.848509788513184, 1.0, 0.5, 0.0]
pPWF.ScalarRangeInitialized = 1
# ----------------------------------------------------------------
# setup the visualization in view 'renderView1'
# ----------------------------------------------------------------
# show data from tube1
tube1Display = Show(tube1, renderView1)
# trace defaults for the display properties.
tube1Display.Representation = 'Surface'
tube1Display.ColorArrayName = ['POINTS', 'p']
tube1Display.LookupTable = pLUT
tube1Display.OSPRayScaleArray = 'p'
tube1Display.OSPRayScaleFunction = 'PiecewiseFunction'
tube1Display.SelectOrientationVectors = 'Normals'
tube1Display.ScaleFactor = 0.010432064440101385
tube1Display.SelectScaleArray = 'p'
tube1Display.GlyphType = 'Arrow'
tube1Display.GlyphTableIndexArray = 'p'
tube1Display.DataAxesGrid = 'GridAxesRepresentation'
tube1Display.PolarAxes = 'PolarAxesRepresentation'
tube1Display.GaussianRadius = 0.005216032220050693
tube1Display.SetScaleArray = ['POINTS', 'p']
tube1Display.ScaleTransferFunction = 'PiecewiseFunction'
tube1Display.OpacityArray = ['POINTS', 'p']
tube1Display.OpacityTransferFunction = 'PiecewiseFunction'
# show color legend
tube1Display.SetScalarBarVisibility(renderView1, True)
# show data from annotateTime1
annotateTime1Display = Show(annotateTime1, renderView1)
# setup the color legend parameters for each legend in this view
# get color legend/bar for pLUT in view renderView1
pLUTColorBar = GetScalarBar(pLUT, renderView1)
pLUTColorBar.Title = 'p'
pLUTColorBar.ComponentTitle = ''
# ----------------------------------------------------------------
# finally, restore active source
SetActiveSource(parallelMultiBlockDataSetWriter1)
# ----------------------------------------------------------------
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 = {'input': [1, 1, 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(True, 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)
_______________________________________________
Powered by www.kitware.com
Visit other Kitware open-source projects at
http://www.kitware.com/opensource/opensource.html
Please keep messages on-topic and check the ParaView Wiki at:
http://paraview.org/Wiki/ParaView
Search the list archives at: http://markmail.org/search/?q=ParaView
Follow this link to subscribe/unsubscribe:
https://paraview.org/mailman/listinfo/paraview