7 #ifndef __LINEAR_FORMS_INTEGRATORS_IMPL_HPP__
8 #define __LINEAR_FORMS_INTEGRATORS_IMPL_HPP__
13 template <
typename OpBase>
struct S {
S() =
delete; };
18 template <
typename OpBase>
struct S {
S() =
delete; };
22 template <
int BASE_DIM,
int FIELD_DIM, IntegrationType I,
typename OpBase>
30 template <
typename OpBase>
42 boost::shared_ptr<Range> ents_ptr =
nullptr)
44 sourceFun(source_fun) {}
56 boost::shared_ptr<Range> ents_ptr =
nullptr)
58 sourceFun(source_fun) {}
65 template <
int FIELD_DIM,
typename OpBase>
79 boost::shared_ptr<Range> ents_ptr =
nullptr)
90 boost::shared_ptr<Range> ents_ptr =
nullptr)
92 sourceFun(source_fun) {}
99 template <
int FIELD_DIM,
typename OpBase>
105 boost::shared_ptr<Range> ents_ptr =
nullptr)
107 sourceFun(source_fun) {}
110 boost::shared_ptr<Range> ents_ptr =
nullptr)
112 sourceFun(source_fun) {}
119 template <
int BASE_DIM,
int S, IntegrationType I,
typename OpBase>
122 template <
int S,
typename OpBase>
126 const std::string
field_name, boost::shared_ptr<VectorDouble> vec,
127 ScalarFun beta_coeff = [](
double,
double,
double) constexpr {
return 1; },
128 boost::shared_ptr<Range> ents_ptr =
nullptr)
130 betaCoeff(beta_coeff) {}
142 template <
int FIELD_DIM,
int S,
typename OpBase>
146 const std::string
field_name, boost::shared_ptr<MatrixDouble> vec,
147 ScalarFun beta_coeff = [](
double,
double,
double) constexpr {
return 1; },
148 boost::shared_ptr<Range> ents_ptr =
nullptr)
150 betaCoeff(beta_coeff) {}
159 template <
int FIELD_DIM,
int S,
typename OpBase>
163 const std::string
field_name, boost::shared_ptr<MatrixDouble> vec,
164 ScalarFun beta_coeff = [](
double,
double,
double) constexpr {
return 1; },
165 boost::shared_ptr<Range> ents_ptr =
nullptr)
167 betaCoeff(beta_coeff) {}
180 template <
int SPACE_DIM,
int S,
typename OpBase>
187 const std::string
field_name, boost::shared_ptr<MatrixDouble> mat_vals,
188 ScalarFun beta_coeff = [](
double,
double,
double) constexpr {
return 1; },
189 boost::shared_ptr<Range> ents_ptr =
nullptr)
191 matVals(mat_vals), betaCoeff(beta_coeff) {}
199 template <
int SPACE_DIM,
int S,
typename OpBase>
207 const std::string
field_name, boost::shared_ptr<MatrixDouble> mat_vals,
208 ScalarFun beta_coeff = [](
double,
double,
double) constexpr {
return 1; },
209 boost::shared_ptr<Range> ents_ptr =
nullptr)
211 matVals(mat_vals), betaCoeff(beta_coeff) {}
223 template <
int SPACE_DIM,
int S,
typename OpBase>
228 const std::string
field_name, boost::shared_ptr<MatrixDouble> mat_vals,
229 ScalarFun beta_coeff = [](
double,
double,
double) constexpr {
return 1; })
231 betaCoeff(beta_coeff) {}
250 const std::string
field_name, boost::shared_ptr<MatrixDouble> mat_vals,
251 ScalarFun beta = [](
double,
double,
double) {
return 1; },
252 boost::shared_ptr<Range> ents_ptr =
nullptr)
254 matVals(mat_vals), betaConst(beta) {}
264 template <
int SPACE_DIM,
typename OpBase, CoordinateTypes CoordSys>
268 const std::string
field_name, boost::shared_ptr<VectorDouble> vec_vals,
269 ScalarFun beta = [](
double,
double,
double) constexpr {
return 1; },
270 boost::shared_ptr<Range> ents_ptr =
nullptr)
272 vecVals(vec_vals), betaConst(beta) {}
281 template <
int FIELD_DIM,
typename OpBase, CoordinateTypes CoordSys>
286 const std::string
field_name, boost::shared_ptr<VectorDouble> vec,
287 ScalarFun beta = [](
double,
double,
double) constexpr {
return 1; },
288 boost::shared_ptr<Range> ents_ptr =
nullptr)
309 template <
int SPACE_DIM, IntegrationType I,
typename OpBase>
312 template <
int SPACE_DIM,
typename OpBase>
315 boost::shared_ptr<MatrixDouble> mat_vals)
319 boost::shared_ptr<MatrixDouble> mat_vals,
322 betaCoeff(beta_fun) {}
343 template <
int SPACE_DIM, IntegrationType I,
typename OpBase>
346 template <
int SPACE_DIM,
typename OpBase>
349 boost::shared_ptr<MatrixDouble> mat_vals)
353 boost::shared_ptr<MatrixDouble> mat_vals,
356 betaCoeff(beta_fun) {}
377 template <
int SPACE_DIM, IntegrationType I,
typename OpBase>
386 template <
int FIELD_DIM, IntegrationType I,
typename OpBase>
394 template <
typename OpBase>
398 ScalarFun source_fun = [](
double,
double,
double) constexpr {
return 1; },
399 boost::shared_ptr<Range> ents_ptr =
nullptr)
401 sourceFun(source_fun) {}
409 template <
typename OpBase>
413 ScalarFun source_fun = [](
double,
double,
double) constexpr {
return 1; },
414 boost::shared_ptr<Range> ents_ptr =
nullptr)
416 sourceFun(source_fun) {}
434 template <
int SPACE_DIM, IntegrationType I,
typename OpBase>
437 template <
int SPACE_DIM,
typename OpBase>
441 const std::string
field_name, boost::shared_ptr<MatrixDouble> u_ptr,
442 ScalarFun beta_coeff = [](
double,
double,
double) constexpr {
return 1; },
443 boost::shared_ptr<Range> ents_ptr =
nullptr)
445 betaCoeff(beta_coeff) {}
448 boost::shared_ptr<MatrixDouble>
uPtr;
457 template <
int SPACE_DIM,
typename OpBase>
460 const std::string
field_name, boost::shared_ptr<MatrixDouble> u_ptr,
461 boost::shared_ptr<MatrixDouble> y_grad_ptr,
462 ConstantFun source_fun = []() constexpr {
return 1; })
464 yGradPtr(y_grad_ptr), alphaConstant(source_fun) {}
467 boost::shared_ptr<MatrixDouble>
uPtr;
473 template <
int FIELD_DIM,
int SPACE_DIM,
typename OpBase>
477 const std::string
field_name, boost::shared_ptr<MatrixDouble> u_ptr,
478 boost::shared_ptr<MatrixDouble> y_grad_ptr,
479 ConstantFun source_fun = []() constexpr {
return 1; })
481 yGradPtr(y_grad_ptr), alphaConstant(source_fun) {}
484 boost::shared_ptr<MatrixDouble>
uPtr;
490 template <
typename OpBase>
497 const double vol = OpBase::getMeasure();
499 auto t_w = OpBase::getFTensor0IntegrationWeight();
503 auto t_coords = OpBase::getFTensor1CoordsAtGaussPts();
508 t_w * vol * sourceFun(t_coords(0), t_coords(1), t_coords(2));
523 template <
int FIELD_DIM,
typename OpBase>
531 const double vol = OpBase::getMeasure();
533 auto t_w = OpBase::getFTensor0IntegrationWeight();
537 auto t_coords = OpBase::getFTensor1CoordsAtGaussPts();
541 auto t_source = sourceFun(t_coords(0), t_coords(1), t_coords(2));
543 const double alpha = t_w * vol;
545 auto t_nf = getFTensor1FromArray<FIELD_DIM, FIELD_DIM>(
OpBase::locF);
548 t_nf(
i) += alpha * t_row_base * t_source(
i);
560 template <
int FIELD_DIM,
typename OpBase>
567 const size_t nb_base_functions = row_data.
getN().size2() / 3;
569 const double vol = OpBase::getMeasure();
571 auto t_w = OpBase::getFTensor0IntegrationWeight();
575 auto t_coords = OpBase::getFTensor1CoordsAtGaussPts();
579 auto t_source = sourceFun(t_coords(0), t_coords(1), t_coords(2));
581 const double alpha = t_w * vol;
588 for (; rr < nb_base_functions; ++rr)
596 template <
int S,
typename OpBase>
602 const double vol = OpBase::getMeasure();
604 auto t_w = OpBase::getFTensor0IntegrationWeight();
608 auto t_vec = getFTensor0FromVec<S>(*sourceVec);
613 "Wrong number of integration points %d != %d",
619 auto t_coords = OpBase::getFTensor1CoordsAtGaussPts();
624 t_w * vol * betaCoeff(t_coords(0), t_coords(1), t_coords(2));
640 template <
int FIELD_DIM,
int S,
typename OpBase>
646 const double vol = OpBase::getMeasure();
648 auto t_w = OpBase::getFTensor0IntegrationWeight();
652 auto t_coords = OpBase::getFTensor1CoordsAtGaussPts();
654 auto t_vec = getFTensor1FromMat<FIELD_DIM, S>(*sourceVec);
659 t_w * vol * betaCoeff(t_coords(0), t_coords(1), t_coords(2));
661 auto t_nf = OpBase::template getNf<FIELD_DIM>();
665 t_nf(
i) += alpha * t_row_base * t_vec(
i);
678 template <
int FIELD_DIM,
int S,
typename OpBase>
683 const size_t nb_base_functions = row_data.
getN().size2() / 3;
685 const double vol = OpBase::getMeasure();
687 auto t_w = OpBase::getFTensor0IntegrationWeight();
691 auto t_coords = OpBase::getFTensor1CoordsAtGaussPts();
693 auto t_vec = getFTensor1FromMat<FIELD_DIM, S>(*sourceVec);
698 t_w * vol * betaCoeff(t_coords(0), t_coords(1), t_coords(2));
705 for (; rr < nb_base_functions; ++rr)
714 template <
int SPACE_DIM,
int S,
typename OpBase>
721 const double vol = OpBase::getMeasure();
723 auto t_w = OpBase::getFTensor0IntegrationWeight();
727 auto t_val_grad = getFTensor1FromMat<SPACE_DIM, S>(*(matVals));
729 auto t_coords = OpBase::getFTensor1CoordsAtGaussPts();
732 const double beta = vol * betaCoeff(t_coords(0), t_coords(1), t_coords(2));
734 const double alpha = t_w * beta;
753 template <
int SPACE_DIM,
int S,
typename OpBase>
760 const double vol = OpBase::getMeasure();
762 auto t_w = OpBase::getFTensor0IntegrationWeight();
766 auto t_val_grad = getFTensor2FromMat<SPACE_DIM, SPACE_DIM>(*(matVals));
768 auto t_coords = OpBase::getFTensor1CoordsAtGaussPts();
773 t_w * vol * betaCoeff(t_coords(0), t_coords(1), t_coords(2));
775 auto t_nf = OpBase::template getNf<SPACE_DIM>();
780 t_nf(
i) += alpha * (t_row_grad(
j) * t_val_grad(
i,
j));
795 template <
int SPACE_DIM,
int S,
typename OpBase>
801 const double vol = OpBase::getMeasure();
803 auto t_coords = OpBase::getFTensor1CoordsAtGaussPts();
805 auto t_w = OpBase::getFTensor0IntegrationWeight();
809 auto t_val_mat = getFTensor2SymmetricFromMat<SPACE_DIM, S>(*(matVals));
814 t_w * vol * betaCoeff(t_coords(0), t_coords(1), t_coords(2));
816 auto t_nf = OpBase::template getNf<SPACE_DIM>();
821 t_nf(
j) += alpha * (t_row_grad(
i) * t_val_mat(
i,
j));
842 const size_t nb_base_functions = row_data.
getN().size2() / 3;
843 auto t_w = this->getFTensor0IntegrationWeight();
845 auto t_coords = OpBase::getFTensor1CoordsAtGaussPts();
848 auto t_u = getFTensor1FromMat<FIELD_DIM>(*(matVals));
852 const double alpha = this->getMeasure() * t_w *
853 betaConst(t_coords(0), t_coords(1), t_coords(2));
854 auto t_nf = OpBase::template getNf<FIELD_DIM>();
857 for (; bb != this->nbRows /
FIELD_DIM; ++bb) {
858 const double t_div_base = t_diff_base(
j,
j);
859 t_nf(
i) += alpha * t_div_base * t_u(
i);
861 t_nf(
i) += t_base(0) * (alpha / t_coords(0)) * t_u(
i);
867 for (; bb < nb_base_functions; ++bb) {
880 template <
int SPACE_DIM,
typename OpBase, CoordinateTypes CoordSys>
886 const size_t nb_base_functions = row_data.
getN().size2() / 3;
887 auto t_w = this->getFTensor0IntegrationWeight();
889 auto t_coords = OpBase::getFTensor1CoordsAtGaussPts();
895 const double alpha = this->getMeasure() * t_w *
896 betaConst(t_coords(0), t_coords(1), t_coords(2));
900 for (; bb != this->nbRows; ++bb) {
901 const double t_div_base = t_diff_base(
j,
j);
905 for (; bb < nb_base_functions; ++bb)
936 template <
int FIELD_DIM,
typename OpBase, CoordinateTypes CoordSys>
944 const double vol = OpBase::getMeasure();
946 auto t_w = OpBase::getFTensor0IntegrationWeight();
948 auto t_coords = OpBase::getFTensor1CoordsAtGaussPts();
957 t_w * vol * betaCoeff(t_coords(0), t_coords(1), t_coords(2));
958 auto t_nf = getFTensor1FromArray<FIELD_DIM, FIELD_DIM>(
OpBase::locF);
962 t_nf(
i) += alpha * t_row_grad(
i) * t_vec;
975 template <
int SPACE_DIM,
typename OpBase>
980 const size_t nb_base_functions = row_data.
getN().size2() / 3;
981 auto t_w = this->getFTensor0IntegrationWeight();
982 auto t_coords = this->getFTensor1CoordsAtGaussPts();
984 auto t_grad = getFTensor2FromMat<SPACE_DIM, SPACE_DIM>(*(matVals));
988 const double alpha = this->getMeasure() * t_w;
989 auto t_nf = OpBase::template getNf<SPACE_DIM>();
992 for (; bb != this->nbRows /
SPACE_DIM; ++bb) {
993 t_nf(
i) += alpha * betaCoeff(t_coords(0), t_coords(1), t_coords(2)) *
994 t_base(
j) * t_grad(
i,
j);
998 for (; bb < nb_base_functions; ++bb)
1009 template <
int SPACE_DIM,
typename OpBase>
1014 const size_t nb_base_functions = row_data.
getN().size2();
1015 auto t_w = this->getFTensor0IntegrationWeight();
1016 auto t_coords = this->getFTensor1CoordsAtGaussPts();
1018 auto t_div = getFTensor1FromMat<SPACE_DIM>(*(matVals));
1021 const double alpha = this->getMeasure() * t_w;
1022 auto t_nf = OpBase::template getNf<SPACE_DIM>();
1025 for (; bb != this->nbRows /
SPACE_DIM; ++bb) {
1026 t_nf(
i) += alpha * t_base *
1027 betaCoeff(t_coords(0), t_coords(1), t_coords(2)) * t_div(
i);
1031 for (; bb < nb_base_functions; ++bb)
1042 template <
typename OpBase>
1047 const size_t nb_base_functions = row_data.
getN().size2() / 3;
1050 auto t_w = OpBase::getFTensor0IntegrationWeight();
1054 auto t_coords = OpBase::getFTensor1CoordsAtGaussPts();
1056 auto t_normal = OpBase::getFTensor1NormalsAtGaussPts();
1058 if (this->getNumeredEntFiniteElementPtr()->getEntType() == MBTRI)
1063 const double alpha =
1064 t_w * sourceFun(t_coords(0), t_coords(1), t_coords(2)) /
a;
1071 for (; rr < nb_base_functions; ++rr)
1080 template <
typename OpBase>
1085 const size_t nb_base_functions = row_data.
getN().size2() / 3;
1089 auto t_w = OpBase::getFTensor0IntegrationWeight();
1093 auto t_coords = OpBase::getFTensor1CoordsAtGaussPts();
1095 auto t_tangent = OpBase::getFTensor1TangentAtGaussPts();
1099 const double alpha = t_w * sourceFun(t_coords(0), t_coords(1), t_coords(2));
1109 for (; rr < nb_base_functions; ++rr)
1118 template <
int SPACE_DIM,
typename OpBase>
1126 const size_t nb_base_functions = row_data.
getN().size2() / 3;
1129 auto t_w = OpBase::getFTensor0IntegrationWeight();
1133 auto t_coords = OpBase::getFTensor1CoordsAtGaussPts();
1135 auto t_normal = OpBase::getFTensor1NormalsAtGaussPts();
1137 auto t_u = getFTensor1FromMat<SPACE_DIM>(*uPtr);
1139 auto a = OpBase::getMeasure();
1142 auto l2 = std::sqrt(t_normal(
i) * t_normal(
i));
1143 const double alpha =
1144 t_w * betaCoeff(t_coords(0), t_coords(1), t_coords(2)) * (
a / l2);
1146 auto t_nf = OpBase::template getNf<SPACE_DIM>();
1150 t_nf(
J) += alpha * (t_row_base(
i) * t_normal(
i)) * t_u(
J);
1154 for (; rr < nb_base_functions; ++rr)
1164 template <
int SPACE_DIM,
typename OpBase>
1170 auto t_w = this->getFTensor0IntegrationWeight();
1173 auto t_u = getFTensor1FromMat<SPACE_DIM>(*uPtr);
1174 auto t_grad_y = getFTensor1FromMat<SPACE_DIM>(*yGradPtr);
1177 const double alpha_constant = alphaConstant();
1181 const double vol = OpBase::getMeasure();
1182 const double c = (t_grad_y(
i) * t_u(
i)) * (t_w * vol * alpha_constant);
1201 template <
int FIELD_DIM,
int SPACE_DIM,
typename OpBase>
1207 auto t_w = this->getFTensor0IntegrationWeight();
1210 auto t_u = getFTensor1FromMat<SPACE_DIM>(*uPtr);
1211 auto t_grad_y = getFTensor2FromMat<FIELD_DIM, SPACE_DIM>(*yGradPtr);
1215 const double alpha_constant = alphaConstant();
1219 const double vol = OpBase::getMeasure();
1222 t_c(
J) = (t_grad_y(
J,
i) * t_u(
i)) * (t_w * vol * alpha_constant);
1224 auto t_nf = getFTensor1FromArray<FIELD_DIM, FIELD_DIM>(
OpBase::locF);
1227 t_nf(
J) += t_base * t_c(
J);
1244 #endif // __LINEAR_FORMS_INTEGRATORS_HPP__