dolfin team mailing list archive
-
dolfin team
-
Mailing list archive
-
Message #11674
MeshData erase patch
In attachment simple patch which gives possibility to erase/delete
MeshFunctions, Arrays and Mappings in the MeshData structure.
Quite useful for me.
regrd.
BArtek
diff -r 8891ff7fba42 dolfin/mesh/MeshData.cpp
--- a/dolfin/mesh/MeshData.cpp Tue Jan 13 01:01:24 2009 +0100
+++ b/dolfin/mesh/MeshData.cpp Tue Jan 13 16:36:20 2009 -0700
@@ -176,6 +176,48 @@
return it->second;
}
//-----------------------------------------------------------------------------
+void MeshData::eraseMeshFunction(const std::string name)
+{
+ mf_iterator it = meshfunctions.find(name);
+ if (it != meshfunctions.end())
+ {
+ delete it->second;
+ meshfunctions.erase(it);
+ }
+ else
+ {
+ warning("Mesh data named \"%s\" doesn't exist.", name.c_str());
+ }
+}
+//-----------------------------------------------------------------------------
+void MeshData::eraseArray(const std::string name)
+{
+ a_iterator it = arrays.find(name);
+ if (it != arrays.end())
+ {
+ delete it->second;
+ arrays.erase(it);
+ }
+ else
+ {
+ warning("Mesh data named \"%s\" doesn't exist.", name.c_str());
+ }
+}
+//-----------------------------------------------------------------------------
+void MeshData::eraseMapping(const std::string name)
+{
+ m_iterator it = maps.find(name);
+ if (it != maps.end())
+ {
+ delete it->second;
+ maps.erase(it);
+ }
+ else
+ {
+ warning("Mesh data named \"%s\" doesn't exist.", name.c_str());
+ }
+}
+//-----------------------------------------------------------------------------
void MeshData::disp() const
{
// Begin indentation
diff -r 8891ff7fba42 dolfin/mesh/MeshData.h
--- a/dolfin/mesh/MeshData.h Tue Jan 13 01:01:24 2009 +0100
+++ b/dolfin/mesh/MeshData.h Tue Jan 13 16:36:20 2009 -0700
@@ -62,6 +62,15 @@
/// Return Map with given name (returning zero if data is not available)
std::map<uint, uint>* mapping(const std::string name) const;
+
+ /// Erase MeshFunction with given name
+ void eraseMeshFunction(const std::string name);
+
+ /// Erase Array with given name
+ void eraseArray(const std::string name);
+
+ /// Erase Mapping with given name
+ void eraseMapping(const std::string name);
/// Display data
void disp() const;