DOLFIN
DOLFIN C++ interface
TetrahedronCell.h
1 // Copyright (C) 2006-2017 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 // Modified by Johan Hoffman, 2006.
19 // Modified by Garth N. Wells, 2006.
20 // Modified by Kristoffer Selim, 2008.
21 //
22 // First added: 2006-06-05
23 // Last changed: 2017-09-26
24 
25 #ifndef __TETRAHEDRON_CELL_H
26 #define __TETRAHEDRON_CELL_H
27 
28 #include <vector>
29 #include <boost/multi_array.hpp>
30 
31 #include "CellType.h"
32 
33 namespace dolfin
34 {
35 
36  class Cell;
37 
39 
40  class TetrahedronCell : public CellType
41  {
42  public:
43 
45  TetrahedronCell() : CellType(Type::tetrahedron, Type::triangle) {}
46 
48  bool is_simplex() const
49  { return true; }
50 
52  std::size_t dim() const;
53 
55  std::size_t num_entities(std::size_t dim) const;
56 
58  std::size_t num_vertices(std::size_t dim) const;
59 
61  std::size_t orientation(const Cell& cell) const;
62 
64  void create_entities(boost::multi_array<unsigned int, 2>& e,
65  std::size_t dim, const unsigned int* v) const;
66 
68  double volume(const MeshEntity& tetrahedron) const;
69 
71  double circumradius(const MeshEntity& tetrahedron) const;
72 
74  double squared_distance(const Cell& cell, const Point& point) const;
75 
78  double normal(const Cell& cell, std::size_t facet, std::size_t i) const;
79 
81  Point normal(const Cell& cell, std::size_t facet) const;
82 
84  Point cell_normal(const Cell& cell) const;
85 
87  double facet_area(const Cell& cell, std::size_t facet) const;
88 
90  void order(Cell& cell, const std::vector<std::int64_t>&
91  local_to_global_vertex_indices) const;
92 
94  bool collides(const Cell& cell, const Point& point) const;
95 
97  bool collides(const Cell& cell, const MeshEntity& entity) const;
98 
100  std::string description(bool plural) const;
101 
103  std::vector<std::int8_t> vtk_mapping() const
104  { return {0, 1, 2, 3}; }
105 
106  private:
107 
108  // Find local index of edge i according to ordering convention
109  std::size_t find_edge(std::size_t i, const Cell& cell) const;
110 
111  // Check whether point is outside region defined by facet ABC.
112  // The fourth vertex is needed to define the orientation.
113  bool point_outside_of_plane(const Point& point,
114  const Point& A,
115  const Point& B,
116  const Point& C,
117  const Point& D) const;
118 
119  };
120 
121 }
122 
123 #endif
TetrahedronCell()
Specify cell type and facet type.
Definition: TetrahedronCell.h:45
bool collides(const Cell &cell, const Point &point) const
Check whether given point collides with cell.
Definition: TetrahedronCell.cpp:530
std::size_t num_vertices() const
Return number of vertices for cell.
Definition: CellType.h:92
Definition: adapt.h:29
Definition: Point.h:40
std::vector< std::int8_t > vtk_mapping() const
Mapping of DOLFIN/UFC vertex ordering to VTK/XDMF ordering.
Definition: TetrahedronCell.h:103
std::size_t dim() const
Return topological dimension of cell.
Definition: TetrahedronCell.cpp:44
Type
Enum for different cell types.
Definition: CellType.h:51
double facet_area(const Cell &cell, std::size_t facet) const
Compute the area/length of given facet with respect to the cell.
Definition: TetrahedronCell.cpp:333
A Cell is a MeshEntity of topological codimension 0.
Definition: Cell.h:42
double normal(const Cell &cell, std::size_t facet, std::size_t i) const
Definition: TetrahedronCell.cpp:275
std::size_t num_entities(std::size_t dim) const
Return number of entities of given topological dimension.
Definition: TetrahedronCell.cpp:49
double volume(const MeshEntity &tetrahedron) const
Compute volume of tetrahedron.
Definition: TetrahedronCell.cpp:143
Definition: CellType.h:46
std::string description(bool plural) const
Return description of cell type.
Definition: TetrahedronCell.cpp:540
Point cell_normal(const Cell &cell) const
Compute normal to given cell (viewed as embedded in 4D ...)
Definition: TetrahedronCell.cpp:324
void create_entities(boost::multi_array< unsigned int, 2 > &e, std::size_t dim, const unsigned int *v) const
Create entities e of given topological dimension from vertices v.
Definition: TetrahedronCell.cpp:108
std::size_t orientation(const Cell &cell) const
Return orientation of the cell.
Definition: TetrahedronCell.cpp:91
double circumradius(const MeshEntity &tetrahedron) const
Compute circumradius of tetrahedron.
Definition: TetrahedronCell.cpp:184
Definition: MeshEntity.h:42
bool is_simplex() const
Check if cell is a simplex.
Definition: TetrahedronCell.h:48
double squared_distance(const Cell &cell, const Point &point) const
Compute squared distance to given point.
Definition: TetrahedronCell.cpp:232
This class implements functionality for tetrahedral cell meshes.
Definition: TetrahedronCell.h:40
void order(Cell &cell, const std::vector< std::int64_t > &local_to_global_vertex_indices) const
Order entities locally.
Definition: TetrahedronCell.cpp:362