Loading [MathJax]/extensions/tex2jax.js
ug4
All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Modules Pages
subdivision_rules_piecewise_loop.h
Go to the documentation of this file.
1/*
2 * Copyright (c) 2010-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__SUBDIVISION_RULES_PIECEWISE_LOOP__
34#define __H__UG__SUBDIVISION_RULES_PIECEWISE_LOOP__
35
36#include <vector>
37#include <cassert>
38#include "lib_grid/lg_base.h"
39
40namespace ug
41{
42
45
48{
49 public:
52 NeighborInfo(Vertex* n, size_t cval) :
53 nbr(n), creaseValence(cval) {}
54
60 };
61
62 public:
65 {
66 static SubdivRules_PLoop subdivRules;
67 return subdivRules;
68 }
69
71 // WEIGHTS
73 {return 1. - (number)valence * get_beta(valence);}
74
75 number ref_even_inner_nbr_weight(size_t valence) const
76 {return get_beta(valence);}
77
80 {return vector3(0.75, 0.125, 0.125);}
81
83 {return vector4(0.375, 0.375, 0.125, 0.125);}
84
86
93 vector4 ref_odd_inner_weights(size_t creaseValence) const
94 {
95 assert(creaseValence > 2 && "Bad crease valence. Underlying grid is not a surface grid.");
96 if(creaseValence == 4)
97 return ref_odd_inner_weights();
98 number gamma = 0.5 - 0.25 * cos(PI / (number)(creaseValence - 1));
99 return vector4(0.75 - gamma, gamma, 0.125, 0.125);
100
101 //number c = 0.25 * cos((2.*PI) / (number)(creaseValence - 1));
102 //return vector4(0.5 - c, 0.25 + c, 0.125, 0.125);
103 }
104
106 {return vector2(0.5, 0.5);}
107
108 number proj_inner_center_weight(size_t valence) const
109 {return 1.0 - (number)valence / (0.375 / get_beta(valence) + valence);}
110
111 number proj_inner_nbr_weight(size_t valence) const
112 {return 1.0 / (0.375 / get_beta(valence) + valence);}
113
115 {return vector3(2./3., 1./6., 1./6.);}
116
118 void proj_inner_crease_nbr_weights(number& centerWgtOut, number* nbrWgtsOut,
119 NeighborInfo* nbrInfos, size_t numNbrs) const
120 {
121 number wcntrProj = proj_inner_center_weight(numNbrs);
122 number wnbrProj = proj_inner_nbr_weight(numNbrs);
123
124 // initialize all weights with 0
125 centerWgtOut = 0;
126 for(size_t i = 0; i < numNbrs; ++i)
127 nbrWgtsOut[i] = 0;
128
129 for(size_t i = 0; i < numNbrs; ++i){
130 NeighborInfo& nbrInfo = nbrInfos[i];
131 vector4 oddWeights(0.5, 0.5, 0, 0);
132
133 if(nbrInfo.creaseValence == 0){
134 // Calculate the weights for odd-refinement on the given edge
135 oddWeights = ref_odd_inner_weights();
136 }
137 else{
138 oddWeights = ref_odd_inner_weights(nbrInfo.creaseValence);
139 }
140
141 nbrWgtsOut[i] += oddWeights.x() * wnbrProj;
142 centerWgtOut += oddWeights.y() * wnbrProj;
143 nbrWgtsOut[next_ind(i, numNbrs)] += oddWeights.z() * wnbrProj;
144 nbrWgtsOut[prev_ind(i, numNbrs)] += oddWeights.w() * wnbrProj;
145 }
146
147
148 // add scaled weights for evem refinement mask
149 centerWgtOut += wcntrProj * ref_even_inner_center_weight(numNbrs);
150 for(size_t i = 0; i < numNbrs; ++i)
151 nbrWgtsOut[i] += wcntrProj * ref_even_inner_nbr_weight(numNbrs);
152 }
153/*
154 number proj_inner_crease_nbr_center_weight(size_t valence);
155 number proj_inner_crease_nbr_nbr_weight(size_t valence);
156 number proj_inner_crease_nbr_nbr_weight(size_t valence, size_t cValence);
157*/
159
161 number get_beta(size_t valency) const;
162/*
164 // EVEN MASKS
165 template <class TAAPos>
166 typename TAAPos::ValueType
167 apply_even_mask(Grid& grid, Vertex* center,
168 TAAPos& aaPos);
169
170 template <class TAAPos>
171 typename TAAPos::ValueType
172 apply_even_crease_mask(Vertex* center, Vertex* nbr1,
173 Vertex* nbr2, TAAPos& aaPos);
174
176 // ODD MASKS
177 template <class TAAPos>
178 typename TAAPos::ValueType
179 apply_odd_mask(Vertex* vrt, Edge* parent,
180 TAAPos& aaPos);
181
182 template <class TAAPos>
183 typename TAAPos::ValueType
184 apply_odd_crease_mask(Vertex* vrt, Edge* parent,
185 TAAPos& aaPos);
186
187 template <class TAAPos>
188 typename TAAPos::ValueType
189 apply_odd_crease_nbr_mask(Grid& grid, Vertex* vrt,
190 Edge* parent, TAAPos& aaPos);
191
193 // PROJECTION
194 template <class TAAPos>
195 typename TAAPos::ValueType
196 project_inner_vertex(Grid& grid, Vertex* vrt,
197 TAAPos& aaPos);
198
199 template <class TAAPos>
200 typename TAAPos::ValueType
201 project_inner_vertex(Vertex* vrt, Vertex* nbrs,
202 int* nbrCreaseValencies, int numNbrs,
203 TAAPos& aaPos);
204
205 template <class TAAPos>
206 typename TAAPos::ValueType
207 project_crease_vertex(Vertex* vrt, Vertex* nbr1,
208 Vertex* nbr2, TAAPos& aaPos);
209*/
210 private:
212 number calculate_beta(size_t valency) const;
213
214 private:
217
220
223
225 inline size_t next_ind(size_t ind, size_t numInds) const {return (ind + 1) % numInds;}
227 inline size_t prev_ind(size_t ind, size_t numInds) const {return (ind + numInds - 1) % numInds;}
228
229
230 private:
231 std::vector<number> m_betas;//< precalculated betas.
232};
233
235
236}// end of namespace
237
238#endif
A singleton that stores all rules for a piecewise-loop subdivision surface.
Definition subdivision_rules_piecewise_loop.h:48
number proj_inner_nbr_weight(size_t valence) const
Definition subdivision_rules_piecewise_loop.h:111
vector4 ref_odd_inner_weights() const
Definition subdivision_rules_piecewise_loop.h:82
std::vector< number > m_betas
Definition subdivision_rules_piecewise_loop.h:231
SubdivRules_PLoop & operator=(const SubdivRules_PLoop &src)
private assignment operator prohibits assignment.
Definition subdivision_rules_piecewise_loop.cpp:59
size_t next_ind(size_t ind, size_t numInds) const
returns the next index in a cyclic index set
Definition subdivision_rules_piecewise_loop.h:225
number calculate_beta(size_t valency) const
calculates beta as it is used in the subdivision masks.
Definition subdivision_rules_piecewise_loop.cpp:76
number ref_even_inner_center_weight(size_t valence) const
Definition subdivision_rules_piecewise_loop.h:72
SubdivRules_PLoop()
private constructor prohibits multiple instantiation.
Definition subdivision_rules_piecewise_loop.cpp:42
number proj_inner_center_weight(size_t valence) const
Definition subdivision_rules_piecewise_loop.h:108
static SubdivRules_PLoop & inst()
returns the only instance to this singleton.
Definition subdivision_rules_piecewise_loop.h:64
void proj_inner_crease_nbr_weights(number &centerWgtOut, number *nbrWgtsOut, NeighborInfo *nbrInfos, size_t numNbrs) const
Definition subdivision_rules_piecewise_loop.h:118
vector4 ref_odd_inner_weights(size_t creaseValence) const
weights of an odd vertex on an inner edge that is connected to a crease.
Definition subdivision_rules_piecewise_loop.h:93
size_t prev_ind(size_t ind, size_t numInds) const
returns the previous index in a cyclic index set
Definition subdivision_rules_piecewise_loop.h:227
vector3 ref_even_crease_weights() const
returns weights for center, nbr1 and nbr2.
Definition subdivision_rules_piecewise_loop.h:79
vector2 ref_odd_crease_weights() const
Definition subdivision_rules_piecewise_loop.h:105
number get_beta(size_t valency) const
returns beta as it is used in the subdivision masks.
Definition subdivision_rules_piecewise_loop.cpp:67
vector3 proj_crease_weights() const
Definition subdivision_rules_piecewise_loop.h:114
number ref_even_inner_nbr_weight(size_t valence) const
Definition subdivision_rules_piecewise_loop.h:75
Base-class for all vertex-types.
Definition grid_base_objects.h:231
double number
Definition types.h:124
MathVector< 2, number > vector2
a 2d vector
Definition ugmath_types.h:69
MathVector< 3, number > vector3
a 3d vector
Definition ugmath_types.h:72
MathVector< 4, number > vector4
a 4d vector
Definition ugmath_types.h:75
the ug namespace
const number PI
Definition math_constants.h:45
Definition subdivision_rules_piecewise_loop.h:50
NeighborInfo()
Definition subdivision_rules_piecewise_loop.h:51
Vertex * nbr
Definition subdivision_rules_piecewise_loop.h:55
NeighborInfo(Vertex *n, size_t cval)
Definition subdivision_rules_piecewise_loop.h:52
size_t creaseValence
Definition subdivision_rules_piecewise_loop.h:59