OpenFCST: The open-source Fuel Cell Simulation Toolbox
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
application_data.h
Go to the documentation of this file.
1 // ------------------------------------------------------------------
2 // $Id: application_data.h 1348 2013-08-16 00:45:07Z secanell $
3 //
4 // Copyright (C) 2006, 2007, 2008, 2009 by Guido Kanschat.
5 // Copyright (C) 2012 by Valentin N. Zingan, University of Alberta.
6 //
7 // This file is subject to QPL and may not be distributed
8 // without copyright and license information. Please refer
9 // to the file deal.II/doc/license.html for the text and
10 // further information on this license.
11 // ------------------------------------------------------------------
12 
13 #ifndef _DEALII_APPFRAME_APPLICATION_DATA_H_
14 #define _DEALII_APPFRAME_APPLICATION_DATA_H_
15 
16 #include <lac/vector_memory.h>
17 #include <lac/block_vector.h>
18 
19 #include <algorithm>
20 #include <fstream>
21 
22 using namespace dealii;
23 
24 namespace AppFrame
25 {
26 
31 
54 {
55 public:
56 
60  ~ApplicationData();
61 
65  void enter(std::string name,
66  const double& s);
67 
71  void enter(std::string name,
72  const FEVector& v);
73 
78  void erase_scalar(std::string name);
79 
84  void erase_vector(std::string name);
85 
94  const double* scalar(std::string name) const;
95 
104  const FEVector* vector(std::string name) const;
105 
109  void log() const;
110 
120  GrowingVectorMemory< Vector<double> > vector_pool;
121 
131  GrowingVectorMemory<FEVector> block_vector_pool;
132 
137  typedef std::map< std::string, const double* > scalar_map;
138 
143  typedef std::map< std::string, const FEVector* > vector_map;
144 
150  DeclException2(ExcNotFound,
151  char*,
152  std::string,
153  << "A " << arg1 << " with name " << arg2 << " was not stored in this data object");
154 
155 private:
156 
162 
168 };
169 
170 inline
171 ApplicationData::~ApplicationData()
172 { }
173 
174 inline
175 void
176 ApplicationData::enter(std::string name,
177  const double& s)
178 {
179  named_scalars.insert(std::make_pair(name, &s));
180 }
181 
182 inline
183 void
184 ApplicationData::enter(std::string name,
185  const FEVector& v)
186 {
187  named_vectors.insert(std::make_pair(name, &v));
188 }
189 
190 inline
191 void
192 ApplicationData::erase_scalar(std::string name)
193 {
194  scalar_map::iterator iter = named_scalars.find(name);
195  Assert(iter != named_scalars.end(), ExcNotInitialized());
196  named_scalars.erase(iter);
197 }
198 
199 inline
200 void
201 ApplicationData::erase_vector(std::string name)
202 {
203  vector_map::iterator iter = named_vectors.find(name);
204  Assert(iter != named_vectors.end(), ExcNotInitialized());
205  named_vectors.erase(iter);
206 }
207 
208 inline
209 const double*
210 ApplicationData::scalar(std::string name) const
211 {
212  scalar_map::const_iterator iter = named_scalars.find(name);
213  AssertThrow(iter != named_scalars.end(), ExcNotFound("scalar", name));
214  return iter->second;
215 }
216 
217 inline
218 const FEVector*
219 ApplicationData::vector(std::string name) const
220 {
221  vector_map::const_iterator iter = named_vectors.find(name);
222  AssertThrow(iter != named_vectors.end(), ExcNotFound("vector", name));
223  return iter->second;
224 }
225 
226 inline
227 void
228 ApplicationData::log() const
229 {
230  deallog.push("scalar");
231  for(scalar_map::const_iterator iter = named_scalars.begin(); iter != named_scalars.end(); ++iter)
232  deallog << iter->first << '\t' << iter->second << std::endl;
233  deallog.pop();
234 
235  deallog.push("vector");
236  for(vector_map::const_iterator iter = named_vectors.begin(); iter != named_vectors.end(); ++iter)
237  deallog << iter->first << '\t' << iter->second->size() << std::endl;
238  deallog.pop();
239 }
240 
241 }
242 
243 #endif