OpenFCST: The open-source Fuel Cell Simulation Toolbox
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
base_layer.h
Go to the documentation of this file.
1 // ----------------------------------------------------------------------------
2 //
3 // FCST: Fuel Cell Simulation Toolbox
4 //
5 // Copyright (C) 2006-2013 by Energy Systems Design Laboratory, University of Alberta
6 //
7 // This software is distributed under the MIT License
8 // For more information, see the README file in /doc/LICENSE
9 //
10 // - Class: base_layer.h
11 // - Description: This is a base class for all available FCST layers
12 // - Developers: Marc Secanell Gallart, University of Alberta
13 // Madhur Bhaiya, University of Alberta
14 // - $Id: base_layer.h 1373 2013-08-21 00:34:53Z madhur $
15 //
16 // ----------------------------------------------------------------------------
17 
18 #ifndef _FUELCELLSHOP__BASE__LAYER_H
19 #define _FUELCELLSHOP__BASE__LAYER_H
20 
21 // Include deal.II classes
22 #include <base/parameter_handler.h>
23 #include <base/point.h>
24 #include <base/function.h>
25 #include <lac/vector.h>
26 #include <fe/fe_values.h>
27 
28 //Include STL
29 #include <cmath>
30 #include <iostream>
31 
32 // Include OpenFCST routines:
33 #include "utils/fcst_variables.h"
35 
36 using namespace dealii;
37 
38 namespace FuelCellShop
39 {
40 
41 
42  namespace Layer
43  {
55  template <int dim>
56  class BaseLayer : public Subscriptor
57  {
58  public:
60 
61 
65  virtual void set_derivative_flags(const std::vector<VariableNames>& flags)
66  {
67  this->derivative_flags = flags;
68  }
69 
74  void set_position(std::vector<Point<dim> > &p)
75  {
76  point = p;
77  }
78 
79 
91  virtual void set_constant_solution(const double& value, const VariableNames& name)
92  {
93  constant_solutions[name] = value;
94  }
95 
105  virtual void set_solution(const std::vector< SolutionVariable >&)
106  {
107  const std::type_info& info = typeid(*this);
108  deallog << "Pure function " << __FUNCTION__
109  << " called in Class "
110  << info.name() << std::endl;
111  }
113 
115 
116 
120  bool belongs_to_material(const char material_id);
121 
125  inline const std::string& name_material();
126 
149  virtual const std::type_info& get_base_type() const
150  {
151  const std::type_info& info = typeid(*this);
152  deallog << "Pure function " << __FUNCTION__
153  << " called in Class "
154  << info.name() << std::endl;
155  }
161  virtual void print_layer_properties() const;
162 
166  virtual bool test_layer()
167  {
168  const std::type_info& info = typeid(*this);
169  deallog << "Pure function " << __FUNCTION__
170  << " called in Class "
171  << info.name() << std::endl;
172 
173  return false;
174  }
175 
179  unsigned int get_material_id()
180  {
181  return material_id;
182  }
184 
185  protected:
186 
188 
189 
195  {};
196 
200  BaseLayer(const std::string& name);
201 
205  virtual ~BaseLayer();
206 
210  virtual void declare_parameters (const std::string &object_name, ParameterHandler &param) const
211  {
212  param.enter_subsection("Fuel cell data");
213  {
214  param.enter_subsection(object_name);
215  {
216  param.declare_entry("Material id",
217  "1",
218  Patterns::Integer(0),
219  "Id number used to identify this layer");
220  }
221  param.leave_subsection();
222  }
223  param.leave_subsection();
224  }
225 
231  virtual void declare_parameters (ParameterHandler &param) const
232  {
233  this->declare_parameters(this->name,param);
234  }
235 
246  virtual void set_parameters(const std::string &object_name,
247  const std::vector<std::string>& name_dvar,
248  const std::vector<double>& value_dvar,
249  ParameterHandler &param)
250  {
251  param.enter_subsection("Fuel cell data");
252  {
253  param.enter_subsection(object_name);
254  {
255  // ADD VARIABLES IF NEEDED
256  //param.set(name_var, value_param);
257  }
258  param.leave_subsection();
259  }
260  param.leave_subsection();
261  };
268  virtual void set_parameters(const std::vector<std::string>& name_dvar,
269  const std::vector<double>& value_dvar,
270  ParameterHandler &param)
271  {
272  param.enter_subsection("Fuel cell data");
273  {
274  param.enter_subsection(this->name);
275  {
276  // ADD VARIABLES IF NEEDED
277  //param.set(name_var, value_param);
278  }
279  param.leave_subsection();
280  }
281  param.leave_subsection();
282  };
283 
288  virtual void initialize (ParameterHandler &param);
289 
291 
293 
294 
296  const std::string name;
298  unsigned int material_id;
300  std::vector<Point<dim> > point;
302  std::vector<VariableNames> derivative_flags;
304  std::map< VariableNames, double > constant_solutions;
306  };
307 
308  } // Layer
309 
310 } // FuelCellShop
311 
312  #endif // _FUELCELLSHOP__GENERIC__LAYER_H