OpenFCST: The open-source Fuel Cell Simulation Toolbox
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
application_data.h
Go to the documentation of this file.
1 // ----------------------------------------------------------------------------
2 //
3 // FCST: Fuel Cell Simulation Toolbox
4 //
5 // Copyright (C) 2006-2009 by Guido Kanschat
6 // Copyright (C) 2006-2015 by Energy Systems Design Laboratory, University of Alberta
7 //
8 // This software is distributed under the MIT license
9 // For more information, see the README file in /doc/LICENSE
10 //
11 // - Class: application_data.h
12 // - Description: This class implements general data of applications
13 // - Developers: Guido Kanschat, Texas A&M University
14 // Valentin N. Zingan, University of Alberta
15 // Marc Secanell, University of Alberta
16 // Mayank Sabharwal, University of Alberta
17 // Aslan Kosakian, University of Alberta
18 //
19 // ----------------------------------------------------------------------------
20 
21 #ifndef _FUEL_CELL_APPLICATION_CORE_APPLICATION_DATA_H_
22 #define _FUEL_CELL_APPLICATION_CORE_APPLICATION_DATA_H_
23 //-- dealII
24 #include <deal.II/lac/vector_memory.h>
25 #include <deal.II/lac/block_vector.h>
26 #include <deal.II/base/parameter_handler.h>
27 
28 //-- OpenFCST
29 #include <utils/logging.h>
30 
31 //-- C++ Standard libraries
32 #include <algorithm>
33 #include <fstream>
34 
35 
36 using namespace dealii;
37 
38 namespace FuelCell
39 {
40 namespace ApplicationCore
41 {
42 
46 typedef BlockVector<double> FEVector;
47 
52 
57 
62 
89 {
90 
91 public:
96 
100  ~ApplicationData();
101 
105  void declare_parameters(ParameterHandler& param) const;
106 
110  void initialize(ParameterHandler& param);
111 
112 
116  void enter_flag(std::string name,
117  const bool& s);
118 
122  void enter(std::string name,
123  const double& s);
124 
128  void enter(std::string name,
129  const FEVector& v);
130 
134  void enter(std::string name,
135  const std::vector<double>& v);
136 
140  void enter(std::string name,
141  const std::vector< std::vector<double> >& v);
142 
146  void erase_flag(std::string name);
147 
151  void erase_scalar(std::string name);
152 
156  void erase_vector(std::string name);
157 
161  void erase_std_vector(std::string name);
162 
166  void erase_std_vector_of_std_vectors(std::string name);
167 
173  bool flag_exists(const std::string& name) const;
174 
178  bool flag(std::string name) const;
179 
184  const double* scalar(std::string name) const;
185 
190  const FEVector* vector(std::string name) const;
191 
196  const std::vector<double>* std_vector(std::string name) const;
197 
202  const std::vector< std::vector<double> >* std_vector_std_vector(std::string name) const;
203 
207  void log() const;
208 
214  GrowingVectorMemory< Vector<double> > vector_pool;
215 
221  GrowingVectorMemory<FEVector> block_vector_pool;
222 
227  {
228  return this->lin_solver;
229  }
230 
235  {
236  return this->nonlin_solver;
237  }
238 
243  {
244  return this->refinement_solver;
245  }
246 
250  void set_linear_solver(const std::string name)
251  {
252  if (name.compare("UMFPACK") == 0)
254  else if ( name.compare("CG") == 0 )
256  else if ( name.compare("ILU-GMRES") == 0 )
258  else if ( name.compare("MUMPS") == 0 )
260  else if ( name.compare("Bicgstab") == 0)
262  else
263  throw(ExcNotFound("linear_solver", name));
264  }
265 
269  void set_nonlinear_solver(const std::string name)
270  {
271  if (name.compare("None") == 0)
273  else if ( name.compare("NewtonBasic") == 0 )
275  else if ( name.compare("Newton3pp") == 0 )
277  else if( name.compare("NewtonLineSearch") == 0)
279  else if ( name.compare("Picard") == 0 )
281  else
282  throw(ExcNotFound("nonlinear_solver", name));
283  }
284 
288  void set_refinement_solver(const std::string name)
289  {
290  if (name.compare("AdaptiveRefinement") == 0)
292  else
293  throw(ExcNotFound("refinement_solver", name));
294  }
295 
300  {
302  return "Newton iterate";
304  return "Solution";
305  }
306 
311  {
313  return "Newton residual";
315  return "residual";
316  }
317 
321  typedef std::map< std::string, bool > flag_map;
322 
326  typedef std::map< std::string, const double* > scalar_map;
327 
332  typedef std::map< std::string, const FEVector* > vector_map;
333 
337  typedef std::map< std::string, const std::vector<double>* > std_vector_map;
338 
342  typedef std::map< std::string, const std::vector< std::vector<double> >* > std_vector_std_vector_map;
343 
348  std::map<std::string,std::map<int,double>> field_data;
349 
353  DeclException2(ExcNotFound,
354  char*,
355  std::string,
356  << "A " << arg1 << " with name " << arg2 << " was not stored in this data object");
357 
358 private:
359 
364 
369 
374 
379 
384 
385 
386 
387 protected:
388 
390 
392 
394 
395 };
396 
397 } // ApplicationCore
398 
399 } // FuelCell
400 
401 #endif
scalar_map named_scalars
A map linking names of data to actual scalars.
Definition: application_data.h:368
std::string get_solution_vector_name(FuelCell::ApplicationCore::NonLinearSolver in)
Function to return solution vector name in the FEVectors object.
Definition: application_data.h:299
GrowingVectorMemory< Vector< double > > vector_pool
VectorMemory object for simple vectors.
Definition: application_data.h:214
Here we handle general data of applications.
Definition: application_data.h:88
vector_map named_vectors
A map linking names of data to actual vectors.
Definition: application_data.h:373
Definition: system_management.h:150
std::map< std::string, const double * > scalar_map
The typedef for the map of scalars.
Definition: application_data.h:326
Definition: simulator_builder.h:58
std::string get_residual_vector_name(FuelCell::ApplicationCore::NonLinearSolver in)
Function to return the residual vector name in the FEVectors object.
Definition: application_data.h:310
FuelCell::ApplicationCore::LinearSolver get_linear_solver()
Function to return the linear solver type.
Definition: application_data.h:226
RefinementSolver
Enumeration class for refinement types.
Definition: application_data.h:61
std_vector_map named_std_vectors
A map linking names of data to actual std vectors.
Definition: application_data.h:378
void set_nonlinear_solver(const std::string name)
Function to set the type of non-linear solver.
Definition: application_data.h:269
std::map< std::string, std::map< int, double > > field_data
Map of field data with names corresponding to the physical meaning of data, which can be read from VT...
Definition: application_data.h:348
FuelCell::ApplicationCore::LinearSolver lin_solver
Definition: application_data.h:389
std::map< std::string, const std::vector< double > * > std_vector_map
The typedef for the map of std vectors.
Definition: application_data.h:337
FCSTLogStream log
Object used to output data to file and, if file attached recorded to a file as well.
DeclException2(VariableShouldExistForEquation, std::string, std::string,<< "The user-defined variable with name \""<< arg1<< "\" should be one of the solution variables for equation with name \""<< arg2<< "\"")
Exception thrown when a particular variable required by the equation class, does not exist in the use...
FuelCell::ApplicationCore::RefinementSolver refinement_solver
Definition: application_data.h:393
void set_linear_solver(const std::string name)
Function to set the type of linear solver.
Definition: application_data.h:250
std::map< std::string, const FEVector * > vector_map
The typedef for the map of vectors.
Definition: application_data.h:332
LinearSolver
Enumeration class for Linear solvers.
Definition: application_data.h:51
void set_refinement_solver(const std::string name)
Function to set the type of refinement.
Definition: application_data.h:288
FuelCell::ApplicationCore::RefinementSolver get_refinement_solver()
Function to return refinement type.
Definition: application_data.h:242
FuelCell::ApplicationCore::NonLinearSolver nonlin_solver
Definition: application_data.h:391
NonLinearSolver
Enumeration class for Non-linear solvers.
Definition: application_data.h:56
std::map< std::string, const std::vector< std::vector< double > > * > std_vector_std_vector_map
The typedef for the map of std vectors of std vectors.
Definition: application_data.h:342
GrowingVectorMemory< FEVector > block_vector_pool
VectorMemory object for block vectors.
Definition: application_data.h:221
FuelCell::ApplicationCore::NonLinearSolver get_nonlinear_solver()
Function to return the non-linear solver type.
Definition: application_data.h:234
std::map< std::string, bool > flag_map
The typedef for the map of boolean flags.
Definition: application_data.h:321
BlockVector< double > FEVector
The vector class used by applications.
Definition: application_data.h:46
std_vector_std_vector_map named_std_vectors_of_std_vectors
A map linking names of data to actual std vectors of std vectors.
Definition: application_data.h:383
flag_map named_flags
A map linking names of data to actual boolean flags.
Definition: application_data.h:363