31 #define __Exporter_H 1
33 #include <feel/feelcore/feel.hpp>
38 #include <feel/feeldiscr/timeset.hpp>
44 EXPORTER_GEOMETRY_STATIC = 0,
45 EXPORTER_GEOMETRY_CHANGE_COORDS_ONLY = 1,
46 EXPORTER_GEOMETRY_CHANGE = 2
81 template<
typename MeshType,
int N = 1>
97 typedef typename timeset_type::mesh_type mesh_type;
98 typedef typename timeset_type::mesh_ptrtype mesh_ptrtype;
99 typedef boost::shared_ptr<timeset_type> timeset_ptrtype;
100 typedef std::vector<timeset_ptrtype> timeset_set_type;
101 typedef typename timeset_set_type::iterator timeset_iterator;
102 typedef typename timeset_set_type::const_iterator timeset_const_iterator;
104 typedef typename timeset_type::step_ptrtype step_ptrtype;
118 Exporter( WorldComm
const& worldComm = Environment::worldComm() );
127 std::string
const&
prefix =
"",
129 WorldComm
const& worldComm = Environment::worldComm() );
137 Exporter( po::variables_map
const& vm,
138 std::string
const& exporter_prefix =
"",
139 WorldComm
const& worldComm = Environment::worldComm() );
156 static boost::shared_ptr<Exporter<MeshType,N> >
New( std::string
const& exportername,
157 std::string
prefix = Environment::about().appName(),
158 WorldComm
const& worldComm = Environment::worldComm() );
165 static boost::shared_ptr<Exporter<MeshType,N> >
New( po::variables_map
const& vm = Environment::vm(),
166 std::string
prefix = Environment::about().appName(),
167 WorldComm
const& worldComm = Environment::worldComm() );
193 std::string
const&
type()
const
250 M_do_export = do_export;
308 timeset_iterator beginTimeSet()
310 return M_ts_set.begin();
312 timeset_iterator endTimeSet()
314 return M_ts_set.end();
317 timeset_const_iterator beginTimeSet()
const
319 return M_ts_set.begin();
321 timeset_const_iterator endTimeSet()
const
323 return M_ts_set.end();
327 timeset_ptrtype defaultTimeSet()
329 return M_ts_set.front();
331 timeset_ptrtype timeSet(
int ts )
336 bool useSingleTransientFile()
const
338 return M_use_single_transient_file;
340 void setUseSingleTransientFile(
bool s )
342 M_use_single_transient_file = s;
345 setMesh( mesh_ptrtype mesh, ExporterGeometry exgeo = EXPORTER_GEOMETRY_CHANGE_COORDS_ONLY )
347 M_ex_geometry = exgeo;
348 M_ts_set.back()->setMesh( mesh );
353 add( std::string
const& name, F
const& u )
355 this->step( 0 )->add( this->
prefix()+
"."+name, u );
361 this->step( 0 )->addRegions( this->
prefix() );
363 step_ptrtype step(
double time )
366 return M_ts_set.back()->step( time,
true );
369 return M_ts_set.back()->step( time,
false );
371 step_ptrtype step(
double time,
int s )
373 if ( M_cptOfSave % this->
freq() )
374 return M_ts_set[s]->step( time,
true );
377 return M_ts_set[s]->step( time,
false );
392 M_ts_set.push_back( __ts );
400 virtual void save()
const = 0;
407 if ( this->worldComm().rank() != this->worldComm().masterRank() )
413 auto __ts_it = this->beginTimeSet();
414 auto __ts_en = this->endTimeSet();
416 for ( ; __ts_it != __ts_en ; ++__ts_it )
418 auto filename = this->
path()+
"/"+
prefix()+
".timeset";
419 ( *__ts_it )->save( filename );
430 auto __ts_it = this->beginTimeSet();
431 auto __ts_en = this->endTimeSet();
433 for ( ; __ts_it != __ts_en ; ++__ts_it )
435 auto filename = this->
path()+
"/"+
prefix()+
".timeset";
436 ( *__ts_it )->load( filename,__time );
438 M_cptOfSave = ( *__ts_it )->numberOfTotalSteps()+1;
442 void setWorldComm( WorldComm
const& wc )
446 WorldComm
const& worldComm()
const
451 ExporterGeometry exporterGeometry()
const {
return M_ex_geometry; }
455 WorldComm M_worldComm;
458 bool M_use_single_transient_file;
460 std::string M_prefix;
462 mutable int M_cptOfSave;
465 ExporterGeometry M_ex_geometry;
467 mutable timeset_set_type M_ts_set;
475 template<
typename Args>
476 struct compute_exporter_return
478 typedef typename boost::remove_pointer<
479 typename boost::remove_const<
480 typename boost::remove_reference<
481 typename parameter::binding<Args, tag::mesh>::type
484 >::type::element_type mesh_type;
488 typedef Exporter<mesh_type,mesh_type::nOrder> type;
489 typedef boost::shared_ptr<type> ptrtype;
494 BOOST_PARAMETER_FUNCTION( (
typename Feel::detail::compute_exporter_return<Args>::ptrtype ),
501 ( fileset, *, option(_name=
"exporter.fileset").
template as<bool>() )
502 ( order, *, mpl::int_<1>() )
503 ( name, *, Environment::about().appName() )
504 ( geo, *, option(_name=
"exporter.geometry").
template as<int>() )
505 ( worldcomm, *, Environment::worldComm() )
509 auto e = exporter_type::New(Environment::vm(),name,worldcomm);
510 e->setPrefix( name );
511 e->setUseSingleTransientFile( fileset );
512 e->setMesh( mesh, (ExporterGeometry) geo );
Exporter< MeshType, N > * setFreq(int __freq)
Definition: exporter.hpp:293
The base class of any Acyclic Visitor.
Definition: visitor.hpp:52
int cptOfSave() const
Definition: exporter.hpp:218
virtual Exporter< MeshType, N > * setOptions(std::string const &exp_prefix="")
Definition: exporterimpl.hpp:175
Definition: visitor.hpp:89
virtual Exporter< MeshType, N > * setOptions(po::variables_map const &vm, std::string const &exp_prefix="") FEELPP_DEPRECATED
Definition: exporter.hpp:263
Exporter< MeshType, N > * setPrefix(std::string const &__prefix)
Definition: exporter.hpp:284
Exporter< MeshType, N > * setType(std::string const &__type)
Definition: exporter.hpp:269
export Feel generated data to some file formatsUse the visitor and factory pattern.
Definition: exporter.hpp:82
void saveTimeSet() const
Definition: exporter.hpp:405
std::string path() const
Definition: exporter.hpp:234
file_type fileType() const
Definition: exporter.hpp:226
data TimeSet
Definition: timeset.hpp:90
#define FEELPP_DEPRECATED
Definition: feelmacros.hpp:352
void addTimeSet(timeset_ptrtype const &__ts)
Definition: exporter.hpp:389
void setDoExport(bool do_export)
Definition: exporter.hpp:248
std::string const & prefix() const
Definition: exporter.hpp:201
Exporter< MeshType, N > * setFileType(file_type __ft)
Definition: exporter.hpp:302
static boost::shared_ptr< Exporter< MeshType, N > > New(std::string const &exportername, std::string prefix=Environment::about().appName(), WorldComm const &worldComm=Environment::worldComm())
Definition: exporterimpl.hpp:127
virtual void save() const =0
a step in a time set
Definition: timeset.hpp:126
bool doExport() const
Definition: exporter.hpp:185
Exporter(WorldComm const &worldComm=Environment::worldComm())
Definition: exporterimpl.hpp:50
std::string const & type() const
Definition: exporter.hpp:193
void restart(double __time)
Definition: exporter.hpp:428
int freq() const
Definition: exporter.hpp:209
virtual ~Exporter()
Definition: exporterimpl.hpp:122
implement the Singleton pattern
Definition: singleton.hpp:57
Exporter< MeshType, N > * addPath(boost::format fmt)
Definition: exporterimpl.hpp:199