Flow123d  DF_patch_fe_mechanics-5faa023
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/eval_subset.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  /// Forbidden default constructor
35  ElQ() = delete;
36 
37  /// Constructor
39  : patch_op_(op) {}
40 
41  ValueType operator()(const BulkPoint &point) const;
42 
43  ValueType operator()(const SidePoint &point) const;
44 
45 private:
46  PatchOp<3> *patch_op_; ///< Pointer to operation
47 };
48 
49 
50 template <class ValueType>
51 class FeQ {
52 public:
53  /// Forbidden default constructor
54  FeQ() = delete;
55 
56  // Class similar to current FeView
57  FeQ(PatchOp<3> *patch_op)
58  : patch_op_bulk_(nullptr), patch_op_side_(nullptr), i_shape_fn_idx_(0) {
59  if (patch_op->domain()==0) patch_op_bulk_ = patch_op;
60  else patch_op_side_ = patch_op;
61  }
62 
63  /// Constructor used only in FeQArray::shape()
64  FeQ(PatchOp<3> *patch_op_bulk, PatchOp<3> *patch_op_side, unsigned int i_shape_fn_idx)
65  : patch_op_bulk_(patch_op_bulk), patch_op_side_(patch_op_side), i_shape_fn_idx_(i_shape_fn_idx) {}
66 
67 
68  ValueType operator()(const BulkPoint &point) const;
69 
70  ValueType operator()(const SidePoint &point) const;
71 
72 private:
73  PatchOp<3> *patch_op_bulk_; ///< Pointer to bulk operation
74  PatchOp<3> *patch_op_side_; ///< Pointer to side operation
75  unsigned int i_shape_fn_idx_; ///< Index of shape function
76 };
77 
78 
79 template <class ValueType>
80 class FeQArray {
81 public:
82  /// Forbidden default constructor
83  FeQArray() = delete;
84 
85  // Class similar to current FeView
86  FeQArray(PatchOp<3> *patch_op)
87  : patch_op_bulk_(nullptr), patch_op_side_(nullptr), n_dofs_(patch_op->n_dofs()) {
88  ASSERT_GT(n_dofs_, 0).error("Invalid number of DOFs.\n");
89 
90  if (patch_op->domain()==0) patch_op_bulk_ = patch_op;
91  else patch_op_side_ = patch_op;
92  }
93 
94 
95  FeQ<ValueType> shape(unsigned int i_shape_fn_idx) const {
96  ASSERT_LT(i_shape_fn_idx, n_dofs_);
97  return FeQ<ValueType>(patch_op_bulk_, patch_op_side_, i_shape_fn_idx);
98  }
99 
100  /// Return number of DOFs
101  inline unsigned int n_dofs() const {
102  return n_dofs_;
103  }
104 
105 private:
106  PatchOp<3> *patch_op_bulk_; ///< Pointer to bulk operation
107  PatchOp<3> *patch_op_side_; ///< Pointer to side operation
108  unsigned int n_dofs_; ///< Number of DOFs
109 };
110 
111 
112 template <class ValueType>
113 class FeQJoin {
114 public:
115  /// Default constructor
117  : patch_op_bulk_(nullptr), patch_op_side_(nullptr), patch_op_zero_bulk_(nullptr), patch_op_zero_side_(nullptr)
118  {}
119 
120  /**
121  * Constructor
122  *
123  * @param patch_op_bulk Pointer to PatchOP bulk object.
124  * @param patch_op_side Pointer to PatchOp side object.
125  * @param patch_op_zero_bulk Pointer to zero PatchOP bulk object.
126  * @param patch_op_zero_side Pointer to zero PatchOp side object.
127  */
128  FeQJoin(PatchOp<3> *patch_op_bulk, PatchOp<3> *patch_op_side, PatchOp<3> *patch_op_zero_bulk, PatchOp<3> *patch_op_zero_side)
129  : 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),
130  n_dofs_high_(patch_op_side->n_dofs()), n_dofs_low_(patch_op_bulk->n_dofs()) {}
131 
132 
133  inline unsigned int n_dofs_low() const {
134  return n_dofs_low_;
135  }
136 
137  inline unsigned int n_dofs_high() const {
138  return n_dofs_high_;
139  }
140 
141  inline unsigned int n_dofs_both() const {
142  return n_dofs_high_ + n_dofs_low_;
143  }
144 
145 // /// Return local index of DOF (on low / high-dim) - should be private method
146 // inline unsigned int local_idx(unsigned int i_join_idx) const {
147 // if (this->is_high_dim(i_join_idx)) return (i_join_idx - n_dofs_low());
148 // else return i_join_idx;
149 // }
150 
151  inline bool is_high_dim(unsigned int i_join_idx) const {
152  return (i_join_idx >= n_dofs_low());
153  }
154 
155  FeQ<ValueType> shape(unsigned int i_join_idx) const {
156  ASSERT_LT(i_join_idx, n_dofs_both());
157 
158  /*
159  * Set zero bulk PatchFeValues for side DOFs and zero side PatchFeValues for bulk DOFs
160  *
161  * TODO After implementation of dependencies:
162  * 1) Implement FeQ::vec() getter (experimental method returned entire data vector)
163  * 2) Test difference of vectors
164  */
165  if (this->is_high_dim(i_join_idx))
167  else
169  }
170 
171 
172 private:
173  // attributes:
174  PatchOp<3> *patch_op_bulk_; ///< Pointer to bulk operation
175  PatchOp<3> *patch_op_side_; ///< Pointer to side operation
176  PatchOp<3> *patch_op_zero_bulk_; ///< Pointer to bulk zero operation
177  PatchOp<3> *patch_op_zero_side_; ///< Pointer to side zero operation
178  unsigned int n_dofs_high_; ///< Number of DOFs on high-dim element
179  unsigned int n_dofs_low_; ///< Number of DOFs on low-dim element
180 };
181 
182 
183 #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.
Definition: eval_subset.hh:55
ElQ(PatchOp< 3 > *op)
Constructor.
Definition: op_accessors.hh:38
ValueType operator()(const BulkPoint &point) const
PatchOp< 3 > * patch_op_
Pointer to operation.
Definition: op_accessors.hh:46
ElQ()=delete
Forbidden default constructor.
FeQArray()=delete
Forbidden default constructor.
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
Definition: op_accessors.hh:95
FeQArray(PatchOp< 3 > *patch_op)
Definition: op_accessors.hh:86
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:73
PatchOp< 3 > * patch_op_side_
Pointer to side operation.
Definition: op_accessors.hh:74
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:64
ValueType operator()(const BulkPoint &point) const
unsigned int i_shape_fn_idx_
Index of shape function.
Definition: op_accessors.hh:75
FeQ(PatchOp< 3 > *patch_op)
Definition: op_accessors.hh:57
FeQ()=delete
Forbidden default constructor.
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 ...
Definition: eval_subset.hh:121
double Scalar
Definition: op_accessors.hh:25
Base class of FE operations.