LehrFEM++ 1.0.0
A simple Finite Element Library for teaching
loc_comp_dpg.h
1#ifndef PROJECTS_DPG_LOC_COMP_DPG
2#define PROJECTS_DPG_LOC_COMP_DPG
3
13#include <lf/base/base.h>
14#include <lf/mesh/mesh.h>
15#include <lf/mesh/utils/utils.h>
16#include <lf/quad/quad.h>
17#include <lf/uscalfe/uscalfe.h>
18
19#include "dpg.h"
20#include "dpg_tools.h"
21#include "product_fe_space.h"
22#include "sub_element_matrix_provider.h"
23#include "sub_element_vector_provider.h"
24
25namespace projects::dpg {
26
32
69template <typename SCALAR, typename DIFF_COEFF>
71 static_assert(lf::mesh::utils::isMeshFunction<DIFF_COEFF>);
72
73 public:
77
79 delete;
81 default;
83 const DiffusionElementMatrixProvider&) = delete;
85 delete;
86
101 std::shared_ptr<ProductUniformFESpace<SCALAR>> fe_space_trial,
102 std::shared_ptr<ProductUniformFESpace<SCALAR>> fe_space_test,
103 size_type trial_component, size_type test_component, DIFF_COEFF alpha);
104
116 ElemMat Eval(const lf::mesh::Entity& cell) override;
117
118 [[nodiscard]] size_type TrialComponent() const override {
119 return trial_component_;
120 }
121
122 [[nodiscard]] size_type TestComponent() const override {
123 return test_component_;
124 }
125
127
128 private:
130 DIFF_COEFF alpha_;
131
135 std::array<lf::uscalfe::PrecomputedScalarReferenceFiniteElement<SCALAR>, 5>
140 std::array<lf::uscalfe::PrecomputedScalarReferenceFiniteElement<SCALAR>, 5>
142
147};
148
149// template deduction hint.
150template <class PTR, class DIFF_COEFF>
151DiffusionElementMatrixProvider(PTR fe_space_trial, PTR fe_space_test,
152 size_type trial_component,
153 size_type test_component, DIFF_COEFF alpha)
154 -> DiffusionElementMatrixProvider<typename PTR::element_type::SCALAR,
155 DIFF_COEFF>;
156
157// Constructor. internal construction of quadrature rules.
158template <typename SCALAR, typename DIFF_COEFF>
161 std::shared_ptr<ProductUniformFESpace<SCALAR>> fe_space_trial,
162 std::shared_ptr<ProductUniformFESpace<SCALAR>> fe_space_test,
163 size_type trial_component, size_type test_component, DIFF_COEFF alpha)
164 : alpha_(std::move(alpha)),
165 trial_component_(trial_component),
166 test_component_(test_component),
167 fe_precomp_trial_(),
168 fe_precomp_test_() {
169 for (auto ref_el : {lf::base::RefEl::kTria(), lf::base::RefEl::kQuad()}) {
170 // obtain descriptions of local shape functions.
171 auto fe_trial =
172 fe_space_trial->ShapeFunctionLayout(ref_el, trial_component_);
173 auto fe_test = fe_space_test->ShapeFunctionLayout(ref_el, test_component_);
174
175 // check, that shape functions for both the trial and test space component
176 // for that entity are available.
177 // Note that the corresponding PrecomputedScalarReferenceFiniteElement local
178 // object is not initialized if the associated description of local shape
179 // functions is missing.
180 if (fe_trial != nullptr && fe_test != nullptr) {
181 // use a quadrature rule whose degree is the sum of the degrees of the fe
182 // spaces.
183 size_type degree = fe_trial->Degree() + fe_test->Degree();
184 lf::quad::QuadRule qr = lf::quad::make_QuadRule(ref_el, degree);
185 // Precompute cell-independent quantities.
186 fe_precomp_trial_[ref_el.Id()] =
188 fe_precomp_test_[ref_el.Id()] =
190 }
191 }
192}
193
194template <typename SCALAR, typename DIFF_COEFF>
197 const lf::mesh::Entity& cell) {
198 // Obtain precomputed information about values of local shape functions
199 // and their gradients at quadrature points.
201 fe_precomp_trial_[cell.RefEl().Id()];
203 fe_precomp_test_[cell.RefEl().Id()];
204
205 // check initialization:
206 LF_ASSERT_MSG(pfe_trial.isInitialized(),
207 "No local shape function on trial space for entity type "
208 << cell.RefEl());
209 LF_ASSERT_MSG(
210 pfe_test.isInitialized(),
211 "No local shape function on test space for entity type " << cell.RefEl());
212 // check the consistency of the quadratrue rules used.
213 LF_ASSERT_MSG(pfe_trial.Qr().Points() == pfe_test.Qr().Points() &&
214 pfe_trial.Qr().Weights() == pfe_test.Qr().Weights() &&
215 pfe_trial.Qr().NumPoints() == pfe_test.Qr().NumPoints(),
216 "Qr missmatch");
217
218 // query the geometry of the cell.
219 const lf::geometry::Geometry* geo_ptr = cell.Geometry();
220 LF_ASSERT_MSG(geo_ptr != nullptr, "Invalid geometry");
221 LF_ASSERT_MSG(geo_ptr->DimLocal() == 2, "Only 2D implementation available");
222
223 // phsical dimension of the cell.
224 const lf::uscalfe::dim_t world_dim = geo_ptr->DimGlobal();
225
226 // retrive information for parametric fem computation:
227 const Eigen::VectorXd determinants(
228 geo_ptr->IntegrationElement(pfe_trial.Qr().Points()));
229 LF_ASSERT_MSG(determinants.size() == pfe_trial.Qr().NumPoints(),
230 "Mismatch " << determinants.size() << " <-> "
231 << pfe_trial.Qr().NumPoints());
232
233 const Eigen::MatrixXd JinvT(
234 geo_ptr->JacobianInverseGramian(pfe_trial.Qr().Points()));
235 LF_ASSERT_MSG(
236 JinvT.cols() == 2 * pfe_trial.Qr().NumPoints() &&
237 JinvT.rows() == world_dim,
238 "Mismatch " << JinvT.cols() << " <-> " << 2 * pfe_trial.Qr().NumPoints());
239
240 // evaluate alpha in the quadrature points
241 auto alphaeval = alpha_(cell, pfe_trial.Qr().Points());
242
243 // initialize the element matrix
244 elem_mat_t mat(pfe_test.NumRefShapeFunctions(),
245 pfe_trial.NumRefShapeFunctions());
246 mat.setZero();
247
248 // loop over quadrature points:
249 for (size_type k = 0; k < pfe_trial.Qr().NumPoints(); ++k) {
250 // transformed quadrature weight.
251 const double w = pfe_trial.Qr().Weights()[k] * determinants[k];
252
253 // transformed gradients
254 const auto trf_trial_grad(
255 JinvT.block(0, 2 * k, world_dim, 2) *
257 .block(0, 2 * k, mat.cols(), 2)
258 .transpose());
259 const auto trf_test_grad(JinvT.block(0, 2 * k, world_dim, 2) *
261 .block(0, 2 * k, mat.rows(), 2)
262 .transpose());
263
264 mat += w * trf_test_grad.transpose() * alphaeval[k] * trf_trial_grad;
265 }
266 return mat;
267}
268
302template <typename SCALAR, typename REACTION_COEFF>
304 static_assert(lf::mesh::utils::isMeshFunction<REACTION_COEFF>);
305
306 public:
310
313 default;
315 const ReactionElementMatrixProvider&) = delete;
317 delete;
318
332 std::shared_ptr<ProductUniformFESpace<SCALAR>> fe_space_trial,
333 std::shared_ptr<ProductUniformFESpace<SCALAR>> fe_space_test,
334 size_type trial_component, size_type test_component,
335 REACTION_COEFF gamma);
336
348 ElemMat Eval(const lf::mesh::Entity& cell) override;
349
350 [[nodiscard]] size_type TrialComponent() const override {
351 return trial_component_;
352 }
353
354 [[nodiscard]] size_type TestComponent() const override {
355 return test_component_;
356 }
357
358 ~ReactionElementMatrixProvider() override = default;
359
360 private:
362 REACTION_COEFF gamma_;
363
367 std::array<lf::uscalfe::PrecomputedScalarReferenceFiniteElement<SCALAR>, 5>
372 std::array<lf::uscalfe::PrecomputedScalarReferenceFiniteElement<SCALAR>, 5>
374
377
380};
381
382// template deduction hint
383template <class PTR, class REACTION_COEFF>
384ReactionElementMatrixProvider(PTR fe_trial, PTR fe_test,
385 size_type trial_component,
386 size_type test_component, REACTION_COEFF gamma)
387 -> ReactionElementMatrixProvider<typename PTR::element_type::SCALAR,
388 REACTION_COEFF>;
389
390// Constructor. internal construction of quadrature rules.
391template <typename SCALAR, typename REACTION_COEFF>
394 std::shared_ptr<ProductUniformFESpace<SCALAR>> fe_space_trial,
395 std::shared_ptr<ProductUniformFESpace<SCALAR>> fe_space_test,
396 size_type trial_component, size_type test_component,
397 REACTION_COEFF gamma)
398 : gamma_(std::move(gamma)),
399 trial_component_(trial_component),
400 test_component_(test_component),
401 fe_precomp_trial_(),
402 fe_precomp_test_() {
403 for (auto ref_el : {lf::base::RefEl::kTria(), lf::base::RefEl::kQuad()}) {
404 // obtain descriptions of local shape functions.
405 auto fe_trial =
406 fe_space_trial->ShapeFunctionLayout(ref_el, trial_component_);
407 auto fe_test = fe_space_test->ShapeFunctionLayout(ref_el, test_component_);
408
409 // check, that shape functions for both the trial and test space component
410 // for that entity are available.
411 // Note that the corresponding PrecomputedScalarReferenceFiniteElement local
412 // object is not initialized if the associated description of local shape
413 // functions is missing.
414 if (fe_trial != nullptr && fe_test != nullptr) {
415 // use a quadrature rule whose degree is the sum of the degrees of the fe
416 // spaces.
417 size_type degree = fe_trial->Degree() + fe_test->Degree();
418 lf::quad::QuadRule qr = lf::quad::make_QuadRule(ref_el, degree);
419 // Precompute cell-independent quantities.
420 fe_precomp_trial_[ref_el.Id()] =
422 fe_precomp_test_[ref_el.Id()] =
424 }
425 }
426}
427
428template <typename SCALAR, typename REACTION_COEFF>
431 const lf::mesh::Entity& cell) {
432 // Obtain precomputed information about values of local shape functions
433 // and their gradients at quadrature points.
435 fe_precomp_trial_[cell.RefEl().Id()];
437 fe_precomp_test_[cell.RefEl().Id()];
438
439 // check initialization:
440 LF_ASSERT_MSG(pfe_trial.isInitialized(),
441 "No local shape function on trial space for entity type "
442 << cell.RefEl());
443 LF_ASSERT_MSG(
444 pfe_test.isInitialized(),
445 "No local shape function on test space for entity type " << cell.RefEl());
446 // check the consistency of the quadratrue rules used.
447 LF_ASSERT_MSG(pfe_trial.Qr().Points() == pfe_test.Qr().Points() &&
448 pfe_trial.Qr().Weights() == pfe_test.Qr().Weights() &&
449 pfe_trial.Qr().NumPoints() == pfe_test.Qr().NumPoints(),
450 "Qr missmatch");
451
452 // query the geometry of the cell.
453 const lf::geometry::Geometry* geo_ptr = cell.Geometry();
454 LF_ASSERT_MSG(geo_ptr != nullptr, "Invalid geometry");
455 LF_ASSERT_MSG(geo_ptr->DimLocal() == 2, "Only 2D implementation available");
456
457 // const lf::uscalfe::dim_t world_dim = geo_ptr->DimGlobal();
458
459 // retrive information for parametric fem computation:
460 const Eigen::VectorXd determinants(
461 geo_ptr->IntegrationElement(pfe_trial.Qr().Points()));
462 LF_ASSERT_MSG(determinants.size() == pfe_trial.Qr().NumPoints(),
463 "Mismatch " << determinants.size() << " <-> "
464 << pfe_trial.Qr().NumPoints());
465
466 // evaluate gamm in the quadrature points.
467 auto gammaeval = gamma_(cell, pfe_trial.Qr().Points());
468
469 // initialize element matrix.
470 elem_mat_t mat(pfe_test.NumRefShapeFunctions(),
471 pfe_trial.NumRefShapeFunctions());
472 mat.setZero();
473
474 for (size_type k = 0; k < pfe_trial.Qr().NumPoints(); ++k) {
475 // transformed quadratrue weight.
476 const double w = pfe_trial.Qr().Weights()[k] * determinants[k];
477 // update element matrix.
478 mat += w * pfe_test.PrecompReferenceShapeFunctions().col(k) * gammaeval[k] *
479 pfe_trial.PrecompReferenceShapeFunctions().col(k).transpose();
480 }
481
482 return mat;
483}
484
529template <typename SCALAR, typename CONVECTION_COEFF_1,
530 typename CONVECTION_COEFF_2>
532 : public SubElementMatrixProvider<SCALAR> {
533 static_assert(lf::mesh::utils::isMeshFunction<CONVECTION_COEFF_1>);
534 static_assert(lf::mesh::utils::isMeshFunction<CONVECTION_COEFF_2>);
535
536 public:
540
542 delete;
544 default;
546 const ConvectionElementMatrixProvider&) = delete;
549
566 std::shared_ptr<ProductUniformFESpace<SCALAR>> fe_space_trial,
567 std::shared_ptr<ProductUniformFESpace<SCALAR>> fe_space_test,
568 size_type trial_component, size_type test_component,
569 CONVECTION_COEFF_1 beta_1, CONVECTION_COEFF_2 beta_2);
570
580 ElemMat Eval(const lf::mesh::Entity& cell) override;
581
582 [[nodiscard]] size_type TrialComponent() const override {
583 return trial_component_;
584 }
585
586 [[nodiscard]] size_type TestComponent() const override {
587 return test_component_;
588 }
589
591
592 private:
594 CONVECTION_COEFF_1 beta_1_;
596 CONVECTION_COEFF_2 beta_2_;
597
601 std::array<lf::uscalfe::PrecomputedScalarReferenceFiniteElement<SCALAR>, 5>
606 std::array<lf::uscalfe::PrecomputedScalarReferenceFiniteElement<SCALAR>, 5>
608
613};
614
615// template deduction hint.
616template <class PTR, typename CONVECTION_COEFF_1, typename CONVECTION_COEFF_2>
617ConvectionElementMatrixProvider(PTR fe_trial, PTR fe_test,
618 size_type trial_component,
619 size_type test_component,
620 CONVECTION_COEFF_1 beta_1,
621 CONVECTION_COEFF_2 beta_2)
622 -> ConvectionElementMatrixProvider<typename PTR::element_type::SCALAR,
623 CONVECTION_COEFF_1, CONVECTION_COEFF_2>;
624
625// Constructor. internal construction of quadrature rules.
626template <typename SCALAR, typename CONVECTION_COEFF_1,
627 typename CONVECTION_COEFF_2>
628ConvectionElementMatrixProvider<SCALAR, CONVECTION_COEFF_1,
629 CONVECTION_COEFF_2>::
631 std::shared_ptr<ProductUniformFESpace<SCALAR>> fe_space_trial,
632 std::shared_ptr<ProductUniformFESpace<SCALAR>> fe_space_test,
633 size_type trial_component, size_type test_component,
634 CONVECTION_COEFF_1 beta_1, CONVECTION_COEFF_2 beta_2)
635 : beta_1_(std::move(beta_1)),
636 beta_2_(std::move(beta_2)),
637 trial_component_(trial_component),
638 test_component_(test_component),
639 fe_precomp_trial_(),
640 fe_precomp_test_() {
641 for (auto ref_el : {lf::base::RefEl::kTria(), lf::base::RefEl::kQuad()}) {
642 // obtain descriptions of local shape functions.
643 auto fe_trial =
644 fe_space_trial->ShapeFunctionLayout(ref_el, trial_component_);
645 auto fe_test = fe_space_test->ShapeFunctionLayout(ref_el, test_component_);
646
647 // check, that shape functions for both the trial and test space component
648 // for that entity are available.
649 // Note that the corresponding PrecomputedScalarReferenceFiniteElement local
650 // object is not initialized if the associated description of local shape
651 // functions is missing.
652 if (fe_trial != nullptr && fe_test != nullptr) {
653 // use a quadrature rule whose degree is the sum of the degrees of the fe
654 // spaces.
655 size_type degree = fe_trial->Degree() + fe_test->Degree();
656 lf::quad::QuadRule qr = lf::quad::make_QuadRule(ref_el, degree);
657 // Precompute cell-independent quantities.
658 fe_precomp_trial_[ref_el.Id()] =
660 fe_precomp_test_[ref_el.Id()] =
662 }
663 }
664}
665
666template <typename SCALAR, typename CONVECTION_COEFF_1,
667 typename CONVECTION_COEFF_2>
668typename ConvectionElementMatrixProvider<SCALAR, CONVECTION_COEFF_1,
669 CONVECTION_COEFF_2>::ElemMat
671 SCALAR, CONVECTION_COEFF_1,
672 CONVECTION_COEFF_2>::Eval(const lf::mesh::Entity& cell) {
673 // Obtain precomputed information about values of local shape functions
674 // and their gradients at quadrature points.
676 fe_precomp_trial_[cell.RefEl().Id()];
678 fe_precomp_test_[cell.RefEl().Id()];
679
680 // check initialization:
681 LF_ASSERT_MSG(pfe_trial.isInitialized(),
682 "No local shape function on trial space for entity type "
683 << cell.RefEl());
684 LF_ASSERT_MSG(
685 pfe_test.isInitialized(),
686 "No local shape function on test space for entity type " << cell.RefEl());
687 // check the consistency of the quadratrue rules used.
688 LF_ASSERT_MSG(pfe_trial.Qr().Points() == pfe_test.Qr().Points() &&
689 pfe_trial.Qr().Weights() == pfe_test.Qr().Weights() &&
690 pfe_trial.Qr().NumPoints() == pfe_test.Qr().NumPoints(),
691 "Qr missmatch");
692
693 // query the geometry of the cell.
694 const lf::geometry::Geometry* geo_ptr = cell.Geometry();
695 LF_ASSERT_MSG(geo_ptr != nullptr, "Invalid geometry");
696 LF_ASSERT_MSG(geo_ptr->DimLocal() == 2, "Only 2D implementation available");
697
698 // phsical dimension of the cell.
699 const lf::uscalfe::dim_t world_dim = geo_ptr->DimGlobal();
700
701 // retrive information for parametric fem computation:
702 const Eigen::VectorXd determinants(
703 geo_ptr->IntegrationElement(pfe_trial.Qr().Points()));
704 LF_ASSERT_MSG(determinants.size() == pfe_trial.Qr().NumPoints(),
705 "Mismatch " << determinants.size() << " <-> "
706 << pfe_trial.Qr().NumPoints());
707
708 const Eigen::MatrixXd JinvT(
709 geo_ptr->JacobianInverseGramian(pfe_trial.Qr().Points()));
710 LF_ASSERT_MSG(
711 JinvT.cols() == 2 * pfe_trial.Qr().NumPoints() &&
712 JinvT.rows() == world_dim,
713 "Mismatch " << JinvT.cols() << " <-> " << 2 * pfe_trial.Qr().NumPoints());
714
715 // evaluate coefficients in the quadrature points
716 auto beta_1_eval = beta_1_(cell, pfe_trial.Qr().Points());
717 auto beta_2_eval = beta_2_(cell, pfe_trial.Qr().Points());
718
719 // initialize element matrix
720 elem_mat_t mat(pfe_test.NumRefShapeFunctions(),
721 pfe_trial.NumRefShapeFunctions());
722 mat.setZero();
723
724 // loop over quadrature points:
725 for (size_type k = 0; k < pfe_trial.Qr().NumPoints(); ++k) {
726 // transformed quadrature wiehgt.
727 const double w = pfe_trial.Qr().Weights()[k] * determinants[k];
728
729 // transformed gradients.
730 const auto trf_trial_grad(
731 JinvT.block(0, 2 * k, world_dim, 2) *
733 .block(0, 2 * k, mat.cols(), 2)
734 .transpose());
735 const auto trf_test_grad(JinvT.block(0, 2 * k, world_dim, 2) *
737 .block(0, 2 * k, mat.rows(), 2)
738 .transpose());
739 // evaluated local shape function.
740 const auto trf_trial_eval(
741 pfe_trial.PrecompReferenceShapeFunctions().col(k));
742 const auto trf_test_eval(pfe_test.PrecompReferenceShapeFunctions().col(k));
743
744 // update element matrix.
745 const auto beta_trf_test_grad = beta_1_eval[k].transpose() * trf_test_grad;
746 const auto beta_trf_trial_grad =
747 beta_2_eval[k].transpose() * trf_trial_grad;
748 mat += w * (beta_trf_test_grad.transpose() * trf_trial_eval.transpose() +
749 trf_test_eval * beta_trf_trial_grad);
750 }
751 return mat;
752}
753
788template <typename SCALAR, typename DIFF_COEFF>
790 static_assert(lf::mesh::utils::isMeshFunction<DIFF_COEFF>);
791
792 public:
796
800 delete;
802
821 std::shared_ptr<ProductUniformFESpace<SCALAR>> fe_space_trial,
822 std::shared_ptr<ProductUniformFESpace<SCALAR>> fe_space_test,
823 size_type trial_component, size_type test_component, DIFF_COEFF alpha);
824
836 ElemMat Eval(const lf::mesh::Entity& cell) override;
837
838 [[nodiscard]] size_type TrialComponent() const override {
839 return trial_component_;
840 }
841
842 [[nodiscard]] size_type TestComponent() const override {
843 return test_component_;
844 }
845
846 ~FluxElementMatrixProvider() override = default;
847
848 private:
850 DIFF_COEFF alpha_;
858 std::array<lf::uscalfe::PrecomputedScalarReferenceFiniteElement<SCALAR>, 5>
865 std::array<
866 std::vector<lf::uscalfe::PrecomputedScalarReferenceFiniteElement<SCALAR>>,
867 5>
869
876};
877
878// template deduction hint.
879template <class PTR, class DIFF_COEFF>
880FluxElementMatrixProvider(PTR fe_space_trial, PTR fe_space_test,
881 size_type trial_component, size_type test_component,
882 DIFF_COEFF alpha)
883 -> FluxElementMatrixProvider<typename PTR::element_type::SCALAR,
884 DIFF_COEFF>;
885
886// constructor internal construction of quadrature rules.
887template <typename SCALAR, typename DIFF_COEFF>
889 std::shared_ptr<ProductUniformFESpace<SCALAR>> fe_space_trial,
890 std::shared_ptr<ProductUniformFESpace<SCALAR>> fe_space_test,
891 size_type trial_component, size_type test_component, DIFF_COEFF alpha)
892 : alpha_(std::move(alpha)),
893 trial_component_(trial_component),
894 test_component_(test_component),
895 sign_provider_(fe_space_trial->Mesh()),
896 fe_precomp_test_(),
897 fe_precomp_trial_() {
898 // obtain description of the shape functions representing the flux.
899 auto fe_trial = fe_space_trial->ShapeFunctionLayout(
901 LF_ASSERT_MSG(fe_trial != nullptr, "Missing description of flux space");
902 LF_ASSERT_MSG(fe_trial->NumRefShapeFunctions(1) == 0,
903 "shape functions associated with endpoints not supported.");
904 for (auto ref_el : {lf::base::RefEl::kTria(), lf::base::RefEl::kQuad()}) {
905 // obtain description of the local shape functions in the test space.
906 auto fe_test = fe_space_test->ShapeFunctionLayout(ref_el, test_component_);
907
908 // check, that shape functions of test space component for
909 // that entity are available.
910 // Note that the corresponding PrecomputedScalarReferenceFiniteElement local
911 // object is not initialized if the associated description of local shape
912 // functions is missing.
913 if (fe_test != nullptr) {
914 // use a quadrature rule whose degree is the sum of the degrees of the fe
915 // spaces.
916 int degree = fe_trial->Degree() + fe_test->Degree();
917 lf::quad::QuadRule segment_qr =
919
920 // precompute cell-independent quantities for the flux
921 fe_precomp_trial_[ref_el.Id()] =
923 segment_qr);
924
925 // transform quadrule to all parts of the boundary.
926 std::vector<lf::quad::QuadRule> boundaryQr =
927 BoundaryQuadRule(ref_el, segment_qr);
928 int numSegments = ref_el.NumSubEntities(1);
929 LF_ASSERT_MSG(boundaryQr.size() == numSegments,
930 "boundaryQr.size() = " << boundaryQr.size() << " <-> "
931 << "numSegments= " << numSegments);
932 fe_precomp_test_[ref_el.Id()].resize(numSegments);
933
934 for (int segment = 0; segment < numSegments; segment++) {
935 // On each edge of the boundary, compute cell-independent quantities for
936 // the test soace,
937 fe_precomp_test_[ref_el.Id()][segment] =
939 fe_test, boundaryQr[segment]);
940 }
941 }
942 }
943}
944
945template <typename SCALAR, typename DIFF_COEFF>
948 const lf::mesh::Entity& cell) {
949 // ibtain precomputed information
950 auto& pfe_trial = fe_precomp_trial_[cell.RefEl().Id()];
951 auto& pfes_test = fe_precomp_test_[cell.RefEl().Id()];
952 // the number of edges of the cell boundary
953 int numSegments = cell.RefEl().NumSubEntities(1);
954
955 // check initialization:
956 LF_ASSERT_MSG(pfes_test.size() == numSegments,
957 "Missing local shape functions for test space on ref_el "
958 << cell.RefEl());
959 LF_ASSERT_MSG(pfe_trial.isInitialized(),
960 "missing local shape functions for trial space on ref_el"
961 << cell.RefEl());
962 for (int i = 0; i < numSegments; ++i) {
963 LF_ASSERT_MSG(pfes_test[i].isInitialized(),
964 "missing local shape functions for test space on ref_el "
965 << cell.RefEl());
966 LF_ASSERT_MSG(pfes_test[i].Qr().NumPoints() == pfe_trial.Qr().NumPoints(),
967 "qr missmatch between trial and test space.");
968 }
969
970 // query the geometry of the cell.
971 const lf::geometry::Geometry* geo_ptr = cell.Geometry();
972 LF_ASSERT_MSG(geo_ptr != nullptr, "Invalid geometry");
973 LF_ASSERT_MSG(geo_ptr->DimLocal() == 2, "Only 2D implementation available");
974
975 // initialize element matrix
976 elem_mat_t mat(pfes_test[0].NumRefShapeFunctions(),
977 pfe_trial.NumRefShapeFunctions() * numSegments);
978 mat.setZero();
979
980 // integrate over all parts of the boundary,
981 for (int segment = 0; segment < numSegments; segment++) {
982 // query the geometry of the segment.
983 const auto segment_geo_ptr = geo_ptr->SubGeometry(1, segment);
984 LF_ASSERT_MSG(segment_geo_ptr != nullptr, "Invalid geometry");
985
986 // retrive determinants for paramteric fem
987 const Eigen::VectorXd determinants =
988 segment_geo_ptr->IntegrationElement(pfe_trial.Qr().Points());
989 LF_ASSERT_MSG(determinants.size() == pfe_trial.Qr().NumPoints(),
990 "Mismatch " << determinants.size() << " <-> "
991 << pfe_trial.Qr().NumPoints());
992
993 // evaluate coefficient- and sign function.
994 auto alphaeval = alpha_(cell, pfes_test[segment].Qr().Points());
995 int sgn =
996 sign_provider_.PrescribedSign(cell, *cell.SubEntities(1)[segment]);
997
998 // iterate over quadrature points.
999 for (size_type k = 0; k < pfe_trial.Qr().NumPoints(); ++k) {
1000 // transformed quadrature weight
1001 const double w = pfe_trial.Qr().Weights()[k] * determinants[k] * sgn;
1002 const auto trial_eval = pfe_trial.PrecompReferenceShapeFunctions().col(k);
1003 const auto test_eval =
1004 pfes_test[segment].PrecompReferenceShapeFunctions().col(k);
1005
1006 // use the assumptions about the local shape function layout of the flux
1007 // component and the rules for ordering local shape functions, to update
1008 // correct part of the element matrix.
1009 mat.block(0, segment * pfe_trial.NumRefShapeFunctions(),
1010 pfes_test[segment].NumRefShapeFunctions(),
1011 pfe_trial.NumRefShapeFunctions()) +=
1012 alphaeval[k] * w * test_eval * trial_eval.transpose();
1013 }
1014 }
1015 return mat;
1016}
1017
1052template <typename SCALAR, typename COEFF>
1054 static_assert(lf::mesh::utils::isMeshFunction<COEFF>);
1055
1056 public:
1060
1064 delete;
1066
1082 std::shared_ptr<ProductUniformFESpace<SCALAR>> fe_space_trial,
1083 std::shared_ptr<ProductUniformFESpace<SCALAR>> fe_space_test,
1084 size_type trial_component, size_type test_component, COEFF beta);
1096 ElemMat Eval(const lf::mesh::Entity& cell) override;
1097
1098 [[nodiscard]] size_type TrialComponent() const override {
1099 return trial_component_;
1100 }
1101
1102 [[nodiscard]] size_type TestComponent() const override {
1103 return test_component_;
1104 }
1105
1106 ~TraceElementMatrixProvider() override = default;
1107
1108 private:
1110 COEFF beta_;
1111
1117 std::array<
1118 std::vector<lf::uscalfe::PrecomputedScalarReferenceFiniteElement<SCALAR>>,
1119 5>
1126 std::array<
1127 std::vector<lf::uscalfe::PrecomputedScalarReferenceFiniteElement<SCALAR>>,
1128 5>
1130
1133 std::array<lf::quad::QuadRule, 5> segment_qr_;
1134
1139};
1140
1141// template deduction hint.
1142template <class PTR, class COEFF>
1143TraceElementMatrixProvider(PTR fe_space_trial, PTR fe_space_test,
1144 size_type trial_component, size_type test_component,
1145 COEFF alpha)
1147
1148// Constructor. internal construction of quadrature rules.
1149template <typename SCALAR, typename COEFF>
1151 std::shared_ptr<ProductUniformFESpace<SCALAR>> fe_space_trial,
1152 std::shared_ptr<ProductUniformFESpace<SCALAR>> fe_space_test,
1153 size_type trial_component, size_type test_component, COEFF beta)
1154 : beta_(std::move(beta)),
1155 trial_component_(trial_component),
1156 test_component_(test_component),
1157 fe_precomp_test_(),
1158 fe_precomp_trial_() {
1159 for (auto ref_el : {lf::base::RefEl::kTria(), lf::base::RefEl::kQuad()}) {
1160 // obtain descriptions of local shape functions.
1161 auto fe_trial =
1162 fe_space_trial->ShapeFunctionLayout(ref_el, trial_component_);
1163 auto fe_test = fe_space_test->ShapeFunctionLayout(ref_el, test_component_);
1164
1165 // check, that shape functions for both the trial and test space component
1166 // for that entity are available.
1167 // Note that the corresponding PrecomputedScalarReferenceFiniteElement local
1168 // object is not initialized if the associated description of local shape
1169 // functions is missing.
1170 if (fe_trial != nullptr && fe_test != nullptr) {
1171 // use a quadrature rule whose degree is the sum of the degrees of the fe
1172 // spaces.
1173 size_type degree = fe_trial->Degree() + fe_test->Degree();
1174 // initialize a quadrule of a the given degree on the reference line
1175 // segment.
1176 lf::quad::QuadRule segment_qr =
1178 segment_qr_[ref_el.Id()] = segment_qr;
1179
1180 // transform it to all parts of the boundary.
1181 std::vector<lf::quad::QuadRule> boundary_qr =
1182 BoundaryQuadRule(ref_el, segment_qr);
1183 int num_segments = ref_el.NumSubEntities(1);
1184 LF_ASSERT_MSG(
1185 boundary_qr.size() == num_segments,
1186 "boundary_qr.size() = " << boundary_qr.size() << "<->"
1187 << "num_segments = " << num_segments);
1188
1189 fe_precomp_trial_[ref_el.Id()].resize(num_segments);
1190 fe_precomp_test_[ref_el.Id()].resize(num_segments);
1191
1192 for (int segment = 0; segment < num_segments; segment++) {
1193 // on each edge of the boundary precompute cell-independent quantities.
1194 fe_precomp_trial_[ref_el.Id()][segment] =
1196 fe_trial, boundary_qr[segment]);
1197 fe_precomp_test_[ref_el.Id()][segment] =
1199 fe_test, boundary_qr[segment]);
1200 }
1201 }
1202 }
1203}
1204
1205template <typename SCALAR, typename COEFF>
1208 // obtain precomputed about values of local shape functions
1209 // and their gradients at quadrature points on all parts of the boundary.
1210 auto& pfes_trial = fe_precomp_trial_[cell.RefEl().Id()];
1211 auto& pfes_test = fe_precomp_test_[cell.RefEl().Id()];
1212
1213 // retrive the original quadrule on the segment, used only for the weights.
1214 auto& segment_qr = segment_qr_[cell.RefEl().Id()];
1215
1216 // the number of edges of the cell boundary.
1217 size_type num_segments = cell.RefEl().NumSubEntities(1);
1218
1219 // check initialization:
1220 LF_ASSERT_MSG(pfes_trial.size() == num_segments,
1221 "Missing local shape functions on trial space for ref_el"
1222 << cell.RefEl());
1223 LF_ASSERT_MSG(
1224 pfes_test.size() == num_segments,
1225 "Missing local shape functions on test space for ref_el" << cell.RefEl());
1226
1227 // check consistency of quadrqture rules between fe spaces.
1228 for (size_type segment = 0; segment < num_segments; segment++) {
1229 LF_ASSERT_MSG(pfes_trial[segment].isInitialized(),
1230 "missing local shape functions on trial space for ref_el"
1231 << cell.RefEl());
1232 LF_ASSERT_MSG(pfes_test[segment].isInitialized(),
1233 "missing local shape functions on trial space for ref_el"
1234 << cell.RefEl());
1235 LF_ASSERT_MSG(
1236 pfes_trial[segment].Qr().Points() == pfes_test[segment].Qr().Points() &&
1237 pfes_trial[segment].Qr().Weights() ==
1238 pfes_test[segment].Qr().Weights() &&
1239 pfes_trial[segment].Qr().NumPoints() ==
1240 pfes_test[segment].Qr().NumPoints(),
1241 "Qr missmatch");
1242 }
1243
1244 // check consistency with semgment quad rule:
1245 LF_ASSERT_MSG(segment_qr.NumPoints() == pfes_trial[0].Qr().NumPoints(),
1246 "QR missmatch");
1247
1248 // query the geometry of the cell.
1249 const lf::geometry::Geometry* geo_ptr = cell.Geometry();
1250 LF_ASSERT_MSG(geo_ptr != nullptr, "Invalid geometry");
1251 LF_ASSERT_MSG(geo_ptr->DimLocal() == 2, "Only 2D implementation available");
1252
1253 // initialize element matrix:
1254 elem_mat_t mat(pfes_test[0].NumRefShapeFunctions(),
1255 pfes_trial[0].NumRefShapeFunctions());
1256 mat.setZero();
1257
1258 // retrive normals on all edges of the cell
1259 Eigen::MatrixXd normals = OuterNormals(*geo_ptr);
1260 LF_ASSERT_MSG(normals.cols() == num_segments,
1261 "normals.cols()= " << normals.cols() << "<->"
1262 << "num_segments= " << num_segments);
1263
1264 // sum up by integrating over all parts of the boundary.
1265 for (size_type segment = 0; segment < num_segments; segment++) {
1266 // query the geometry of the segment
1267 const auto segment_ptr = geo_ptr->SubGeometry(1, segment);
1268 LF_ASSERT_MSG(segment_ptr != nullptr, "Invalid geometry");
1269
1270 // retrive precomputed information on current edge.
1271 auto& pfe_trial = pfes_trial[segment];
1272 auto& pfe_test = pfes_test[segment];
1273
1274 // retrive determinants for paramteric fem.
1275 const Eigen::VectorXd determinants(
1276 segment_ptr->IntegrationElement(segment_qr.Points()));
1277 LF_ASSERT_MSG(determinants.size() == pfe_trial.Qr().NumPoints(),
1278 "Mismatch " << determinants.size() << " <-> "
1279 << segment_qr.NumPoints());
1280
1281 // evaluate coefficient function
1282 auto betaeval = beta_(cell, pfe_trial.Qr().Points());
1283
1284 // iterate over quadrule points on current edge of the boundary.
1285 for (size_type k = 0; k < pfe_trial.Qr().NumPoints(); ++k) {
1286 // transformed quadrature weight
1287 const double w = segment_qr.Weights()[k] * determinants[k];
1288
1289 const auto trial_eval = pfe_trial.PrecompReferenceShapeFunctions().col(k);
1290 const auto test_eval = pfe_test.PrecompReferenceShapeFunctions().col(k);
1291 const auto beta_dot_n = normals.col(segment).transpose() * betaeval[k];
1292
1293 // update element matrix.
1294 mat += w * test_eval * trial_eval.transpose() * beta_dot_n;
1295 }
1296 }
1297 return mat;
1298}
1299
1329template <typename SCALAR, typename FUNCTOR>
1331 static_assert(lf::mesh::utils::isMeshFunction<FUNCTOR>);
1332
1333 public:
1337
1341 delete;
1343
1354 std::shared_ptr<ProductUniformFESpace<SCALAR>> fe_space_test,
1355 size_type test_component, FUNCTOR f);
1356
1364 ElemVec Eval(const lf::mesh::Entity& cell) override;
1365
1366 [[nodiscard]] size_type TestComponent() const override {
1367 return test_component_;
1368 }
1369
1370 ~LoadElementVectorProvider() override = default;
1371
1372 private:
1374 FUNCTOR f_;
1378 std::array<lf::uscalfe::PrecomputedScalarReferenceFiniteElement<SCALAR>, 5>
1380
1383};
1384
1385// template deduction hint
1386template <class PTR, class FUNCTOR>
1387LoadElementVectorProvider(PTR fe_space_test, size_type test_component,
1388 FUNCTOR f)
1390
1391// constructor: internal construction of quadrature rules.
1392template <typename SCALAR, typename FUNCTOR>
1394 std::shared_ptr<ProductUniformFESpace<SCALAR>> fe_space_test,
1395 size_type test_component, FUNCTOR f)
1396 : f_(std::move(f)), test_component_(test_component), fe_precomp_test_() {
1397 for (auto ref_el : {lf::base::RefEl::kTria(), lf::base::RefEl::kQuad()}) {
1398 // obtain description of local shape function
1399 auto fe_test = fe_space_test->ShapeFunctionLayout(ref_el, test_component_);
1400 // check, that shape functions for this component are available
1401 // Note that the corresponding PrecomputedScalarReferenceFiniteElement local
1402 // object is not initialized if the associated description of local shape
1403 // functions is missing.
1404 if (fe_test != nullptr) {
1405 // Precompute cell-independent quantities based on quadrature rules
1406 // with twice the degree of exactness compared to the degree of the
1407 // finite element space.
1408 fe_precomp_test_[ref_el.Id()] =
1410 fe_test, lf::quad::make_QuadRule(ref_el, 2 * fe_test->Degree()));
1411 }
1412 }
1413}
1414
1415template <typename SCALAR, typename FUNCTOR>
1418 // Obtain precomputed information about values of local shape functions and
1419 // their gradients at quadrature points.
1420 auto& pfe_test = fe_precomp_test_[cell.RefEl().Id()];
1421
1422 // check initilization:
1423 LF_ASSERT_MSG(pfe_test.isInitialized(),
1424 "missing local shape function on ref_el " << cell.RefEl());
1425
1426 // querry geometry
1427 const lf::geometry::Geometry* geo_ptr = cell.Geometry();
1428 LF_ASSERT_MSG(geo_ptr != nullptr, "Invalid geometry");
1429 LF_ASSERT_MSG(geo_ptr->DimLocal() == 2, "Only 2D implementation available");
1430
1431 // retrive information for parametric fem computation
1432 const Eigen::VectorXd determinants(
1433 geo_ptr->IntegrationElement(pfe_test.Qr().Points()));
1434 LF_ASSERT_MSG(determinants.size() == pfe_test.Qr().NumPoints(),
1435 "Mismatch " << determinants.size() << " <-> "
1436 << pfe_test.Qr().NumPoints());
1437
1438 // evaluate f at the quadrature points
1439 auto fval = f_(cell, pfe_test.Qr().Points());
1440
1441 // initialize the element vector
1442 elem_vec_t vec(pfe_test.NumRefShapeFunctions());
1443 vec.setZero();
1444
1445 // loop over quadrature points:
1446 for (size_type k = 0; k < pfe_test.Qr().NumPoints(); ++k) {
1447 // transformed quadrature weight
1448 const double w = pfe_test.Qr().Weights()[k] * determinants[k];
1449 vec += fval[k] * w * pfe_test.PrecompReferenceShapeFunctions().col(k);
1450 }
1451
1452 return vec;
1453}
1454
1455} // namespace projects::dpg
1456#endif // PROJECTS_DPG_LOC_COMP_DPG
static constexpr RefEl kSegment()
Returns the (1-dimensional) reference segment.
Definition: ref_el.h:150
constexpr unsigned int Id() const
Return a unique id for this reference element.
Definition: ref_el.h:491
constexpr size_type NumSubEntities(dim_t sub_codim) const
Get the number of sub-entities of this RefEl with the given codimension.
Definition: ref_el.h:305
static constexpr RefEl kTria()
Returns the reference triangle.
Definition: ref_el.h:158
static constexpr RefEl kQuad()
Returns the reference quadrilateral.
Definition: ref_el.h:166
Interface class for shape information on a mesh cell in the spirit of parametric finite element metho...
virtual dim_t DimLocal() const =0
Dimension of the domain of this mapping.
virtual dim_t DimGlobal() const =0
Dimension of the image of this mapping.
virtual Eigen::MatrixXd JacobianInverseGramian(const Eigen::MatrixXd &local) const =0
Evaluate the Jacobian * Inverse Gramian ( ) simultaneously at numPoints.
virtual Eigen::VectorXd IntegrationElement(const Eigen::MatrixXd &local) const =0
The integration element (factor appearing in integral transformation formula, see below) at number of...
virtual std::unique_ptr< Geometry > SubGeometry(dim_t codim, dim_t i) const =0
Construct a new Geometry() object that describes the geometry of the i-th sub-entity with codimension...
Interface class representing a topological entity in a cellular complex
Definition: entity.h:39
virtual const geometry::Geometry * Geometry() const =0
Describes the geometry of this entity.
virtual nonstd::span< const Entity *const > SubEntities(unsigned rel_codim) const =0
Return all sub entities of this entity that have the given codimension (w.r.t. this entity!...
virtual base::RefEl RefEl() const =0
Describes the reference element type of this entity.
Represents a Quadrature Rule over one of the Reference Elements.
Definition: quad_rule.h:58
const Eigen::VectorXd & Weights() const
All quadrature weights as a vector.
Definition: quad_rule.h:152
const Eigen::MatrixXd & Points() const
All quadrature points as column vectors.
Definition: quad_rule.h:145
base::size_type NumPoints() const
Return the total number of quadrature points (num of columns of points/weights)
Definition: quad_rule.h:158
Helper class which stores a ScalarReferenceFiniteElement with precomputed values at the nodes of a qu...
size_type NumRefShapeFunctions() const override
Total number of reference shape functions associated with the reference cell.
const Eigen::Matrix< SCALAR, Eigen::Dynamic, Eigen::Dynamic > & PrecompReferenceShapeFunctions() const
Value of EvalReferenceShapeFunctions(Qr().Points())
const quad::QuadRule & Qr() const
Return the Quadrature rule at which the shape functions (and their gradients) have been precomputed.
const Eigen::Matrix< SCALAR, Eigen::Dynamic, Eigen::Dynamic > & PrecompGradientsReferenceShapeFunctions() const
Value of EvalGradientsReferenceShapeFunctions(Qr().Points())
Class for local quadrature based computations sub element matrices corresponding to convection-like e...
Definition: loc_comp_dpg.h:532
CONVECTION_COEFF_2 beta_2_
functor providing the "second" convection coefficient
Definition: loc_comp_dpg.h:596
ConvectionElementMatrixProvider(const ConvectionElementMatrixProvider &)=delete
ElemMat Eval(const lf::mesh::Entity &cell) override
main routine for the computation of element matrices
Definition: loc_comp_dpg.h:672
typename SubElementMatrixProvider< SCALAR >::elem_mat_t elem_mat_t
inherited types for element matrices
Definition: loc_comp_dpg.h:538
size_type TestComponent() const override
returns the index of the test space component which is the test space for the bilinear form
Definition: loc_comp_dpg.h:586
size_type trial_component_
index of the involved trial component
Definition: loc_comp_dpg.h:610
size_type test_component_
index of the involved test component
Definition: loc_comp_dpg.h:612
std::array< lf::uscalfe::PrecomputedScalarReferenceFiniteElement< SCALAR >, 5 > fe_precomp_trial_
array containing the precomputed information for the trial space: fe_precomp_trial[i] contains the pr...
Definition: loc_comp_dpg.h:602
std::array< lf::uscalfe::PrecomputedScalarReferenceFiniteElement< SCALAR >, 5 > fe_precomp_test_
array containing the precomputed information for the test space: fe_precomp_trial[i] contains the pre...
Definition: loc_comp_dpg.h:607
typename SubElementMatrixProvider< SCALAR >::ElemMat ElemMat
Definition: loc_comp_dpg.h:539
size_type TrialComponent() const override
returns the index of the trial space component which is the trial space for the bilinear form
Definition: loc_comp_dpg.h:582
CONVECTION_COEFF_1 beta_1_
functor providing "first" convection coefficient
Definition: loc_comp_dpg.h:594
ConvectionElementMatrixProvider(ConvectionElementMatrixProvider &&) noexcept=default
Class for local quadrature based computations of sub element matrices corresponding to diffusion elem...
Definition: loc_comp_dpg.h:70
DiffusionElementMatrixProvider(DiffusionElementMatrixProvider &&) noexcept=default
typename SubElementMatrixProvider< SCALAR >::ElemMat ElemMat
Definition: loc_comp_dpg.h:76
size_type trial_component_
index of trial component u
Definition: loc_comp_dpg.h:144
std::array< lf::uscalfe::PrecomputedScalarReferenceFiniteElement< SCALAR >, 5 > fe_precomp_trial_
array containing the precomputed information for the trial space: fe_precomp_trial[i] contains the pr...
Definition: loc_comp_dpg.h:136
DIFF_COEFF alpha_
functor providing the diffusion coefficient
Definition: loc_comp_dpg.h:130
DiffusionElementMatrixProvider(const DiffusionElementMatrixProvider &)=delete
size_type TestComponent() const override
returns the index of the test space component which is the test space for the bilinear form
Definition: loc_comp_dpg.h:122
ElemMat Eval(const lf::mesh::Entity &cell) override
main routine for the computation of element matrices
Definition: loc_comp_dpg.h:196
std::array< lf::uscalfe::PrecomputedScalarReferenceFiniteElement< SCALAR >, 5 > fe_precomp_test_
array containing the precomputed information for the test space: fe_precomp_trial[i] contains the pre...
Definition: loc_comp_dpg.h:141
size_type test_component_
index of test component v
Definition: loc_comp_dpg.h:146
size_type TrialComponent() const override
returns the index of the trial space component which is the trial space for the bilinear form
Definition: loc_comp_dpg.h:118
typename SubElementMatrixProvider< SCALAR >::elem_mat_t elem_mat_t
inherited types for element matrices
Definition: loc_comp_dpg.h:75
class for local quadrature based computations of sub element matrices corresponding to element matric...
Definition: loc_comp_dpg.h:789
ElemMat Eval(const lf::mesh::Entity &cell) override
main routine for the computation of element matrices
Definition: loc_comp_dpg.h:947
std::array< lf::uscalfe::PrecomputedScalarReferenceFiniteElement< SCALAR >, 5 > fe_precomp_trial_
array containing the precomputed information for the trial space flux component: fe_precomp_trial[i] ...
Definition: loc_comp_dpg.h:859
typename SubElementMatrixProvider< SCALAR >::ElemMat ElemMat
Definition: loc_comp_dpg.h:795
size_type TestComponent() const override
returns the index of the test space component which is the test space for the bilinear form
Definition: loc_comp_dpg.h:842
typename SubElementMatrixProvider< SCALAR >::elem_mat_t elem_mat_t
inherited types for element matrices
Definition: loc_comp_dpg.h:794
size_type trial_component_
index of the trial component
Definition: loc_comp_dpg.h:871
FluxElementMatrixProvider(FluxElementMatrixProvider &&) noexcept=default
DIFF_COEFF alpha_
functor providing the coefficient invoved in the bilinear form
Definition: loc_comp_dpg.h:850
PrescribedSignProvider sign_provider_
helper class, to evaluate the sgn_K function
Definition: loc_comp_dpg.h:875
std::array< std::vector< lf::uscalfe::PrecomputedScalarReferenceFiniteElement< SCALAR > >, 5 > fe_precomp_test_
array containing the precomputed information for the trial space: fe_precomp_trial[i][j] contains the...
Definition: loc_comp_dpg.h:868
FluxElementMatrixProvider(const FluxElementMatrixProvider &)=delete
size_type TrialComponent() const override
returns the index of the trial space component which is the trial space for the bilinear form
Definition: loc_comp_dpg.h:838
size_type test_component_
index of test component v
Definition: loc_comp_dpg.h:873
Class for local quadrature based computations of sub vectors corresponding to load vectors.
typename SubElementVectorProvider< SCALAR >::elem_vec_t elem_vec_t
inherited types for element vectors
LoadElementVectorProvider(LoadElementVectorProvider &&) noexcept=default
size_type test_component_
index of test component v
LoadElementVectorProvider(const LoadElementVectorProvider &)=delete
FUNCTOR f_
functor providing the source function
ElemVec Eval(const lf::mesh::Entity &cell) override
main routine for the computation of element vectors
std::array< lf::uscalfe::PrecomputedScalarReferenceFiniteElement< SCALAR >, 5 > fe_precomp_test_
array containing precomputed information for the test space: fe_precomp_test_[i] contains the precomp...
size_type TestComponent() const override
returns the index of the test space component which is the test space for the linear form
typename SubElementVectorProvider< SCALAR >::ElemVec ElemVec
Class which allows evaluation of the function.
Definition: dpg_tools.h:81
cartesian/prodcut space of finite element functions on a hybrid 2D mesh.
Class for local quadrature based computations of sub element matrices corresponding to reaction eleme...
Definition: loc_comp_dpg.h:303
typename SubElementMatrixProvider< SCALAR >::elem_mat_t elem_mat_t
inherited types for element matrices
Definition: loc_comp_dpg.h:308
size_type test_component_
index of test component v
Definition: loc_comp_dpg.h:379
std::array< lf::uscalfe::PrecomputedScalarReferenceFiniteElement< SCALAR >, 5 > fe_precomp_trial_
array containing the precomputed information for the trial space: fe_precomp_trial[i] contains the pr...
Definition: loc_comp_dpg.h:368
typename SubElementMatrixProvider< SCALAR >::ElemMat ElemMat
Definition: loc_comp_dpg.h:309
size_type TestComponent() const override
returns the index of the test space component which is the test space for the bilinear form
Definition: loc_comp_dpg.h:354
std::array< lf::uscalfe::PrecomputedScalarReferenceFiniteElement< SCALAR >, 5 > fe_precomp_test_
array containing the precomputed information for the test space: fe_precomp_trial[i] contains the pre...
Definition: loc_comp_dpg.h:373
size_type trial_component_
index of trial component u
Definition: loc_comp_dpg.h:376
ReactionElementMatrixProvider(ReactionElementMatrixProvider &&) noexcept=default
ElemMat Eval(const lf::mesh::Entity &cell) override
main routine for the computation of element matrices
Definition: loc_comp_dpg.h:430
size_type TrialComponent() const override
returns the index of the trial space component which is the trial space for the bilinear form
Definition: loc_comp_dpg.h:350
REACTION_COEFF gamma_
functor providing reaction coefficient
Definition: loc_comp_dpg.h:362
ReactionElementMatrixProvider(const ReactionElementMatrixProvider &)=delete
Interface class providing sub element matrices associated with bilinear forms between components of C...
Eigen::Matrix< SCALAR, Eigen::Dynamic, Eigen::Dynamic > elem_mat_t
internal type for element matrices
Interface class providing element vectors associated with linear forms of a component of a cartesian/...
Eigen::Matrix< SCALAR, Eigen::Dynamic, 1 > elem_vec_t
internal type for element vectors
Class for local quadrature based computations of sub element matrices corresponding to element matric...
typename SubElementMatrixProvider< SCALAR >::ElemMat ElemMat
COEFF beta_
functor providing the coefficient invoved in the bilinear form
size_type test_component_
index of test component v
size_type TestComponent() const override
returns the index of the test space component which is the test space for the bilinear form
std::array< std::vector< lf::uscalfe::PrecomputedScalarReferenceFiniteElement< SCALAR > >, 5 > fe_precomp_test_
array containing the precomputed information for the test space: fe_precomp_trial[i][j] contains the ...
std::array< lf::quad::QuadRule, 5 > segment_qr_
the original segment quad rule used to construct the quadrules on ref_el boundaries....
typename SubElementMatrixProvider< SCALAR >::elem_mat_t elem_mat_t
inherited types for element matrices
TraceElementMatrixProvider(TraceElementMatrixProvider &&) noexcept=default
ElemMat Eval(const lf::mesh::Entity &cell) override
main routine for the computation of element matrices
std::array< std::vector< lf::uscalfe::PrecomputedScalarReferenceFiniteElement< SCALAR > >, 5 > fe_precomp_trial_
array containing the precomputed information for the trial space: fe_precomp_trial[i][j] contains the...
size_type TrialComponent() const override
returns the index of the trial space component which is the trial space for the bilinear form
TraceElementMatrixProvider(const TraceElementMatrixProvider &)=delete
size_type trial_component_
index of trial component
QuadRule make_QuadRule(base::RefEl ref_el, unsigned degree)
Returns a QuadRule object for the given Reference Element and Degree.
lf::assemble::dim_t dim_t
Definition: lagr_fe.h:32
std::map< lf::base::RefEl, lf::quad::QuadRule > quad_rule_collection_t
Auxiliary data structure for passing collections of quadrature rules.
Definition: assemble.h:30
Contains functionality for the implementation of DPG methods.
Definition: primal_dpg.h:33
std::vector< lf::quad::QuadRule > BoundaryQuadRule(lf::base::RefEl ref_el, const lf::quad::QuadRule &qr)
Constructs a quadrature rule on the boundary of a reference element.
Definition: dpg_tools.cc:13
FluxElementMatrixProvider(PTR fe_space_trial, PTR fe_space_test, size_type trial_component, size_type test_component, DIFF_COEFF alpha) -> FluxElementMatrixProvider< typename PTR::element_type::SCALAR, DIFF_COEFF >
lf::uscalfe::quad_rule_collection_t quad_rule_collection_t
data structure for passing collections of quadrature rules, see lf::uscalfe for more information.
Definition: loc_comp_dpg.h:31
DiffusionElementMatrixProvider(PTR fe_space_trial, PTR fe_space_test, size_type trial_component, size_type test_component, DIFF_COEFF alpha) -> DiffusionElementMatrixProvider< typename PTR::element_type::SCALAR, DIFF_COEFF >
ConvectionElementMatrixProvider(PTR fe_trial, PTR fe_test, size_type trial_component, size_type test_component, CONVECTION_COEFF_1 beta_1, CONVECTION_COEFF_2 beta_2) -> ConvectionElementMatrixProvider< typename PTR::element_type::SCALAR, CONVECTION_COEFF_1, CONVECTION_COEFF_2 >
LoadElementVectorProvider(PTR fe_space_test, size_type test_component, FUNCTOR f) -> LoadElementVectorProvider< typename PTR::element_type::SCALAR, FUNCTOR >
ReactionElementMatrixProvider(PTR fe_trial, PTR fe_test, size_type trial_component, size_type test_component, REACTION_COEFF gamma) -> ReactionElementMatrixProvider< typename PTR::element_type::SCALAR, REACTION_COEFF >
lf::uscalfe::size_type size_type
Type for vector length/matrix sizes.
Definition: dpg.h:17
Eigen::MatrixXd OuterNormals(const lf::geometry::Geometry &geometry)
Compute the outer normals of a geometry object.
Definition: dpg_tools.cc:49
TraceElementMatrixProvider(PTR fe_space_trial, PTR fe_space_test, size_type trial_component, size_type test_component, COEFF alpha) -> TraceElementMatrixProvider< typename PTR::element_type::SCALAR, COEFF >