70
70
//-----------------------------------------------------------------------------
71
boost::shared_ptr<MeshValueCollection<unsigned int> >
72
MeshDomains::markers(uint dim)
74
dolfin_assert(dim < _markers.size());
77
//-----------------------------------------------------------------------------
78
boost::shared_ptr<const MeshValueCollection<unsigned int> >
79
MeshDomains::markers(uint dim) const
81
dolfin_assert(dim < _markers.size());
84
//-----------------------------------------------------------------------------
85
std::vector<std::string> MeshDomains::marker_names(uint dim) const
71
boost::shared_ptr<MeshValueCollection<std::size_t> >
72
MeshDomains::markers(std::size_t dim)
74
dolfin_assert(dim < _markers.size());
77
//-----------------------------------------------------------------------------
78
boost::shared_ptr<const MeshValueCollection<std::size_t> >
79
MeshDomains::markers(std::size_t dim) const
81
dolfin_assert(dim < _markers.size());
84
//-----------------------------------------------------------------------------
85
std::vector<std::string> MeshDomains::marker_names(std::size_t dim) const
87
87
dolfin_assert(dim < _named_markers.size());
88
88
std::vector<std::string> names;
89
boost::unordered_map<std::string, boost::shared_ptr<MeshValueCollection<uint> > >::const_iterator m;
89
boost::unordered_map<std::string, boost::shared_ptr<MeshValueCollection<std::size_t> > >::const_iterator m;
90
90
for (m = _named_markers[dim].begin(); m != _named_markers[dim].end(); ++m)
91
91
names.push_back(m->first);
94
94
//-----------------------------------------------------------------------------
95
boost::shared_ptr<const MeshFunction<dolfin::uint> >
96
MeshDomains::cell_domains(const Mesh& mesh, uint unset_value) const
95
boost::shared_ptr<const MeshFunction<std::size_t> >
96
MeshDomains::cell_domains(const Mesh& mesh, std::size_t unset_value) const
98
98
// Check if any markers have been set
99
const uint D = mesh.topology().dim();
99
const std::size_t D = mesh.topology().dim();
100
100
dolfin_assert(D < _markers.size());
102
102
// Create markers if mesh collection present
103
103
if (!_markers[D]->empty() and !_cell_domains)
105
MeshValueCollection<unsigned int> domain = *(_markers[D]);
105
MeshValueCollection<std::size_t> domain = *(_markers[D]);
106
106
_cell_domains = mesh_function(mesh, domain, unset_value);
109
109
return _cell_domains;
111
111
//-----------------------------------------------------------------------------
112
boost::shared_ptr<const MeshFunction<dolfin::uint> >
113
MeshDomains::facet_domains(const Mesh& mesh, uint unset_value) const
112
boost::shared_ptr<const MeshFunction<std::size_t> >
113
MeshDomains::facet_domains(const Mesh& mesh, std::size_t unset_value) const
115
115
// Check if any markers have been set
116
const uint D = mesh.topology().dim();
116
const std::size_t D = mesh.topology().dim();
117
117
dolfin_assert((D - 1) < _markers.size());
119
119
// Create markers if mesh collection present
120
120
if (!_markers[D - 1]->empty() and !_facet_domains)
122
const MeshValueCollection<unsigned int> domain = *(_markers[D - 1]);
122
const MeshValueCollection<std::size_t> domain = *(_markers[D - 1]);
123
123
_facet_domains = mesh_function(mesh, domain, unset_value);
126
126
return _facet_domains;
128
128
//-----------------------------------------------------------------------------
129
boost::shared_ptr<MeshFunction<dolfin::uint> >
129
boost::shared_ptr<MeshFunction<std::size_t> >
130
130
MeshDomains::mesh_function(const Mesh& mesh,
131
const MeshValueCollection<unsigned int>& collection,
131
const MeshValueCollection<std::size_t>& collection,
132
std::size_t unset_value)
134
134
// Get dimensions
135
const uint d = collection.dim();
136
const uint D = mesh.topology().dim();
135
const std::size_t d = collection.dim();
136
const std::size_t D = mesh.topology().dim();
138
138
// Create MeshFunction
139
boost::shared_ptr<MeshFunction<uint> >
140
mesh_function(new MeshFunction<uint>(mesh, d, unset_value));
139
boost::shared_ptr<MeshFunction<std::size_t> >
140
mesh_function(new MeshFunction<std::size_t>(mesh, d, unset_value));
142
142
// Get mesh connectivity D --> d
143
143
dolfin_assert(d <= D);
145
145
dolfin_assert(D == d || !connectivity.empty());
147
147
// Iterate over all values
148
const std::map<std::pair<uint, uint>, uint> values = collection.values();
149
std::map<std::pair<uint, uint>, uint>::const_iterator it;
148
const std::map<std::pair<std::size_t, std::size_t>, std::size_t>& values = collection.values();
149
std::map<std::pair<std::size_t, std::size_t>, std::size_t>::const_iterator it;
150
150
for (it = values.begin(); it != values.end(); ++it)
152
152
// Get marker data
153
const uint cell_index = it->first.first;
154
const uint local_entity = it->first.second;
155
const uint value = it->second;
153
const std::size_t cell_index = it->first.first;
154
const std::size_t local_entity = it->first.second;
155
const std::size_t value = it->second;
157
157
// Get global entity index. Note that we ignore the local entity
158
158
// index when the function is defined over cells.
159
uint entity_index = 0;
159
std::size_t entity_index = 0;
161
161
entity_index = cell_index;