surfMeshTemplates.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 | www.openfoam.com
6  \\/ M anipulation |
7 -------------------------------------------------------------------------------
8  Copyright (C) 2019 OpenCFD Ltd.
9 -------------------------------------------------------------------------------
10 License
11  This file is part of OpenFOAM.
12 
13  OpenFOAM is free software: you can redistribute it and/or modify it
14  under the terms of the GNU General Public License as published by
15  the Free Software Foundation, either version 3 of the License, or
16  (at your option) any later version.
17 
18  OpenFOAM is distributed in the hope that it will be useful, but WITHOUT
19  ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
20  FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
21  for more details.
22 
23  You should have received a copy of the GNU General Public License
24  along with OpenFOAM. If not, see <http://www.gnu.org/licenses/>.
25 
26 \*---------------------------------------------------------------------------*/
27 
28 #include "surfMesh.H"
29 #include "surfFields.H"
30 
31 // * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * //
32 
33 template<class Type, class GeoMeshType>
35 (
36  const word& fieldName,
37  const dimensionSet& dims,
38  const Field<Type>& values
39 )
40 {
41  const objectRegistry& fieldDb = *this;
42 
43  auto* dimfield =
45 
46  if (dimfield)
47  {
48  dimfield->dimensions() = dims;
49  dimfield->field() = values;
50  }
51  else
52  {
54  (
55  IOobject
56  (
57  fieldName,
58  fieldDb,
59  IOobject::NO_READ,
60  IOobject::NO_WRITE,
61  true
62  ),
63  *this,
64  dims,
65  values
66  );
67 
68  dimfield->store();
69  }
70 }
71 
72 
73 template<class Type, class GeoMeshType>
75 (
76  const word& fieldName,
77  const dimensionSet& dims,
79 )
80 {
81  const objectRegistry& fieldDb = *this;
82 
83  auto* dimfield =
85 
86  if (dimfield)
87  {
88  dimfield->dimensions() = dims;
89  dimfield->field() = std::move(values);
90  }
91  else
92  {
94  (
95  IOobject
96  (
97  fieldName,
98  fieldDb,
99  IOobject::NO_READ,
100  IOobject::NO_WRITE,
101  true
102  ),
103  *this,
104  dims,
105  std::move(values)
106  );
107 
108  dimfield->store();
109  }
110 }
111 
112 
113 // ************************************************************************* //
Foam::objectRegistry::getObjectPtr
Type * getObjectPtr(const word &name, const bool recursive=false) const
Definition: objectRegistryTemplates.C:423
Foam::IOobject
Defines the attributes of an object for which implicit objectRegistry management is supported,...
Definition: IOobject.H:169
Foam::word
A class for handling words, derived from Foam::string.
Definition: word.H:65
Foam::surfMesh::storeField
void storeField(const word &fieldName, const dimensionSet &dims, const Field< Type > &values)
Copy/store named field as face or point data (template parameter).
Definition: surfMeshTemplates.C:35
Foam::HashTableOps::values
List< T > values(const HashTable< T, Key, Hash > &tbl, const bool doSort=false)
List of values from HashTable, optionally sorted.
Definition: HashOps.H:149
Foam::dimensionSet
Dimension set for the base types, which can be used to implement rigorous dimension checking for alge...
Definition: dimensionSet.H:108
Foam::objectRegistry
Registry of regIOobjects.
Definition: objectRegistry.H:60
Foam::Field
Generic templated field type.
Definition: Field.H:63
surfMesh.H
Foam::DimensionedField::dimensions
const dimensionSet & dimensions() const
Return dimensions.
Definition: DimensionedFieldI.H:49
surfFields.H
Foam::DimensionedField
Field with dimensions and associated with geometry type GeoMesh which is used to size the field and a...
Definition: DimensionedField.H:54