35 template<
class Mesh,
template<
class>
class MeshObjectType,
class Type>
38 MeshObjectType<Mesh>(Type::typeName,
mesh.thisDb()),
43 template<
class Mesh,
template<
class>
class MeshObjectType,
class Type>
50 MeshObjectType<Mesh>(objName,
mesh.thisDb()),
57 template<
class Mesh,
template<
class>
class MeshObjectType,
class Type>
58 template<
class... Args>
66 mesh.thisDb().objectRegistry::template
67 getObjectPtr<Type>(Type::typeName);
76 Pout<<
"MeshObject::New(const " << Mesh::typeName
77 <<
"&, ...) : constructing <" << Type::typeName
78 <<
">, region=" <<
mesh.name() <<
endl;
81 ptr =
new Type(
mesh, std::forward<Args>(
args)...);
83 regIOobject::store(
static_cast<MeshObjectType<Mesh>*
>(ptr));
89 template<
class Mesh,
template<
class>
class MeshObjectType,
class Type>
90 template<
class... Args>
99 mesh.thisDb().objectRegistry::template
100 getObjectPtr<Type>(objName);
109 Pout<<
"MeshObject::New('" << objName
110 <<
"', const " << Mesh::typeName
111 <<
"&, ...) : constructing <" << Type::typeName
112 <<
">, region=" <<
mesh.name() <<
endl;
115 ptr =
new Type(objName,
mesh, std::forward<Args>(
args)...);
117 regIOobject::store(
static_cast<MeshObjectType<Mesh>*
>(ptr));
125 template<
class Mesh,
template<
class>
class MeshObjectType,
class Type>
133 mesh.thisDb().objectRegistry::template
134 getObjectPtr<Type>(objName);
140 Pout<<
"MeshObject::Delete() : deleting <" << Type::typeName
141 <<
"> " << objName <<
endl;
144 return mesh.thisDb().checkOut(
static_cast<MeshObjectType<Mesh>*
>(ptr));
151 template<
class Mesh,
template<
class>
class MeshObjectType,
class Type>
160 mesh.thisDb().objectRegistry::template
161 getObjectPtr<Type>(objName);
163 std::unique_ptr<Type> released;
167 auto* casted =
static_cast<MeshObjectType<Mesh>*
>(ptr);
169 if (casted->regIOobject::ownedByRegistry())
172 casted->regIOobject::release();
184 casted->regIOobject::checkOut();
190 Pout<<
"MeshObject::Release() : release <" << Type::typeName
191 <<
"> " << objName <<
", owned=" << bool(released) <<
endl;
201 template<
class Mesh,
template<
class>
class MeshObjectType,
class Type>
204 std::unique_ptr<Type>&& ptr
211 auto* casted =
static_cast<MeshObjectType<Mesh>*
>(ptr.get());
213 ok = casted->regIOobject::store();
218 (void) ptr.release();
223 Pout<<
"MeshObject::Store() : store <" << Type::typeName
224 <<
">, owned=" << ok <<
endl;
244 Pout<<
"meshObject::movePoints() : moving " 245 << meshObjects.
size() <<
" <" << Mesh::typeName
246 <<
"> meshObjects, region=" << obr.
name() <<
endl;
249 for (
auto& item : meshObjects)
252 auto* objectPtr =
dynamic_cast<MoveableMeshObject<Mesh>*
>(&item);
260 objectPtr->movePoints();
277 UPtrList<GeometricMeshObject<Mesh>> meshObjects
279 obr.sorted<GeometricMeshObject<Mesh>>()
284 Pout<<
"meshObject::updateMesh() : updating " 285 << meshObjects.size() <<
" <" << Mesh::typeName
286 <<
"> meshObjects, region=" << obr.
name() <<
endl;
289 for (
auto& item : meshObjects)
292 auto* objectPtr =
dynamic_cast<UpdateableMeshObject<Mesh>*
>(&item);
300 objectPtr->updateMesh(mpm);
314 template<
class Mesh,
template<
class>
class MeshObjectType>
317 UPtrList<MeshObjectType<Mesh>> meshObjects
319 obr.sorted<MeshObjectType<Mesh>>()
324 Pout<<
"meshObject::clear() : clearing " 325 << meshObjects.size() <<
" <" << Mesh::typeName
326 <<
"> meshObjects, region=" << obr.
name() <<
endl;
329 for (
auto& item : meshObjects)
343 template<
class>
class FromType,
344 template<
class>
class ToType
350 obr.
sorted<FromType<Mesh>>()
355 Pout<<
"meshObject::clearUpto() : clearing " 356 << meshObjects.
size() <<
" <" << Mesh::typeName
357 <<
"> meshObjects, region=" << obr.
name() <<
endl;
360 for (
auto& item : meshObjects)
363 auto* objectPtr =
dynamic_cast<ToType<Mesh>*
>(&item);
static void updateMesh(objectRegistry &obr, const mapPolyMesh &mpm)
Update topology using the given map.
static void clearUpto(objectRegistry &obr)
Clear all meshObject derived from FromType up to (but not including) ToType.
const word & name() const noexcept
Return the object name.
static const Type & New(const Mesh &mesh, Args &&... args)
Get existing or create MeshObject registered with typeName.
Ostream & endl(Ostream &os)
Add newline and flush stream.
static bool Store(std::unique_ptr< Type > &&ptr)
Transfer ownership of meshObject to registry.
bool checkOut(regIOobject *io) const
Remove a regIOobject from registry and free memory if the object is ownedByRegistry. A nullptr is ignored.
static void clear(objectRegistry &obr)
Clear/remove all meshObject of MeshObjectType via objectRegistry::checkOut()
virtual const fileName & name() const override
Get the name of the output serial stream. (eg, the name of the Fstream file name) ...
UPtrList< Type > sorted()
Return sorted list of objects with a class satisfying isA<Type> or isType<Type> (with Strict) ...
Useful combination of include files which define Sin, Sout and Serr and the use of IO streams general...
A class for handling words, derived from Foam::string.
label size() const noexcept
The number of entries in the list.
A list of pointers to objects of type <T>, without allocation/deallocation management of the pointers...
int debug
Static debugging option.
static std::unique_ptr< Type > Release(const word &objName, const Mesh &mesh, const bool checkout=false)
Release ownership of meshObject (with given registration name) from registry. Returns nullptr if not ...
static void movePoints(objectRegistry &obr)
Update for mesh motion.
static bool Delete(const word &objName, const Mesh &mesh)
Static destructor using given registration name.
Registry of regIOobjects.
Foam::argList args(argc, argv)
MeshObject(const Mesh &mesh)
Construct with Type::typeName on Mesh.
prefixOSstream Pout
OSstream wrapped stdout (std::cout) with parallel prefix.