GRINS-0.8.0
cached_values.C
Go to the documentation of this file.
1 //-----------------------------------------------------------------------bl-
2 //--------------------------------------------------------------------------
3 //
4 // GRINS - General Reacting Incompressible Navier-Stokes
5 //
6 // Copyright (C) 2014-2017 Paul T. Bauman, Roy H. Stogner
7 // Copyright (C) 2010-2013 The PECOS Development Team
8 //
9 // This library is free software; you can redistribute it and/or
10 // modify it under the terms of the Version 2.1 GNU Lesser General
11 // Public License as published by the Free Software Foundation.
12 //
13 // This library is distributed in the hope that it will be useful,
14 // but WITHOUT ANY WARRANTY; without even the implied warranty of
15 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
16 // Lesser General Public License for more details.
17 //
18 // You should have received a copy of the GNU Lesser General Public
19 // License along with this library; if not, write to the Free Software
20 // Foundation, Inc. 51 Franklin Street, Fifth Floor,
21 // Boston, MA 02110-1301 USA
22 //
23 //-----------------------------------------------------------------------el-
24 
25 
26 #include "grins/cached_values.h"
27 
28 namespace GRINS
29 {
31  {
32  return;
33  }
34 
36  {
37  return;
38  }
39 
40  void CachedValues::add_quantity( unsigned int quantity )
41  {
42  _cache_list.insert(quantity);
43  return;
44  }
45 
46  void CachedValues::add_quantities( const std::set<unsigned int>& cache_list )
47  {
48  _cache_list.insert(cache_list.begin(), cache_list.end());
49  return;
50  }
51 
53  {
54  _cached_values.clear();
56  _cached_vector_values.clear();
58 
59  return;
60  }
61 
62  bool CachedValues::is_active(unsigned int quantity)
63  {
64  bool value = false;
65 
66  if( _cache_list.find(quantity) != _cache_list.end() )
67  value = true;
68 
69  return value;
70  }
71 
72  void CachedValues::set_values( unsigned int quantity, std::vector<libMesh::Number>& values )
73  {
74  _cached_values.insert( std::make_pair( quantity, values ) );
75  return;
76  }
77 
78  void CachedValues::set_gradient_values( unsigned int quantity,
79  std::vector<libMesh::Gradient>& values )
80  {
81  // Using insert() breaks here. Not entirely sure why...
82  _cached_gradient_values[quantity] = values;
83  return;
84  }
85 
86  void CachedValues::set_vector_gradient_values( unsigned int quantity,
87  std::vector<std::vector<libMesh::Gradient> >& values )
88  {
89  _cached_vector_gradient_values[quantity] = values;
90  return;
91  }
92 
93  void CachedValues::set_vector_values( unsigned int quantity, std::vector<std::vector<libMesh::Number> >& values )
94  {
95  _cached_vector_values[quantity] = values;
96  return;
97  }
98 
99  const std::vector<libMesh::Number>& CachedValues::get_cached_values( unsigned int quantity ) const
100  {
101  libmesh_assert( _cached_values.find(quantity) != _cached_values.end() );
102  return _cached_values.find(quantity)->second;
103  }
104 
105  const std::vector<libMesh::Gradient>& CachedValues::get_cached_gradient_values( unsigned int quantity ) const
106  {
107  libmesh_assert( _cached_gradient_values.find(quantity) != _cached_gradient_values.end() );
108  return _cached_gradient_values.find(quantity)->second;
109  }
110 
111  const std::vector<std::vector<libMesh::Number> >& CachedValues::get_cached_vector_values( unsigned int quantity ) const
112  {
113  libmesh_assert( _cached_vector_values.find(quantity) != _cached_vector_values.end() );
114  return _cached_vector_values.find(quantity)->second;
115  }
116 
117  const std::vector<std::vector<libMesh::Gradient> >& CachedValues::get_cached_vector_gradient_values( unsigned int quantity ) const
118  {
119  libmesh_assert( _cached_vector_gradient_values.find(quantity) != _cached_vector_gradient_values.end() );
120  return _cached_vector_gradient_values.find(quantity)->second;
121  }
122 
123 } // namespace GRINS
bool is_active(unsigned int quantity)
Definition: cached_values.C:62
void add_quantities(const std::set< unsigned int > &cache_list)
Definition: cached_values.C:46
std::map< unsigned int, std::vector< std::vector< libMesh::Number > > > _cached_vector_values
Definition: cached_values.h:85
void set_values(unsigned int quantity, std::vector< libMesh::Number > &values)
Definition: cached_values.C:72
std::set< unsigned int > _cache_list
Definition: cached_values.h:81
void set_vector_gradient_values(unsigned int quantity, std::vector< std::vector< libMesh::Gradient > > &values)
Definition: cached_values.C:86
std::map< unsigned int, std::vector< std::vector< libMesh::Gradient > > > _cached_vector_gradient_values
Definition: cached_values.h:86
GRINS namespace.
const std::vector< std::vector< libMesh::Number > > & get_cached_vector_values(unsigned int quantity) const
std::map< unsigned int, std::vector< libMesh::Number > > _cached_values
Definition: cached_values.h:83
const std::vector< std::vector< libMesh::Gradient > > & get_cached_vector_gradient_values(unsigned int quantity) const
const std::vector< libMesh::Gradient > & get_cached_gradient_values(unsigned int quantity) const
void add_quantity(unsigned int quantity)
Definition: cached_values.C:40
void set_vector_values(unsigned int quantity, std::vector< std::vector< libMesh::Number > > &values)
Definition: cached_values.C:93
void set_gradient_values(unsigned int quantity, std::vector< libMesh::Gradient > &values)
Definition: cached_values.C:78
const std::vector< libMesh::Number > & get_cached_values(unsigned int quantity) const
Definition: cached_values.C:99
std::map< unsigned int, std::vector< libMesh::Gradient > > _cached_gradient_values
Definition: cached_values.h:84

Generated on Tue Dec 19 2017 12:47:28 for GRINS-0.8.0 by  doxygen 1.8.9.1