23 #ifndef __MESH_GEOMETRY_H 24 #define __MESH_GEOMETRY_H 28 #include <dolfin/geometry/Point.h> 29 #include <dolfin/log/log.h> 56 std::size_t
dim()
const 66 dolfin_assert(coordinates.size() % _dim == 0);
69 dolfin_assert(entity_offsets.size() > 1);
70 dolfin_assert(entity_offsets[1].size() > 0);
71 return entity_offsets[1][0];
73 return coordinates.size()/_dim;
80 dolfin_assert(coordinates.size() % _dim == 0);
81 return coordinates.size()/_dim;
88 return &coordinates[point_index*_dim];
94 dolfin_assert(point_index*_dim < coordinates.size());
95 return &coordinates[point_index*_dim];
99 double x(std::size_t n, std::size_t i)
const 101 dolfin_assert((n*_dim + i) < coordinates.size());
102 dolfin_assert(i < _dim);
103 return coordinates[n*_dim + i];
107 const double*
x(std::size_t n)
const 109 dolfin_assert(n*_dim < coordinates.size());
110 return &coordinates[n*_dim];
114 std::vector<double>&
x()
115 {
return coordinates; }
118 const std::vector<double>&
x()
const 119 {
return coordinates; }
128 void init_entities(
const std::vector<std::size_t>& num_entities);
140 return (_degree - 1);
142 return (_degree - 2)*(_degree - 1)/2;
144 return (_degree - 3)*(_degree - 2)*(_degree - 1)/6;
147 "calculate number of points",
148 "Entity dimension out of range");
154 std::size_t index)
const 156 dolfin_assert(entity_dim < entity_offsets.size());
157 dolfin_assert(order < entity_offsets[entity_dim].size());
158 const std::size_t idx = (entity_offsets[entity_dim][order] + index);
159 dolfin_assert(idx*_dim < coordinates.size());
164 void set(std::size_t local_index,
const double*
x);
172 std::size_t
hash()
const;
175 std::string
str(
bool verbose)
const;
186 std::vector<std::vector<std::size_t>> entity_offsets;
189 std::vector<double> coordinates;
std::size_t num_vertices() const
Return the number of vertex coordinates.
Definition: MeshGeometry.h:64
MeshGeometry stores the geometry imposed on a mesh.
Definition: MeshGeometry.h:39
const std::vector< double > & x() const
Return array of values for all coordinates.
Definition: MeshGeometry.h:118
std::vector< double > & x()
Return array of values for all coordinates.
Definition: MeshGeometry.h:114
void init_entities(const std::vector< std::size_t > &num_entities)
Initialise entities. To be called after init.
Definition: MeshGeometry.cpp:95
const double * x(std::size_t n) const
Return array of values for coordinate with local index n.
Definition: MeshGeometry.h:107
MeshGeometry()
Create empty set of coordinates.
Definition: MeshGeometry.cpp:33
std::size_t num_entity_coordinates(std::size_t entity_dim) const
Get the number of coordinate points per entity for this degree.
Definition: MeshGeometry.h:131
double x(std::size_t n, std::size_t i) const
Return value of coordinate with local index n in direction i.
Definition: MeshGeometry.h:99
std::size_t degree() const
Return polynomial degree of coordinate field.
Definition: MeshGeometry.h:60
void init(std::size_t dim, std::size_t degree)
Initialize coordinate list to given dimension and degree.
Definition: MeshGeometry.cpp:65
Point point(std::size_t n) const
Return coordinate with local index n as a 3D point value.
Definition: MeshGeometry.cpp:60
~MeshGeometry()
Destructor.
Definition: MeshGeometry.cpp:43
std::string str(bool verbose) const
Return informal string representation (pretty-print)
Definition: MeshGeometry.cpp:129
const double * vertex_coordinates(std::size_t point_index)
Get vertex coordinates.
Definition: MeshGeometry.h:85
std::size_t hash() const
Definition: MeshGeometry.cpp:121
std::size_t num_points() const
Definition: MeshGeometry.h:78
const double * point_coordinates(std::size_t point_index)
Get vertex coordinates.
Definition: MeshGeometry.h:92
void dolfin_error(std::string location, std::string task, std::string reason,...)
Definition: log.cpp:129
std::size_t dim() const
Return Euclidean dimension of coordinate system.
Definition: MeshGeometry.h:56
std::size_t get_entity_index(std::size_t entity_dim, std::size_t order, std::size_t index) const
Get the index for an entity point in coordinates.
Definition: MeshGeometry.h:153
const MeshGeometry & operator=(const MeshGeometry &geometry)
Assignment.
Definition: MeshGeometry.cpp:48