v0.16.0
Loading...
Searching...
No Matches
TriLinearFormsIntegrators.hpp
Go to the documentation of this file.
1/** \file TriLinearFormsIntegrators.hpp
2 * \brief Trilinear forms integrators
3 * \ingroup mofem_form
4 */
5
6#ifndef __TRILINEAR_FORMS_INTEGRATORS_HPP__
7#define __TRILINEAR_FORMS_INTEGRATORS_HPP__
8
9namespace MoFEM {
10
11template <int BASE_DIM, int FIELD_DIM, int SPACE_DIM, IntegrationType I,
12 typename OpBase>
14
15template <int BASE_DIM, int FIELD_DIM, int SPACE_DIM, IntegrationType I,
16 typename OpBase>
18
19template <int SPACE_DIM, typename OpBase>
21 : public OpBase {
23 const std::string field_name_row, const std::string field_name_col,
24 boost::shared_ptr<MatrixDouble> y_grad_ptr,
25 ConstantFun alpha_fun = []() { return 1; })
26 : OpBase(field_name_row, field_name_col, OpBase::OPROWCOL),
27 yGradPtr(y_grad_ptr), alphaConstant(alpha_fun) {
28
29 this->assembleTranspose = false;
30 this->onlyTranspose = false;
31 this->sYmm = false;
32 }
33
34protected:
35 boost::shared_ptr<MatrixDouble> yGradPtr;
39};
40
41template <int SPACE_DIM, typename OpBase>
43 : public OpBase {
45 const std::string field_name_row, const std::string field_name_col,
46 boost::shared_ptr<MatrixDouble> u_ptr,
47 ConstantFun alpha_fun = []() { return 1; })
48 : OpBase(field_name_row, field_name_col, OpBase::OPROWCOL), uPtr(u_ptr),
49 alphaConstant(alpha_fun) {
50
51 this->assembleTranspose = false;
52 this->onlyTranspose = false;
53 this->sYmm = false;
54 }
55
56protected:
58 boost::shared_ptr<MatrixDouble> uPtr;
61};
62
63template <int FIELD_DIM, int SPACE_DIM, typename OpBase>
65 : public OpBase {
67 const std::string field_name_row, const std::string field_name_col,
68 boost::shared_ptr<MatrixDouble> y_grad_ptr,
69 ConstantFun alpha_fun = []() { return 1; })
70 : OpBase(field_name_row, field_name_col, OpBase::OPROWCOL),
71 yGradPtr(y_grad_ptr), alphaConstant(alpha_fun) {
72
73 this->assembleTranspose = false;
74 this->onlyTranspose = false;
75 this->sYmm = false;
76 }
77
78protected:
80 boost::shared_ptr<MatrixDouble> yGradPtr;
83};
84
85template <int FIELD_DIM, int SPACE_DIM, typename OpBase>
87 : public OpBase {
89 const std::string field_name_row, const std::string field_name_col,
90 boost::shared_ptr<MatrixDouble> u_ptr,
91 ConstantFun alpha_fun = []() { return 1; })
92 : OpBase(field_name_row, field_name_col, OpBase::OPROWCOL), uPtr(u_ptr),
93 alphaConstant(alpha_fun) {
94
95 this->assembleTranspose = false;
96 this->onlyTranspose = false;
97 this->sYmm = false;
98 }
99
100protected:
102 boost::shared_ptr<MatrixDouble> uPtr;
103 MoFEMErrorCode iNtegrate(EntitiesFieldData::EntData &row_data,
105};
106
107/**
108 * @brief Trilinear integrator form
109 * @ingroup mofem_forms
110 *
111 * @tparam EleOp
112 * @tparam A
113 * @tparam I
114 */
115template <typename EleOp>
116template <AssemblyType A>
117template <IntegrationType I>
118struct FormsIntegrators<EleOp>::Assembly<A>::TriLinearForm {
119
120 /**
121 * @brief Integrate \f$(\lambda_{ij},u_{i,j})_\Omega\f$
122 *
123 * @tparam SPACE_DIM
124 */
125 template <int SPACE_DIM>
127
128 template <int BASE_DIM, int FIELD_DIM, int SPACE_DIM>
131
132 template <int BASE_DIM, int FIELD_DIM, int SPACE_DIM>
135};
136
137template <int SPACE_DIM, typename OpBase>
141 EntitiesFieldData::EntData &col_data) {
143
145 auto get_grad_y_at_pts =
147 *yGradPtr, OpBase::nbIntegrationPts);
148
149 // get element volume
150 const double vol = OpBase::getMeasure();
151 // get integration weights
152 auto t_w = OpBase::getFTensor0IntegrationWeight();
153 // get base function gradient on rows
154 auto t_row_base = row_data.getFTensor0N();
155
156 auto get_t_vec = [&](const int rr) {
157 std::array<double *, SPACE_DIM> ptrs;
158 for (auto i = 0; i != SPACE_DIM; ++i)
159 ptrs[i] = &OpBase::locMat(rr, i);
161 ptrs);
162 };
163
164 auto t_grad_y_at_pts = get_grad_y_at_pts();
166
167 const double alpha_constant = alphaConstant();
168 // loop over integration points
169 for (int gg = 0; gg != OpBase::nbIntegrationPts; gg++) {
170 // take into account Jacobian
171 const double alpha = t_w * vol * alpha_constant;
172 // access local matrix
173 auto t_vec = get_t_vec(0);
174 // loop over rows base functions
175 int rr = 0;
176 for (; rr != OpBase::nbRows; rr++) {
177 // get column base functions gradient at gauss point gg
178 auto t_col_base = col_data.getFTensor0N(gg, 0);
179 // loop over columns
180 for (int cc = 0; cc != OpBase::nbCols / SPACE_DIM; cc++) {
181 // calculate element of local matrix
182 t_vec(i) += alpha * t_row_base * t_col_base * t_grad_y_at_pts(i);
183 ++t_col_base;
184 ++t_vec;
185 }
186 ++t_row_base;
187 }
188 for (; rr < OpBase::nbRowBaseFunctions; ++rr)
189 ++t_row_base;
190
191 ++t_grad_y_at_pts;
192 ++t_w; // move to another integration weight
193 }
195};
196
197template <int SPACE_DIM, typename OpBase>
201 EntitiesFieldData::EntData &col_data) {
203
205 auto get_u_at_pts =
208
209 // get element volume
210 const double vol = OpBase::getMeasure();
211 // get integration weights
212 auto t_w = OpBase::getFTensor0IntegrationWeight();
213 // get base function gradient on rows
214 auto t_row_base = row_data.getFTensor0N();
215
216 auto t_u_at_pts = get_u_at_pts();
218 const double alpha_constant = alphaConstant();
219 // loop over integration points
220 for (int gg = 0; gg != OpBase::nbIntegrationPts; gg++) {
221 // take into account Jacobian
222 const double alpha = t_w * vol * alpha_constant;
223 // loop over rows base functions
224 auto a_mat_ptr = &*OpBase::locMat.data().begin();
225 int rr = 0;
226 for (; rr != OpBase::nbRows; rr++) {
227 // get column base functions gradient at gauss point gg
228 auto t_diff_col_base = col_data.getFTensor1DiffN<SPACE_DIM>(gg, 0);
229 // loop over columns
230 for (int cc = 0; cc != OpBase::nbCols; cc++) {
231 // calculate element of local matrix
232 (*a_mat_ptr) +=
233 alpha * t_row_base * t_diff_col_base(i) * t_u_at_pts(i);
234 ++t_diff_col_base;
235 ++a_mat_ptr;
236 }
237 ++t_row_base;
238 }
239 for (; rr < OpBase::nbRowBaseFunctions; ++rr)
240 ++t_row_base;
241
242 ++t_u_at_pts;
243 ++t_w; // move to another integration weight
244 }
246};
247
248template <int FIELD_DIM, int SPACE_DIM, typename OpBase>
252 EntitiesFieldData::EntData &col_data) {
254
256 auto get_grad_y_at_pts =
259 DL>::get(*yGradPtr, OpBase::nbIntegrationPts);
260
261 // get element volume
262 const double vol = OpBase::getMeasure();
263 // get integration weights
264 auto t_w = OpBase::getFTensor0IntegrationWeight();
265 // get base function gradient on rows
266 auto t_row_base = row_data.getFTensor0N();
267
268 auto t_grad_y_at_pts = get_grad_y_at_pts();
271
272 auto get_t_mat = [&](const int rr) {
273 std::array<double *, FIELD_DIM * SPACE_DIM> ptrs;
274 int s = 0;
275 for (int j = 0; j != FIELD_DIM; ++j)
276 for (auto i = 0; i != SPACE_DIM; ++i, ++s)
277 ptrs[s] = &OpBase::locMat(rr + j, i);
279 SPACE_DIM>(ptrs);
280 };
281
282 const double alpha_constant = alphaConstant();
283 // loop over integration points
284 for (int gg = 0; gg != OpBase::nbIntegrationPts; gg++) {
285 // take into account Jacobian
286 const double alpha = t_w * vol * alpha_constant;
287
288 // loop over rows base functions
289 int rr = 0;
290 for (; rr != OpBase::nbRows / FIELD_DIM; rr++) {
291 // get column base functions gradient at gauss point gg
292 auto t_col_base = col_data.getFTensor0N(gg, 0);
293 // get mat
294 auto t_mat = get_t_mat(FIELD_DIM * rr);
295 // loop over columns
296 for (int cc = 0; cc != OpBase::nbCols / SPACE_DIM; cc++) {
297 // calculate element of local matrix
298 t_mat(I, k) +=
299 (alpha * t_row_base * t_col_base) * t_grad_y_at_pts(I, k);
300 ++t_col_base;
301 ++t_mat;
302 }
303 ++t_row_base;
304 }
305 for (; rr < OpBase::nbRowBaseFunctions; ++rr)
306 ++t_row_base;
307
308 ++t_grad_y_at_pts;
309 ++t_w; // move to another integration weight
310 }
312};
313
314template <int FIELD_DIM, int SPACE_DIM, typename OpBase>
318 EntitiesFieldData::EntData &col_data) {
320
322 auto get_u_at_pts =
325
326 // get element volume
327 const double vol = OpBase::getMeasure();
328 // get integration weights
329 auto t_w = OpBase::getFTensor0IntegrationWeight();
330 // get base function gradient on rows
331 auto t_row_base = row_data.getFTensor0N();
332
333 auto get_t_mat = [&](const int rr) {
334 std::array<double *, FIELD_DIM * FIELD_DIM> ptrs;
335 int s = 0;
336 for (int i = 0; i != FIELD_DIM; ++i)
337 for (int j = 0; j != FIELD_DIM; ++j, ++s)
338 ptrs[s] = &(OpBase::locMat(rr + i, j));
340 FIELD_DIM>(ptrs);
341 };
342
343 auto t_u_at_pts = get_u_at_pts();
345
349
350 const double alpha_constant = alphaConstant();
351 // loop over integration points
352 for (int gg = 0; gg != OpBase::nbIntegrationPts; gg++) {
353 // take into account Jacobian
354 const double alpha = t_w * vol * alpha_constant;
355
356 // loop over rows base functions
357 int rr = 0;
358 for (; rr != OpBase::nbRows / FIELD_DIM; ++rr) {
359 // get matrix vec
360 auto t_mat = get_t_mat(FIELD_DIM * rr);
361 // get column base functions gradient at gauss point gg
362 auto t_diff_col_base = col_data.getFTensor1DiffN<SPACE_DIM>(gg, 0);
363 // loop over columns
364 for (int cc = 0; cc != OpBase::nbCols / FIELD_DIM; ++cc) {
365 t_mat(I, L) +=
366 alpha * t_row_base * t_kd(I, L) *
367 (t_diff_col_base(k) * t_u_at_pts(k));
368 ++t_mat;
369 ++t_diff_col_base;
370 }
371 ++t_row_base;
372 }
373 for (; rr < OpBase::nbRowBaseFunctions; ++rr)
374 ++t_row_base;
375
376 ++t_u_at_pts;
377 ++t_w; // move to another integration weight
378 }
380};
381
382} // namespace MoFEM
383
384#endif //__TRILINEAR_FORMS_INTEGRATORS_HPP__
constexpr int SPACE_DIM
constexpr int FIELD_DIM
Kronecker Delta class symmetric.
#define MoFEMFunctionBegin
First executable line of each MoFEM function, used for error handling. Final line of MoFEM functions ...
#define MoFEMFunctionReturn(a)
Last executable line of each PETSc function used for error handling. Replaces return()
constexpr int BASE_DIM
constexpr auto t_kd
IntegrationType
Form integrator integration types.
@ GAUSS
Gaussian quadrature integration.
FTensor::Index< 'i', SPACE_DIM > i
FTensor::Index< 'j', 3 > j
FTensor::Index< 'k', 3 > k
PetscErrorCode MoFEMErrorCode
MoFEM/PETSc error code.
implementation of Data Operators for Forces and Sources
Definition Common.hpp:10
boost::function< double()> ConstantFun
Constant function type.
decltype(GetFTensor1FromMatImpl< Tensor_Dim, S, DL, M >::get(std::declval< M & >(), 0, 0)) GetFTensor1FromMatType
decltype(GetFTensor2FromMatImpl< Tensor_Dim0, Tensor_Dim1, S, DL, M >::get(std::declval< M & >(), 0, 0)) GetFTensor2FromMatType
constexpr IntegrationType I
Data on single entity (This is passed as argument to DataOperator::doWork)
FTensor::Tensor0< FTensor::PackPtr< double *, 1 > > getFTensor0N(const FieldApproximationBase base)
Get base function as Tensor0.
auto getFTensor1DiffN(const FieldApproximationBase base)
Get derivatives of base functions.
int nbRows
number of dofs on rows
int nbIntegrationPts
number of integration points
MatrixDouble locMat
local entity block matrix
int nbCols
number if dof on column
int nbRowBaseFunctions
number or row base functions
OpConvectiveTermLhsDuImpl(const std::string field_name_row, const std::string field_name_col, boost::shared_ptr< MatrixDouble > y_grad_ptr, ConstantFun alpha_fun=[]() { return 1;})
OpConvectiveTermLhsDuImpl(const std::string field_name_row, const std::string field_name_col, boost::shared_ptr< MatrixDouble > y_grad_ptr, ConstantFun alpha_fun=[]() { return 1;})
OpConvectiveTermLhsDyImpl(const std::string field_name_row, const std::string field_name_col, boost::shared_ptr< MatrixDouble > u_ptr, ConstantFun alpha_fun=[]() { return 1;})
OpConvectiveTermLhsDyImpl(const std::string field_name_row, const std::string field_name_col, boost::shared_ptr< MatrixDouble > u_ptr, ConstantFun alpha_fun=[]() { return 1;})