Logo  0.95.0-final
Finite Element Embedded Library and Language in C++
Feel++ Feel++ on Github Feel++ community
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
exporterquick.hpp
Go to the documentation of this file.
1 /* -*- mode: c++; coding: utf-8; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4; show-trailing-whitespace: t -*- vim:fenc=utf-8:ft=tcl:et:sw=4:ts=4:sts=4
2 
3  This file is part of the Feel library
4 
5  Author(s): Christophe Prud'homme <christophe.prudhomme@feelpp.org>
6  Date: 2008-02-21
7 
8  Copyright (C) 2008 Universite Joseph Fourier (Grenoble I)
9 
10  This library is free software; you can redistribute it and/or
11  modify it under the terms of the GNU Lesser General Public
12  License as published by the Free Software Foundation; either
13  version 3.0 of the License, or (at your option) any later version.
14 
15  This library is distributed in the hope that it will be useful,
16  but WITHOUT ANY WARRANTY; without even the implied warranty of
17  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
18  Lesser General Public License for more details.
19 
20  You should have received a copy of the GNU Lesser General Public
21  License along with this library; if not, write to the Free Software
22  Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
23 */
29 #ifndef __FEELPP_EXPORTERQUICK_HPP__
30 #define __FEELPP_EXPORTERQUICK_HPP__ 1
31 #include <feel/feelfilters/exporter.hpp>
32 #include <feel/feelfilters/exporterensight.hpp>
33 #include <feel/feelfilters/exportergmsh.hpp>
34 
35 namespace Feel
36 {
42 template<typename MeshType>
44 {
45 public:
46  typedef MeshType mesh_type;
47  typedef boost::shared_ptr<mesh_type> mesh_ptrtype;
49  typedef boost::shared_ptr<export_type> export_ptrtype;
50  typedef typename export_type::timeset_type timeset_type;
51  typedef typename export_type::timeset_ptrtype timeset_ptrtype;
52 
53  ExporterQuick( std::string const& name, po::variables_map& vm )
54  :
55  exporter( new ExporterEnsight<mesh_type,1> ( vm )),//Exporter<mesh_type>::New( vm["exporter"].template as<std::string>() )->setOptions( vm ) ),
56  timeSet( new timeset_type( name ) )
57  {
58  exporter->setOptions( vm );
59  timeSet->setTimeIncrement( 1.0 );
60  exporter->addTimeSet( timeSet );
61  exporter->setPrefix( name );
62 
63  }
64  ExporterQuick( std::string const& name, std::string const& exp )
65  :
66  exporter( new ExporterEnsight<mesh_type,1> ( exp ) ),//Exporter<mesh_type>::New( exp ) ),
67  timeSet( new timeset_type( name ) )
68  {
69  timeSet->setTimeIncrement( 1.0 );
70  exporter->addTimeSet( timeSet );
71  exporter->setPrefix( name );
72 
73  }
74  void save( mesh_ptrtype const& mesh )
75  {
76  if ( !mesh )
77  {
78  FEELPP_ASSERT( mesh ).error( "[ExporterQuick] invalid mesh (=0)" );
79  return;
80  }
81 
82  typename timeset_type::step_ptrtype timeStep = timeSet->step( 0 );
83  timeStep->setMesh( mesh );
84 
85  exporter->save();
86  }
87 
88  template<typename F1>
89  void save( double time, F1 const& f1 )
90  {
91  typename timeset_type::step_ptrtype timeStep = timeSet->step( time );
92  timeStep->setMesh( f1.functionSpace()->mesh() );
93 
94  timeStep->add( f1.name(), f1 );
95 
96  exporter->save();
97  }
98 
99  template<typename F1, typename F2>
100  void save( double time, F1 const& f1, F2 const& f2 )
101  {
102  typename timeset_type::step_ptrtype timeStep = timeSet->step( time );
103  timeStep->setMesh( f1.functionSpace()->mesh() );
104 
105  timeStep->add( f1.name(), f1 );
106  timeStep->add( f2.name(), f2 );
107 
108  exporter->save();
109  }
110 
111 
112  template<typename F1, typename F2, typename F3>
113  void save( double time, F1 const& f1, F2 const& f2, F3 const& f3 )
114  {
115  typename timeset_type::step_ptrtype timeStep = timeSet->step( time );
116  timeStep->setMesh( f1.functionSpace()->mesh() );
117 
118  timeStep->add( f1.name(), f1 );
119  timeStep->add( f2.name(), f2 );
120  timeStep->add( f3.name(), f3 );
121 
122  exporter->save();
123  }
124 
125 private:
126  export_ptrtype exporter;
127  timeset_ptrtype timeSet;
128 };
129 
130 }
131 #endif // __FEELPP_EXPORTERQUICK_HPP__

Generated on Sun Oct 20 2013 08:24:57 for Feel++ by doxygen 1.8.4