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 <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 #include "fcst_utilities.h"
40 
41 using namespace dealii;
42 
43 namespace FuelCellShop
44 {
45  namespace Geometry
46  {
47 
90  template <int dim>
91  class GridBase
92  {
93  public:
95 
182  static void declare_GridGenerator_parameters (ParameterHandler &param);
183 
187  static boost::shared_ptr<FuelCellShop::Geometry::GridBase<dim> > create_GridGenerator (ParameterHandler &param)
188  {
189  boost::shared_ptr<FuelCellShop::Geometry::GridBase<dim> > pointer;
190  std::string concrete_name;
191 
192  param.enter_subsection("Grid generation");
193  {
194  concrete_name = param.get("Type of mesh");
195  FcstUtilities::log <<" "<<std::endl;
196  FcstUtilities::log << "name: "<<concrete_name.c_str()<<std::endl;
197  }
198  param.leave_subsection();
199 
201 
203  {
204  if (iterator->second)
205  {
206  pointer = iterator->second->create_replica();
207  }
208  else
209  {
210  FcstUtilities::log<<"Pointer not initialized"<<std::endl;
211  abort();
212  }
213  }
214  else
215  {
216  FcstUtilities::log<<"Concrete name does not exist"<<std::endl;
217  abort();
218  }
219 
220  pointer->initialize(param);
221 
222  return pointer;
223  }
225 
229  virtual void generate_grid (Triangulation<dim>& ) const
230  {
231  const std::type_info& info = typeid ( *this );
232  FcstUtilities::log << "Pure function " << __FUNCTION__
233  << " called in Class "
234  << info.name() << std::endl;
235  }
236 
243  const types::boundary_id& bdry_id,
244  boost::shared_ptr< Boundary<dim> > boundary) const
245  {
246  FcstUtilities::log << "Read mesh from file: " << std::endl;
247  FcstUtilities::log << "\t mesh name: " << this->mesh_name << std::endl;
248  FcstUtilities::log << "\t mesh type: " << this->mesh_type << std::endl;
249 
250  GridIn<dim> grid_in;
251  grid_in.attach_triangulation(triangulation);
252  std::ifstream input_file( this->mesh_name.c_str() );
253  grid_in.read( input_file , grid_in.parse_format( this->mesh_type ) );
254  input_file.close();
255 
256  triangulation.set_boundary(bdry_id,
257  *boundary);
258 
259  triangulation.refine_global(this->num_refine);
260  }
261 
267  std::vector<unsigned int> get_material_id ( const std::string ) const;
268 
270  unsigned int get_boundary_id ( ParameterHandler& param,
271  const std::string boundary ) const;
272 
274  unsigned int get_boundary_id ( const std::string ) const;
275 
277  void output_grid ( const Triangulation<dim> &triangulation, const std::string filename ) const;
278 
282  void refine_area ( Triangulation<dim> &triangulation, const unsigned int material_id );
283 
289  std::string get_mesh_type()
290  {
291  return mesh_type_name;
292  }
294 
295 
298  inline double L_channel_c(){return 2.0*l_channel_c;}
302  inline double L_land_c(){return 2.0*l_land_c;}
306  inline double L_gdl_c(){return l_gdl_c;}
310  inline std::vector<double> L_cat_c(){return l_cat_c;}
311 
315  inline double L_mpl_c(){return l_mpl_c;}
316 
317 
321  inline double L_mem(){return l_mem;}
322 
326  inline double L_cat_a(){return l_cat_a;}
330  inline double L_mpl_a(){return l_mpl_a;}
334  inline double L_gdl_a(){return l_gdl_a;}
338  inline double L_channel_a(){return 2.0*l_channel_a;}
342  inline double L_land_a(){return 2.0*l_land_a;}
344 
346 
347  protected:
349 
350 
353  GridBase();
354 
359  virtual ~GridBase();
360 
364  void initialize(ParameterHandler& param);
365 
367 
368 
370 
371 
374  typedef std::map< std::string, GridBase<dim>* > _mapFactory;
376 
378 
379 
383  {
384  static _mapFactory mapFactory;
385  return &mapFactory;
386  }
388 
390 
395  virtual boost::shared_ptr<FuelCellShop::Geometry::GridBase<dim> > create_replica ()
396  {
397  const std::type_info& info = typeid(*this);
398  FcstUtilities::log << "Pure function " << __FUNCTION__
399  << " called in Class "
400  << info.name() << std::endl;
401  }
403 
405 
406  void print_material_id_and_boundary_id ( const Triangulation<dim> &triangulation ) const;
408 
410 
411 
415  std::string mesh_type_name;
417  std::string mesh_name;
419  std::string mesh_type;
421  unsigned int num_refine;
423 
425 
426 
430  double l_channel_c;
434  double l_land_c;
438  double l_gdl_c;
442  double l_mpl_c;
446  //double l_cat_c; //##
447  std::vector<double> l_cat_c;
451  double l_mem;
455  double l_cat_a;
459  double l_mpl_a;
463  double l_gdl_a;
467  double l_channel_a;
471  double l_land_a;
472 
474  double l_cube;
476 
478 
479 
483  unsigned int num_vert;
484 
488  unsigned int num_c_GDL;
492  unsigned int num_c_MPL;
496  unsigned int num_c_CL;
497 
501  unsigned int num_membrane;
505  unsigned int num_a_CL;
509  unsigned int num_a_MPL;
513  unsigned int num_a_GDL;
514 
516 
517 
519 
520 
523  unsigned int test_mid;
527  unsigned int c_CC_mid;
531  unsigned int c_GC_mid;
535  unsigned int c_GDL_mid;
539  unsigned int c_MPL_mid;
543  std::vector<unsigned int> c_CL_mid;
547  unsigned int membrane_mid;
551  unsigned int a_CL_mid;
555  unsigned int a_MPL_mid;
559  unsigned int a_GDL_mid;
563  unsigned int a_CC_mid;
567  unsigned int a_GC_mid;
568 
569 
571 
573 
574 
577  unsigned int c_Ch_GDL_bid;
581  unsigned int c_BPP_GDL_bid;
585  unsigned int c_GDL_CL_bid;
589  unsigned int c_CL_Membrane_bid;
590 
594  unsigned int c_GDL_MPL_bid;
598  unsigned int c_MPL_CL_bid;
599 
603  unsigned int a_Membrane_CL_bid;
607  unsigned int a_CL_GDL_bid;
611  unsigned int a_GDL_BPP_bid;
615  unsigned int a_GDL_Ch_bid;
616 
620  unsigned int a_MPL_GDL_bid;
624  unsigned int a_CL_MPL_bid;
626 
628 
629 
630  double r_agg;
631 
633  double delta_agg;
634 
636  unsigned int r_agg_mid;
637 
639  unsigned int delta_agg_mid;
640 
642  unsigned int r_delta_bid;
643 
645  unsigned int delta_bid;
646 
648  Point<dim> center;
650  };
651 
652  }//namespace Geometry
653 
654 }//namespace FuelCell
655 
656 #endif
unsigned int c_CL_Membrane_bid
Boundary id cathode CL and membrane.
Definition: geometry.h:589
unsigned int c_Ch_GDL_bid
Boundary id cathode channel and GDL.
Definition: geometry.h:577
std::string get_mesh_type()
Return the type of mesh that is being used.
Definition: geometry.h:289
unsigned int num_c_GDL
Number of cells wide cathode gas diffusion layer.
Definition: geometry.h:488
double l_land_c
Width of the cathode current collector.
Definition: geometry.h:434
unsigned int a_Membrane_CL_bid
Boundary id anode membrane and CL.
Definition: geometry.h:603
double L_gdl_c()
Return the Thickness of the cathode gas diffusion layer.
Definition: geometry.h:306
unsigned int c_GDL_CL_bid
Boundary id cathode GDL and CL.
Definition: geometry.h:585
unsigned int c_GDL_mid
Material id cathode GDL.
Definition: geometry.h:535
unsigned int a_GDL_Ch_bid
Boundary id anode GDL and channel.
Definition: geometry.h:615
double l_land_a
Width of the anode current collector.
Definition: geometry.h:471
unsigned int c_BPP_GDL_bid
Boundary id cathode BPP and GDL.
Definition: geometry.h:581
unsigned int c_MPL_CL_bid
Boundary id cathode MPL and CL.
Definition: geometry.h:598
double L_channel_c()
Return the Width of the cathode gas channel.
Definition: geometry.h:298
std::vector< double > L_cat_c()
Return the thickness of the cathode catalyst layer.
Definition: geometry.h:310
double r_agg
Agglomerate radius.
Definition: geometry.h:630
unsigned int a_MPL_GDL_bid
Boundary id anode GDL and MPL.
Definition: geometry.h:620
unsigned int membrane_mid
Material id membrane.
Definition: geometry.h:547
double l_cube
Cube edge for HyperCube mesh.
Definition: geometry.h:474
double L_mpl_c()
Return the Thickness of the cathode microporous layer.
Definition: geometry.h:315
static _mapFactory * get_mapFactory()
Definition: geometry.h:382
double l_gdl_a
Thickness of the anode gas diffusion layer.
Definition: geometry.h:463
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:187
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:242
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:415
bool read_from_file
Definition: geometry.h:345
unsigned int a_CL_MPL_bid
Boundary id anode MPL and CL.
Definition: geometry.h:624
std::string mesh_type
Specify if it is a UNV file, MSH file, etc.
Definition: geometry.h:419
double l_channel_a
Width of the anode gas channel.
Definition: geometry.h:467
double L_land_a()
Return the Width of the anode current collector.
Definition: geometry.h:342
unsigned int num_c_MPL
Number of cells wide cathode microporous layer.
Definition: geometry.h:492
unsigned int num_refine
Initial number of refinements.
Definition: geometry.h:421
double L_channel_a()
Return the Width of the anode gas channel.
Definition: geometry.h:338
double L_mem()
Return the Thickness of the membrane.
Definition: geometry.h:321
virtual void generate_grid(Triangulation< dim > &) const
Function is empty and must be reimplemented in derived classes.
Definition: geometry.h:229
unsigned int a_CC_mid
Material id anode current collector.
Definition: geometry.h:563
double l_gdl_c
Thickness of the cathode gas diffusion layer.
Definition: geometry.h:438
unsigned int a_CL_GDL_bid
Boundary id anode CL and GDL.
Definition: geometry.h:607
Point< dim > center
Centre point of the circular/spherical domain.
Definition: geometry.h:648
double L_mpl_a()
Return the Thickness of the anode microporous layer.
Definition: geometry.h:330
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:523
unsigned int c_GDL_MPL_bid
Boundary id cathode GDL and MPL.
Definition: geometry.h:594
unsigned int num_a_MPL
Number of cells wide anode microporous layer.
Definition: geometry.h:509
std::map< std::string, GridBase< dim > * > _mapFactory
This object is used to store all objects of type GasDiffusionLayer.
Definition: geometry.h:374
unsigned int num_c_CL
Number of cells wide cathode catalyst layer.
Definition: geometry.h:496
std::string mesh_name
Name of the mesh file.
Definition: geometry.h:417
unsigned int delta_agg_mid
Electrolyte Thin Film Material ID.
Definition: geometry.h:639
double l_mpl_c
Thickness of the cathode microporous layer.
Definition: geometry.h:442
double L_land_c()
Return the Width of the cathode current collector.
Definition: geometry.h:302
double l_cat_a
Thickness of the anode catalyst layer.
Definition: geometry.h:455
unsigned int a_GDL_BPP_bid
Boundary id anode GDL and BPP.
Definition: geometry.h:611
double l_channel_c
Width of the cathode gas channel.
Definition: geometry.h:430
unsigned int c_MPL_mid
Material id cathode MPL.
Definition: geometry.h:539
unsigned int a_GC_mid
Material id anode gas channel.
Definition: geometry.h:567
double l_mpl_a
Thickness of the anode microporous layer.
Definition: geometry.h:459
double L_cat_a()
Return the Thickness of the anode catalyst layer.
Definition: geometry.h:326
std::vector< unsigned int > c_CL_mid
Material id cathode catalyst layer.
Definition: geometry.h:543
unsigned int num_a_CL
Number of cells wide anode catalyst layer.
Definition: geometry.h:505
FuelCell Geometry information class.
Definition: geometry.h:91
virtual boost::shared_ptr< FuelCellShop::Geometry::GridBase< dim > > create_replica()
This member function is used to create an object of type gas diffusion layer.
Definition: geometry.h:395
unsigned int num_a_GDL
Number of cells wide anode gas diffusion layer.
Definition: geometry.h:513
unsigned int num_vert
Number of cells tall the initial grid.
Definition: geometry.h:483
unsigned int c_CC_mid
Material id cathode current collector.
Definition: geometry.h:527
double l_mem
Thickness of the membrane.
Definition: geometry.h:451
double L_gdl_a()
Return the Thickness of the anode gas diffusion layer.
Definition: geometry.h:334
std::vector< double > l_cat_c
Thickness of the cathode catalyst layer.
Definition: geometry.h:447
unsigned int a_GDL_mid
Material id anode GDL.
Definition: geometry.h:559
double delta_agg
Electrolyte thin film thickness.
Definition: geometry.h:633
unsigned int r_delta_bid
Boundary ID for agglomerate/thin film boundary.
Definition: geometry.h:642
unsigned int r_agg_mid
Porous Agglomerate Material ID.
Definition: geometry.h:636
unsigned int a_CL_mid
Material id anode catalyst layer.
Definition: geometry.h:551
unsigned int c_GC_mid
Material id cathode gas channel.
Definition: geometry.h:531
unsigned int a_MPL_mid
Material id anode MPL.
Definition: geometry.h:555
unsigned int delta_bid
Boundary ID for thin film external boundary.
Definition: geometry.h:645
unsigned int num_membrane
Number of cells wide membrane layer.
Definition: geometry.h:501