OpenFCST: The open-source Fuel Cell Simulation Toolbox
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
geometry.h
Go to the documentation of this file.
1 //---------------------------------------------------------------------------
2 //
3 // FCST: Fuel Cell Simulation Toolbox
4 //
5 // Copyright (C) 2006-13 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: geometry.h
11 // - Description: Used to store and output information for general fuel cell geometries
12 // - Developers: M. Secanell and Peter Dobson
13 // Salome parser dealii::GridIn<dim, spacedim>::read_unv(): Valentin N. Zingan, University of Alberta, (C) 2012.
14 // - $Id: geometry.h 1385 2013-08-24 00:20:25Z madhur $
15 //
16 //---------------------------------------------------------------------------
17 
18 #ifndef _FUELCELLSHOP__GEOMETRY_H
19 #define _FUELCELLSHOP__GEOMETRY_H
20 
21 //------------------------------
22 // STANDARD LIBRARY DECLARATIONS
23 //------------------------------
24 #include <fstream>
25 #include <iostream>
26 
27 //------------------------------
28 // DEAL.II DECLARATIONS
29 //------------------------------
30 #include <grid/tria.h>
31 #include <grid/tria_accessor.h>
32 #include <grid/tria_iterator.h>
33 #include <grid/tria_boundary_lib.h>
34 #include <grid/grid_generator.h>
35 #include <grid/grid_in.h>
36 #include <grid/grid_out.h>
37 #include <base/parameter_handler.h>
38 #include <base/exceptions.h>
39 
40 using namespace dealii;
41 
42 namespace FuelCellShop
43 {
44  namespace Geometry
45  {
46 
94  template <int dim>
95  class GridBase
96  {
97  public:
99 
186  static void declare_GridGenerator_parameters (ParameterHandler &param);
187 
207  static void set_GridGenerator_parameters (const std::vector<std::string>& name_dvar,
208  const std::vector<double>& value_dvar,
209  ParameterHandler &param);
213  static boost::shared_ptr<FuelCellShop::Geometry::GridBase<dim> > create_GridGenerator (ParameterHandler &param)
214  {
215 
216  boost::shared_ptr<FuelCellShop::Geometry::GridBase<dim> > pointer;
217 
218  std::string concrete_name;
219 
220  param.enter_subsection("Grid generation");
221  {
222  concrete_name = param.get("Type of mesh");
223  deallog << "name: "<<concrete_name.c_str()<<std::endl;
224  }
225  param.leave_subsection();
226 
227 
229 
231  {
232  if (iterator->second)
233  {
234  pointer = iterator->second->create_replica();
235  }
236  else
237  {
238  deallog<<"Pointer not initialized"<<std::endl;
239  abort();
240  }
241  }
242  else
243  {
244  deallog<<"Concrete name does not exist"<<std::endl;
245  abort();
246  }
247 
248  pointer->initialize(param);
249 
250  return pointer;
251  }
253 
257  virtual void generate_grid (Triangulation<dim>& ) const
258  {
259  const std::type_info& info = typeid ( *this );
260  std::cout << "Pure function " << __FUNCTION__
261  << " called in Class "
262  << info.name() << std::endl;
263  }
264 
265  // --- Zingan ---
267  unsigned int get_material_id (ParameterHandler& param,
268  const std::string material ) const;
269 
271  virtual unsigned int get_material_id ( const std::string ) const
272  {
273  const std::type_info& info = typeid ( *this );
274  std::cout << "Pure function " << __FUNCTION__
275  << " called in Class "
276  << info.name() << std::endl;
277  return 0;
278  }
279 
281  unsigned int get_boundary_id ( ParameterHandler& param,
282  const std::string boundary ) const;
283 
285  unsigned int get_boundary_id ( const std::string ) const;
286 
288  void output_grid ( const Triangulation<dim> &triangulation, const std::string filename ) const;
289 
293  void refine_area ( Triangulation<dim> &triangulation, const unsigned int material_id );
294 
300  std::string get_mesh_type()
301  {
302  return mesh_type_name;
303  }
305 
306 
309  inline double L_channel_c(){return 2.0*l_channel_c;}
313  inline double L_land_c(){return 2.0*l_land_c;}
317  inline double L_gdl_c(){return l_gdl_c;}
321  inline double L_cat_c(){return l_cat_c;}
322 
326  inline double L_mpl_c(){return l_mpl_c;}
327 
328 
332  inline double L_mem(){return l_mem;}
333 
337  inline double L_cat_a(){return l_cat_a;}
341  inline double L_mpl_a(){return l_mpl_a;}
345  inline double L_gdl_a(){return l_gdl_a;}
349  inline double L_channel_a(){return 2.0*l_channel_a;}
353  inline double L_land_a(){return 2.0*l_land_a;}
355 
357 
358  protected:
360 
361 
364  GridBase();
365 
370  virtual ~GridBase();
371 
375  void initialize(ParameterHandler& param);
376 
378 
379 
381 
382 
385  typedef std::map< std::string, GridBase<dim>* > _mapFactory;
387 
389 
390 
393  static _mapFactory * get_mapFactory()
394  {
395  static _mapFactory mapFactory;
396  return &mapFactory;
397  }
399 
400 
401 
406  virtual boost::shared_ptr<FuelCellShop::Geometry::GridBase<dim> > create_replica ()
407  {
408  const std::type_info& info = typeid(*this);
409  deallog << "Pure function " << __FUNCTION__
410  << " called in Class "
411  << info.name() << std::endl;
412  }
414 
415 
416 
417  void print_material_id_and_boundary_id ( const Triangulation<dim> &triangulation ) const;
419 
421 
422 
426  std::string mesh_type_name;
428  std::string mesh_name;
430  std::string mesh_type;
432  unsigned int num_refine;
434 
436 
437 
441  double l_channel_c;
445  double l_land_c;
449  double l_gdl_c;
453  double l_mpl_c;
457  double l_cat_c;
461  double l_mem;
465  double l_cat_a;
469  double l_mpl_a;
473  double l_gdl_a;
477  double l_channel_a;
481  double l_land_a;
483 
485 
486 
490  unsigned int num_vert;
491 
495  unsigned int num_c_GDL;
499  unsigned int num_c_MPL;
503  unsigned int num_c_CL;
504 
508  unsigned int num_membrane;
512  unsigned int num_a_CL;
516  unsigned int num_a_MPL;
520  unsigned int num_a_GDL;
521 
523 
524 
526 
527 
530  unsigned int test_mid;
534  unsigned int c_CC_mid;
538  unsigned int c_GC_mid;
542  unsigned int c_GDL_mid;
546  unsigned int c_MPL_mid;
550  unsigned int c_CL_mid;
554  unsigned int membrane_mid;
558  unsigned int a_CL_mid;
562  unsigned int a_MPL_mid;
566  unsigned int a_GDL_mid;
570  unsigned int a_CC_mid;
574  unsigned int a_GC_mid;
575 
576 
578 
580 
581 
584  unsigned int c_Ch_GDL_bid;
588  unsigned int c_BPP_GDL_bid;
592  unsigned int c_GDL_CL_bid;
596  unsigned int c_CL_Membrane_bid;
597 
601  unsigned int c_GDL_MPL_bid;
605  unsigned int c_MPL_CL_bid;
606 
610  unsigned int a_Membrane_CL_bid;
614  unsigned int a_CL_GDL_bid;
618  unsigned int a_GDL_BPP_bid;
622  unsigned int a_GDL_Ch_bid;
623 
627  unsigned int a_MPL_GDL_bid;
631  unsigned int a_CL_MPL_bid;
633 
635 
636 
637  double r_agg;
638 
640  double delta_agg;
641 
643  unsigned int r_agg_mid;
644 
646  unsigned int delta_agg_mid;
647 
649  unsigned int r_delta_bid;
650 
652  unsigned int delta_bid;
653 
655  Point<dim> center;
657  };
658 
659  }//namespace Geometry
660 
661 }//namespace FuelCell
662 
663 #endif