53template <
typename TGr
idFunc>
64 if ((m_fct = sp_gf->fct_id_by_name (fct_name)) >= sp_gf->num_fct ())
65 UG_THROW (
"LSIntegral: Function space does not contain any function with name '" << fct_name <<
"'.");
68 UG_THROW (
"LSIntegral: Only vertex-centered grid functions are supported.");
70 int n_ss = m_spLSF->num_subsets ();
74 m_ss_integral.resize (n_ss);
75 for (
int si = 0; si < n_ss; si++) m_ss_integral[si] = 0;
83 for (
int si = 0; si < n_ss; si++)
91template <
typename TGr
idFunc>
97 SubsetGroup ss_grp (m_spLSF->domain()->subset_handler ());
101 for (
size_t i = 0; i < ss_grp.
size (); i++)
102 ss_integral += m_ss_integral[ss_grp[i]];
109template <
typename TGr
idFunc>
110template <
typename TElem>
113 typedef typename gf_type::template traits<TElem>::const_iterator ElemIter;
116 static const size_t num_corners = ref_elem_t::numCorners;
119 const gf_type & integrand = * m_sp_gf;
121 std::vector<DoFIndex> ind (1);
123 number lsf_values [num_corners];
127 if (m_ssGrp.subset_handler().valid () && ! m_ssGrp.contains (si))
131 ElemIter iterEnd = lsf.template end<TElem> (si);
132 for (ElemIter iter = lsf.template begin<TElem> (si); iter != iterEnd; ++iter)
134 TElem * elem = *iter;
137 for (
size_t i = 0; i < num_corners; i++)
139 Vertex * vrt = elem->vertex (i);
140 corners [i] = aaPos [vrt];
142 UG_THROW (
"LSIntegral: Not a scalar grid function for the LSF!");
143 lsf_values [i] =
DoFRef (lsf, ind [0]);
147 number vol_plus, vol_minus;
153 size_t n_co_minus = 0;
154 for (
size_t i = 0; i < num_corners; i++)
155 if (lsf_values [i] < 0)
157 Vertex * vrt = elem->vertex (i);
158 if (integrand.inner_dof_indices (vrt, m_fct, ind) != 1)
159 UG_THROW (
"LSIntegral: Not a scalar grid function for the integrand!");
160 ave_integrand +=
DoFRef (integrand, ind[0]);
167 ss_integral += vol_minus * ave_integrand / n_co_minus;
169 m_ss_integral[si] += ss_integral;
170 m_integral += ss_integral;
179template <
typename TGr
idFunc>
183 const char * fct_name,
190 m_sp_gf = sp_gf; m_limval = limval;
191 if ((m_fct = sp_gf->fct_id_by_name (fct_name)) >= sp_gf->num_fct ())
192 UG_THROW (
"LSHeavisideIntegral: Function space does not contain any function with name '" << fct_name <<
"'.");
195 UG_THROW (
"LSHeavisideIntegral: Only vertex-centered grid functions are supported.");
197 int n_ss = m_spLSF->num_subsets ();
200 m_levol = m_gevol = 0;
201 m_ss_levol.resize (n_ss); m_ss_gevol.resize (n_ss);
202 for (
int si = 0; si < n_ss; si++) m_ss_levol[si] = m_ss_gevol[si] = 0;
211 for (
int si = 0; si < n_ss; si++)
222template <
typename TGr
idFunc>
225 const char * ss_names
228 SubsetGroup ss_grp (m_spLSF->domain()->subset_handler ());
232 for (
size_t i = 0; i < ss_grp.
size (); i++)
233 ss_levol += m_ss_levol[ss_grp[i]];
240template <
typename TGr
idFunc>
243 const char * ss_names
246 SubsetGroup ss_grp (m_spLSF->domain()->subset_handler ());
250 for (
size_t i = 0; i < ss_grp.
size (); i++)
251 ss_gevol += m_ss_gevol[ss_grp[i]];
258template <
typename TGr
idFunc>
259template <
typename TElem>
262 typedef typename gf_type::template traits<TElem>::const_iterator ElemIter;
265 static const size_t num_corners = ref_elem_t::numCorners;
268 const gf_type & integrand = * m_sp_gf;
270 std::vector<DoFIndex> ind (1);
272 number lsf_values [num_corners];
276 if (m_ssGrp.subset_handler().valid () && ! m_ssGrp.contains (si))
279 number ss_levol = 0, ss_gevol = 0;
280 ElemIter iterEnd = lsf.template end<TElem> (si);
281 for (ElemIter iter = lsf.template begin<TElem> (si); iter != iterEnd; ++iter)
283 TElem * elem = *iter;
286 for (
size_t i = 0; i < num_corners; i++)
288 Vertex * vrt = elem->vertex (i);
289 corners [i] = aaPos [vrt];
291 UG_THROW (
"LSHeavisideIntegral: Not a scalar grid function for the LSF!");
292 lsf_values [i] =
DoFRef (lsf, ind [0]);
296 number vol_plus, vol_minus;
301 size_t sum_integrand = 0;
302 size_t n_co_minus = 0;
303 for (
size_t i = 0; i < num_corners; i++)
304 if (lsf_values [i] < 0)
306 Vertex * vrt = elem->vertex (i);
307 if (integrand.inner_dof_indices (vrt, m_fct, ind) != 1)
308 UG_THROW (
"LSHeavisideIntegral: Not a scalar grid function for the integrand!");
310 if (gf_val <= m_limval)
318 ss_levol += (vol_minus * sum_integrand) / n_co_minus;
319 ss_gevol += (vol_minus * (n_co_minus - sum_integrand)) / n_co_minus;
321 m_ss_levol[si] += ss_levol; m_ss_gevol[si] += ss_gevol;
322 m_levol += ss_levol; m_gevol += ss_gevol;
331template <
typename TGr
idFunc>
335 const char * fct_name
342 if ((m_fct = sp_gf->fct_id_by_name (fct_name)) >= sp_gf->num_fct ())
343 UG_THROW (
"FVLSIntegral: Function space does not contain any function with name '" << fct_name <<
"'.");
346 UG_THROW (
"FVLSIntegral: Only vertex-centered grid functions are supported.");
348 int n_ss = m_spLSF->num_subsets ();
352 m_ss_integral.resize (n_ss);
353 for (
int si = 0; si < n_ss; si++) m_ss_integral[si] = 0;
361 for (
int si = 0; si < n_ss; si++)
369template <
typename TGr
idFunc>
372 const char * ss_names
375 SubsetGroup ss_grp (m_spLSF->domain()->subset_handler ());
379 for (
size_t i = 0; i < ss_grp.
size (); i++)
380 ss_integral += m_ss_integral[ss_grp[i]];
387template <
typename TGr
idFunc>
388template <
typename TElem>
391 typedef typename gf_type::template traits<TElem>::const_iterator ElemIter;
395 static const size_t num_corners = ref_elem_t::numCorners;
398 const gf_type & integrand = * m_sp_gf;
400 std::vector<DoFIndex> ind (1);
402 number lsf_values [num_corners];
406 if (m_ssGrp.subset_handler().valid () && ! m_ssGrp.contains (si))
410 ElemIter iterEnd = lsf.template end<TElem> (si);
411 for (ElemIter iter = lsf.template begin<TElem> (si); iter != iterEnd; ++iter)
413 TElem * elem = *iter;
416 bool elem_to_compute =
false;
417 for (
size_t i = 0; i < num_corners; i++)
419 Vertex * vrt = elem->vertex (i);
420 corners [i] = aaPos [vrt];
422 UG_THROW (
"FVLSIntegral: Not a scalar grid function for the LSF!");
423 lsf_values [i] =
DoFRef (lsf, ind [0]);
424 if (lsf_values [i] <= 0) elem_to_compute =
true;
426 if (! elem_to_compute)
433 geo.update (elem, corners);
435 UG_CATCH_THROW (
"FVLSIntegral: Cannot update Finite Volume Geometry.");
438 for (
size_t i = 0; i < num_corners; i++)
439 if (lsf_values [i] <= 0)
441 Vertex * vrt = elem->vertex (i);
442 if (integrand.inner_dof_indices (vrt, m_fct, ind) != 1)
443 UG_THROW (
"FVLSIntegral: Not a scalar grid function for the integrand!");
445 const number scv_vol = geo.scv(i).volume ();
446 ss_integral += scv_vol * dof_val;
449 m_ss_integral[si] += ss_integral;
450 m_integral += ss_integral;
size_t allreduce(const size_t &t, pcl::ReduceOperation op) const
size_t inner_dof_indices(TElem *elem, size_t fct, std::vector< DoFIndex > &ind, bool bClear=true) const
SmartPtr< TDomain > domain()
void compute_for(SmartPtr< gf_type > sp_gf, const char *fct_name)
computes the integrals
Definition ls_integral_impl.h:333
void add_integrals_of_all()
adds contributions of all elements of a given type
Definition ls_integral_impl.h:389
domain_type::position_accessor_type position_accessor_type
type of the position accessor
Definition ls_integral.h:328
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_volume.h:246
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 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
void add_integrals_of_all()
adds contributions of all elements of a given type
Definition ls_integral_impl.h:260
void compute_for(SmartPtr< gf_type > sp_gf, const char *fct_name, number limval)
computes the integrals
Definition ls_integral_impl.h:181
number integral_over_subsets(const char *ss_names) const
returns the integral over the negative part of subsets
Definition ls_integral_impl.h:93
domain_type::position_accessor_type position_accessor_type
type of the position accessor
Definition ls_integral.h:84
TGridFunction gf_type
type of the grid function
Definition ls_integral.h:72
void add_integrals_of_all()
adds contributions of all elements of a given type
Definition ls_integral_impl.h:111
void compute_for(SmartPtr< gf_type > sp_gf, const char *fct_name)
computes the integrals
Definition ls_integral_impl.h:55
void add(const char *name)
vector< string > TokenizeString(const char *str, const char delimiter=',')
#define UG_CATCH_THROW(msg)
const number & DoFRef(const TMatrix &mat, const DoFIndex &iInd, const DoFIndex &jInd)
helper class for the computation of the volumes
Definition ls_integral.h:389
helper class for the computation of the volumes
Definition ls_integral.h:273
helper class for the computation of the volumes
Definition ls_integral.h:145