G+Smo  24.08.0
Geometry + Simulation Modules
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
gsParaviewCollection Class Reference

Detailed Description

This class is used to create a Paraview .pvd (collection) file.

A collection is an XML file that contains a list of other files to be opened in Paraview.

Typical usage is

gsParaviewCollection pc(fn); // Initialize collection

// add files ("parts"), make sure that these files exist
pc.addPart(filename1);
pc.addPart(filename2);

pc.save() // finalize and close the file

Or when working with gsExpressions:

gsParaviewCollection pc(fn, &evaluator ); // Initialize collection

// Specify plotting options
pc.options().setInt("numPoints", 100);
pc.options().setInt("precision",5);
pc.options().setSwitch("plotElements",true);
pc.options().setSwitch("plotControlNet",true);

// In your solution loop:
while ( ... )
{
    // Create new file(s) for this timestep
    pc.newTimestep(&multiPatch)
    // Solve here 

    // Write solution fields ( e.g Pressure, Temperature, Stress )
    pc.addField( gsExpression_1, "label_1" );
    pc.addField( gsExpression_2, "label_2" );
    pc.saveTimeStep(); // Save file(s) for this timestep
} // end solution loop

pc.save() // finalize and close the .pvd file

The above creates a file with extension pvd. When opening this file with Paraview, the contents of all parts in the list are loaded.

+ Collaboration diagram for gsParaviewCollection:

Public Member Functions

void addDataSet (gsParaviewDataSet &dataSet, real_t time=-1)
 Adds all the files relevant to a gsParaviewDataSet, to the collection. More...
 
template<typename... Rest>
void addField (Rest...rest)
 All arguments are forwarded to gsParaviewDataSet::addField().
 
template<typename... Rest>
void addFields (Rest...rest)
 All arguments are forwarded to gsParaviewDataSet::addFields().
 
void addPart (String const &fn, real_t tStep=-1, std::string name="", index_t part=-1)
 Appends a file to the Paraview collection (.pvd file). More...
 
 gsParaviewCollection (String const &fn, gsExprEvaluator<> *evaluator=nullptr)
 Constructor using a filename and an (optional) evaluator.
 
void newTimeStep (gsMultiPatch< real_t > *geometry, real_t time=-1)
 Creates a new time step where all information will be added to. More...
 
gsOptionListoptions ()
 Accessor to the current options.
 
void save ()
 
void saveTimeStep ()
 The current timestep is saved and files written to disk.
 

Private Attributes

std::string m_filename
 File name.
 
bool m_isSaved
 Flag for checking if collection is already saved.
 
std::stringstream mfile
 Pointer to char stream.
 

Member Function Documentation

void addDataSet ( gsParaviewDataSet dataSet,
real_t  time = -1 
)

Adds all the files relevant to a gsParaviewDataSet, to the collection.

Parameters
dataSetThe gsParaviewDataSet to be added.
timeTime step (optional, else an internal integer counter is used)
void addPart ( String const &  fn,
real_t  tStep = -1,
std::string  name = "",
index_t  part = -1 
)
inline

Appends a file to the Paraview collection (.pvd file).

Parameters
fnFilename to be added. Can also be a path relative to the where the collection file is.
tStepTime step ( optional )
nameAn optional name for this part. This is the name that will show up in Paraview's MultiBlock inspector for this Part. It is not the filename.
partPart ID ( optional )
void newTimeStep ( gsMultiPatch< real_t > *  geometry,
real_t  time = -1 
)

Creates a new time step where all information will be added to.

Parameters
geometryA gsMultiPatch of the geometry where the solution fields are defined.
timeValue of time for this timestep (optional, else an internal integer counter is used)
void save ( )
inline

Finalizes the collection by closing the XML tags, always call this function (once) when you finish adding files