FreeFOAM The Cross-Platform CFD Toolkit
MeshObject.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) 1991-2010 OpenCFD Ltd.
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 "MeshObject.H"
28 
29 // * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * //
30 
31 template<class Mesh, class Type>
33 :
35  (
36  IOobject
37  (
38  Type::typeName,
39  mesh.thisDb().instance(),
40  mesh.thisDb()
41  )
42  ),
43  mesh_(mesh)
44 {}
45 
46 
47 // * * * * * * * * * * * * * * * * Selectors * * * * * * * * * * * * * * * * //
48 
49 template<class Mesh, class Type>
51 (
52  const Mesh& mesh
53 )
54 {
55  if (!mesh.thisDb().objectRegistry::foundObject<Type>(Type::typeName))
56  {
57  return store(new Type(mesh));
58  }
59  else
60  {
61  return mesh.thisDb().objectRegistry::lookupObject<Type>(Type::typeName);
62  }
63 }
64 
65 
66 template<class Mesh, class Type>
67 template<class Data1>
69 (
70  const Mesh& mesh,
71  const Data1& d
72 )
73 {
74  if (!mesh.thisDb().objectRegistry::foundObject<Type>(Type::typeName))
75  {
76  return store(new Type(mesh, d));
77  }
78  else
79  {
80  return mesh.thisDb().objectRegistry::lookupObject<Type>(Type::typeName);
81  }
82 }
83 
84 
85 template<class Mesh, class Type>
86 template<class Data1, class Data2>
88 (
89  const Mesh& mesh,
90  const Data1& d1,
91  const Data2& d2
92 )
93 {
94  if (!mesh.thisDb().objectRegistry::foundObject<Type>(Type::typeName))
95  {
96  return store(new Type(mesh, d1, d2));
97  }
98  else
99  {
100  return mesh.thisDb().objectRegistry::lookupObject<Type>(Type::typeName);
101  }
102 }
103 
104 
105 template<class Mesh, class Type>
106 template<class Data1, class Data2, class Data3>
108 (
109  const Mesh& mesh,
110  const Data1& d1,
111  const Data2& d2,
112  const Data3& d3
113 )
114 {
115  if (!mesh.thisDb().objectRegistry::foundObject<Type>(Type::typeName))
116  {
117  return store(new Type(mesh, d1, d2, d3));
118  }
119  else
120  {
121  return mesh.thisDb().objectRegistry::lookupObject<Type>(Type::typeName);
122  }
123 }
124 
125 
126 template<class Mesh, class Type>
127 template<class Data1, class Data2, class Data3, class Data4>
129 (
130  const Mesh& mesh,
131  const Data1& d1,
132  const Data2& d2,
133  const Data3& d3,
134  const Data4& d4
135 )
136 {
137  if (!mesh.thisDb().objectRegistry::foundObject<Type>(Type::typeName))
138  {
139  return store(new Type(mesh, d1, d2, d3, d4));
140  }
141  else
142  {
143  return mesh.thisDb().objectRegistry::lookupObject<Type>(Type::typeName);
144  }
145 }
146 
147 
148 // * * * * * * * * * * * * * * * * Destructor * * * * * * * * * * * * * * //
149 
150 template<class Mesh, class Type>
152 {
153  if (mesh.thisDb().objectRegistry::foundObject<Type>(Type::typeName))
154  {
155  return mesh.thisDb().checkOut
156  (
157  const_cast<Type&>
158  (
159  mesh.thisDb().objectRegistry::lookupObject<Type>
160  (
161  Type::typeName
162  )
163  )
164  );
165  }
166  else
167  {
168  return false;
169  }
170 }
171 
172 
173 template<class Mesh, class Type>
175 {
176  release();
177 }
178 
179 
180 // ************************ vim: set sw=4 sts=4 et: ************************ //