Memosa-FVM  0.2
GlobalFields.cpp
Go to the documentation of this file.
1 // This file os part of FVM
2 // Copyright (c) 2012 FVM Authors
3 // See LICENSE file for terms.
4 
5 #include "GlobalFields.h"
6 
8 
9 Field&
11 {
12  FieldMap& fMap = getFieldMap();
13  FieldMap::iterator p = fMap.find(&fieldLabel);
14  if (p == fMap.end())
15  {
16  shared_ptr<Field> f(new Field(fieldLabel.getName()));
17  fMap[&fieldLabel] = f;
18  return *f;
19  }
20  else
21  return *p->second;
22 }
23 
24 const Field&
26 {
27  FieldMap& fMap = getFieldMap();
28  FieldMap::iterator p = fMap.find(&fieldLabel);
29  if (p != fMap.end()) return *p->second;
30  throw CException("No such field " + fieldLabel.getName());
31 }
32 
35 {
36  if (!_fieldMap)
37  {
38  _fieldMap = new FieldMap();
39  }
40  return *_fieldMap;
41 }
static const Field & getField(const FieldLabel &fieldLabel)
static FieldMap & getFieldMap()
Definition: Field.h:14
static FieldMap * _fieldMap
Definition: GlobalFields.h:22
static Field & createField(const FieldLabel &fieldLabel)
map< const FieldLabel *, shared_ptr< Field > > FieldMap
Definition: GlobalFields.h:15
const string & getName() const
Definition: FieldLabel.h:15