Plugins
Loading...
Searching...
No Matches
ls_integral.h
Go to the documentation of this file.
1/*
2 * Copyright (c) 2021: G-CSC, Goethe University Frankfurt
3 * Author: 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
33/*
34 * Quadrature of grid functions under the level-set
35 */
36#ifndef __H__UG__PLUGINS__LEVEL_SET_LS_INTEGRAL_H__
37#define __H__UG__PLUGINS__LEVEL_SET_LS_INTEGRAL_H__
38
39#include <vector>
40#include <iostream>
41#include <limits>
42#include <cmath>
43
44#include "common/common.h"
45
56
57namespace ug {
58namespace LevelSet {
59
67template <typename TGridFunction>
69{
70public:
72 typedef TGridFunction gf_type;
73
75 static const int dim = gf_type::dim;
76
79
81 typedef typename gf_type::domain_type domain_type;
82
84 typedef typename domain_type::position_accessor_type position_accessor_type;
85
87 typedef typename gf_type::algebra_type algebra_type;
88
91
94
95public:
96
99 (
101 )
102 : m_spLSF (sp_lsf)
103 {}
104
106 virtual ~LSIntegral () {}
107
110 (
111 const char * ss_names
112 )
113 {
114 m_ssGrp.set_subset_handler (m_sp_gf->domain()->subset_handler ());
115 m_ssGrp.add (TokenizeString (ss_names));
116 }
117
119 void compute_for
120 (
121 SmartPtr<gf_type> sp_gf,
122 const char * fct_name
123 );
124
127 (
128 const char * ss_names
129 ) const;
130
133 {
134 return m_integral;
135 }
136
137private:
138
140 template <typename TElem>
141 void add_integrals_of_all ();
142
145 {
147
150 (
151 this_type * pThis
152 )
153 : m_pThis (pThis) {}
154
156 template <typename TElem> void operator() (TElem)
157 {
158 m_pThis->template add_integrals_of_all<TElem> ();
159 }
160 };
161
162private:
163
165 size_t m_fct;
166
169
170 std::vector<number> m_ss_integral;
172};
173
182template <typename TGridFunction>
184{
185public:
187 typedef TGridFunction gf_type;
188
190 static const int dim = gf_type::dim;
191
194
196 typedef typename gf_type::domain_type domain_type;
197
199 typedef typename domain_type::position_accessor_type position_accessor_type;
200
202 typedef typename gf_type::algebra_type algebra_type;
203
206
209
210public:
211
214 (
216 )
217 : m_spLSF (sp_lsf)
218 {}
219
222
225 (
226 const char * ss_names
227 )
228 {
229 m_ssGrp.set_subset_handler (m_sp_gf->domain()->subset_handler ());
230 m_ssGrp.add (TokenizeString (ss_names));
231 }
232
234 void compute_for
235 (
236 SmartPtr<gf_type> sp_gf,
237 const char * fct_name,
238 number limval
239 );
240
243 (
244 const char * ss_names
245 ) const;
246
249 (
250 const char * ss_names
251 ) const;
252
254 number le_vol () const
255 {
256 return m_levol;
257 }
258
260 number ge_vol () const
261 {
262 return m_gevol;
263 }
264
265private:
266
268 template <typename TElem>
269 void add_integrals_of_all ();
270
273 {
275
278 (
279 this_type * pThis
280 )
281 : m_pThis (pThis) {}
282
284 template <typename TElem> void operator() (TElem)
285 {
286 m_pThis->template add_integrals_of_all<TElem> ();
287 }
288 };
289
290private:
291
293 size_t m_fct;
295
298
299 std::vector<number> m_ss_gevol;
300 std::vector<number> m_ss_levol;
302};
303
311template <typename TGridFunction>
313{
314public:
316 typedef TGridFunction gf_type;
317
319 static const int dim = gf_type::dim;
320
323
325 typedef typename gf_type::domain_type domain_type;
326
328 typedef typename domain_type::position_accessor_type position_accessor_type;
329
331 typedef typename gf_type::algebra_type algebra_type;
332
335
338
339public:
340
343 (
345 )
346 : m_spLSF (sp_lsf)
347 {}
348
350 virtual ~FVLSIntegral () {}
351
354 (
355 const char * ss_names
356 )
357 {
358 m_ssGrp.set_subset_handler (m_sp_gf->domain()->subset_handler ());
359 m_ssGrp.add (TokenizeString (ss_names));
360 }
361
363 void compute_for
364 (
365 SmartPtr<gf_type> sp_gf,
366 const char * fct_name
367 );
368
371 (
372 const char * ss_names
373 ) const;
374
377 {
378 return m_integral;
379 }
380
381private:
382
384 template <typename TElem>
385 void add_integrals_of_all ();
386
389 {
391
394 (
395 this_type * pThis
396 )
397 : m_pThis (pThis) {}
398
400 template <typename TElem> void operator() (TElem)
401 {
402 m_pThis->template add_integrals_of_all<TElem> ();
403 }
404 };
405
406private:
407
409 size_t m_fct;
410
413
414 std::vector<number> m_ss_integral;
416};
417
418} // namespace LevelSet
419} // end namespace ug
420
421#include "ls_integral_impl.h"
422
423#endif // __H__UG__PLUGINS__LEVEL_SET_LS_INTEGRAL_H__
424
425/* End of File */
Definition ls_integral.h:313
SmartPtr< gf_type > m_sp_gf
the grid function
Definition ls_integral.h:408
FVLSIntegral(SmartPtr< ls_gf_type > sp_lsf)
Constructor.
Definition ls_integral.h:343
CPUAlgebra lsf_algebra_type
algebra type for the LSF
Definition ls_integral.h:334
std::vector< number > m_ss_integral
integrals over the subsets
Definition ls_integral.h:414
size_t m_fct
the function inside of the grid function
Definition ls_integral.h:409
number integral() const
return the integral over the entire negative subdomain
Definition ls_integral.h:376
SubsetGroup m_ssGrp
the subset group (if subsets specified)
Definition ls_integral.h:412
static const int dim
world dimension
Definition ls_integral.h:319
void compute_for(SmartPtr< gf_type > sp_gf, const char *fct_name)
computes the integrals
Definition ls_integral_impl.h:333
number m_integral
the entire integral
Definition ls_integral.h:415
GridFunction< domain_type, lsf_algebra_type > ls_gf_type
grid function type for the LSF
Definition ls_integral.h:337
void add_integrals_of_all()
adds contributions of all elements of a given type
Definition ls_integral_impl.h:389
virtual ~FVLSIntegral()
Destructor.
Definition ls_integral.h:350
domain_type::position_accessor_type position_accessor_type
type of the position accessor
Definition ls_integral.h:328
SmartPtr< ls_gf_type > m_spLSF
the specified LSF
Definition ls_integral.h:411
FVLSIntegral< gf_type > this_type
this type
Definition ls_integral.h:322
gf_type::algebra_type algebra_type
algebra type
Definition ls_integral.h:331
gf_type::domain_type domain_type
domain type
Definition ls_integral.h:325
void on_subsets(const char *ss_names)
sets the subsets to restrict the computation on
Definition ls_integral.h:354
TGridFunction gf_type
type of the grid function
Definition ls_integral.h:316
number integral_over_subsets(const char *ss_names) const
returns the integral over the negative part of subsets
Definition ls_integral_impl.h:371
Definition ls_integral.h:184
GridFunction< domain_type, lsf_algebra_type > ls_gf_type
grid function type for the LSF
Definition ls_integral.h:208
gf_type::domain_type domain_type
domain type
Definition ls_integral.h:196
SmartPtr< ls_gf_type > m_spLSF
the specified LSF
Definition ls_integral.h:296
std::vector< number > m_ss_gevol
integrals over the subsets for gf >= limval
Definition ls_integral.h:299
CPUAlgebra lsf_algebra_type
algebra type for the LSF
Definition ls_integral.h:205
virtual ~LSHeavisideIntegral()
Destructor.
Definition ls_integral.h:221
LSHeavisideIntegral(SmartPtr< ls_gf_type > sp_lsf)
Constructor.
Definition ls_integral.h:214
std::vector< number > m_ss_levol
integrals over the subsets for gf <= limval
Definition ls_integral.h:300
TGridFunction gf_type
type of the grid function
Definition ls_integral.h:187
domain_type::position_accessor_type position_accessor_type
type of the position accessor
Definition ls_integral.h:199
number ge_vol_over_subsets(const char *ss_names) const
returns the volume for gf >= limval over the given subsets
Definition ls_integral_impl.h:242
number m_gevol
Definition ls_integral.h:301
number m_levol
the entire integral for gf >= limval and gf <= limval
Definition ls_integral.h:301
number ge_vol() const
return the integral over the entire negative subdomain where gf <= limval
Definition ls_integral.h:260
number le_vol_over_subsets(const char *ss_names) const
returns the volume for gf <= limval over the given subsets
Definition ls_integral_impl.h:224
SubsetGroup m_ssGrp
the subset group (if subsets specified)
Definition ls_integral.h:297
static const int dim
world dimension
Definition ls_integral.h:190
size_t m_fct
the function inside of the grid function
Definition ls_integral.h:293
gf_type::algebra_type algebra_type
algebra type
Definition ls_integral.h:202
number m_limval
the switch value for the Heaviside function
Definition ls_integral.h:294
number le_vol() const
return the integral over the entire negative subdomain where gf <= limval
Definition ls_integral.h:254
SmartPtr< gf_type > m_sp_gf
the grid function
Definition ls_integral.h:292
LSHeavisideIntegral< gf_type > this_type
this type
Definition ls_integral.h:193
void add_integrals_of_all()
adds contributions of all elements of a given type
Definition ls_integral_impl.h:260
void on_subsets(const char *ss_names)
sets the subsets to restrict the computation on
Definition ls_integral.h:225
void compute_for(SmartPtr< gf_type > sp_gf, const char *fct_name, number limval)
computes the integrals
Definition ls_integral_impl.h:181
Definition ls_integral.h:69
LSIntegral(SmartPtr< ls_gf_type > sp_lsf)
Constructor.
Definition ls_integral.h:99
number integral_over_subsets(const char *ss_names) const
returns the integral over the negative part of subsets
Definition ls_integral_impl.h:93
LSIntegral< gf_type > this_type
this type
Definition ls_integral.h:78
SmartPtr< gf_type > m_sp_gf
the grid function
Definition ls_integral.h:164
GridFunction< domain_type, lsf_algebra_type > ls_gf_type
grid function type for the LSF
Definition ls_integral.h:93
void on_subsets(const char *ss_names)
sets the subsets to restrict the computation on
Definition ls_integral.h:110
domain_type::position_accessor_type position_accessor_type
type of the position accessor
Definition ls_integral.h:84
size_t m_fct
the function inside of the grid function
Definition ls_integral.h:165
TGridFunction gf_type
type of the grid function
Definition ls_integral.h:72
virtual ~LSIntegral()
Destructor.
Definition ls_integral.h:106
number m_integral
the entire integral
Definition ls_integral.h:171
void add_integrals_of_all()
adds contributions of all elements of a given type
Definition ls_integral_impl.h:111
gf_type::domain_type domain_type
domain type
Definition ls_integral.h:81
CPUAlgebra lsf_algebra_type
algebra type for the LSF
Definition ls_integral.h:90
std::vector< number > m_ss_integral
integrals over the subsets
Definition ls_integral.h:170
void compute_for(SmartPtr< gf_type > sp_gf, const char *fct_name)
computes the integrals
Definition ls_integral_impl.h:55
number integral() const
return the integral over the entire negative subdomain
Definition ls_integral.h:132
gf_type::algebra_type algebra_type
algebra type
Definition ls_integral.h:87
SubsetGroup m_ssGrp
the subset group (if subsets specified)
Definition ls_integral.h:168
static const int dim
world dimension
Definition ls_integral.h:75
SmartPtr< ls_gf_type > m_spLSF
the specified LSF
Definition ls_integral.h:167
void add(const char *name)
void set_subset_handler(ConstSmartPtr< ISubsetHandler > sh)
vector< string > TokenizeString(const char *str, const char delimiter=',')
double number
helper class for the computation of the volumes
Definition ls_integral.h:389
void operator()(TElem)
computation of the volume for all elements of the given type
Definition ls_integral.h:400
this_type * m_pThis
Definition ls_integral.h:390
AddIntegrals(this_type *pThis)
constructor
Definition ls_integral.h:394
helper class for the computation of the volumes
Definition ls_integral.h:273
this_type * m_pThis
Definition ls_integral.h:274
AddIntegrals(this_type *pThis)
constructor
Definition ls_integral.h:278
void operator()(TElem)
computation of the volume for all elements of the given type
Definition ls_integral.h:284
helper class for the computation of the volumes
Definition ls_integral.h:145
AddIntegrals(this_type *pThis)
constructor
Definition ls_integral.h:150
this_type * m_pThis
Definition ls_integral.h:146
void operator()(TElem)
computation of the volume for all elements of the given type
Definition ls_integral.h:156