Flow123d  DF_patch_fe_darcy_complete-579fe1e
op_accessors.hh
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 op_accessors.hh
15  * @brief Declares accessors to FE operations.
16  * @author David Flanderka
17  */
18 
19 #ifndef OP_ACCESSORS_HH_
20 #define OP_ACCESSORS_HH_
21 
22 #include "fem/integral_points.hh"
23 #include "fem/patch_op.hh"
24 
25 using Scalar = double;
28 
29 
30 
31 template <class ValueType>
32 class ElQ {
33 public:
34  /**
35  * Default constructor.
36  *
37  * Used only in template specialization of CoplingIntegral. DO NOT USE in other cases.
38  */
39  ElQ()
40  : patch_op_(nullptr) {}
41 
42  /// Constructor
44  : patch_op_(op) {}
45 
46  ValueType operator()(const BulkPoint &point) const;
47 
48  ValueType operator()(const SidePoint &point) const;
49 
50 private:
51  PatchOp<3> *patch_op_; ///< Pointer to operation
52 };
53 
54 
55 template <class ValueType>
56 class FeQ {
57 public:
58  /**
59  * Default constructor.
60  *
61  * Used only in template specialization of CoplingIntegral. DO NOT USE in other cases.
62  */
63  FeQ()
64  : patch_op_bulk_(nullptr), patch_op_side_(nullptr), i_shape_fn_idx_(0) {}
65 
66  // Class similar to current FeView
67  FeQ(PatchOp<3> *patch_op)
68  : patch_op_bulk_(nullptr), patch_op_side_(nullptr), i_shape_fn_idx_(0) {
69  if (patch_op->domain()==0) patch_op_bulk_ = patch_op;
70  else patch_op_side_ = patch_op;
71  }
72 
73  /// Constructor used only in FeQArray::shape()
74  FeQ(PatchOp<3> *patch_op_bulk, PatchOp<3> *patch_op_side, unsigned int i_shape_fn_idx)
75  : patch_op_bulk_(patch_op_bulk), patch_op_side_(patch_op_side), i_shape_fn_idx_(i_shape_fn_idx) {}
76 
77 
78  ValueType operator()(const BulkPoint &point) const;
79 
80  ValueType operator()(const SidePoint &point) const;
81 
82 private:
83  PatchOp<3> *patch_op_bulk_; ///< Pointer to bulk operation
84  PatchOp<3> *patch_op_side_; ///< Pointer to side operation
85  unsigned int i_shape_fn_idx_; ///< Index of shape function
86 };
87 
88 
89 template <class ValueType>
90 class FeQArray {
91 public:
92  /// Default constructor
94  : patch_op_bulk_(nullptr), patch_op_side_(nullptr), n_dofs_(1) {}
95 
96  // Class similar to current FeView
97  FeQArray(PatchOp<3> *patch_op)
98  : patch_op_bulk_(nullptr), patch_op_side_(nullptr), n_dofs_(patch_op->n_dofs()) {
99  ASSERT_GT(n_dofs_, 0).error("Invalid number of DOFs.\n");
100 
101  if (patch_op->domain()==0) patch_op_bulk_ = patch_op;
102  else patch_op_side_ = patch_op;
103  }
104 
105 
106  FeQ<ValueType> shape(unsigned int i_shape_fn_idx) const {
107  ASSERT_LT(i_shape_fn_idx, n_dofs_);
108  return FeQ<ValueType>(patch_op_bulk_, patch_op_side_, i_shape_fn_idx);
109  }
110 
111  /// Return number of DOFs
112  inline unsigned int n_dofs() const {
113  return n_dofs_;
114  }
115 
116 private:
117  PatchOp<3> *patch_op_bulk_; ///< Pointer to bulk operation
118  PatchOp<3> *patch_op_side_; ///< Pointer to side operation
119  unsigned int n_dofs_; ///< Number of DOFs
120 };
121 
122 
123 template <class ValueType>
124 class FeQJoin {
125 public:
126  /// Default constructor
128  : patch_op_bulk_(nullptr), patch_op_side_(nullptr), patch_op_zero_bulk_(nullptr), patch_op_zero_side_(nullptr)
129  {}
130 
131  /**
132  * Constructor
133  *
134  * @param patch_op_bulk Pointer to PatchOP bulk object.
135  * @param patch_op_side Pointer to PatchOp side object.
136  * @param patch_op_zero_bulk Pointer to zero PatchOP bulk object.
137  * @param patch_op_zero_side Pointer to zero PatchOp side object.
138  */
139  FeQJoin(PatchOp<3> *patch_op_bulk, PatchOp<3> *patch_op_side, PatchOp<3> *patch_op_zero_bulk, PatchOp<3> *patch_op_zero_side)
140  : patch_op_bulk_(patch_op_bulk), patch_op_side_(patch_op_side), patch_op_zero_bulk_(patch_op_zero_bulk), patch_op_zero_side_(patch_op_zero_side),
141  n_dofs_high_(patch_op_side->n_dofs()), n_dofs_low_(patch_op_bulk->n_dofs()) {}
142 
143 
144  inline unsigned int n_dofs_low() const {
145  return n_dofs_low_;
146  }
147 
148  inline unsigned int n_dofs_high() const {
149  return n_dofs_high_;
150  }
151 
152  inline unsigned int n_dofs_both() const {
153  return n_dofs_high_ + n_dofs_low_;
154  }
155 
156 // /// Return local index of DOF (on low / high-dim) - should be private method
157 // inline unsigned int local_idx(unsigned int i_join_idx) const {
158 // if (this->is_high_dim(i_join_idx)) return (i_join_idx - n_dofs_low());
159 // else return i_join_idx;
160 // }
161 
162  inline bool is_high_dim(unsigned int i_join_idx) const {
163  return (i_join_idx >= n_dofs_low());
164  }
165 
166  FeQ<ValueType> shape(unsigned int i_join_idx) const {
167  ASSERT_LT(i_join_idx, n_dofs_both());
168 
169  /*
170  * Set zero bulk PatchFeValues for side DOFs and zero side PatchFeValues for bulk DOFs
171  *
172  * TODO After implementation of dependencies:
173  * 1) Implement FeQ::vec() getter (experimental method returned entire data vector)
174  * 2) Test difference of vectors
175  */
176  if (this->is_high_dim(i_join_idx))
178  else
180  }
181 
182 
183 private:
184  // attributes:
185  PatchOp<3> *patch_op_bulk_; ///< Pointer to bulk operation
186  PatchOp<3> *patch_op_side_; ///< Pointer to side operation
187  PatchOp<3> *patch_op_zero_bulk_; ///< Pointer to bulk zero operation
188  PatchOp<3> *patch_op_zero_side_; ///< Pointer to side zero operation
189  unsigned int n_dofs_high_; ///< Number of DOFs on high-dim element
190  unsigned int n_dofs_low_; ///< Number of DOFs on low-dim element
191 };
192 
193 
194 #endif /* OP_ACCESSORS_HH_ */
#define ASSERT_LT(a, b)
Definition of comparative assert macro (Less Than) only for debug mode.
Definition: asserts.hh:301
#define ASSERT_GT(a, b)
Definition of comparative assert macro (Greater Than) only for debug mode.
Definition: asserts.hh:317
Base point accessor class.
ElQ(PatchOp< 3 > *op)
Constructor.
Definition: op_accessors.hh:43
ValueType operator()(const BulkPoint &point) const
PatchOp< 3 > * patch_op_
Pointer to operation.
Definition: op_accessors.hh:51
FeQArray()
Default constructor.
Definition: op_accessors.hh:93
unsigned int n_dofs() const
Return number of DOFs.
unsigned int n_dofs_
Number of DOFs.
PatchOp< 3 > * patch_op_bulk_
Pointer to bulk operation.
PatchOp< 3 > * patch_op_side_
Pointer to side operation.
FeQ< ValueType > shape(unsigned int i_shape_fn_idx) const
FeQArray(PatchOp< 3 > *patch_op)
Definition: op_accessors.hh:97
bool is_high_dim(unsigned int i_join_idx) const
unsigned int n_dofs_both() const
unsigned int n_dofs_low() const
unsigned int n_dofs_low_
Number of DOFs on low-dim element.
PatchOp< 3 > * patch_op_bulk_
Pointer to bulk operation.
FeQJoin(PatchOp< 3 > *patch_op_bulk, PatchOp< 3 > *patch_op_side, PatchOp< 3 > *patch_op_zero_bulk, PatchOp< 3 > *patch_op_zero_side)
unsigned int n_dofs_high_
Number of DOFs on high-dim element.
FeQJoin()
Default constructor.
PatchOp< 3 > * patch_op_zero_side_
Pointer to side zero operation.
unsigned int n_dofs_high() const
FeQ< ValueType > shape(unsigned int i_join_idx) const
PatchOp< 3 > * patch_op_side_
Pointer to side operation.
PatchOp< 3 > * patch_op_zero_bulk_
Pointer to bulk zero operation.
PatchOp< 3 > * patch_op_bulk_
Pointer to bulk operation.
Definition: op_accessors.hh:83
PatchOp< 3 > * patch_op_side_
Pointer to side operation.
Definition: op_accessors.hh:84
FeQ(PatchOp< 3 > *patch_op_bulk, PatchOp< 3 > *patch_op_side, unsigned int i_shape_fn_idx)
Constructor used only in FeQArray::shape()
Definition: op_accessors.hh:74
ValueType operator()(const BulkPoint &point) const
unsigned int i_shape_fn_idx_
Index of shape function.
Definition: op_accessors.hh:85
FeQ(PatchOp< 3 > *patch_op)
Definition: op_accessors.hh:67
ElemDomain domain() const
Getter for bulk_side flag.
Definition: patch_op.hh:87
General point a+ side_begin_ + ccessor allow iterate over quadrature points of given side defined in ...
double Scalar
Definition: op_accessors.hh:25
Base class of FE operations.