OpenFCST: The open-source Fuel Cell Simulation Toolbox
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
poly_agglomerate.h
Go to the documentation of this file.
1 // ----------------------------------------------------------------------------
2 //
3 // FCST: Fuel Cell Simulation Toolbox
4 //
5 // Copyright (C) 2006-2014 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: PolyAgglomerate
11 // - Description: Poly agglomerate class (work in progress)
12 // - Developers: Philip Wardlaw, University of Alberta
13 // - $Id: poly_agglomerate.h 2605 2014-08-15 03:36:44Z secanell $
14 //
15 // ----------------------------------------------------------------------------
16 
17 #ifndef POLYAGGLOMERATE_H_
18 #define POLYAGGLOMERATE_H_
19 
21 
22 namespace FuelCellShop
23 {
24 namespace MicroScale
25 {
26 
27 
28 class MicroSet{
29  /*
30  * A simple container for storing a set of micro structures with corresponding volume fractions.
31  *
32  * Push back all the items you wish to and then normalize volume fractions using normalize_vols()
33  *
34  * Iterate the micro set by indexs 0 through (size() -1) using the at() and volAt() accessors
35  */
36 
37 public:
38 
39 
41  size_ =0;
42  }
43 
44  ~MicroSet(){};
45 
46  inline void push_back(const double & volumeFraction, boost::shared_ptr<FuelCellShop::MicroScale::MicroScaleBase> micro){
47 
48 
49  //Add the pointer
50  Assert(micro, ExcMessage("boost::shared_ptr<FuelCellShop::MicroScale::MicroScaleBase> with null pointer out of range for MicroMap."));
51  micros.push_back(micro);
52  vols.push_back(volumeFraction);
53  size_++;
54 
55 
56  }
57 
58  inline void normalize_vols(){
59  double sum = 0.0;
60 
61  //Perform normalization to 1.0
62  for(double v: vols)
63  sum +=v;
64 
65  for(double &v: vols)
66  v/=sum;
67  }
68 
69  inline unsigned int size() const{
70  return size_;
71  }
72 
73  inline boost::shared_ptr<FuelCellShop::MicroScale::MicroScaleBase>& at(unsigned int idx){
74  Assert(idx < size_, ExcMessage("Index out of range for MicroMap."));
75  return micros.at(idx);
76  }
77 
78  inline double& volAt(unsigned int idx){
79  Assert(idx < size_, ExcMessage("Index out of range for MicroMap."));
80  return vols.at(idx);
81  }
82 
83 
84 private:
85  unsigned int size_;
86  std::vector<boost::shared_ptr<FuelCellShop::MicroScale::MicroScaleBase>> micros;
87  std::vector<double> vols;
88 
89 
90 };
91 
92 
134 public:
135 
136 
137 
138 
139  static const std::string concrete_name;
140  PolyAgglomerate(std::string);
142  virtual ~PolyAgglomerate();
143 
144 
145 
147 
148 
158  virtual void set_solution(const std::map<VariableNames,SolutionVariable>& sols,const VariableNames& name, const int& index);
160 
168  virtual SolutionMap compute_current ( );
169 
181  virtual std::vector<double> compute_derivative_current ()
182  {
183  Assert(false, ExcPureFunctionCalled());
184  return std::vector<double>(3, 0.0);
185  }
186 
195  virtual bool has_derivatives(){
196  //Compute numerically
197  return false;
198  }
199 
203  virtual std::string get_name(){
204  return concrete_name;
205  }
206 
210  virtual void print_properties(){
211 
212  FcstUtilities::log << "=--------- PolyAgglomerate -----------=" << std::endl;
213  FcstUtilities::log << "= Number of sub agglomerates: " << micro.size() << std::endl;
214 
215  for(unsigned int i = 0; i < micro.size(); i++){
216  FcstUtilities::log << "Sub agglomerate #" << i << std::endl;
217  FcstUtilities::log << "Associated volume fraction:" << micro.volAt(i) << std::endl;
218  micro.at(i)->print_properties();
219  }
220 
221  }
222 
223 
228  virtual double aux_volume_fraction();
229 
230 
231  virtual void make_thread_safe(ParameterHandler &param, unsigned int thread_index);
232 
233 protected:
234 
235 
236 
237  //name Instance Delivery (Prototype)
238  static PolyAgglomerate const* PROTOTYPE;
239 
240  /*
241  * Protected pure virtual member function for declaring parameters, must be implemented
242  * by all children. Parameter structure is hierarchical, therefore children
243  * should call their parent's declare parameter function from their own declare
244  * parameter function.
245  */
246  virtual void declare_parameters (ParameterHandler &param) const;
247 
248  /*
249  * Protected pure virtual member function for initializing parameters, must be implemented
250  * by all children. Parameter structure is hierarchical, therefore children
251  * should call their parent's initialize function from their own initialize function.
252  */
253  virtual void initialize (ParameterHandler &param);
254  /*
255  * Protected member function for setting up MicroScale structure after object
256  * initialization.
257  *
258  * Responsible for pulling structural properties from catalyst layer.
259  *
260  * Responsible for setting up points to materials and kinetics.
261  *
262  */
263  virtual void set_structure ();
264 
266 
267 
272  virtual boost::shared_ptr<MicroScaleBase> create_replica ()
273  {
274  return boost::shared_ptr<FuelCellShop::MicroScale::MicroScaleBase> (new FuelCellShop::MicroScale::PolyAgglomerate ());
275  }
276 
278 
279 private:
280  //The micro scale objects are stored within the following convenient contianer
282 
283  //loop preventor to control how parameter subsections are declared
284  static bool inf_loop_preventor;
285 
286  //Number of sub micro scale objects allowed, hard coded in header
287  static int num_sub_micro;
288 
289 };
290 
291 
292 
293 }
294 } /* namespace FuelCellShop */
295 
296 #endif /* POLYAGGLOMERATE_H_ */
virtual void declare_parameters(ParameterHandler &param) const
double & volAt(unsigned int idx)
Definition: poly_agglomerate.h:78
void push_back(const double &volumeFraction, boost::shared_ptr< FuelCellShop::MicroScale::MicroScaleBase > micro)
Definition: poly_agglomerate.h:46
MicroSet()
Definition: poly_agglomerate.h:40
virtual bool has_derivatives()
Returns true if the class instance can calculate current density derivatives.
Definition: poly_agglomerate.h:195
VariableNames
The enumeration containing the names of some of the available FCST solution variables and their deriv...
Definition: system_management.h:63
Convenient storage object for SolutionVariables.
Definition: fcst_variables.h:457
std::vector< boost::shared_ptr< FuelCellShop::MicroScale::MicroScaleBase > > micros
Definition: poly_agglomerate.h:86
virtual void initialize(ParameterHandler &param)
~MicroSet()
Definition: poly_agglomerate.h:44
MicroSet micro
Definition: poly_agglomerate.h:281
static bool inf_loop_preventor
Definition: poly_agglomerate.h:284
virtual boost::shared_ptr< MicroScaleBase > create_replica()
This member function is used to create an object of MicroScaleBase.
Definition: poly_agglomerate.h:272
static int num_sub_micro
Definition: poly_agglomerate.h:287
virtual std::string get_name()
Return name of class instance, i.e.
Definition: poly_agglomerate.h:203
PolyAgglomerate()
Definition: poly_agglomerate.h:141
virtual void set_solution(const std::map< VariableNames, SolutionVariable > &sols, const VariableNames &name, const int &index)
Function for setting the solution map(reactant concentration, phi_s, phi_m, etc.).
virtual double aux_volume_fraction()
MicroScale object may have extra contribution to volume of layer, e.g.
An agglomerate model which considers a combination of agglomerates.
Definition: poly_agglomerate.h:133
FCSTLogStream log
Object used to output data to file and, if file attached recorded to a file as well.
std::vector< double > vols
Definition: poly_agglomerate.h:87
unsigned int size() const
Definition: poly_agglomerate.h:69
The base class for micro scale objects in OpenFCST.
Definition: micro_scale_base.h:134
virtual SolutionMap compute_current()
Function used to compute the current density produced by the micro structure.
virtual void print_properties()
Print out key micro-structural dimensions, defined by child.
Definition: poly_agglomerate.h:210
static PolyAgglomerate const * PROTOTYPE
Definition: poly_agglomerate.h:238
unsigned int size_
Definition: poly_agglomerate.h:85
boost::shared_ptr< FuelCellShop::MicroScale::MicroScaleBase > & at(unsigned int idx)
Definition: poly_agglomerate.h:73
Definition: poly_agglomerate.h:28
static const std::string concrete_name
Definition: poly_agglomerate.h:139
void normalize_vols()
Definition: poly_agglomerate.h:58
virtual std::vector< double > compute_derivative_current()
Function to compute the derivative of the current density at the local operating conditions.
Definition: poly_agglomerate.h:181
virtual void make_thread_safe(ParameterHandler &param, unsigned int thread_index)