DOLFIN
DOLFIN C++ interface
DynamicMeshEditor.h
1 // Copyright (C) 2008 Anders Logg
2 //
3 // This file is part of DOLFIN.
4 //
5 // DOLFIN is free software: you can redistribute it and/or modify
6 // it under the terms of the GNU Lesser General Public License as published by
7 // the Free Software Foundation, either version 3 of the License, or
8 // (at your option) any later version.
9 //
10 // DOLFIN is distributed in the hope that it will be useful,
11 // but WITHOUT ANY WARRANTY; without even the implied warranty of
12 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13 // GNU Lesser General Public License for more details.
14 //
15 // You should have received a copy of the GNU Lesser General Public License
16 // along with DOLFIN. If not, see <http://www.gnu.org/licenses/>.
17 //
18 // First added: 2008-09-22
19 // Last changed: 2008-11-13
20 
21 #ifndef __DYNAMIC_MESH_EDITOR_H
22 #define __DYNAMIC_MESH_EDITOR_H
23 
24 #include "CellType.h"
25 
26 namespace dolfin
27 {
28 
29  class Mesh;
30  class Point;
31  class Vector;
32 
37 
39  {
40  public:
41 
44 
47 
49  void open(Mesh& mesh, CellType::Type type, std::size_t tdim,
50  std::size_t gdim, std::size_t num_global_vertices,
51  std::size_t num_global_cells);
52 
54  void open(Mesh& mesh, std::string type, std::size_t tdim, std::size_t gdim,
55  std::size_t num_global_vertices, std::size_t num_global_cells);
56 
58  void add_vertex(std::size_t v, const Point& p);
59 
61  void add_vertex(std::size_t v, double x);
62 
64  void add_vertex(std::size_t v, double x, double y);
65 
67  void add_vertex(std::size_t v, double x, double y, double z);
68 
70  void add_cell(std::size_t c, const std::vector<std::size_t>& v);
71 
73  void add_cell(std::size_t c, std::size_t v0, std::size_t v1);
74 
76  void add_cell(std::size_t c, std::size_t v0, std::size_t v1,
77  std::size_t v2);
78 
80  void add_cell(std::size_t c, std::size_t v0, std::size_t v1,
81  std::size_t v2, std::size_t v3);
82 
84  void close(bool order=false);
85 
86  private:
87 
88  // Clear data
89  void clear();
90 
91  // The mesh
92  Mesh* _mesh;
93 
94  // Topological dimension
95  std::size_t _tdim;
96 
97  // Geometrical (Euclidean) dimension
98  std::size_t _gdim;
99 
100  // Cell type
101  CellType* _cell_type;
102 
103  // Number of global vertices and cells
104  std::size_t _num_global_vertices, _num_global_cells;
105 
106  // Dynamic storage for vertex coordinates
107  std::vector<double> vertex_coordinates;
108 
109  // Dynamic storage for cells
110  std::vector<std::size_t> cell_vertices;
111 
112  };
113 
114 }
115 
116 #endif
DynamicMeshEditor()
Constructor.
Definition: DynamicMeshEditor.cpp:30
~DynamicMeshEditor()
Destructor.
Definition: DynamicMeshEditor.cpp:38
Definition: adapt.h:29
Definition: Point.h:40
Type
Enum for different cell types.
Definition: CellType.h:51
Definition: CellType.h:46
void close(bool order=false)
Close mesh, finish editing, and order entities locally.
Definition: DynamicMeshEditor.cpp:176
void add_cell(std::size_t c, const std::vector< std::size_t > &v)
Add cell with given vertices.
Definition: DynamicMeshEditor.cpp:122
void add_vertex(std::size_t v, const Point &p)
Add vertex v at given point p.
Definition: DynamicMeshEditor.cpp:91
void open(Mesh &mesh, CellType::Type type, std::size_t tdim, std::size_t gdim, std::size_t num_global_vertices, std::size_t num_global_cells)
Open mesh of given cell type, topological and geometrical dimension.
Definition: DynamicMeshEditor.cpp:43
Definition: Mesh.h:82
Definition: DynamicMeshEditor.h:38