79 typedef std::string String;
88 m_evaluator(evaluator),
92 std::string path = gsFileManager::getPath(m_filename);
95 if ( !gsFileManager::isFullyQualified(path) )
96 path = gsFileManager::getCurrentPath() + path;
98 m_filename = path + gsFileManager::getBasename(m_filename) +
".pvd";
99 gsFileManager::mkdir( path );
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 =
"";
117 if (gsFileManager::getExtension(fn) ==
"")
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)
158 addPart( fn+
"_"+std::to_string(part)+ext, tstep,
"", part);
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 );
258inline void makeCollection(std::string
const & fn, std::string
const & ext,
int n = 0)
263 for (
int i=0; i<n ; i++)
264 pc.
addPart(fn + std::to_string(i) + ext);
Generic evaluator of isogeometric expressions.
Definition gsExprEvaluator.h:39
Class which holds a list of parameters/options, and provides easy access to them.
Definition gsOptionList.h:33
This class is used to create a Paraview .pvd (collection) file.
Definition gsParaviewCollection.h:77
void addFields(Rest... rest)
All arguments are forwarded to gsParaviewDataSet::addFields().
Definition gsParaviewCollection.h:189
bool m_isSaved
Flag for checking if collection is already saved.
Definition gsParaviewCollection.h:233
gsParaviewCollection(String const &fn, gsExprEvaluator<> *evaluator=nullptr)
Constructor using a filename and an (optional) evaluator.
Definition gsParaviewCollection.h:83
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
void saveTimeStep()
The current timestep is saved and files written to disk.
Definition gsParaviewCollection.h:196
void save()
Definition gsParaviewCollection.h:203
void addField(Rest... rest)
All arguments are forwarded to gsParaviewDataSet::addField().
Definition gsParaviewCollection.h:181
std::string m_filename
File name.
Definition gsParaviewCollection.h:230
std::stringstream mfile
Pointer to char stream.
Definition gsParaviewCollection.h:227
gsOptionList & options()
Accessor to the current options.
Definition gsParaviewCollection.h:223
This class represents a group of vtk (Paraview) files that refer to one multiPatch,...
Definition gsParaviewDataSet.h:38
#define index_t
Definition gsConfig.h:32
#define gsDebug
Definition gsDebug.h:61
#define GISMO_ERROR(message)
Definition gsDebug.h:118
#define GISMO_ENSURE(cond, message)
Definition gsDebug.h:102
#define GISMO_ASSERT(cond, message)
Definition gsDebug.h:89
Utility class for finding files and handling paths.
Provides forward declarations of types and structs.
Provides a helper class to write Paraview (.vts) files.
The G+Smo namespace, containing all definitions for the library.
void makeCollection(std::string const &fn, std::string const &ext, int n=0)
Definition gsParaviewCollection.h:258