Flow123d  JS_before_hm-983-gccfd4b3
eval_subset.cc
Go to the documentation of this file.
1 /*!
2  *
3  * Copyright (C) 2015 Technical University of Liberec. All rights reserved.
4  *
5  * This program is free software; you can redistribute it and/or modify it under
6  * the terms of the GNU General Public License version 3 as published by the
7  * Free Software Foundation. (http://www.gnu.org/licenses/gpl-3.0.en.html)
8  *
9  * This program is distributed in the hope that it will be useful, but WITHOUT
10  * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
11  * FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details.
12  *
13  *
14  * @file eval_subset.cc
15  * @brief
16  * @author David Flanderka
17  */
18 
19 #include "fields/eval_subset.hh"
20 #include "fields/eval_points.hh"
22 
23 
24 /******************************************************************************
25  * Implementation of BaseIntegral methods
26  */
27 
29 {}
30 
31 
32 /******************************************************************************
33  * Implementation of BulkIntegral methods
34  */
35 
37 {}
38 
39 Range< BulkPoint > BulkIntegral::points(const DHCellAccessor &cell, const ElementCacheMap *elm_cache_map) const {
41  THROW( ExcElementNotInCache() << EI_ElementIdx(cell.elm_idx()) );
42 
43  auto bgn_it = make_iter<BulkPoint>( BulkPoint(cell, elm_cache_map, shared_from_this(), eval_points_->subset_begin(dim_, subset_index_)) );
44  auto end_it = make_iter<BulkPoint>( BulkPoint(cell, elm_cache_map, shared_from_this(), eval_points_->subset_end(dim_, subset_index_)) );
45  return Range<BulkPoint>(bgn_it, end_it);
46 }
47 
48 
49 /******************************************************************************
50  * Implementation of EdgeIntegral methods
51  */
52 
53 EdgeIntegral::EdgeIntegral(std::shared_ptr<EvalPoints> eval_points, unsigned int dim, unsigned int n_permutations, unsigned int points_per_side)
54 : BaseIntegral(eval_points, dim), subset_index_(eval_points_->n_subsets(dim)), n_permutations_(n_permutations) {
55  n_sides_ = dim_+1;
56  perm_indices_ = new unsigned int** [n_sides_];
57  for (unsigned int i_side=0; i_side<n_sides_; ++i_side) {
58  perm_indices_[i_side] = new unsigned int* [n_permutations_];
59  for (unsigned int i_perm=0; i_perm<n_permutations_; ++i_perm) {
60  perm_indices_[i_side][i_perm] = new unsigned int [points_per_side];
61  }
62  }
63 }
64 
66  for (unsigned int i_side=0; i_side<n_sides_; ++i_side) {
67  for (unsigned int i_perm=0; i_perm<n_permutations_; ++i_perm) {
68  delete perm_indices_[i_side][i_perm];
69  }
70  delete perm_indices_[i_side];
71  }
72  delete perm_indices_;
73 }
74 
75 Range< EdgePoint > EdgeIntegral::points(const DHCellSide &cell_side, const ElementCacheMap *elm_cache_map) const {
77  THROW( ExcElementNotInCache() << EI_ElementIdx(cell_side.cell().elm_idx()) );
78 
79  unsigned int begin_idx = eval_points_->subset_begin(dim_, subset_index_);
80  unsigned int end_idx = eval_points_->subset_end(dim_, subset_index_);
81  unsigned int points_per_side = (end_idx - begin_idx) / this->n_sides();
82  auto bgn_it = make_iter<EdgePoint>( EdgePoint(cell_side, elm_cache_map, shared_from_this(), 0 ) );
83  auto end_it = make_iter<EdgePoint>( EdgePoint(cell_side, elm_cache_map, shared_from_this(), points_per_side ) );
84  return Range<EdgePoint>(bgn_it, end_it);
85 }
86 
87 
88 /******************************************************************************
89  * Implementation of CouplingIntegral methods
90  */
91 
92 CouplingIntegral::CouplingIntegral(std::shared_ptr<EdgeIntegral> edge_integral, std::shared_ptr<BulkIntegral> bulk_integral)
93  : BaseIntegral(edge_integral->eval_points(), edge_integral->dim()), edge_integral_(edge_integral), bulk_integral_(bulk_integral) {
94  ASSERT_EQ_DBG(edge_integral->dim(), bulk_integral->dim());
95 }
96 
98  edge_integral_.reset();
99  bulk_integral_.reset();
100 }
101 
103  return bulk_integral_->points(cell, elm_cache_map);
104 }
105 
106 Range< EdgePoint > CouplingIntegral::points(const DHCellSide &cell_side, const ElementCacheMap *elm_cache_map) const {
107  return edge_integral_->points(cell_side, elm_cache_map);
108 }
109 
110 
111 
112 /******************************************************************************
113  * Implementation of BoundaryIntegral methods
114  */
115 
116 BoundaryIntegral::BoundaryIntegral(std::shared_ptr<EdgeIntegral> edge_integral)
117  : BaseIntegral(edge_integral->eval_points(), edge_integral->dim()), edge_integral_(edge_integral) {}
118 
120  edge_integral_.reset();
121 }
122 
123 Range< EdgePoint > BoundaryIntegral::points(const DHCellSide &cell_side, const ElementCacheMap *elm_cache_map) const {
124  return edge_integral_->points(cell_side, elm_cache_map);
125 }
126 
127 
128 /******************************************************************************
129  * Implementation of BulkPoint methods
130  */
131 
132 
133 /******************************************************************************
134  * Implementation of EdgePoint methods
135  */
136 
138  return EdgePoint(edg_side, elm_cache_map_, this->integral_, this->local_point_idx_);
139 }
std::shared_ptr< EdgeIntegral > edge_integral_
Integral according to side subset part (element of higher dim) in EvalPoints object.
Definition: eval_subset.hh:179
unsigned int n_sides() const
Getter of n_sides.
Definition: eval_subset.hh:114
#define ASSERT_EQ_DBG(a, b)
Definition of comparative assert macro (EQual) only for debug mode.
Definition: asserts.hh:332
unsigned int elm_idx() const
Return serial idx to element of loc_ele_idx_.
Point accessor allow iterate over bulk quadrature points defined in local element coordinates...
Definition: eval_subset.hh:215
Point accessor allow iterate over quadrature points of given side defined in local element coordinate...
Definition: eval_subset.hh:289
friend class EdgePoint
Definition: eval_subset.hh:142
unsigned int dim() const
Returns dimension.
Definition: eval_subset.hh:61
EdgePoint permute(DHCellSide edg_side) const
Return corresponds EdgePoint of neighbour side of same dimension (computing of side integrals)...
Definition: eval_subset.cc:137
Directing class of FieldValueCache.
unsigned int element_cache_index() const
Getter of elm_cache_index_.
Cell accessor allow iterate over DOF handler cells.
~CouplingIntegral()
Destructor.
Definition: eval_subset.cc:97
std::shared_ptr< EvalPoints > eval_points_
Pointer to EvalPoints.
Definition: eval_subset.hh:66
std::shared_ptr< EdgeIntegral > edge_integral_
Boundary integral according to edge integral (? but need own special data members and methods ...
Definition: eval_subset.hh:208
std::shared_ptr< BulkIntegral > bulk_integral_
Integral according to bulk subset part (element of lower dim) in EvalPoints object.
Definition: eval_subset.hh:181
~BulkIntegral()
Destructor.
Definition: eval_subset.cc:36
~BoundaryIntegral()
Destructor.
Definition: eval_subset.cc:119
unsigned int dim_
Dimension of points.
Definition: eval_subset.hh:68
Range< EdgePoint > points(const DHCellSide &cell_side, const ElementCacheMap *elm_cache_map) const
Returns range of bulk local points for appropriate cell accessor.
Definition: eval_subset.cc:123
unsigned int *** perm_indices_
Indices to EvalPoints for different sides and permutations reflecting order of points.
Definition: eval_subset.hh:135
Range helper class.
static const unsigned int undef_elem_idx
Index of invalid element in cache.
unsigned int subset_index_
Index of data block according to subset in EvalPoints object.
Definition: eval_subset.hh:133
~EdgeIntegral()
Destructor.
Definition: eval_subset.cc:65
Range< BulkPoint > points(const DHCellAccessor &cell, const ElementCacheMap *elm_cache_map) const
Returns range of bulk local points for appropriate cell accessor.
Definition: eval_subset.cc:102
CouplingIntegral()
Default constructor.
Definition: eval_subset.hh:153
unsigned int n_permutations_
Number of permutations (value 0 indicates bulk set)
Definition: eval_subset.hh:139
virtual ~BaseIntegral()
Destructor.
Definition: eval_subset.cc:28
const DHCellAccessor & cell() const
Return DHCellAccessor appropriate to the side.
unsigned int n_sides_
Number of sides (value 0 indicates bulk set)
Definition: eval_subset.hh:137
BoundaryIntegral()
Default constructor.
Definition: eval_subset.hh:190
EdgeIntegral()
Default constructor.
Definition: eval_subset.hh:105
Range< BulkPoint > points(const DHCellAccessor &cell, const ElementCacheMap *elm_cache_map) const
Returns range of bulk local points for appropriate cell accessor.
Definition: eval_subset.cc:39
std::shared_ptr< EvalPoints > eval_points() const
Getter of eval_points.
Definition: eval_subset.hh:56
Range< EdgePoint > points(const DHCellSide &cell_side, const ElementCacheMap *elm_cache_map) const
Returns range of side local points for appropriate cell side accessor.
Definition: eval_subset.cc:75
#define THROW(whole_exception_expr)
Wrapper for throw. Saves the throwing point.
Definition: exceptions.hh:53
Side accessor allows to iterate over sides of DOF handler cell.