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
simget.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: 2010-07-15
7 
8  Copyright (C) 2010-2011 Université 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 2.1 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 __Simget_H
30 #define __Simget_H 1
31 
32 #include <boost/property_tree/ptree.hpp>
33 #include <boost/property_tree/xml_parser.hpp>
34 
35 #include <feel/feelcore/feel.hpp>
36 #include <feel/feelcore/about.hpp>
39 
40 namespace Feel
41 {
42 namespace ptree = boost::property_tree;
43 
44 class Application;
45 
60 class Simget
61 {
62 public:
63 
64 
68 
69 
71 
75 
76 
78 
82 
86  Simget();
87 
89  virtual ~Simget() {}
90 
92 
96 
98  Simget& operator=( Simget const & o )
99  {
100  if ( this != &o )
101  {
102  }
103 
104  return *this;
105  }
107 
111 
113  virtual std::string name() const
114  {
115  return M_about.appName();
116  }
117 
119  mpi::communicator comm() const
120  {
121  return M_comm;
122  }
123 
125  po::variables_map const& vm() const
126  {
127  return M_vm;
128  }
129 
131  AboutData const& about() const
132  {
133  return M_about;
134  }
135 
137  double meshSize() const
138  {
139  return M_meshSize;
140  }
142  double meshSizeInit() const
143  {
144  return M_meshSizeInit;
145  }
146 
148  int level() const
149  {
150  return M_level;
151  }
152 
154  ptree::ptree const& stats() const
155  {
156  return M_stats;
157  }
159  ptree::ptree& stats()
160  {
161  return M_stats;
162  }
163 
165 
169 
171  void setMeshSize( double h )
172  {
173  M_meshSize= h;
174  }
175 
177  void setMeshSizeInit( double h )
178  {
179  M_meshSizeInit = h;
180  }
181 
183  void setLevel( int level )
184  {
185  M_level= level;
186  }
187 
189 
193 
197  virtual void run() = 0;
198 
202  virtual void run( const double* X, unsigned long P, double* Y, unsigned long N ) { run(); };
203 
207  void print( std::ostream& out, std::vector<ptree::ptree> & stats );
208 
210 
211 protected:
212 
213  friend class Application;
214 
218  Simget& changeRepository( boost::format fmt );
219 
220 protected:
221  double M_meshSize;
222  double M_meshSizeInit;
223  int M_level;
224  ptree::ptree M_stats;
225 private:
226  mpi::communicator M_comm;
227  po::variables_map M_vm;
228  AboutData M_about;
229 
230 
231 };
232 
233 
238 
239 #if 0
240 template<typename SimgetType>
241 Simget*
242 createSimget( AboutData cponst& about )
243 {
244  return new SimgetType( about );
245 }
246 
247 #define REGISTER_SIMGET_IN_FACTORY( simget, simgetname, about ) \
248  SimgetFactory::instance().registerProduct( simgetname, &createSimget<simget>( about )
249 
250 #if defined( FEELPP_HAS_OCT_H )
251 #define OCTNAME(name,dim, order) BOOST_PP_CAT(BOOST_PP_CAT(BOOST_PP_CAT(name,dim),_),order)
252 
253 #define REGISTER_SIMGET( dim, order ) \
254  DEFUN_DLD (OCTNAME(residualestimator_,dim,order), args, nargout, "Residual Estimator for the Laplacian") \
255  { \
256  int nargin = args.length (); \
257  if (nargin != 1) \
258  print_usage (); \
259  else \
260  { \
261  NDArray A = args(0).array_value (); \
262  dim_vector dims = A.dims(); \
263  dim_vector ydims(1); \
264  ydims(0)=4; \
265  \
266  NDArray Y(ydims); \
267  { \
268  static bool is_init = false; \
269  if ( !is_init ) \
270  { \
271  if (!Feel::Environment::initialized() ) \
272  new Feel::Environment(); \
273  is_init = true; \
274  } \
275  boost::shared_ptr<ResidualEstimator<dim,order> > OCTNAME(app_,dim,order)( new ResidualEstimator<dim,order>( makeAbout() ) ); \
276  std::vector<double> x( dims(0) ); \
277  for( int j = 0; j < dims(0); ++j ) \
278  { \
279  x[j] = A(j); \
280  std::cout << "x["<< j << "]=" << x[j] << "\n"; \
281  } \
282  std::vector<double> y( 4 ); \
283  OCTNAME(app_,dim,order)->run( x.data(), dims(1), y.data(), 4 ); \
284  Y(0)=y[0]; \
285  Y(1)=y[1]; \
286  Y(2)=y[2]; \
287  Y(3)=y[3]; \
288  } \
289  if (! error_state) \
290  return octave_value (Y); \
291  } \
292  return octave_value_list (); \
293  }
294 
295 
296 
297 #endif /* FEELPP_HAS_OCT_H */
298 #endif // 0
299 }
300 #endif /* __Simget_H */
virtual void run(const double *X, unsigned long P, double *Y, unsigned long N)
Definition: simget.hpp:202
Simulation Object.
Definition: simget.hpp:60
provides information about the Application
Definition: application.hpp:71
void setMeshSize(double h)
set the mesh size
Definition: simget.hpp:171
po::variables_map const & vm() const
Definition: simget.hpp:125
Holds information needed by the &quot;About&quot; box and other classes.
Definition: about.hpp:173
AboutData const & about() const
Definition: simget.hpp:131
void setLevel(int level)
set the refinment level if applicable
Definition: simget.hpp:183
mpi::communicator comm() const
Definition: simget.hpp:119
Simget & operator=(Simget const &o)
copy operator
Definition: simget.hpp:98
double meshSize() const
return the mesh size
Definition: simget.hpp:137
void print(std::ostream &out, std::vector< ptree::ptree > &stats)
Definition: simget.cpp:50
int level() const
return the refinement level
Definition: simget.hpp:148
Singleton< Factory< Simget, std::string > > SimgetFactory
Definition: simget.hpp:237
virtual ~Simget()
destructor
Definition: simget.hpp:89
ptree::ptree & stats()
return the statistics associated to the simget after calling run
Definition: simget.hpp:159
virtual std::string name() const
return the name of the simget
Definition: simget.hpp:113
double meshSizeInit() const
return the mesh size
Definition: simget.hpp:142
virtual void run()=0
ptree::ptree const & stats() const
return the statistics associated to the simget after calling run
Definition: simget.hpp:154
implement the Singleton pattern
Definition: singleton.hpp:57
Simget()
Definition: simget.cpp:36
void setMeshSizeInit(double h)
set the initial mesh size
Definition: simget.hpp:177
std::string appName() const
Definition: about.cpp:225
Simget & changeRepository(boost::format fmt)
Definition: simget.cpp:43

Generated on Sun Dec 22 2013 13:11:13 for Feel++ by doxygen 1.8.5