79 typedef std::string String;
88 m_evaluator(evaluator),
104 mfile <<
"<?xml version=\"1.0\"?>\n";
105 mfile <<
"<VTKFile type=\"Collection\" version=\"0.1\">\n";
106 mfile <<
"<Collection>\n";
114 void addPart(String
const & fn, real_t tStep=-1, std::string name=
"",
index_t part=-1)
116 std::string ext =
"";
119 if (name==
"Mesh" || name==
"mesh")
121 else if (name==
"Geometry" || name==
"geometry" || name==
"Solution" || name==
"solution")
124 GISMO_ERROR(
"No extension could be found for file "<<fn<<
". Try to add an extension or add name 'Mesh','Solution','Geometry'");
127 GISMO_ASSERT( !m_isSaved ,
"Error: collection has been already saved." );
128 mfile <<
"<DataSet ";
129 if (part != -1) mfile <<
"part=\""<< part <<
"\" ";
130 if (tStep != -1) mfile <<
"timestep=\""<< tStep <<
"\" ";
131 if (name !=
"") mfile <<
"name=\"" << name <<
"\" ";
132 mfile <<
"file=\"" << fn+ext <<
"\"/>\n";
149 GISMO_DEPRECATED
void addTimestep(String
const & fn,
double tstep, String
const & ext)
152 addPart( fn+ext, tstep);
155 GISMO_DEPRECATED
void addTimestep(String
const & fn,
int part,
double tstep, String
const & ext)
163 GISMO_DEPRECATED
void addPart(String
const & fn, String extension)
165 addPart( fn+extension);
171 void addDataSet(gsParaviewDataSet & dataSet, real_t time=-1);
176 void newTimeStep(gsMultiPatch<real_t> * geometry, real_t time=-1);
180 template <
typename... Rest>
183 GISMO_ENSURE( !m_dataset.isEmpty(),
"The gsParaviewDataSet, stored internally by gsParaviewCollection, is empty! Try running newTimestep() before addField().");
184 m_dataset.addField(rest...);
188 template <
typename... Rest>
191 GISMO_ENSURE( !m_dataset.isEmpty(),
"The gsParaviewDataSet, stored internally by gsParaviewCollection, is empty! Try running newTimestep() before addFields().");
192 m_dataset.addFields(rest...);
197 GISMO_ENSURE( !m_dataset.isEmpty(),
"The gsParaviewDataSet, stored internally by gsParaviewCollection, is empty! Try running newTimestep() before saveTimeStep().");
198 addDataSet(m_dataset,m_time);
205 GISMO_ASSERT(!m_isSaved,
"Error: gsParaviewCollection::save() already called." );
208 mfile <<
"</Collection>\n";
209 mfile <<
"</VTKFile>\n";
211 gsDebug <<
"Exporting to " << m_filename <<
"\n";
212 std::ofstream f( m_filename.c_str() );
213 GISMO_ASSERT(f.is_open(),
"Error creating "<< m_filename );
258 inline void makeCollection(std::string
const & fn, std::string
const & ext,
int n = 0)
263 for (
int i=0; i<n ; i++)
std::stringstream mfile
Pointer to char stream.
Definition: gsParaviewCollection.h:227
void addFields(Rest...rest)
All arguments are forwarded to gsParaviewDataSet::addFields().
Definition: gsParaviewCollection.h:189
#define gsDebug
Definition: gsDebug.h:61
static std::string getBasename(std::string const &fn)
Returns the base name without path and extension of the filename fn.
Definition: gsFileManager.cpp:579
void addField(Rest...rest)
All arguments are forwarded to gsParaviewDataSet::addField().
Definition: gsParaviewCollection.h:181
static std::string getExtension(std::string const &fn)
Returns the extension of the filename fn.
Definition: gsFileManager.cpp:568
#define index_t
Definition: gsConfig.h:32
#define GISMO_ENSURE(cond, message)
Definition: gsDebug.h:102
#define GISMO_ASSERT(cond, message)
Definition: gsDebug.h:89
std::string to_string(const unsigned &i)
Helper to convert small unsigned to string.
Definition: gsXml.cpp:74
void saveTimeStep()
The current timestep is saved and files written to disk.
Definition: gsParaviewCollection.h:196
void save()
Definition: gsParaviewCollection.h:203
static std::string getCurrentPath()
Get current directory.
Definition: gsFileManager.cpp:401
Provides forward declarations of types and structs.
Generic evaluator of isogeometric expressions.
Definition: gsExprEvaluator.h:38
bool m_isSaved
Flag for checking if collection is already saved.
Definition: gsParaviewCollection.h:233
This class is used to create a Paraview .pvd (collection) file.
Definition: gsParaviewCollection.h:76
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).
Definition: gsParaviewCollection.h:114
static std::string getPath(std::string const &fn, bool resolve=false)
Definition: gsFileManager.cpp:608
This class represents a group of vtk (Paraview) files that refer to one multiPatch, for one timestep.
Definition: gsParaviewDataSet.h:36
std::string m_filename
File name.
Definition: gsParaviewCollection.h:230
static bool isFullyQualified(const std::string &fn)
Checks if the path is fully qualified, also known as "absolute path" Under Unix, if a name starts wit...
Definition: gsFileManager.cpp:152
Utility class for finding files and handling paths.
#define GISMO_ERROR(message)
Definition: gsDebug.h:118
static bool mkdir(std::string fn)
Make directory.
Definition: gsFileManager.cpp:328
Class which holds a list of parameters/options, and provides easy access to them. ...
Definition: gsOptionList.h:32
gsParaviewCollection(String const &fn, gsExprEvaluator<> *evaluator=nullptr)
Constructor using a filename and an (optional) evaluator.
Definition: gsParaviewCollection.h:83
void makeCollection(std::string const &fn, std::string const &ext, int n=0)
Definition: gsParaviewCollection.h:258
gsOptionList & options()
Accessor to the current options.
Definition: gsParaviewCollection.h:223
Provides a helper class to write Paraview (.vts) files.