Plugins
mesh.h
Go to the documentation of this file.
1 /*
2  * Copyright (c) 2014-2015: G-CSC, Goethe University Frankfurt
3  * Author: Sebastian Reiter
4  *
5  * This file is part of UG4.
6  *
7  * UG4 is free software: you can redistribute it and/or modify it under the
8  * terms of the GNU Lesser General Public License version 3 (as published by the
9  * Free Software Foundation) with the following additional attribution
10  * requirements (according to LGPL/GPL v3 §7):
11  *
12  * (1) The following notice must be displayed in the Appropriate Legal Notices
13  * of covered and combined works: "Based on UG4 (www.ug4.org/license)".
14  *
15  * (2) The following notice must be displayed at a prominent place in the
16  * terminal output of covered works: "Based on UG4 (www.ug4.org/license)".
17  *
18  * (3) The following bibliography is recommended for citation and must be
19  * preserved in all covered files:
20  * "Reiter, S., Vogel, A., Heppner, I., Rupp, M., and Wittum, G. A massively
21  * parallel geometric multigrid solver on hierarchically distributed grids.
22  * Computing and visualization in science 16, 4 (2013), 151-164"
23  * "Vogel, A., Reiter, S., Rupp, M., Nägel, A., and Wittum, G. UG4 -- a novel
24  * flexible software system for simulating pde based models on high performance
25  * computers. Computing and visualization in science 16, 4 (2013), 165-179"
26  *
27  * This program is distributed in the hope that it will be useful,
28  * but WITHOUT ANY WARRANTY; without even the implied warranty of
29  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
30  * GNU Lesser General Public License for more details.
31  */
32 
33 #ifndef __H__UG__mesh_object__
34 #define __H__UG__mesh_object__
35 
36 #include "lib_grid/grid/grid.h"
37 #include "lib_grid/grid/geometry.h"
39 #include "lib_grid/selector.h"
43 
44 namespace ug{
45 namespace promesh{
46 
47 
48 template <class TElem>
50  public:
52 
54 
57  {return make_sp(new ElementIterator(m_iter));}
58 
60  TElem* value() {return *m_iter;}
61  void advance() {++m_iter;}
62  bool equal(ElementIterator& i) {return (m_iter == i.m_iter);}
63  bool unequal(ElementIterator& i) {return (m_iter != i.m_iter);}
64 
65  private:
67 };
68 
69 
72 class Mesh
73 {
74  public:
77 
79  typedef Grid::FaceAttachmentAccessor<normal_attachment_t> normal_accessor_t;
80 
83 
88 
93 
94  Mesh();
95  Mesh(const Mesh& m);
96 
97  virtual ~Mesh() {}
98 
99  Grid& grid() {return m_grid;}
104 
107 
108  // pivot
109  void set_pivot(const vector3& pivot) {m_pivot = pivot;}
110  vector3& pivot() {return m_pivot;}
111 
115 
116  void set_position(Vertex* v, const vector3& p) {m_aaPos[v] = p;}
117  vector3& position(Vertex* v) {return m_aaPos[v];}
118 
122 
125  {
127  return m_aaVolumeConstraint;
128  }
129 
132  {
134  return m_aVolumeConstraint;
135  }
136 
139  {
143  }
144  }
145 
147  Vertex* create_vertex(const vector3& p);
148  Edge* create_edge(Vertex* v0, Vertex* v1);
149  Face* create_triangle(Vertex* v0, Vertex* v1, Vertex* v2);
150  Face* create_quadrilateral(Vertex* v0, Vertex* v1, Vertex* v2, Vertex* v3);
151  Volume* create_tetrahedron(Vertex* v0, Vertex* v1, Vertex* v2, Vertex* v3);
152  Volume* create_pyramid(Vertex* v0, Vertex* v1, Vertex* v2,
153  Vertex* v3, Vertex* v4);
154  Volume* create_prism(Vertex* v0, Vertex* v1, Vertex* v2,
155  Vertex* v3, Vertex* v4, Vertex* v5);
156  Volume* create_hexahedron(Vertex* v0, Vertex* v1, Vertex* v2, Vertex* v3,
157  Vertex* v4, Vertex* v5, Vertex* v6, Vertex* v7);
159  Vertex* v3, Vertex* v4, Vertex* v5);
160 
161  // iterators
163 
167  template <class TElem>
170  {return make_sp(new ElementIterator<typename TElem::grid_base_object>(grid().begin<TElem>()));}
171 
172  template <class TElem>
176 
177  template <class TElem>
179  subset_begin(int si)
184 
188  template <class TElem>
190  end()
191  {return make_sp(new ElementIterator<typename TElem::grid_base_object>(grid().end<TElem>()));}
192 
193  template <class TElem>
197 
198  template <class TElem>
200  subset_end(int si)
204  protected:
206  {
210  }
211  }
212 
213  protected:
214  void init();
215 
227 };
228 
230 }}// end of namespace
231 
232 #endif
parameterString p
Definition: Biogas.lua:1
bool access(Grid &grid, TAttachment &a)
void attach_to_volumes_dv(TAttachment &attachment, const typename TAttachment::ValueType &defaultValue)
void detach_from_volumes(IAttachment &attachment)
Definition: mesh.h:49
iterator_t m_iter
Definition: mesh.h:66
void advance()
Definition: mesh.h:61
Grid::traits< TElem >::iterator iterator_t
Definition: mesh.h:51
void assign(ElementIterator &i)
Definition: mesh.h:59
bool unequal(ElementIterator &i)
Definition: mesh.h:63
ElementIterator(iterator_t i)
Definition: mesh.h:53
bool equal(ElementIterator &i)
Definition: mesh.h:62
TElem * value()
Definition: mesh.h:60
SmartPtr< ElementIterator< TElem > > clone()
Definition: mesh.h:56
Definition: mesh.h:73
Grid m_grid
Definition: mesh.h:216
position_accessor_t & position_accessor()
returns accessor to vertex positions
Definition: mesh.h:113
SmartPtr< Geometry< 3, 3 > > m_geometry
Definition: mesh.h:226
SmartPtr< ElementIterator< typename TElem::grid_base_object > > subset_end(int si)
returns an iterator to the position behind the last element of the specified type
Definition: mesh.h:200
Grid::VolumeAttachmentAccessor< volume_constraint_attachment_t > volume_constraint_accessor_t
Definition: mesh.h:82
SubsetHandler m_creaseHandler
Definition: mesh.h:218
void volume_constraints_required()
Definition: mesh.h:205
ConstSmartPtr< Geometry< 3, 3 > > geometry() const
Definition: mesh.h:106
ElementIterator< Vertex > vertex_iter_t
Definition: mesh.h:84
Grid & grid()
Definition: mesh.h:99
ProjectionHandler & projection_handler()
Definition: mesh.h:103
Volume * create_pyramid(Vertex *v0, Vertex *v1, Vertex *v2, Vertex *v3, Vertex *v4)
Definition: mesh.cpp:105
ElementIterator< Volume > volume_iter_t
Definition: mesh.h:87
vector3 & pivot()
Definition: mesh.h:110
SmartPtr< Geometry< 3, 3 > > geometry()
Definition: mesh.h:105
volume_constraint_attachment_t m_aVolumeConstraint
Definition: mesh.h:224
Volume * create_octahedron(Vertex *v0, Vertex *v1, Vertex *v2, Vertex *v3, Vertex *v4, Vertex *v5)
Definition: mesh.cpp:125
vector3 & position(Vertex *v)
Definition: mesh.h:117
ANormal normal_attachment_t
Definition: mesh.h:78
SmartPtr< edge_iter_t > sp_edge_iter_t
Definition: mesh.h:90
Grid::VertexAttachmentAccessor< position_attachment_t > position_accessor_t
Definition: mesh.h:76
volume_constraint_accessor_t m_aaVolumeConstraint
Definition: mesh.h:225
ElementIterator< Edge > edge_iter_t
Definition: mesh.h:85
SubsetHandler & subset_handler()
Definition: mesh.h:100
ANumber volume_constraint_attachment_t
Definition: mesh.h:81
volume_constraint_accessor_t & volume_constraint_accessor()
returns accessor to volume constraints.
Definition: mesh.h:124
APosition position_attachment_t
Definition: mesh.h:75
volume_constraint_attachment_t & volume_constraint_attachment()
returns the volume constraint attachment
Definition: mesh.h:131
SubsetHandler m_subsetHandler
Definition: mesh.h:217
Face * create_triangle(Vertex *v0, Vertex *v1, Vertex *v2)
Definition: mesh.cpp:87
ElementIterator< Face > face_iter_t
Definition: mesh.h:86
Selector m_selector
Definition: mesh.h:219
normal_attachment_t & normal_attachment()
Definition: mesh.h:121
void set_position(Vertex *v, const vector3 &p)
Definition: mesh.h:116
position_accessor_t m_aaPos
Definition: mesh.h:221
Volume * create_hexahedron(Vertex *v0, Vertex *v1, Vertex *v2, Vertex *v3, Vertex *v4, Vertex *v5, Vertex *v6, Vertex *v7)
Definition: mesh.cpp:118
SmartPtr< vertex_iter_t > sp_vertex_iter_t
Definition: mesh.h:89
Volume * create_tetrahedron(Vertex *v0, Vertex *v1, Vertex *v2, Vertex *v3)
Definition: mesh.cpp:99
position_attachment_t & position_attachment()
Definition: mesh.h:114
Edge * create_edge(Vertex *v0, Vertex *v1)
Definition: mesh.cpp:81
SmartPtr< ElementIterator< typename TElem::grid_base_object > > begin()
returns an iterator to the first element of the specified type
Definition: mesh.h:169
SubsetHandler & crease_handler()
Definition: mesh.h:101
SmartPtr< face_iter_t > sp_face_iter_t
Definition: mesh.h:91
ProjectionHandler m_projectionHandler
Definition: mesh.h:220
SmartPtr< ElementIterator< typename TElem::grid_base_object > > subset_begin(int si)
returns an iterator to the first element of the specified type
Definition: mesh.h:179
vector3 m_pivot
Definition: mesh.h:223
Vertex * create_vertex(const vector3 &p)
element creation and deletion
Definition: mesh.cpp:73
void set_pivot(const vector3 &pivot)
Definition: mesh.h:109
normal_accessor_t m_aaNorm
Definition: mesh.h:222
SmartPtr< ElementIterator< typename TElem::grid_base_object > > selection_end()
returns an iterator to the position behind the last element of the specified type
Definition: mesh.h:195
Volume * create_prism(Vertex *v0, Vertex *v1, Vertex *v2, Vertex *v3, Vertex *v4, Vertex *v5)
Definition: mesh.cpp:111
normal_accessor_t & normal_accessor()
returns accessor to face normals
Definition: mesh.h:120
SmartPtr< ElementIterator< typename TElem::grid_base_object > > end()
returns an iterator to the position behind the last element of the specified type
Definition: mesh.h:190
SmartPtr< volume_iter_t > sp_volume_iter_t
Definition: mesh.h:92
Face * create_quadrilateral(Vertex *v0, Vertex *v1, Vertex *v2, Vertex *v3)
Definition: mesh.cpp:93
void init()
Definition: mesh.cpp:54
SmartPtr< ElementIterator< typename TElem::grid_base_object > > selection_begin()
returns an iterator to the first element of the specified type
Definition: mesh.h:174
virtual ~Mesh()
Definition: mesh.h:97
Mesh()
Definition: mesh.cpp:38
Selector & selector()
Definition: mesh.h:102
void clear_volume_constraints()
clears the volume constraints (removes the attachment)
Definition: mesh.h:138
Grid::FaceAttachmentAccessor< normal_attachment_t > normal_accessor_t
Definition: mesh.h:79
ANormal aNormal("normal", true)
APosition aPosition("position", true)
SmartPtr< T, FreePolicy > make_sp(T *inst)
geometry_traits< TElem >::iterator iterator