OpenFCST: The open-source Fuel Cell Simulation Toolbox
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
fe_vectors.h
Go to the documentation of this file.
1 // ----------------------------------------------------------------------------
2 //
3 // FCST: Fuel Cell Simulation Toolbox
4 //
5 // Copyright (C) 2006-2009 by Guido Kanschat
6 // Copyright (C) 2006-2014 by Energy Systems Design Laboratory, University of Alberta
7 //
8 // This software is distributed under the MIT License
9 // For more information, see the README file in /doc/LICENSE
10 //
11 // - Class: fe_vectors.h
12 // - Description: This class implements data type
13 // used in function calls of applications
14 // - Developers: Guido Kanschat, Texas A&M University
15 // Valentin N. Zingan, University of Alberta
16 // Marc Secanell, University of Alberta
17 // - Id: $Id: fe_vectors.h 2605 2014-08-15 03:36:44Z secanell $
18 //
19 // ----------------------------------------------------------------------------
20 
21 #ifndef _FUEL_CELL_APPLICATION_CORE_FE_VECTORS_H_
22 #define _FUEL_CELL_APPLICATION_CORE_FE_VECTORS_H_
23 
24 #include <lac/vector_memory.h>
25 #include <lac/block_vector.h>
26 
27 #include <algorithm>
28 #include <fstream>
29 
30 using namespace dealii;
31 
32 namespace FuelCell
33 {
34 namespace ApplicationCore
35 {
36 
40 typedef BlockVector<double> FEVector;
41 
59 class FEVectors : public Subscriptor
60 {
61 public:
62 
66  FEVectors();
67 
69 
70 
75  void add_scalar(double& s,
76  const std::string& name);
77 
82  void add_vector(FEVector& v,
83  const std::string& name);
84 
88  void add_vector(const FEVector& v,
89  const std::string& name);
90 
96  void merge(FEVectors& other);
97 
107  void merge(const FEVectors& other);
108 
110 
112 
113 
117  unsigned int n_scalars() const;
118 
122  unsigned int n_vectors() const;
123 
127  double& scalar(unsigned int i);
128 
132  const double& scalar(unsigned int i) const;
133 
137  FEVector& vector(unsigned int i);
138 
142  const FEVector& vector(unsigned int i) const;
143 
147  const std::string& scalar_name(unsigned int i) const;
148 
152  const std::string& vector_name(unsigned int i) const;
153 
157  unsigned int find_scalar(const std::string& name) const;
158 
162  unsigned int find_vector(const std::string& name) const;
163 
167  unsigned int count_vector(const std::string& name) const;
168 
175  template<typename OUT>
176  void list(OUT& out,
177  unsigned int verbosity = 1) const;
178 
180 
188  DeclException2(ExcNameMismatch,
189  int,
190  std::string,
191  << "Name at position " << arg1 << " is not equal to " << arg2);
192 
193 private:
194 
199 
203  std::vector<double*> scalars;
204 
208  std::vector<std::string> scalar_names;
209 
213  std::vector<FEVector*> vectors;
214 
218  std::vector<std::string> vector_names;
219 };
220 
221 } // ApplicationCore
222 
223 } // FuelCell
224 
225 #endif
std::vector< FEVector * > vectors
The vectors stored.
Definition: fe_vectors.h:213
std::vector< std::string > vector_names
The names of the vectors.
Definition: fe_vectors.h:218
bool is_constant
True if the object is to be treated constant.
Definition: fe_vectors.h:198
std::vector< double * > scalars
The scalars stored.
Definition: fe_vectors.h:203
std::vector< std::string > scalar_names
The names of the scalars.
Definition: fe_vectors.h:208
DeclException2(VariableShouldExistForEquation, std::string, std::string,<< "The user-defined variable with name \""<< arg1<< "\" should be one of the solution variables for equation with name \""<< arg2<< "\"")
Exception thrown when a particular variable required by the equation class, does not exist in the use...
BlockVector< double > FEVector
The vector class used by applications.
Definition: application_data.h:39
The data type used in function calls of Application.
Definition: fe_vectors.h:59