~corrado-maurini/dolfin/tao

« back to all changes in this revision

Viewing changes to dolfin/mesh/BoundaryComputation.cpp

  • Committer: corrado maurini
  • Date: 2012-12-18 12:16:08 UTC
  • mfrom: (6685.78.207 trunk)
  • Revision ID: corrado.maurini@upmc.fr-20121218121608-nk82ly9jgsld9u84
updating with trunk, fix uint in TAO solver and hacking the check for tao FindTAO.cmake

Show diffs side-by-side

added added

removed removed

Lines of Context:
64
64
  log(TRACE, "Computing boundary mesh.");
65
65
 
66
66
  // Open boundary mesh for editing
67
 
  const uint D = mesh.topology().dim();
 
67
  const std::size_t D = mesh.topology().dim();
68
68
  MeshEditor editor;
69
69
  editor.open(boundary, mesh.type().facet_type(), D - 1, mesh.geometry().dim());
70
70
 
72
72
  mesh.init(D - 1, D);
73
73
 
74
74
  // Temporary array for assignment of indices to vertices on the boundary
75
 
  const uint num_vertices = mesh.num_vertices();
76
 
  std::vector<uint> boundary_vertices(num_vertices, num_vertices);
 
75
  const std::size_t num_vertices = mesh.num_vertices();
 
76
  std::vector<std::size_t> boundary_vertices(num_vertices, num_vertices);
77
77
 
78
78
  // Determine boundary facet, count boundary vertices and facets,
79
79
  // and assign vertex indices
80
 
  uint num_boundary_vertices = 0;
81
 
  uint num_boundary_cells = 0;
 
80
  std::size_t num_boundary_vertices = 0;
 
81
  std::size_t num_boundary_cells = 0;
82
82
  MeshFunction<bool> boundary_facet(mesh, D - 1, false);
83
83
  for (FacetIterator f(mesh); !f.end(); ++f)
84
84
  {
96
96
        // Count boundary vertices and assign indices
97
97
        for (VertexIterator v(*f); !v.end(); ++v)
98
98
        {
99
 
          const uint vertex_index = v->index();
 
99
          const std::size_t vertex_index = v->index();
100
100
          if (boundary_vertices[vertex_index] == num_vertices)
101
101
            boundary_vertices[vertex_index] = num_boundary_vertices++;
102
102
        }
112
112
  editor.init_cells(num_boundary_cells);
113
113
 
114
114
  // Initialize mapping from vertices in boundary to vertices in mesh
115
 
  MeshFunction<unsigned int>& vertex_map = boundary.vertex_map();
 
115
  MeshFunction<std::size_t>& vertex_map = boundary.vertex_map();
116
116
  if (num_boundary_vertices > 0)
117
117
    vertex_map.init(boundary, 0, num_boundary_vertices);
118
118
 
119
119
  // Initialize mapping from cells in boundary to facets in mesh
120
 
  MeshFunction<unsigned int>& cell_map = boundary.cell_map();
 
120
  MeshFunction<std::size_t>& cell_map = boundary.cell_map();
121
121
  if (num_boundary_cells > 0)
122
122
    cell_map.init(boundary, D - 1, num_boundary_cells);
123
123
 
124
124
  // Create vertices
125
125
  for (VertexIterator v(mesh); !v.end(); ++v)
126
126
  {
127
 
    const uint vertex_index = boundary_vertices[v->index()];
 
127
    const std::size_t vertex_index = boundary_vertices[v->index()];
128
128
    if (vertex_index != mesh.num_vertices())
129
129
    {
130
130
      // Create mapping from boundary vertex to mesh vertex if requested
138
138
  }
139
139
 
140
140
  // Create cells (facets)
141
 
  std::vector<uint> cell(boundary.type().num_vertices(boundary.topology().dim()));
142
 
  uint current_cell = 0;
 
141
  std::vector<std::size_t> cell(boundary.type().num_vertices(boundary.topology().dim()));
 
142
  std::size_t current_cell = 0;
143
143
  for (FacetIterator f(mesh); !f.end(); ++f)
144
144
  {
145
145
    if (boundary_facet[*f])
146
146
    {
147
147
      // Compute new vertex numbers for cell
148
 
      const uint* vertices = f->entities(0);
149
 
      for (uint i = 0; i < cell.size(); i++)
 
148
      const std::size_t* vertices = f->entities(0);
 
149
      for (std::size_t i = 0; i < cell.size(); i++)
150
150
        cell[i] = boundary_vertices[vertices[i]];
151
151
 
152
152
      // Reorder vertices so facet is right-oriented w.r.t. facet normal
167
167
  editor.close(false);
168
168
}
169
169
//-----------------------------------------------------------------------------
170
 
void BoundaryComputation::reorder(std::vector<uint>& vertices,
 
170
void BoundaryComputation::reorder(std::vector<std::size_t>& vertices,
171
171
                                  const Facet& facet)
172
172
{
173
173
  // Get mesh
174
174
  const Mesh& mesh = facet.mesh();
175
175
 
176
176
  // Get the vertex opposite to the facet (the one we remove)
177
 
  uint vertex = 0;
 
177
  std::size_t vertex = 0;
178
178
  const Cell cell(mesh, facet.entities(mesh.topology().dim())[0]);
179
 
  for (uint i = 0; i < cell.num_entities(0); i++)
 
179
  for (std::size_t i = 0; i < cell.num_entities(0); i++)
180
180
  {
181
181
    bool not_in_facet = true;
182
182
    vertex = cell.entities(0)[i];
183
 
    for (uint j = 0; j < facet.num_entities(0); j++)
 
183
    for (std::size_t j = 0; j < facet.num_entities(0); j++)
184
184
    {
185
185
      if (vertex == facet.entities(0)[j])
186
186
      {
210
210
 
211
211
      if (n.dot(p0 - p) < 0.0)
212
212
      {
213
 
        const uint tmp = vertices[0];
 
213
        const std::size_t tmp = vertices[0];
214
214
        vertices[0] = vertices[1];
215
215
        vertices[1] = tmp;
216
216
      }
229
229
 
230
230
      if (n.dot(p0 - p) < 0.0)
231
231
      {
232
 
        const uint tmp = vertices[0];
 
232
        const std::size_t tmp = vertices[0];
233
233
        vertices[0] = vertices[1];
234
234
        vertices[1] = tmp;
235
235
      }