dataTemplates.C
Go to the documentation of this file.
1 /*---------------------------------------------------------------------------*\
2  ========= |
3  \\ / F ield | OpenFOAM: The Open Source CFD Toolbox
4  \\ / O peration |
5  \\ / A nd | Copyright (C) 2015-2016 OpenFOAM Foundation
6  \\/ M anipulation |
7 -------------------------------------------------------------------------------
8 License
9  This file is part of OpenFOAM.
10 
11  OpenFOAM is free software: you can redistribute it and/or modify it
12  under the terms of the GNU General Public License as published by
13  the Free Software Foundation, either version 3 of the License, or
14  (at your option) any later version.
15 
16  OpenFOAM is distributed in the hope that it will be useful, but WITHOUT
17  ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
18  FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
19  for more details.
20 
21  You should have received a copy of the GNU General Public License
22  along with OpenFOAM. If not, see <http://www.gnu.org/licenses/>.
23 
24 \*---------------------------------------------------------------------------*/
25 
26 #include "data.H"
27 #include "Time.H"
28 #include "solverPerformance.H"
29 
30 // * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * //
31 
32 template<class Type>
34 (
35  const word& name,
36  const SolverPerformance<Type>& sp
37 ) const
38 {
39  dictionary& dict = const_cast<dictionary&>(solverPerformanceDict());
40 
42 
43  if (prevTimeIndex_ != this->time().timeIndex())
44  {
45  // Reset solver performance between iterations
46  prevTimeIndex_ = this->time().timeIndex();
47  dict.clear();
48  }
49  else
50  {
51  dict.readIfPresent(name, perfs);
52  }
53 
54  // Append to list
55  perfs.setSize(perfs.size()+1, sp);
56 
57  dict.set(name, perfs);
58 }
59 
60 
61 template<class Type>
63 (
64  const SolverPerformance<Type>& sp
65 ) const
66 {
67  setSolverPerformance(sp.fieldName(), sp);
68 }
69 
70 
71 // ************************************************************************* //
dictionary dict
void setSolverPerformance(const word &name, const SolverPerformance< Type > &) const
Add/set the solverPerformance entry for the named field.
Definition: dataTemplates.C:34
A list of keyword definitions, which are a keyword followed by any number of values (e...
Definition: dictionary.H:137
const word & fieldName() const
Return field name.
A 1D array of objects of type <T>, where the size of the vector is known and used for subscript bound...
Definition: HashTable.H:60
void size(const label)
Override size to be inconsistent with allocated storage.
Definition: ListI.H:163
A class for handling words, derived from string.
Definition: word.H:59
SolverPerformance is the class returned by the LduMatrix solver containing performance statistics...
bool readIfPresent(const word &, T &, bool recursive=false, bool patternMatch=true) const
Find an entry if present, and assign to T.
void setSize(const label)
Reset size of List.
Definition: List.C:281
void set(entry *)
Assign a new entry, overwrite any existing entry.
Definition: dictionary.C:941
void clear()
Clear the dictionary.
Definition: dictionary.C:1135