1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
|
// Copyright (C) 2008 Anders Logg.
// Licensed under the GNU LGPL Version 2.1.
//
// First added: 2008-05-19
// Last changed: 2008-05-21
#include "MeshData.h"
using namespace dolfin;
typedef std::map<std::string, MeshFunction<dolfin::uint>*>::iterator mf_iterator;
typedef std::map<std::string, MeshFunction<dolfin::uint>*>::const_iterator mf_const_iterator;
typedef std::map<std::string, Array<dolfin::uint>*>::iterator a_iterator;
typedef std::map<std::string, Array<dolfin::uint>*>::const_iterator a_const_iterator;
//-----------------------------------------------------------------------------
MeshData::MeshData(Mesh& mesh) : mesh(mesh)
{
// Do nothing
}
//-----------------------------------------------------------------------------
MeshData::~MeshData()
{
clear();
}
//-----------------------------------------------------------------------------
void MeshData::clear()
{
for (mf_iterator it = meshfunctions.begin(); it != meshfunctions.end(); ++it)
delete it->second;
meshfunctions.clear();
for (a_iterator it = arrays.begin(); it != arrays.end(); ++it)
delete it->second;
arrays.clear();
}
//-----------------------------------------------------------------------------
MeshFunction<dolfin::uint>* MeshData::createMeshFunction(std::string name, uint dim)
{
// Check if data already exists
mf_iterator it = meshfunctions.find(name);
if (it != meshfunctions.end())
{
warning("Mesh data named \"%s\" already exists.", name.c_str());
return it->second;
}
// Create new data
MeshFunction<uint>* f = new MeshFunction<uint>(mesh);
f->init(mesh, dim);
// Add to map
meshfunctions[name] = f;
return f;
}
//-----------------------------------------------------------------------------
Array<dolfin::uint>* MeshData::createArray(std::string name, uint size)
{
// Check if data already exists
a_iterator it = arrays.find(name);
if (it != arrays.end())
{
warning("Mesh data named \"%s\" already exists.", name.c_str());
return it->second;
}
// Create new data
Array<uint>* a = new Array<uint>(size);
*a = 0;
// Add to map
arrays[name] = a;
return a;
}
//-----------------------------------------------------------------------------
MeshFunction<dolfin::uint>* MeshData::meshfunction(std::string name)
{
// Check if data exists
mf_iterator it = meshfunctions.find(name);
if (it == meshfunctions.end())
return 0;
return it->second;
}
//-----------------------------------------------------------------------------
Array<dolfin::uint>* MeshData::array(std::string name)
{
// Check if data exists
a_iterator it = arrays.find(name);
if (it == arrays.end())
return 0;
return it->second;
}
//-----------------------------------------------------------------------------
void MeshData::disp() const
{
// Begin indentation
cout << "Auxiliary mesh data" << endl;
begin("-------------------");
cout << endl;
for (mf_const_iterator it = meshfunctions.begin(); it != meshfunctions.end(); ++it)
{
cout << "MeshFunction<uint> of size "
<< it->second->size()
<< " on entities of topological dimension "
<< it->second->dim()
<< ": \"" << it->first << "\"" << endl;
}
for (a_const_iterator it = arrays.begin(); it != arrays.end(); ++it)
cout << "Array<uint> of size " << it->second->size()
<< ": \"" << it->first << "\"" << endl;
// End indentation
end();
}
//-----------------------------------------------------------------------------
|