ENH: MeshObject: add selective clearing function

This commit is contained in:
mattijs
2013-12-17 08:55:07 +00:00
parent 4dd1ce0869
commit 0f86a78673
2 changed files with 38 additions and 0 deletions

View File

@ -374,4 +374,32 @@ void Foam::meshObject::clear(objectRegistry& obr)
}
template
<
class Mesh,
template<class> class FromType,
template<class> class ToType
>
void Foam::meshObject::clearUpto(objectRegistry& obr)
{
HashTable<FromType<Mesh>*> meshObjects
(
obr.lookupClass<FromType<Mesh> >()
);
forAllIter(typename HashTable<FromType<Mesh>*>, meshObjects, iter)
{
if (!isA<ToType<Mesh> >(*iter()))
{
if (meshObject::debug)
{
Pout<< "meshObject::clearUpto(objectRegistry&) : destroying "
<< iter()->name() << endl;
}
obr.checkOut(*iter());
}
}
}
// ************************************************************************* //

View File

@ -182,6 +182,16 @@ public:
template<class Mesh, template<class> class MeshObjectType>
static void clear(objectRegistry&);
//- Clear all meshObject derived from FromType up to (but not including)
// ToType. Used to clear e.g. all non-updateable meshObjects
template
<
class Mesh,
template<class> class FromType,
template<class> class ToType
>
static void clearUpto(objectRegistry&);
};