Commit 5bd81cab authored by Mark Olesen's avatar Mark Olesen

STYLE: reorganize subdir names, adjust method catalystCoprocess method name

- was check(), now query()

- emit/suppress information output based on 'log' setting
  (as per other functionObjects)
parent f2c8e739
...@@ -43,19 +43,19 @@ set(LIBRARY_OUTPUT_PATH $ENV{FOAM_LIBBIN} ...@@ -43,19 +43,19 @@ set(LIBRARY_OUTPUT_PATH $ENV{FOAM_LIBBIN}
file(GLOB SOURCE_FILES file(GLOB SOURCE_FILES
catalystCoprocess.C catalystCoprocess.C
catalystCloud.C cloud/catalystCloud.C
foamVtkCloudAdaptor.C cloud/foamVtkCloudAdaptor.C
catalystFaMesh.C areaMesh/catalystFaMesh.C
foamVtkFaMeshAdaptor.C areaMesh/foamVtkFaMeshAdaptor.C
foamVtkFaMeshAdaptorGeom.C areaMesh/foamVtkFaMeshAdaptorGeom.C
foamVtkFaMeshAdaptorFields.C areaMesh/foamVtkFaMeshAdaptorFields.C
catalystFvMesh.C volMesh/catalystFvMesh.C
foamVtkFvMeshAdaptor.C volMesh/foamVtkFvMeshAdaptor.C
foamVtkFvMeshAdaptorGeom.C volMesh/foamVtkFvMeshAdaptorGeom.C
foamVtkFvMeshAdaptorGeomVtu.C volMesh/foamVtkFvMeshAdaptorGeomVtu.C
foamVtkFvMeshAdaptorFields.C volMesh/foamVtkFvMeshAdaptorFields.C
) )
set(OPENFOAM_LIBRARIES set(OPENFOAM_LIBRARIES
......
...@@ -175,8 +175,6 @@ bool Foam::functionObjects::catalystFaMesh::execute() ...@@ -175,8 +175,6 @@ bool Foam::functionObjects::catalystFaMesh::execute()
return false; return false;
} }
const catalystCoprocess::timeQuery when(time_);
// Enforce sanity for backends and adaptor // Enforce sanity for backends and adaptor
{ {
bool updateAdaptor = false; bool updateAdaptor = false;
...@@ -213,36 +211,42 @@ bool Foam::functionObjects::catalystFaMesh::execute() ...@@ -213,36 +211,42 @@ bool Foam::functionObjects::catalystFaMesh::execute()
// Data description for co-processing // Data description for co-processing
vtkNew<vtkCPDataDescription> descrip; vtkNew<vtkCPDataDescription> descrip;
// Form query for catalyst // Form data query for catalyst
catalystCoprocess::dataQuery query catalystCoprocess::dataQuery dataq
( (
vtk::faMeshAdaptor::channelNames.names(), vtk::faMeshAdaptor::channelNames.names(),
when, time_, // timeQuery
descrip.Get() descrip.Get()
); );
// Query catalyst // Query catalyst
HashTable<wordHashSet> expecting = adaptor_().check(query, allFields); const HashTable<wordHashSet> expecting(adaptor_().query(dataq, allFields));
if (expecting.empty()) if (catalystCoprocess::debug)
{ {
Info<< "No data expected for ParaView Catalyst. " << when << endl; if (expecting.empty())
return true; {
Info<< type() << ": expecting no data" << nl;
}
else
{
Info<< type() << ": expecting data " << expecting << nl;
}
} }
else if (catalystCoprocess::debug)
if (expecting.empty())
{ {
Info<< type() << " expecting data:" << expecting << endl; return true;
} }
auto output = vtkSmartPointer<vtkMultiBlockDataSet>::New(); auto output = vtkSmartPointer<vtkMultiBlockDataSet>::New();
// TODO: currently don't rely on the results from expecting much at all // TODO: currently don't rely on the results from expecting much at all
// Store each region in a separate block // Each region in a separate block
unsigned int regionNo = 0; unsigned int regionNo = 0;
for (const word& regionName : regionNames) for (const word& regionName : regionNames)
{ {
#if 1
auto pieces = backends_[regionName]->output(selectFields_); auto pieces = backends_[regionName]->output(selectFields_);
output->SetBlock(regionNo, pieces); output->SetBlock(regionNo, pieces);
...@@ -252,15 +256,14 @@ bool Foam::functionObjects::catalystFaMesh::execute() ...@@ -252,15 +256,14 @@ bool Foam::functionObjects::catalystFaMesh::execute()
vtkCompositeDataSet::NAME(), vtkCompositeDataSet::NAME(),
regionName regionName
); );
#endif
++regionNo; ++regionNo;
} }
if (regionNo) if (regionNo)
{ {
Info<< "Send data to ParaView Catalyst. " << when << endl; Log << type() << ": send data" << nl;
adaptor_().process(query, output); adaptor_().process(dataq, output);
} }
return true; return true;
......
...@@ -50,15 +50,23 @@ Usage ...@@ -50,15 +50,23 @@ Usage
\table \table
Property | Description | Required | Default Property | Description | Required | Default
type | catalyst::area | yes | type | catalyst::area | yes |
log | report extra information | no | false
region | | no | region0 region | | no | region0
regions | wordRe list of regions | no | regions | wordRe list of regions | no |
fields | wordRe list of fields | yes | fields | wordRe list of fields | yes |
scripts | Python pipeline scripts | yes | scripts | Python pipeline scripts | yes |
\endtable \endtable
Note
The execution frequency can be defined by the functionObject and
by the Catalyst pipeline.
See also See also
Foam::functionObjects::functionObject
Foam::functionObjects::fvMeshFunctionObject Foam::functionObjects::fvMeshFunctionObject
Foam::functionObjects::timeControl Foam::functionObjects::timeControl
Foam::catalystCoprocess
Foam::vtk::faMeshAdaptor
SourceFiles SourceFiles
catalystFaMesh.C catalystFaMesh.C
...@@ -153,7 +161,7 @@ public: ...@@ -153,7 +161,7 @@ public:
//- Read the specification //- Read the specification
virtual bool read(const dictionary& dict); virtual bool read(const dictionary& dict);
//- Execute pipeline //- Execute catalyst pipelines
virtual bool execute(); virtual bool execute();
//- Write - does nothing //- Write - does nothing
......
...@@ -42,7 +42,7 @@ License ...@@ -42,7 +42,7 @@ License
namespace Foam namespace Foam
{ {
defineTypeNameAndDebug(catalystCoprocess, 0); defineTypeNameAndDebug(catalystCoprocess, 0);
} }
...@@ -121,64 +121,60 @@ Foam::label Foam::catalystCoprocess::expand ...@@ -121,64 +121,60 @@ Foam::label Foam::catalystCoprocess::expand
template<class DataType> template<class DataType>
bool Foam::catalystCoprocess::processImpl bool Foam::catalystCoprocess::processImpl
( (
const dataQuery& query, const dataQuery& dataq,
HashTable<vtkSmartPointer<DataType>>& outputs vtkSmartPointer<DataType>& output
) )
{ {
vtkCPDataDescription* descrip = query.get(); vtkCPDataDescription* descrip = dataq.get();
if (!coproc_->RequestDataDescription(descrip)) if (!coproc_->RequestDataDescription(descrip))
{ {
return false; return false;
} }
for (const word& channel : query.channels()) for (const word& chanName : dataq.channels())
{ {
if (outputs.found(channel)) auto* input = descrip->GetInputDescriptionByName(chanName.c_str());
{
auto* input = descrip->GetInputDescriptionByName(channel.c_str());
if (input && input->GetIfGridIsNecessary()) if (input && input->GetIfGridIsNecessary())
{ {
input->SetGrid(outputs[channel]); input->SetGrid(output);
}
} }
} }
coproc_->CoProcess(descrip); coproc_->CoProcess(descrip);
return true; return true;
} }
template<class DataType> template<class DataType>
bool Foam::catalystCoprocess::process1Impl bool Foam::catalystCoprocess::processImpl
( (
const dataQuery& query, const dataQuery& dataq,
vtkSmartPointer<DataType>& output HashTable<vtkSmartPointer<DataType>>& outputs
) )
{ {
vtkCPDataDescription* descrip = query.get(); vtkCPDataDescription* descrip = dataq.get();
if (!coproc_->RequestDataDescription(descrip)) if (!coproc_->RequestDataDescription(descrip))
{ {
return false; return false;
} }
for (const word& channel : query.channels()) for (const word& chanName : dataq.channels())
{ {
auto* input = descrip->GetInputDescriptionByName(channel.c_str()); if (outputs.found(chanName))
if (input && input->GetIfGridIsNecessary())
{ {
input->SetGrid(output); auto* input = descrip->GetInputDescriptionByName(chanName.c_str());
}
break; if (input && input->GetIfGridIsNecessary())
{
input->SetGrid(outputs[chanName]);
}
}
} }
coproc_->CoProcess(descrip); coproc_->CoProcess(descrip);
return true; return true;
} }
...@@ -256,14 +252,14 @@ void Foam::catalystCoprocess::reset(const UList<string>& scripts) ...@@ -256,14 +252,14 @@ void Foam::catalystCoprocess::reset(const UList<string>& scripts)
coproc_->AddPipeline(pipeline.GetPointer()); coproc_->AddPipeline(pipeline.GetPointer());
} }
// Do something different with (!nscript) ?? // Do something different with (nscript == 0) ?
} }
Foam::HashTable<Foam::wordHashSet> Foam::HashTable<Foam::wordHashSet>
Foam::catalystCoprocess::check Foam::catalystCoprocess::query
( (
dataQuery& query, dataQuery& dataq,
const wordHashSet& allFields const wordHashSet& allFields
) )
{ {
...@@ -276,37 +272,33 @@ Foam::catalystCoprocess::check ...@@ -276,37 +272,33 @@ Foam::catalystCoprocess::check
return requests; return requests;
} }
if (query.channels().empty()) if (dataq.channels().empty())
{ {
// No channels names have been published by the simulation // No channels names have been published by the simulation
return requests; return requests;
} }
vtkCPDataDescription* descrip = query.get(); vtkCPDataDescription* descrip = dataq.get();
descrip->SetTimeData(query.timeValue, query.timeIndex); descrip->SetTimeData(dataq.timeValue, dataq.timeIndex);
descrip->SetForceOutput(query.forced); descrip->SetForceOutput(dataq.forced);
// Sort out which channels already exist, are new, or disappeared // Sort out which channels already exist, are new, or disappeared
{ {
// The currently defined channels // The currently defined channels
wordHashSet currentChannels; wordHashSet currChannels;
const unsigned n = descrip->GetNumberOfInputDescriptions(); const unsigned n = descrip->GetNumberOfInputDescriptions();
for (unsigned i=0; i < n; ++i) for (unsigned i=0; i < n; ++i)
{ {
currentChannels.insert currChannels.insert
( (
word word::validate(descrip->GetInputDescriptionName(i))
(
descrip->GetInputDescriptionName(i),
false // no stripping (ie, accept bad names too)
)
); );
} }
wordHashSet newChannels(query.channels()); wordHashSet newChannels(dataq.channels());
wordHashSet oldChannels(currentChannels); wordHashSet oldChannels(currChannels);
oldChannels.erase(newChannels); oldChannels.erase(newChannels);
if (oldChannels.size()) if (oldChannels.size())
...@@ -315,14 +307,14 @@ Foam::catalystCoprocess::check ...@@ -315,14 +307,14 @@ Foam::catalystCoprocess::check
} }
else else
{ {
newChannels.erase(currentChannels); newChannels.erase(currChannels);
} }
// Add channels // Add channels
for (const word& channel : newChannels) for (const word& chanName : newChannels)
{ {
descrip->AddInput(channel.c_str()); descrip->AddInput(chanName.c_str());
auto* input = descrip->GetInputDescriptionByName(channel.c_str()); auto* input = descrip->GetInputDescriptionByName(chanName.c_str());
for (const word& fieldName : allFields) for (const word& fieldName : allFields)
{ {
...@@ -344,13 +336,13 @@ Foam::catalystCoprocess::check ...@@ -344,13 +336,13 @@ Foam::catalystCoprocess::check
return requests; return requests;
} }
for (const word& channel : query.channels()) for (const word& chanName : dataq.channels())
{ {
auto* input = descrip->GetInputDescriptionByName(channel.c_str()); auto* input = descrip->GetInputDescriptionByName(chanName.c_str());
if (input && input->GetIfGridIsNecessary()) if (input && input->GetIfGridIsNecessary())
{ {
wordHashSet& fields = requests(channel); wordHashSet& fields = requests(chanName); // auto-vivify
for (const word& fieldName : allFields) for (const word& fieldName : allFields)
{ {
...@@ -368,21 +360,21 @@ Foam::catalystCoprocess::check ...@@ -368,21 +360,21 @@ Foam::catalystCoprocess::check
bool Foam::catalystCoprocess::process bool Foam::catalystCoprocess::process
( (
const dataQuery& query, const dataQuery& dataq,
vtkSmartPointer<vtkMultiBlockDataSet>& output vtkSmartPointer<vtkMultiBlockDataSet>& output
) )
{ {
return process1Impl(query, output); return processImpl(dataq, output);
} }
bool Foam::catalystCoprocess::process bool Foam::catalystCoprocess::process
( (
const dataQuery& query, const dataQuery& dataq,
HashTable<vtkSmartPointer<vtkMultiBlockDataSet>>& outputs HashTable<vtkSmartPointer<vtkMultiBlockDataSet>>& outputs
) )
{ {
return processImpl(query, outputs); return processImpl(dataq, outputs);
} }
......
...@@ -28,24 +28,18 @@ Description ...@@ -28,24 +28,18 @@ Description
Low-level interface between OpenFOAM and ParaView Catalyst. Low-level interface between OpenFOAM and ParaView Catalyst.
\code \code
... initialize catalyst ... initialize catalyst
... define a data query for catalyst ... define a data query for catalyst
// Data description for co-processing // Data description for co-processing
vtkNew<vtkCPDataDescription> descrip; vtkNew<vtkCPDataDescription> descrip;
// Form query for catalyst // Form data query for catalyst
catalystCoprocess::dataQuery query catalystCoprocess::dataQuery dataq(channelNames, runTime, descrip.Get());
(
vtkPVFoam::channelNames.names(),
when,
descrip.Get()
);
// Query catalyst // Query catalyst
HashTable<wordHashSet> expecting = adaptor_().check(query, allFields); HashTable<wordHashSet> expecting = adaptor_().query(dataq, fields);
\endcode \endcode
...@@ -116,9 +110,8 @@ public: ...@@ -116,9 +110,8 @@ public:
: :
public timeQuery public timeQuery
{ {
//- Catalyst channels to query //- Catalyst channel names to query
List<word> channels_; List<word> channels_;
mutable vtkCPDataDescription* descrip_; mutable vtkCPDataDescription* descrip_;
public: public:
...@@ -169,18 +162,20 @@ private: ...@@ -169,18 +162,20 @@ private:
// Private Member Functions // Private Member Functions
//- Process single output channel
template<class DataType> template<class DataType>
bool processImpl bool processImpl
( (
const dataQuery& query, const dataQuery& query,
HashTable<vtkSmartPointer<DataType>>& outputs vtkSmartPointer<DataType>& outputs
); );
//- Process multiple output channels
template<class DataType> template<class DataType>
bool process1Impl bool processImpl
( (
const dataQuery& query, const dataQuery& query,
vtkSmartPointer<DataType>& outputs HashTable<vtkSmartPointer<DataType>>& outputs
); );
public: public:
...@@ -223,36 +218,34 @@ public: ...@@ -223,36 +218,34 @@ public:
//- Query the coprocess pipelines if they should be executed at this //- Query the coprocess pipelines if they should be executed at this
//- iteration and possibly which fields they require. //- iteration and possibly which fields they require.
// //
// \param[in,out] query for catalyst. // \param[in,out] dataq the data query for catalyst.
// On input it contains the published channel names, the current // On input it contains the published channel names, the current
// simulation time (index, value) and allocation for the coprocess // simulation time (index, value) and allocation for the coprocess
// data description. // data description.
// On output the data description willbe filled with the field names // On output the data description will be filled with the field
// contains the published channel names, the current // names added per channel.
// \param[in] allFields the fields that can be published from the // \param[in] allFields the fields that can be published from the
// simulation. // simulation.
// //
// \return HashTable with fields requested (what Catalyst expects) // \return HashTable with fields requested (what Catalyst expects)
// on a per-channel basis. // on a per-channel basis.
HashTable<wordHashSet> check HashTable<wordHashSet> query
( (
dataQuery& query, dataQuery& dataq,
const wordHashSet& allFields const wordHashSet& allFields
); );
//- Single-channel source (eg, "input" or "cloud", ...) //- Single-channel source (eg, "input" or "cloud", ...)
// Uses the currentTime values
bool process bool process
( (
const dataQuery& query, const dataQuery& dataq,
vtkSmartPointer<vtkMultiBlockDataSet>& output vtkSmartPointer<vtkMultiBlockDataSet>& output
); );
//- Multi-channel source (eg, "input", "mesh", "patches") //- Multi-channel source (eg, "input", "mesh", "patches")
// Uses the currentTime values
bool process bool process
( (
const dataQuery& query, const dataQuery& dataq,
HashTable<vtkSmartPointer<vtkMultiBlockDataSet>>& outputs HashTable<vtkSmartPointer<vtkMultiBlockDataSet>>& outputs
); );
......
...@@ -123,8 +123,6 @@ bool Foam::functionObjects::catalystCloud::execute() ...@@ -123,8 +123,6 @@ bool Foam::functionObjects::catalystCloud::execute()
return true; return true;
} }
const catalystCoprocess::timeQuery when(time_);
// Enforce sanity for backends and adaptor // Enforce sanity for backends and adaptor
{ {
if (!adaptor_.valid()) if (!adaptor_.valid())
...@@ -143,30 +141,37 @@ bool Foam::functionObjects::catalystCloud::execute() ...@@ -143,30 +141,37 @@ bool Foam::functionObjects::catalystCloud::execute()
// Data description for co-processing // Data description for co-processing
vtkNew<vtkCPDataDescription> descrip; vtkNew<vtkCPDataDescription> descrip;
// Form query for catalyst // Form data query for catalyst
catalystCoprocess::dataQuery query catalystCoprocess::dataQuery dataq
( (
vtk::cloudAdaptor::channelNames.names(), vtk::cloudAdaptor::channelNames.names(),
when, time_, // timeQuery
descrip.Get() descrip.Get()
); );
// Query catalyst // Query catalyst
HashTable<wordHashSet> expecting = adaptor_().check(query, allFields); const HashTable<wordHashSet> expecting(adaptor_().query(dataq, allFields));
if (expecting.empty()) if (catalystCoprocess::debug)
{ {
Info<< "No data expected for ParaView Catalyst. " << when << endl; if (expecting.empty())
return true; {
Info<< type() << ": expecting no data" << nl;
}
else
{
Info<< type() << ": expecting data " << expecting << nl;
}
} }
else if (catalystCoprocess::debug)
if (expecting.empty())
{ {
Info<< type() << " expecting data:" << expecting << endl; return true;
} }
auto output = vtkSmartPointer<vtkMultiBlockDataSet>::New(); auto output = vtkSmartPointer<vtkMultiBlockDataSet>::New();
// Store each cloud in a separate block // Each cloud in a separate block.
unsigned int cloudNo = 0; unsigned int cloudNo = 0;
for (const word& cloudName : cloudNames) for (const word& cloudName : cloudNames)
{ {