OpenFCST: The open-source Fuel Cell Simulation Toolbox
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
fcst_variables.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: fcst_variables.h
11 // - Description: Header file storing list of fcst variables and solution variable structures etc.
12 // - Developers: Phil Wardlaw, University of Alberta
13 // Madhur Bhaiya, University of Alberta
14 // - $Id: base_layer.h 1267 2013-08-07 17:22:53Z madhur $
15 //
16 // ----------------------------------------------------------------------------
17 
18 #ifndef _FUELCELLSHOP_VARIABLES_H
19 #define _FUELCELLSHOP_VARIABLES_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:
34 
35 using namespace dealii;
36 
37 namespace FuelCellShop
38 {
75  {
77 
78 
81  {
82  data = NULL;
83  initialized = false;
84  }
85 
89  SolutionVariable(const std::vector<double>* data_in, const VariableNames& name_in)
90  {
91  data = data_in;
92  name = name_in;
93  initialized = true;
94  }
95 
102  SolutionVariable(const double& value, const unsigned int& length, const VariableNames& name_in)
103  {
104  data = NULL;
105  default_data = std::vector<double>(length, value);
106  name = name_in;
107  initialized = true;
108  }
109 
115  SolutionVariable(const std::vector<double>& data_in, const VariableNames& name_in)
116  {
117  data = NULL;
118  default_data = data_in;
119  name = name_in;
120  initialized = true;
121  }
122 
124 
126 
127 
131  const double& operator[](const unsigned int& i) const
132  {
133  Assert( initialized, ExcMessage("SolutionVariables struct is not initialized !!!") );
134 
135  if (data != NULL)
136  {
137  Assert( i < data->size(), ExcMessage("Index is out of range in operator[] for SolutionVariables struct.") );
138  return data->at(i);
139  }
140  else if (data == NULL)
141  {
142  Assert( i < default_data.size(), ExcMessage("Index is out of range in operator[] for SolutionVariables struct.") );
143  return default_data.at(i);
144  }
145  }
146 
150  bool is_initialized() const
151  {
152  return initialized;
153  }
154 
158  unsigned int size() const
159  {
160  unsigned int answer = 0;
161  //If initialized and pointer is not NULL
162  if (initialized && (data != NULL))
163  answer = data->size();
164  else if (initialized && (data == NULL))
165  answer = default_data.size();
166 
167  return answer;
168  }
169 
173  VariableNames get_variablename() const
174  {
175  Assert( initialized, ExcMessage("SolutionVariable not initialized !!!") );
176  return name;
177  }
179 
180 
181  private:
183  std::vector<double> default_data;
184 
186  const std::vector<double>* data;
187 
190 
193  };
194 
196 
197 
201  static bool is_phiM(const SolutionVariable& sol_var)
202  {
203  return (sol_var.get_variablename() == protonic_electrical_potential);
204  }
205 
209  static bool is_phiS(const SolutionVariable& sol_var)
210  {
212  }
213 
215 
216 
217 } // FuelCellShop
218 
219 #endif // _FUELCELLSHOP_VARIABLES_H