Loading [MathJax]/extensions/tex2jax.js
ug4
All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Modules Pages
geometry.h
Go to the documentation of this file.
1/*
2 * Copyright (c) 2016: 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_geometry
34#define __H__UG_geometry
35
39#include "lib_grid/grid/grid.h"
40
41namespace ug{
42
44
62template <int dim>
63class IGeometry {
64public:
66
68 m_grid(g)
69 {}
70
71 virtual ~IGeometry () {}
72
73 virtual vector_t pos (Vertex* vrt) const = 0;
74 virtual void set_pos (Vertex* vrt, const vector_t& p) = 0;
75
76 Grid& grid() const {return m_grid;}
77
78 virtual int position_attachment_dim() const = 0;
79 virtual const IAttachment& position_attachment() const = 0;
80
81 virtual vector_t element_center(Vertex* e) const = 0;
82 virtual vector_t element_center(Edge* e) const = 0;
83 virtual vector_t element_center(Face* e) const = 0;
84 virtual vector_t element_center(Volume* e) const = 0;
85
86private:
88};
89
90
94
98
99
101
104template <int dim, int attachmentDim>
105class Geometry : public IGeometry<dim> {
106public:
108 typedef typename base_t::vector_t vector_t;
111
113 base_t (g),
114 m_aPos(a)
115 {
117 "the specified attachment is not attached to the "
118 "vertices of the specified grid.");
119 m_aaPos.access(g, a);
120 }
121
122 virtual vector_t pos (Vertex* vrt) const
123 {
124 return vector_t::from(m_aaPos[vrt]);
125 }
126
127 virtual void set_pos (Vertex* vrt, const vector_t& p)
128 {
129 m_aaPos[vrt] = attached_vector_t::from(p);
130 }
131
132 virtual int position_attachment_dim () const {return attachmentDim;}
133 const IAttachment& position_attachment () const {return m_aPos;}
134
135
136 virtual vector_t element_center (Vertex* e) const {
137 return vector_t::from(m_aaPos[e]);
138 }
139
140 virtual vector_t element_center (Edge* e) const {
142 }
143
144 virtual vector_t element_center (Face* e) const {
146 }
147
148 virtual vector_t element_center (Volume* e) const {
150 }
151
152
153private:
156};
157
158
159
161template <class TAPos>
163MakeGeometry3d (Grid& grid, TAPos aPos)
164{
165 return make_sp(new Geometry<3, TAPos::ValueType::Size>(grid, aPos));
166}
167}// end of namespace
168
169#endif //__H__UG_geometry
parameterString p
Definition smart_pointer.h:108
A generic specialization of IAttachment.
Definition attachment_pipe.h:263
Base-class for edges.
Definition grid_base_objects.h:397
Faces are 2-dimensional objects.
Definition grid_base_objects.h:510
provides a grid and access to the coordinates of the vertices
Definition geometry.h:105
virtual vector_t element_center(Vertex *e) const
Definition geometry.h:136
virtual vector_t element_center(Volume *e) const
Definition geometry.h:148
virtual vector_t element_center(Edge *e) const
Definition geometry.h:140
Geometry(Grid &g, position_attachment_t a)
Definition geometry.h:112
position_attachment_t m_aPos
Definition geometry.h:155
const IAttachment & position_attachment() const
Definition geometry.h:133
Grid::VertexAttachmentAccessor< position_attachment_t > m_aaPos
Definition geometry.h:154
Attachment< attached_vector_t > position_attachment_t
Definition geometry.h:110
MathVector< attachmentDim > attached_vector_t
Definition geometry.h:109
virtual vector_t element_center(Face *e) const
Definition geometry.h:144
base_t::vector_t vector_t
Definition geometry.h:108
virtual int position_attachment_dim() const
Definition geometry.h:132
virtual void set_pos(Vertex *vrt, const vector_t &p)
Definition geometry.h:127
IGeometry< dim > base_t
Definition geometry.h:107
virtual vector_t pos(Vertex *vrt) const
Definition geometry.h:122
bool access(Grid &grid, TAttachment &a)
Definition grid.h:189
Manages the elements of a grid and their interconnection.
Definition grid.h:132
bool has_vertex_attachment(IAttachment &attachment)
Definition grid.h:798
the interface for attachments.
Definition attachment_pipe.h:239
provides a grid and access to the coordinates of the vertices
Definition geometry.h:63
virtual vector_t pos(Vertex *vrt) const =0
Grid & grid() const
Definition geometry.h:76
MathVector< dim > vector_t
Definition geometry.h:65
Grid & m_grid
Definition geometry.h:87
virtual void set_pos(Vertex *vrt, const vector_t &p)=0
virtual int position_attachment_dim() const =0
virtual vector_t element_center(Face *e) const =0
virtual vector_t element_center(Edge *e) const =0
virtual vector_t element_center(Volume *e) const =0
virtual const IAttachment & position_attachment() const =0
IGeometry(Grid &g)
Definition geometry.h:67
virtual ~IGeometry()
Definition geometry.h:71
virtual vector_t element_center(Vertex *e) const =0
a mathematical Vector with N entries.
Definition math_vector.h:97
static MathVector from(const MathVector< fromN, T > &v)
Definition math_vector.h:109
Base-class for all vertex-types.
Definition grid_base_objects.h:231
Volumes are 3-dimensional objects.
Definition grid_base_objects.h:754
#define UG_COND_THROW(cond, msg)
UG_COND_THROW(cond, msg) : performs a UG_THROW(msg) if cond == true.
Definition error.h:61
void CalculateCenter(vector_t &centerOut, const vector_t *pointSet, size_t numPoints)
calculates the center of a point-set
Definition math_util_impl.hpp:98
the ug namespace
SmartPtr< IGeometry2d > SPIGeometry2d
Definition geometry.h:96
IGeometry< 2 > IGeometry2d
Definition geometry.h:92
IGeometry< 1 > IGeometry1d
Definition geometry.h:91
SPIGeometry3d MakeGeometry3d(Grid &grid, TAPos aPos)
Utility method to construct an IGeometry3d for a given grid and position attachment.
Definition geometry.h:163
IGeometry< 3 > IGeometry3d
Definition geometry.h:93
SmartPtr< IGeometry3d > SPIGeometry3d
Definition geometry.h:97
SmartPtr< IGeometry1d > SPIGeometry1d
Definition geometry.h:95
SmartPtr< T, FreePolicy > make_sp(T *inst)
returns a SmartPtr for the passed raw pointer
Definition smart_pointer.h:836
typedefs for ugmath