~ubuntu-branches/ubuntu/wily/dolfin/wily-proposed

« back to all changes in this revision

Viewing changes to dolfin/mesh/MeshTopology.cpp

  • Committer: Package Import Robot
  • Author(s): Johannes Ring
  • Date: 2014-09-22 14:35:34 UTC
  • mfrom: (1.1.17) (19.1.23 sid)
  • Revision ID: package-import@ubuntu.com-20140922143534-0yi89jyuqbgdxwm9
Tags: 1.4.0+dfsg-4
* debian/control: Disable libcgal-dev on i386, mipsel and sparc.
* debian/rules: Remove bad directives in pkg-config file dolfin.pc
  (closes: #760658).
* Remove debian/libdolfin-dev.lintian-overrides.

Show diffs side-by-side

added added

removed removed

Lines of Context:
21
21
#include <numeric>
22
22
#include <sstream>
23
23
#include <dolfin/log/log.h>
24
 
#include <dolfin/common/MPI.h>
25
24
#include <dolfin/common/utils.h>
26
25
#include "MeshConnectivity.h"
27
26
#include "MeshTopology.h"
32
31
MeshTopology::MeshTopology()
33
32
 
34
33
{
35
 
  // Make shared vertices empty when in serial
36
 
  if (MPI::num_processes() == 1)
37
 
    shared_entities(0);
 
34
  // Do nothing
38
35
}
39
36
//-----------------------------------------------------------------------------
40
37
MeshTopology::MeshTopology(const MeshTopology& topology)
41
38
  : coloring(topology.coloring), num_entities(topology.num_entities),
42
 
    global_num_entities(topology.global_num_entities), 
 
39
    global_num_entities(topology.global_num_entities),
43
40
    _global_indices(topology._global_indices),
44
41
    _shared_entities(topology._shared_entities),
45
42
    connectivity(topology.connectivity)
98
95
void MeshTopology::clear()
99
96
{
100
97
  // Clear data
 
98
  coloring.clear();
101
99
  num_entities.clear();
102
100
  global_num_entities.clear();
 
101
  _global_indices.clear();
 
102
  _shared_entities.clear();
103
103
  connectivity.clear();
104
 
  _global_indices.clear();
105
 
  coloring.clear();
106
104
}
107
105
//-----------------------------------------------------------------------------
108
106
void MeshTopology::clear(std::size_t d0, std::size_t d1)
131
129
      connectivity[d0].push_back(MeshConnectivity(d0, d1));
132
130
}
133
131
//-----------------------------------------------------------------------------
134
 
void MeshTopology::init(std::size_t dim, std::size_t local_size)
 
132
void MeshTopology::init(std::size_t dim, std::size_t local_size,
 
133
                        std::size_t global_size)
135
134
{
136
135
  dolfin_assert(dim < num_entities.size());
137
136
  num_entities[dim] = local_size;
138
137
 
139
 
  if (MPI::num_processes() == 1)
140
 
    init_global(dim, local_size);
141
 
}
142
 
//-----------------------------------------------------------------------------
143
 
void MeshTopology::init_global(std::size_t dim, std::size_t global_size)
144
 
{
145
138
  dolfin_assert(dim < global_num_entities.size());
146
139
  global_num_entities[dim] = global_size;
 
140
 
 
141
  // FIXME: Remove this when ghost/halo cells are supported
 
142
  // If mesh is local, make shared vertices empty
 
143
  if (dim == 0 && (local_size == global_size))
 
144
    shared_entities(0);
147
145
}
148
146
//-----------------------------------------------------------------------------
149
147
void MeshTopology::init_global_indices(std::size_t dim, std::size_t size)
150
148
{
151
149
  dolfin_assert(dim < _global_indices.size());
152
 
  _global_indices[dim] = std::vector<std::size_t>(size, std::numeric_limits<std::size_t>::max());
 
150
  _global_indices[dim]
 
151
    = std::vector<std::size_t>(size, std::numeric_limits<std::size_t>::max());
153
152
}
154
153
//-----------------------------------------------------------------------------
155
 
dolfin::MeshConnectivity& MeshTopology::operator() (std::size_t d0, std::size_t d1)
 
154
dolfin::MeshConnectivity& MeshTopology::operator() (std::size_t d0,
 
155
                                                    std::size_t d1)
156
156
{
157
157
  dolfin_assert(d0 < connectivity.size());
158
158
  dolfin_assert(d1 < connectivity[d0].size());
159
159
  return connectivity[d0][d1];
160
160
}
161
161
//-----------------------------------------------------------------------------
162
 
const dolfin::MeshConnectivity& MeshTopology::operator() (std::size_t d0, std::size_t d1) const
 
162
const dolfin::MeshConnectivity& MeshTopology::operator() (std::size_t d0,
 
163
                                                          std::size_t d1) const
163
164
{
164
165
  dolfin_assert(d0 < connectivity.size());
165
166
  dolfin_assert(d1 < connectivity[d0].size());
167
168
}
168
169
//-----------------------------------------------------------------------------
169
170
std::map<unsigned int, std::set<unsigned int> >&
170
 
  MeshTopology::shared_entities(unsigned int dim)
 
171
MeshTopology::shared_entities(unsigned int dim)
171
172
{
172
 
  dolfin_assert(dim < this->dim());
 
173
  dolfin_assert(dim <= this->dim());
173
174
  return _shared_entities[dim];
174
175
}
175
176
//-----------------------------------------------------------------------------
176
177
const std::map<unsigned int, std::set<unsigned int> >&
177
 
  MeshTopology::shared_entities(unsigned int dim) const
 
178
MeshTopology::shared_entities(unsigned int dim) const
178
179
{
179
 
  std::map<unsigned int, std::map<unsigned int, std::set<unsigned int> > >::const_iterator e;
 
180
  std::map<unsigned int, std::map<unsigned int,
 
181
                                  std::set<unsigned int> > >::const_iterator e;
180
182
  e = _shared_entities.find(dim);
181
183
  if (e == _shared_entities.end())
182
184
  {
215
217
      s << "    " << d0;
216
218
      for (std::size_t d1 = 0; d1 <= _dim; d1++)
217
219
      {
218
 
        if ( !connectivity[d0][d1].empty() )
 
220
        if (!connectivity[d0][d1].empty())
219
221
          s << " x";
220
222
        else
221
223
          s << " -";
228
230
    {
229
231
      for (std::size_t d1 = 0; d1 <= _dim; d1++)
230
232
      {
231
 
        if ( connectivity[d0][d1].empty() )
 
233
        if (connectivity[d0][d1].empty())
232
234
          continue;
233
235
        s << indent(connectivity[d0][d1].str(true));
234
236
        s << std::endl;