ug4
grid_objects_0d.h
Go to the documentation of this file.
1 /*
2  * Copyright (c) 2011-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__grid_objects_0d__
34 #define __H__UG__grid_objects_0d__
35 
36 #include "../grid/grid.h"
37 #include "common/math/ugmath.h"
38 #include "common/assert.h"
39 
40 namespace ug
41 {
44 
46 {
47  CSVRT_NONE = -1,
50 };
51 
52 
54 // RegularVertex
56 
61 class UG_API RegularVertex : public Vertex
62 {
63  friend class Grid;
64  public:
65  inline static bool type_match(GridObject* pObj) {return dynamic_cast<RegularVertex*>(pObj) != NULL;}
66 
67  virtual ~RegularVertex() {}
68 
69  virtual GridObject* create_empty_instance() const {return new RegularVertex;}
70 
71  virtual int container_section() const {return CSVRT_REGULAR_VERTEX;}
73 };
74 
75 template <>
77 {
78  public:
82 
84 
85  enum
86  {
87  CONTAINER_SECTION = CSVRT_REGULAR_VERTEX,
88  BASE_OBJECT_ID = VERTEX
89  };
90 
91  static const ReferenceObjectID REFERENCE_OBJECT_ID = ROID_VERTEX;
92 };
93 
96 
97 
98 
100 // ConstrainedVertex
102 
110 {
111  friend class Grid;
112  public:
113  inline static bool type_match(GridObject* pObj) {return dynamic_cast<ConstrainedVertex*>(pObj) != NULL;}
114 
115  ConstrainedVertex() : m_constrainingObj(NULL), m_parentBaseObjectId(-1) {}
117  {
118  if(m_constrainingObj)
119  m_constrainingObj->remove_constraint_link(this);
120  }
121 
122  virtual GridObject* create_empty_instance() const {return new ConstrainedVertex;}
123 
124  virtual int container_section() const {return CSVRT_CONSTRAINED_VERTEX;}
126 
127  virtual bool is_constrained() const {return true;}
128 
129  virtual void remove_constraint_link(const Edge* e)
130  {
131  if(m_constrainingObj == static_cast<const GridObject*>(e)){
132  m_constrainingObj = NULL;
133  }
134  }
135 
136  virtual void remove_constraint_link(const Face* f)
137  {
138  if(m_constrainingObj == static_cast<const GridObject*>(f)){
139  m_constrainingObj = NULL;
140  }
141  }
142 
143  inline void set_constraining_object(GridObject* constrObj)
144  {
145  m_constrainingObj = constrObj;
146  if(constrObj)
147  m_parentBaseObjectId = constrObj->base_object_id();
148  }
149 
150  inline GridObject* get_constraining_object() {return m_constrainingObj;}
151  inline int get_parent_base_object_id() {return m_parentBaseObjectId;}
152  inline void set_parent_base_object_id(int id)
153  {
154  if((m_parentBaseObjectId != -1) && (m_parentBaseObjectId != id)){
155  UG_THROW("Bad parent base object id specified! The given id"
156  " has to match the id of the constraining object if that"
157  " is present. Call this method only, if no constraining"
158  " object has been set!");
159  }
160  m_parentBaseObjectId = id;
161  }
162 
163  inline const vector2& get_local_coordinates() const {return m_localCoord;}
164  inline number get_local_coordinate_1() const {return m_localCoord.x();}
165  inline number get_local_coordinate_2() const {return m_localCoord.y();}
166 
167  inline void set_local_coordinates(number x, number y) {m_localCoord.x() = x; m_localCoord.y() = y;}
168  inline void set_local_coordinates(const vector2& coords) {m_localCoord = coords;}
169  inline void set_local_coordinate_1(number coord) {m_localCoord.x() = coord;}
170  inline void set_local_coordinate_2(number coord) {m_localCoord.y() = coord;}
171 
172  protected:
176 };
177 
178 template <>
180 {
181  public:
185 
187 
188  enum
189  {
190  CONTAINER_SECTION = CSVRT_CONSTRAINED_VERTEX,
191  BASE_OBJECT_ID = VERTEX
192  };
193  static const ReferenceObjectID REFERENCE_OBJECT_ID = ROID_VERTEX;
194 };
195 
198 
199 
200 }// end of namespace
201 
202 #endif
Use this class as a tool to create const_iterators to your own geometric objects.
Definition: generic_grid_object_iterator.h:70
A vertex appearing on edges or faces.
Definition: grid_objects_0d.h:110
void set_local_coordinate_2(number coord)
Definition: grid_objects_0d.h:170
ConstrainedVertex()
Definition: grid_objects_0d.h:115
number get_local_coordinate_1() const
Definition: grid_objects_0d.h:164
virtual ~ConstrainedVertex()
Definition: grid_objects_0d.h:116
GridObject * m_constrainingObj
Definition: grid_objects_0d.h:173
virtual GridObject * create_empty_instance() const
create an instance of the derived type
Definition: grid_objects_0d.h:122
virtual ReferenceObjectID reference_object_id() const
Definition: grid_objects_0d.h:125
virtual bool is_constrained() const
returns true if the object is constrained by other objects.
Definition: grid_objects_0d.h:127
virtual void remove_constraint_link(const Edge *e)
removes a constraint link to the grid object.
Definition: grid_objects_0d.h:129
void set_constraining_object(GridObject *constrObj)
Definition: grid_objects_0d.h:143
int m_parentBaseObjectId
Definition: grid_objects_0d.h:175
GridObject * get_constraining_object()
Definition: grid_objects_0d.h:150
int get_parent_base_object_id()
Definition: grid_objects_0d.h:151
virtual int container_section() const
Definition: grid_objects_0d.h:124
vector2 m_localCoord
Definition: grid_objects_0d.h:174
static bool type_match(GridObject *pObj)
Definition: grid_objects_0d.h:113
number get_local_coordinate_2() const
Definition: grid_objects_0d.h:165
void set_local_coordinates(number x, number y)
Definition: grid_objects_0d.h:167
virtual void remove_constraint_link(const Face *f)
removes a constraint link to the grid object.
Definition: grid_objects_0d.h:136
void set_local_coordinates(const vector2 &coords)
Definition: grid_objects_0d.h:168
void set_parent_base_object_id(int id)
Definition: grid_objects_0d.h:152
const vector2 & get_local_coordinates() const
Definition: grid_objects_0d.h:163
void set_local_coordinate_1(number coord)
Definition: grid_objects_0d.h:169
Base-class for edges.
Definition: grid_base_objects.h:397
Faces are 2-dimensional objects.
Definition: grid_base_objects.h:510
Use this class as a tool to create iterators to your own geometric objects.
Definition: generic_grid_object_iterator.h:44
Manages the elements of a grid and their interconnection.
Definition: grid.h:132
The base class for all geometric objects, such as vertices, edges, faces, volumes,...
Definition: grid_base_objects.h:157
virtual int base_object_id() const =0
A basic vertex-type.
Definition: grid_objects_0d.h:62
virtual int container_section() const
Definition: grid_objects_0d.h:71
virtual ~RegularVertex()
Definition: grid_objects_0d.h:67
virtual GridObject * create_empty_instance() const
create an instance of the derived type
Definition: grid_objects_0d.h:69
static bool type_match(GridObject *pObj)
Definition: grid_objects_0d.h:65
virtual ReferenceObjectID reference_object_id() const
Definition: grid_objects_0d.h:72
Base-class for all vertex-types.
Definition: grid_base_objects.h:231
GenericGridObjectIterator< ConstrainedVertex *, VertexIterator > iterator
Definition: grid_objects_0d.h:182
Vertex grid_base_object
Definition: grid_objects_0d.h:186
ConstGenericGridObjectIterator< ConstrainedVertex *, VertexIterator, ConstVertexIterator > const_iterator
Definition: grid_objects_0d.h:184
GenericGridObjectIterator< RegularVertex *, VertexIterator > iterator
Definition: grid_objects_0d.h:79
ConstGenericGridObjectIterator< RegularVertex *, VertexIterator, ConstVertexIterator > const_iterator
Definition: grid_objects_0d.h:81
Vertex grid_base_object
Definition: grid_objects_0d.h:83
Definition: grid_base_object_traits.h:68
#define UG_THROW(msg)
Definition: error.h:57
#define UG_API
Definition: ug_config.h:65
double number
Definition: types.h:124
the ug namespace
ElementStorage< Vertex >::SectionContainer::iterator VertexIterator
This Iterator will be used as base-class for iterators of specialized geometric objects.
Definition: grid_base_object_traits.h:73
ReferenceObjectID
these ids are used to identify the shape of a geometric object.
Definition: grid_base_objects.h:74
@ ROID_VERTEX
Definition: grid_base_objects.h:76
geometry_traits< ConstrainedVertex >::const_iterator ConstConstrainedVertexIterator
Definition: grid_objects_0d.h:197
geometry_traits< RegularVertex >::iterator RegularVertexIterator
Definition: grid_objects_0d.h:94
@ VERTEX
Definition: grid_base_objects.h:60
geometry_traits< ConstrainedVertex >::iterator ConstrainedVertexIterator
Definition: grid_objects_0d.h:196
geometry_traits< RegularVertex >::const_iterator ConstRegularVertexIterator
Definition: grid_objects_0d.h:95
VertexContainerSections
These numbers define where in the vertex-section-container a vertex will be stored.
Definition: grid_objects_0d.h:46
@ CSVRT_NONE
Definition: grid_objects_0d.h:47
@ CSVRT_REGULAR_VERTEX
Definition: grid_objects_0d.h:48
@ CSVRT_CONSTRAINED_VERTEX
Definition: grid_objects_0d.h:49
ElementStorage< Vertex >::SectionContainer::const_iterator ConstVertexIterator
Definition: grid_base_object_traits.h:74