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 2605 2014-08-15 03:36:44Z secanell $
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 <deal.II/grid/tria.h>
31 #include <deal.II/grid/tria_accessor.h>
32 #include <deal.II/grid/tria_iterator.h>
33 #include <deal.II/grid/tria_boundary_lib.h>
34 #include <deal.II/grid/grid_generator.h>
35 #include <deal.II/grid/grid_in.h>
36 #include <deal.II/grid/grid_out.h>
37 #include <deal.II/base/parameter_handler.h>
38 #include <deal.II/base/exceptions.h>
39 
40 #include <utils/fcst_utilities.h>
41 
42 using namespace dealii;
43 
44 namespace FuelCellShop
45 {
46  namespace Geometry
47  {
48 
91  template <int dim>
92  class GridBase
93  {
94  public:
96 
183  static void declare_GridGenerator_parameters (ParameterHandler &param);
184 
188  static boost::shared_ptr<FuelCellShop::Geometry::GridBase<dim> > create_GridGenerator (ParameterHandler &param)
189  {
190  boost::shared_ptr<FuelCellShop::Geometry::GridBase<dim> > pointer;
191  std::string concrete_name;
192 
193  param.enter_subsection("Grid generation");
194  {
195  concrete_name = param.get("Type of mesh");
196  FcstUtilities::log <<" "<<std::endl;
197  FcstUtilities::log << "name: "<<concrete_name.c_str()<<std::endl;
198  }
199  param.leave_subsection();
200  //FcstUtilities::log <<FuelCellShop::Geometry::GridBase<dim>::get_mapFactory()->empty()<<std::endl;
201 
204  {
205  if (iterator->second)
206  {
207  pointer = iterator->second->create_replica(concrete_name);
208  }
209  else
210  {
211  FcstUtilities::log<<"Pointer not initialized"<<std::endl;
212  abort();
213  }
214  }
215  else
216  {
217  FcstUtilities::log<<"Concrete name does not exist"<<std::endl;
218  abort();
219  }
220 
221  pointer->initialize(param);
222 
223  return pointer;
224  }
226 
231  {
232  const std::type_info& info = typeid ( *this );
233  FcstUtilities::log << "Pure function " << __FUNCTION__
234  << " called in Class "
235  << info.name() << std::endl;
236  }
237 
244  const types::boundary_id& bdry_id,
245  boost::shared_ptr< Boundary<dim> > boundary) const
246  {
247  FcstUtilities::log << "Read mesh from file: " << std::endl;
248  FcstUtilities::log << "\t mesh name: " << this->mesh_name << std::endl;
249  FcstUtilities::log << "\t mesh type: " << this->mesh_type << std::endl;
250 
251  GridIn<dim> grid_in;
252  grid_in.attach_triangulation(triangulation);
253  std::ifstream input_file( this->mesh_name.c_str() );
254  grid_in.read( input_file , grid_in.parse_format( this->mesh_type ) );
255  input_file.close();
256 
257  triangulation.set_boundary(bdry_id,
258  *boundary);
259 
260  triangulation.refine_global(this->num_refine);
261  }
262 
268  std::vector<unsigned int> get_material_id ( const std::string ) const;
269 
271  unsigned int get_boundary_id ( ParameterHandler& param,
272  const std::string boundary ) const;
273 
275  unsigned int get_boundary_id ( const std::string ) const;
276 
278  void output_grid ( const Triangulation<dim> &triangulation, const std::string filename ) const;
279 
283  void refine_area ( Triangulation<dim> &triangulation, const unsigned int material_id );
284 
290  std::string get_mesh_type()
291  {
292  return mesh_type_name;
293  }
295 
296 
299  inline double L_channel_c(){return 2.0*l_channel_c;}
303  inline double L_channelLength_c(){return l_channelLength_c;}
307  inline double L_channelHeight_c(){return l_channelHeight_c;}
311  inline double L_channelEntrance_c(){return l_channelEntrance_c;}
315  inline double L_channelExit_c(){return l_channelExit_c;}
319  inline double L_land_c(){return 2.0*l_land_c;}
323  inline double L_gdl_c(){return l_gdl_c;}
327  inline std::vector<double> L_cat_c(){return l_cat_c;}
328 
332  inline double L_mpl_c(){return l_mpl_c;}
333 
334 
338  inline double L_mem(){return l_mem;}
339 
343  inline double L_cat_a(){return l_cat_a;}
347  inline double L_mpl_a(){return l_mpl_a;}
351  inline double L_gdl_a(){return l_gdl_a;}
355  inline double L_channel_a(){return 2.0*l_channel_a;}
359  inline double L_land_a(){return 2.0*l_land_a;}
361 
363 
367  boost::shared_ptr<GridIn<dim>> grid_in;
368 
369 
370  protected:
372 
373 
376  GridBase();
377 
382  virtual ~GridBase();
383 
387  void initialize(ParameterHandler& param);
388 
390 
391 
393 
394 
397  typedef std::map< std::string, GridBase<dim>* > _mapFactory;
399 
401 
402 
406  {
407  static _mapFactory mapFactory;
408  return &mapFactory;
409  }
411 
413 
418  virtual boost::shared_ptr<FuelCellShop::Geometry::GridBase<dim> > create_replica (const std::string &name)
419  {
420  const std::type_info& info = typeid(*this);
421  FcstUtilities::log << "Pure function " << __FUNCTION__
422  << " called in Class "
423  << info.name() << std::endl;
424  }
426 
428 
429  void print_material_id_and_boundary_id ( const Triangulation<dim> &triangulation ) const;
431 
433 
434 
438  std::string mesh_type_name;
440  std::string mesh_name;
442  std::string mesh_type;
444  unsigned int num_refine;
446 
448 
449 
453  double l_channel_c;
473  double l_land_c;
477  double l_gdl_c;
481  double l_mpl_c;
485  //double l_cat_c; //##
486  std::vector<double> l_cat_c;
490  double l_mem;
494  double l_cat_a;
498  double l_mpl_a;
502  double l_gdl_a;
506  double l_channel_a;
510  double l_land_a;
511 
513  double l_cube;
515 
517 
518 
522  unsigned int num_vert;
523 
527  unsigned int num_c_Channel;
531  unsigned int num_c_GDL;
535  unsigned int num_c_MPL;
539  unsigned int num_c_CL;
540 
544  unsigned int num_membrane;
548  unsigned int num_a_CL;
552  unsigned int num_a_MPL;
556  unsigned int num_a_GDL;
557 
559 
560 
562 
563 
566  unsigned int test_mid;
570  unsigned int c_CC_mid;
574  unsigned int c_GC_mid;
578  unsigned int c_GDL_mid;
582  unsigned int c_MPL_mid;
586  std::vector<unsigned int> c_CL_mid;
590  unsigned int membrane_mid;
594  unsigned int a_CL_mid;
598  unsigned int a_MPL_mid;
602  unsigned int a_GDL_mid;
606  unsigned int a_CC_mid;
610  unsigned int a_GC_mid;
611 
612 
614 
616 
617 
620  unsigned int c_Ch_Inlet_bid;
624  unsigned int c_Ch_Outlet_bid;
628  unsigned int c_Ch_base_bid;
632  unsigned int c_Ch_roof_bid;
636  unsigned int c_Ch_GDL_bid;
640  unsigned int c_BPP_GDL_bid;
644  unsigned int c_GDL_CL_bid;
648  unsigned int c_CL_Membrane_bid;
649 
653  unsigned int c_GDL_MPL_bid;
657  unsigned int c_MPL_CL_bid;
658 
662  unsigned int a_Membrane_CL_bid;
666  unsigned int a_CL_GDL_bid;
670  unsigned int a_GDL_BPP_bid;
674  unsigned int a_GDL_Ch_bid;
675 
679  unsigned int a_MPL_GDL_bid;
683  unsigned int a_CL_MPL_bid;
687  unsigned int a_Ch_Inlet_bid;
691  unsigned int a_Ch_Outlet_bid;
695  unsigned int a_Ch_base_bid;
699  unsigned int a_Ch_roof_bid;
701 
703 
704 
705  double r_agg;
706 
708  double delta_agg;
709 
711  unsigned int r_agg_mid;
712 
714  unsigned int delta_agg_mid;
715 
717  unsigned int r_delta_bid;
718 
720  unsigned int delta_bid;
721 
723  Point<dim> center;
725  };
726 
727  }//namespace Geometry
728 
729 }//namespace FuelCell
730 
731 #endif
unsigned int c_Ch_base_bid
Boundary id cathode channel entrance/exit base.
Definition: geometry.h:628
unsigned int c_CL_Membrane_bid
Boundary id cathode CL and membrane.
Definition: geometry.h:648
unsigned int c_Ch_Inlet_bid
Boundary id cathode channel inlet.
Definition: geometry.h:620
unsigned int c_Ch_GDL_bid
Boundary id cathode channel and GDL.
Definition: geometry.h:636
std::string get_mesh_type()
Return the type of mesh that is being used.
Definition: geometry.h:290
unsigned int num_c_GDL
Number of cells wide cathode gas diffusion layer.
Definition: geometry.h:531
double l_land_c
Width of the cathode current collector.
Definition: geometry.h:473
unsigned int a_Membrane_CL_bid
Boundary id anode membrane and CL.
Definition: geometry.h:662
unsigned int c_Ch_Outlet_bid
Boundary id cathode channel outlet.
Definition: geometry.h:624
double L_gdl_c()
Return the Thickness of the cathode gas diffusion layer.
Definition: geometry.h:323
unsigned int c_GDL_CL_bid
Boundary id cathode GDL and CL.
Definition: geometry.h:644
unsigned int c_GDL_mid
Material id cathode GDL.
Definition: geometry.h:578
unsigned int a_GDL_Ch_bid
Boundary id anode GDL and channel.
Definition: geometry.h:674
double l_land_a
Width of the anode current collector.
Definition: geometry.h:510
unsigned int c_BPP_GDL_bid
Boundary id cathode BPP and GDL.
Definition: geometry.h:640
unsigned int c_MPL_CL_bid
Boundary id cathode MPL and CL.
Definition: geometry.h:657
double L_channel_c()
Return the Width of the cathode gas channel.
Definition: geometry.h:299
std::vector< double > L_cat_c()
Return the thickness of the cathode catalyst layer.
Definition: geometry.h:327
double r_agg
Agglomerate radius.
Definition: geometry.h:705
unsigned int c_Ch_roof_bid
Boundary id cathode channel entrance/exit roof.
Definition: geometry.h:632
unsigned int a_MPL_GDL_bid
Boundary id anode GDL and MPL.
Definition: geometry.h:679
unsigned int membrane_mid
Material id membrane.
Definition: geometry.h:590
unsigned int a_Ch_roof_bid
Boundary id cathode channel entrance/exit roof.
Definition: geometry.h:699
double l_cube
Cube edge for HyperCube mesh.
Definition: geometry.h:513
double L_mpl_c()
Return the Thickness of the cathode microporous layer.
Definition: geometry.h:332
double l_channelLength_c
Length of the cathode gas channel.
Definition: geometry.h:457
static _mapFactory * get_mapFactory()
Definition: geometry.h:405
double l_gdl_a
Thickness of the anode gas diffusion layer.
Definition: geometry.h:502
static boost::shared_ptr< FuelCellShop::Geometry::GridBase< dim > > create_GridGenerator(ParameterHandler &param)
Generate the appropriate mesh generator object based on the parameters in the input file...
Definition: geometry.h:188
void generate_grid_with_curved_boundaries(Triangulation< dim > &triangulation, const types::boundary_id &bdry_id, boost::shared_ptr< Boundary< dim > > boundary) const
This function is like the previous one generate_grid() but allows to assign a curved boundary boundar...
Definition: geometry.h:243
std::string mesh_type_name
Specify if you would like to load a mesh from file or if you would like a module from the mesh genera...
Definition: geometry.h:438
bool read_from_file
Definition: geometry.h:362
unsigned int a_Ch_Outlet_bid
Boundary id cathode channel outlet.
Definition: geometry.h:691
double L_channelHeight_c()
Return the Height of the cathode gas channel.
Definition: geometry.h:307
unsigned int a_CL_MPL_bid
Boundary id anode MPL and CL.
Definition: geometry.h:683
std::string mesh_type
Specify if it is a UNV file, MSH file, etc.
Definition: geometry.h:442
double l_channel_a
Width of the anode gas channel.
Definition: geometry.h:506
double L_land_a()
Return the Width of the anode current collector.
Definition: geometry.h:359
unsigned int num_c_MPL
Number of cells wide cathode microporous layer.
Definition: geometry.h:535
double L_channelEntrance_c()
Return the Entrance Length of the cathode gas channel.
Definition: geometry.h:311
unsigned int num_refine
Initial number of refinements.
Definition: geometry.h:444
double L_channel_a()
Return the Width of the anode gas channel.
Definition: geometry.h:355
double L_mem()
Return the Thickness of the membrane.
Definition: geometry.h:338
unsigned int a_CC_mid
Material id anode current collector.
Definition: geometry.h:606
double l_gdl_c
Thickness of the cathode gas diffusion layer.
Definition: geometry.h:477
unsigned int a_CL_GDL_bid
Boundary id anode CL and GDL.
Definition: geometry.h:666
Point< dim > center
Centre point of the circular/spherical domain.
Definition: geometry.h:723
double L_mpl_a()
Return the Thickness of the anode microporous layer.
Definition: geometry.h:347
FCSTLogStream log
Object used to output data to file and, if file attached recorded to a file as well.
unsigned int test_mid
Material id for test cell (GridTest app)
Definition: geometry.h:566
unsigned int c_GDL_MPL_bid
Boundary id cathode GDL and MPL.
Definition: geometry.h:653
unsigned int num_a_MPL
Number of cells wide anode microporous layer.
Definition: geometry.h:552
std::map< std::string, GridBase< dim > * > _mapFactory
This object is used to store all objects of type GasDiffusionLayer.
Definition: geometry.h:397
unsigned int a_Ch_base_bid
Boundary id cathode channel entrance/exit base.
Definition: geometry.h:695
unsigned int num_c_CL
Number of cells wide cathode catalyst layer.
Definition: geometry.h:539
std::string mesh_name
Name of the mesh file.
Definition: geometry.h:440
unsigned int delta_agg_mid
Electrolyte Thin Film Material ID.
Definition: geometry.h:714
unsigned int num_c_Channel
Number of cells wide cathode channel.
Definition: geometry.h:527
double l_mpl_c
Thickness of the cathode microporous layer.
Definition: geometry.h:481
double L_land_c()
Return the Width of the cathode current collector.
Definition: geometry.h:319
double l_cat_a
Thickness of the anode catalyst layer.
Definition: geometry.h:494
unsigned int a_GDL_BPP_bid
Boundary id anode GDL and BPP.
Definition: geometry.h:670
double l_channel_c
Width of the cathode gas channel.
Definition: geometry.h:453
unsigned int c_MPL_mid
Material id cathode MPL.
Definition: geometry.h:582
unsigned int a_GC_mid
Material id anode gas channel.
Definition: geometry.h:610
double l_mpl_a
Thickness of the anode microporous layer.
Definition: geometry.h:498
double L_cat_a()
Return the Thickness of the anode catalyst layer.
Definition: geometry.h:343
boost::shared_ptr< GridIn< dim > > grid_in
GridIn class object of dealii which allows to read various types of mesh formats. ...
Definition: geometry.h:367
std::vector< unsigned int > c_CL_mid
Material id cathode catalyst layer.
Definition: geometry.h:586
unsigned int num_a_CL
Number of cells wide anode catalyst layer.
Definition: geometry.h:548
FuelCell Geometry information class.
Definition: geometry.h:92
unsigned int num_a_GDL
Number of cells wide anode gas diffusion layer.
Definition: geometry.h:556
unsigned int num_vert
Number of cells tall the initial grid.
Definition: geometry.h:522
unsigned int c_CC_mid
Material id cathode current collector.
Definition: geometry.h:570
double L_channelLength_c()
Return the Length of the cathode gas channel.
Definition: geometry.h:303
double L_channelExit_c()
Return the Exit Length of the cathode gas channel.
Definition: geometry.h:315
double l_mem
Thickness of the membrane.
Definition: geometry.h:490
double L_gdl_a()
Return the Thickness of the anode gas diffusion layer.
Definition: geometry.h:351
unsigned int a_Ch_Inlet_bid
Boundary id cathode channel inlet.
Definition: geometry.h:687
std::vector< double > l_cat_c
Thickness of the cathode catalyst layer.
Definition: geometry.h:486
unsigned int a_GDL_mid
Material id anode GDL.
Definition: geometry.h:602
double delta_agg
Electrolyte thin film thickness.
Definition: geometry.h:708
virtual void generate_grid(Triangulation< dim > &)
Function is empty and must be reimplemented in derived classes.
Definition: geometry.h:230
double l_channelEntrance_c
Entrance length of the cathode gas channel.
Definition: geometry.h:465
unsigned int r_delta_bid
Boundary ID for agglomerate/thin film boundary.
Definition: geometry.h:717
unsigned int r_agg_mid
Porous Agglomerate Material ID.
Definition: geometry.h:711
virtual boost::shared_ptr< FuelCellShop::Geometry::GridBase< dim > > create_replica(const std::string &name)
This member function is used to create an object of type gas diffusion layer.
Definition: geometry.h:418
double l_channelExit_c
Exit Length of the cathode gas channel.
Definition: geometry.h:469
unsigned int a_CL_mid
Material id anode catalyst layer.
Definition: geometry.h:594
unsigned int c_GC_mid
Material id cathode gas channel.
Definition: geometry.h:574
double l_channelHeight_c
Height of the cathode gas channel.
Definition: geometry.h:461
unsigned int a_MPL_mid
Material id anode MPL.
Definition: geometry.h:598
unsigned int delta_bid
Boundary ID for thin film external boundary.
Definition: geometry.h:720
unsigned int num_membrane
Number of cells wide membrane layer.
Definition: geometry.h:544