Plugins
Loading...
Searching...
No Matches
ls_volume.h
Go to the documentation of this file.
1/*
2 * Copyright (c) 2015: G-CSC, Goethe University Frankfurt
3 * Authors: Christian Wehner, Dmitry Logashenko
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
36#ifndef __H__UG__PLUGINS__LEVEL_SET__LS_VOLUME_H__
37#define __H__UG__PLUGINS__LEVEL_SET__LS_VOLUME_H__
38
39// ug4 headers
40#include "common/common.h"
44
45namespace ug{
46namespace LevelSet{
47
54template <typename TGridFunc>
56{
57public:
58
61
63 typedef TGridFunc grid_func_type;
64
66 typedef typename grid_func_type::domain_type domain_type;
67
69 typedef typename grid_func_type::algebra_type algebra_type;
70
72 typedef typename domain_type::position_accessor_type position_accessor_type;
73
75 static const int dim = domain_type::dim;
76
77public:
78
81 (
83 )
84 : m_spLSF (spLSF),
85 m_volume_plus (-1), m_volume_minus (-1), // dummy values
86 m_check_positivity (false)
87 {};
88
90 void on_subsets
91 (
92 const char * ss_names
93 );
94
97
99 void compute ();
100
102 void compute
103 (
104 SmartPtr<UserData<number, dim> > spDensity,
105 number time
106 );
107
110 (
112 )
113 {compute (spDensity, 0);}
114
115#ifdef UG_FOR_LUA
117 void compute (LuaFunctionHandle density_fct) {compute (make_sp(new LuaUserData<number, dim> (density_fct)));}
118 void compute (const char * density_fct_name) {compute (LuaUserDataFactory<number, dim>::create(density_fct_name));}
119#endif
120
123 (
124 const char * ss_names,
125 number & vol_plus,
126 number & vol_minus
127 ) const;
128
131
134 (
135 const char * ss_names
136 ) const
137 {
138 number vol_plus, vol_minus;
139 volume_in_subsets (ss_names, vol_plus, vol_minus);
140 return vol_plus;
141 }
142
145
148 (
149 const char * ss_names
150 ) const
151 {
152 number vol_plus, vol_minus;
153 volume_in_subsets (ss_names, vol_plus, vol_minus);
154 return vol_minus;
155 }
156
158 void print_details () const;
159
160private:
161
163 template <typename TElem>
164 void add_volumes_of_all ();
165
168 {
170
173 (
174 this_type * pThis
175 )
176 : m_pThis (pThis) {}
177
179 template <typename TElem> void operator() (TElem)
180 {
181 m_pThis->template add_volumes_of_all<TElem> ();
182 }
183 };
184
186 template <typename TElem>
188 (
189 UserData<number, dim> * pDensity,
190 number time
191 );
192
195 {
199
202 (
203 this_type * pThis,
204 UserData<number, dim> * pDensity,
205 number time
206 )
207 : m_pThis (pThis), m_pDensity (pDensity), m_time (time) {}
208
210 template <typename TElem> void operator() (TElem)
211 {
212 m_pThis->template add_volumes_of_all<TElem> (m_pDensity, m_time);
213 }
214 };
215
216#ifdef UG_PARALLEL
217// Sum up the volumes from different processes
218 void allreduce_volumes ();
219#endif
220
221private:
222
224
226
229
230 std::vector<number> m_ss_vol_plus;
231 std::vector<number> m_ss_vol_minus;
232
234};
235
244template <typename TRefElem, int WDim>
246{
247public:
248
249 typedef TRefElem ref_element_type;
250 static const int dim = WDim;
251
252public:
253
255
259 static int compute
260 (
261 const MathVector<WDim> * corner,
262 const number * lsf,
263 number & vol_plus,
264 number & vol_minus
265 )
266 {
267 UG_THROW ("LSElementSize: Generic version not implemented");
268 return 0; // never reached
269 }
270};
271
276template <int WDim>
278{
279public:
280
282 static const int dim = WDim;
283
284public:
285
287
291 static int compute
292 (
293 const MathVector<WDim> * corner,
294 const number * lsf,
295 number & vol_plus,
296 number & vol_minus
297 );
298};
299
304template <int WDim>
306{
307public:
308
310 static const int dim = WDim;
311
312public:
313
315
319 static int compute
320 (
321 const MathVector<WDim> * corner,
322 const number * lsf,
323 number & vol_plus,
324 number & vol_minus
325 );
326};
327
332template <int WDim>
334{
335public:
336
338 static const int dim = WDim;
339
340public:
341
343
347 static int compute
348 (
349 const MathVector<WDim> * corner,
350 const number * lsf,
351 number & vol_plus,
352 number & vol_minus
353 );
354};
355
360template <int WDim>
362{
363public:
364
366 static const int dim = WDim;
367
368public:
369
371
375 static int compute
376 (
377 const MathVector<WDim> * corner,
378 const number * lsf,
379 number & vol_plus,
380 number & vol_minus
381 );
382};
383
384} // end namespace LevelSet
385} // end namespace ug
386
387// include implementation
388#include "ls_volume_impl.h"
389
390#endif // __H__UG__PLUGINS__LEVEL_SET__LS_VOLUME_H__
391
392/* End of File */
ReferenceEdge ref_element_type
type of the reference element
Definition ls_volume.h:281
ReferencePrism ref_element_type
type of the reference element
Definition ls_volume.h:365
ReferenceTetrahedron ref_element_type
type of the reference element
Definition ls_volume.h:337
ReferenceTriangle ref_element_type
type of the reference element
Definition ls_volume.h:309
Definition ls_volume.h:246
static const int dim
dimension of the world
Definition ls_volume.h:250
static int compute(const MathVector< WDim > *corner, const number *lsf, number &vol_plus, number &vol_minus)
computation of the volumes
Definition ls_volume.h:260
TRefElem ref_element_type
type of the reference element
Definition ls_volume.h:249
Definition ls_volume.h:56
grid_func_type::algebra_type algebra_type
algebra type
Definition ls_volume.h:69
std::vector< number > m_ss_vol_plus
volume in the 'positive' subsets
Definition ls_volume.h:230
number m_volume_minus
computed volume in the "negative part" of the domain
Definition ls_volume.h:228
void on_subsets(const char *ss_names)
sets the subsets to restrict the computation on
Definition ls_volume_impl.h:53
number volume_minus_in_subsets(const char *ss_names) const
returns the volume in the negative part of subsets
Definition ls_volume.h:148
void check_positivity(bool v)
set the check-positivity flag
Definition ls_volume.h:96
LSVolume< TGridFunc > this_type
'this' type
Definition ls_volume.h:60
number volume_plus() const
returns the volume in the positive part
Definition ls_volume.h:130
void allreduce_volumes()
Definition ls_volume_impl.h:277
SubsetGroup m_ssGrp
the subset group (if subsets specified)
Definition ls_volume.h:225
SmartPtr< TGridFunc > m_spLSF
the specified LSF
Definition ls_volume.h:223
void compute()
computes the volumes
Definition ls_volume_impl.h:65
void print_details() const
prints the details
Definition ls_volume_impl.h:319
number m_volume_plus
computed volume in the "positive part" of the domain
Definition ls_volume.h:227
bool m_check_positivity
if to check the positivity of the volumes in the elements
Definition ls_volume.h:233
void add_volumes_of_all()
adds contributions of all elements of a given type
Definition ls_volume_impl.h:114
domain_type::position_accessor_type position_accessor_type
type of the position accessor
Definition ls_volume.h:72
number volume_plus_in_subsets(const char *ss_names) const
returns the volume in the positive part of subsets
Definition ls_volume.h:134
number volume_minus() const
returns the volume of the negative part
Definition ls_volume.h:144
void compute(SmartPtr< UserData< number, dim > > spDensity)
computes the weights (weighted volumes) without the time argument
Definition ls_volume.h:110
grid_func_type::domain_type domain_type
domain type
Definition ls_volume.h:66
TGridFunc grid_func_type
grid function type
Definition ls_volume.h:63
void volume_in_subsets(const char *ss_names, number &vol_plus, number &vol_minus) const
extracts the volumes enclosed in given subsets
Definition ls_volume_impl.h:297
LSVolume(SmartPtr< grid_func_type > spLSF)
class constructor
Definition ls_volume.h:81
static const int dim
world dimension
Definition ls_volume.h:75
std::vector< number > m_ss_vol_minus
volume in the 'negative' subsets
Definition ls_volume.h:231
#define UG_THROW(msg)
double number
SmartPtr< T, FreePolicy > make_sp(T *inst)
helper class for the computation of the volumes
Definition ls_volume.h:168
AddVolumes(this_type *pThis)
constructor
Definition ls_volume.h:173
void operator()(TElem)
computation of the volume for all elements of the given type
Definition ls_volume.h:179
this_type * m_pThis
Definition ls_volume.h:169
helper class for the computation of the weighted volumes
Definition ls_volume.h:195
void operator()(TElem)
computation of the volume for all elements of the given type
Definition ls_volume.h:210
number m_time
Definition ls_volume.h:198
this_type * m_pThis
Definition ls_volume.h:196
UserData< number, dim > * m_pDensity
Definition ls_volume.h:197
AddWeightedVolumes(this_type *pThis, UserData< number, dim > *pDensity, number time)
constructor
Definition ls_volume.h:202