FEAT 3
Finite Element Analysis Toolbox
Loading...
Searching...
No Matches
domain_assembler_basic_jobs.hpp
1// FEAT3: Finite Element Analysis Toolbox, Version 3
2// Copyright (C) 2010 by Stefan Turek & the FEAT group
3// FEAT3 is released under the GNU General Public License version 3,
4// see the file 'copyright.txt' in the top level directory for details.
5
6#pragma once
7
8#include <kernel/assembly/domain_assembler.hpp>
9#include <kernel/assembly/function_integral_info.hpp>
10#include <kernel/analytic/function.hpp>
11#include <kernel/lafem/dense_vector.hpp>
12#include <kernel/lafem/dense_vector_blocked.hpp>
13
14namespace FEAT
15{
16 namespace Assembly
17 {
43 template<typename Derived_, typename Vector_, typename Space_,
44 TrafoTags trafo_config_, SpaceTags space_config_>
46 {
47 public:
49 typedef typename Vector_::DataType DataType;
51 typedef typename Vector_::ValueType ValueType;
52
54 static constexpr bool need_scatter = true;
56 static constexpr bool need_combine = false;
57
58 protected:
62 Space_,
63 trafo_config_ | TrafoTags::jac_det,
64 space_config_
66
68 Vector_& vector;
70 const Space_& space;
72 const typename AsmTraits::TrafoType& trafo;
86 typename AsmTraits::template TLocalVector<ValueType> local_vector;
88 typename Vector_::ScatterAxpy scatter_axpy;
91
92 public:
108 explicit DomainAssemblyBasicVectorTaskCRTP(Vector_& vector_, const Space_& space_,
109 const Cubature::DynamicFactory& cubature_factory, DataType alpha_) :
110 vector(vector_),
111 space(space_),
112 trafo(space.get_trafo()),
116 cubature_rule(Cubature::ctor_factory, cubature_factory),
118 scatter_alpha(alpha_)
119 {
120 }
121
122#ifdef DOXYGEN
133
146 void eval(ValueType& val, const DataType& weight, const typename AsmTraits::SpaceBasisData& psi);
147#endif // DOXYGEN
148
155 void prepare(Index cell)
156 {
157 // prepare dof mapping
158 dof_mapping.prepare(cell);
159
160 // prepare trafo evaluator
161 trafo_eval.prepare(cell);
162
163 // prepare space evaluator
164 space_eval.prepare(trafo_eval);
165 }
166
170 void assemble()
171 {
172 // format local vector
173 local_vector.format();
174
175 // fetch number of local dofs
176 const int num_loc_dofs = space_eval.get_num_local_dofs();
177
178 // loop over all quadrature points and integrate
179 for(int k(0); k < cubature_rule.get_num_points(); ++k)
180 {
181 // compute trafo data
182 trafo_eval(trafo_data, cubature_rule.get_point(k));
183
184 // compute basis function data
186
187 // evaluate operator
188 static_cast<Derived_&>(*this).set_point(trafo_data);
189
190 // test function loop
191 for(int i(0); i < num_loc_dofs; ++i)
192 {
193 // evaluate functional and integrate
194 static_cast<Derived_&>(*this).eval(local_vector(i),
195 trafo_data.jac_det * cubature_rule.get_weight(k),
196 space_data.phi[i]);
197 // continue with next test function
198 }
199 // continue with next cubature point
200 }
201 }
202
206 void scatter()
207 {
209 }
210
214 void finish()
215 {
216 // finish evaluators
217 space_eval.finish();
218 trafo_eval.finish();
219
220 // finish dof mapping
221 dof_mapping.finish();
222 }
223
227 void combine()
228 {
229 // nothing to do here
230 }
231 }; // class DomainAssemblyBasicVectorTaskCRTP<...>
232
258 template<typename Derived_, typename Matrix_, typename Space_,
259 TrafoTags trafo_config_, SpaceTags space_config_>
261 {
262 public:
264 typedef typename Matrix_::DataType DataType;
266 typedef typename Matrix_::ValueType ValueType;
267
269 static constexpr bool need_scatter = true;
271 static constexpr bool need_combine = false;
272
273 protected:
275 typedef Assembly::AsmTraits1<
276 DataType,
277 Space_,
278 trafo_config_ | TrafoTags::jac_det,
279 space_config_
281
283 Matrix_& matrix;
285 const Space_& space;
301 typename AsmTraits::template TLocalMatrix<ValueType> local_matrix;
303 typename Matrix_::ScatterAxpy scatter_axpy;
306
307 public:
323 explicit DomainAssemblyBasicMatrixTaskCRTP1(Matrix_& matrix_, const Space_& space_,
324 const Cubature::DynamicFactory& cubature_factory, DataType alpha_) :
325 matrix(matrix_),
326 space(space_),
327 trafo(space.get_trafo()),
331 cubature_rule(Cubature::ctor_factory, cubature_factory),
333 scatter_alpha(alpha_)
334 {
335 }
336
337#ifdef DOXYGEN
348
364 void eval(ValueType& val, const DataType& weight,
365 const typename AsmTraits::TrialBasisData& phi, const typename AsmTraits::TestBasisData& psi);
366#endif // DOXYGEN
367
374 void prepare(Index cell)
375 {
376 // prepare dof mapping
377 dof_mapping.prepare(cell);
378
379 // prepare trafo evaluator
380 trafo_eval.prepare(cell);
381
382 // prepare space evaluator
383 space_eval.prepare(trafo_eval);
384 }
385
389 void assemble()
390 {
391 // format local matrix
392 local_matrix.format();
393
394 // fetch number of local dofs
395 const int num_loc_dofs = space_eval.get_num_local_dofs();
396
397 // loop over all quadrature points and integrate
398 for(int k(0); k < cubature_rule.get_num_points(); ++k)
399 {
400 // compute trafo data
401 trafo_eval(trafo_data, cubature_rule.get_point(k));
402
403 // compute basis function data
405
406 // evaluate operator
407 static_cast<Derived_&>(*this).set_point(trafo_data);
408
409 // test function loop
410 for(int i(0); i < num_loc_dofs; ++i)
411 {
412 // trial function loop
413 for(int j(0); j < num_loc_dofs; ++j)
414 {
415 // evaluate operator and integrate
416 static_cast<Derived_&>(*this).eval(local_matrix(i,j),
417 trafo_data.jac_det * cubature_rule.get_weight(k),
418 space_data.phi[j], space_data.phi[i]);
419 // continue with next trial function
420 }
421 // continue with next test function
422 }
423 // continue with next cubature point
424 }
425 }
426
430 void scatter()
431 {
432 // incorporate local matrix
434 }
435
439 void finish()
440 {
441 // finish evaluators
442 space_eval.finish();
443 trafo_eval.finish();
444
445 // finish dof mapping
446 dof_mapping.finish();
447 }
448
452 void combine()
453 {
454 // nothing to do here
455 }
456 }; // class DomainAssemblyBasicMatrixTaskCRTP1<...>
457
489 template<
490 typename Derived_,
491 typename Matrix_,
492 typename TestSpace_,
493 typename TrialSpace_,
494 TrafoTags trafo_config_,
495 SpaceTags test_config_,
496 SpaceTags trial_config_>
498 {
499 public:
501 typedef typename Matrix_::DataType DataType;
503 typedef typename Matrix_::ValueType ValueType;
504
506 static constexpr bool need_scatter = true;
508 static constexpr bool need_combine = false;
509
510 protected:
512 typedef Assembly::AsmTraits2<
513 DataType,
514 TestSpace_,
515 TrialSpace_,
516 trafo_config_ | TrafoTags::jac_det,
517 test_config_,
518 trial_config_
520
522 Matrix_& matrix;
524 const TestSpace_& test_space;
526 const TrialSpace_& trial_space;
533 typename AsmTraits::TrialEvaluator trial_eval;
536 typename AsmTraits::TrialDofMapping trial_dof_mapping;
543 typename AsmTraits::TrialEvalData trial_data;
545 typename AsmTraits::template TLocalMatrix<ValueType> local_matrix;
547 typename Matrix_::ScatterAxpy scatter_axpy;
550
551 public:
570 explicit DomainAssemblyBasicMatrixTaskCRTP2(Matrix_& matrix_,
571 const TestSpace_& test_space_, const TrialSpace_& trial_space_,
572 const Cubature::DynamicFactory& cubature_factory, DataType alpha_) :
573 matrix(matrix_),
574 test_space(test_space_),
575 trial_space(trial_space_),
576 trafo(test_space.get_trafo()),
579 trial_eval(trial_space),
581 trial_dof_mapping(trial_space),
582 cubature_rule(Cubature::ctor_factory, cubature_factory),
584 scatter_alpha(alpha_)
585 {
586 }
587
588#ifdef DOXYGEN
599
615 void eval(ValueType& val, const DataType& weight,
616 const typename AsmTraits::TrialBasisData& phi, const typename AsmTraits::TestBasisData& psi);
617#endif // DOXYGEN
618
625 void prepare(Index cell)
626 {
627 // prepare dof mapping
628 test_dof_mapping.prepare(cell);
629 trial_dof_mapping.prepare(cell);
630
631 // prepare trafo evaluator
632 trafo_eval.prepare(cell);
633
634 // prepare space evaluators
635 test_eval.prepare(trafo_eval);
636 trial_eval.prepare(trafo_eval);
637 }
638
642 void assemble()
643 {
644 // format local matrix
645 local_matrix.format();
646
647 // fetch number of local dofs
648 const int num_loc_test_dofs = test_eval.get_num_local_dofs();
649 const int num_loc_trial_dofs = trial_eval.get_num_local_dofs();
650
651 // loop over all quadrature points and integrate
652 for(int k(0); k < cubature_rule.get_num_points(); ++k)
653 {
654 // compute trafo data
655 trafo_eval(trafo_data, cubature_rule.get_point(k));
656
657 // compute basis function data
659 trial_eval(trial_data, trafo_data);
660
661 // evaluate operator
662 static_cast<Derived_&>(*this).set_point(trafo_data);
663
664 // test function loop
665 for(int i(0); i < num_loc_test_dofs; ++i)
666 {
667 // trial function loop
668 for(int j(0); j < num_loc_trial_dofs; ++j)
669 {
670 // evaluate operator and integrate
671 static_cast<Derived_&>(*this).eval(local_matrix(i,j),
672 trafo_data.jac_det * cubature_rule.get_weight(k),
673 trial_data.phi[j], test_data.phi[i]);
674 // continue with next trial function
675 }
676 // continue with next test function
677 }
678 // continue with next cubature point
679 }
680 }
681
685 void scatter()
686 {
687 // incorporate local matrix
689 }
690
694 void finish()
695 {
696 // finish evaluators
697 trial_eval.finish();
698 test_eval.finish();
699 trafo_eval.finish();
700
701 // finish dof mapping
702 trial_dof_mapping.finish();
703 test_dof_mapping.finish();
704 }
705
709 void combine()
710 {
711 // nothing to do here
712 }
713 }; // class DomainAssemblyBasicMatrixTaskCRTP2<...>
714
732 template<typename LinearFunctional_, typename Vector_, typename Space_>
734 {
735 public:
736 typedef typename Vector_::DataType DataType;
737 typedef typename Vector_::ValueType ValueType;
738
739 static constexpr TrafoTags trafo_config = LinearFunctional_::trafo_config;
740 static constexpr SpaceTags test_config = LinearFunctional_::test_config;
741
742 class Task :
743 public DomainAssemblyBasicVectorTaskCRTP<Task, Vector_, Space_, trafo_config, test_config>
744 {
745 protected:
748
751
753 typename LinearFunctional_::template Evaluator<AsmTraits> func_eval;
754
755 public:
757 BaseClass(job.vector, job.space, job.cubature_factory, job.alpha),
759 {
760 }
761
762 void prepare(Index cell)
763 {
764 BaseClass::prepare(cell);
765 func_eval.prepare(this->trafo_eval);
766 }
767
768 void set_point(typename AsmTraits::TrafoEvalData& tau)
769 {
770 func_eval.set_point(tau);
771 }
772
773 void eval(ValueType& val, const DataType& weight, typename AsmTraits::TestBasisData& psi)
774 {
775 Tiny::axpy(val, func_eval.eval(psi), weight);
776 }
777
778 void finish()
779 {
780 func_eval.finish();
782 }
783 }; // class Task
784
785 protected:
787 const LinearFunctional_& linear_functional;
789 Vector_& vector;
791 const Space_& space;
795 DataType alpha;
796
797 public:
816 explicit DomainAssemblyLinearFunctionalVectorJob(const LinearFunctional_& linear_functional_,
817 Vector_& vector_, const Space_& space_, const String& cubature_, DataType alpha_ = DataType(1)) :
818 linear_functional(linear_functional_),
819 vector(vector_),
820 space(space_),
821 cubature_factory(cubature_),
822 alpha(alpha_)
823 {
824 }
825 }; // class DomainAssemblyLinearFunctionalVectorJob<...>
826
848 template<typename Trafo_, typename Vector_, typename LinFunc_, typename Space_>
850 Vector_& vector, const LinFunc_& linear_functional, const Space_& space,
851 const String& cubature, const typename Vector_::DataType alpha = typename Vector_::DataType(1))
852 {
853 XASSERTM(dom_asm.get_trafo() == space.get_trafo(), "domain assembler and space have different trafos");
854 XASSERTM(vector.size() == space.get_num_dofs(), "invalid vector length");
855
857 linear_functional, vector, space, cubature, alpha);
858 dom_asm.assemble(job);
859 }
860
881 template<typename Function_, typename Vector_, typename Space_>
883 {
884 public:
885 typedef typename Vector_::DataType DataType;
886 typedef typename Vector_::ValueType ValueType;
887
888 static constexpr TrafoTags trafo_config = TrafoTags::img_point | TrafoTags::jac_det;
889 static constexpr SpaceTags test_config = SpaceTags::value;
890
891 class Task :
892 public DomainAssemblyBasicVectorTaskCRTP<Task, Vector_, Space_, trafo_config, test_config>
893 {
894 protected:
897
900
904 typename Function_::template Evaluator<AnalyticEvalTraits> func_eval;
906 typename AnalyticEvalTraits::ValueType func_value;
907
908 public:
910 BaseClass(job.vector, job.space, job.cubature_factory, job.alpha),
912 {
913 }
914
915 void set_point(typename AsmTraits::TrafoEvalData& tau)
916 {
917 func_value = func_eval.value(tau.img_point);
918 }
919
920 void eval(ValueType& val, const DataType& weight, typename AsmTraits::TestBasisData& psi)
921 {
922 Tiny::axpy(val, func_value, weight * psi.value);
923 }
924 }; // class Task
925
926 protected:
928 const Function_& function;
930 Vector_& vector;
932 const Space_& space;
936 DataType alpha;
937
938 public:
957 explicit DomainAssemblyForceFunctionalVectorJob(const Function_& function_,
958 Vector_& vector_, const Space_& space_, const String& cubature_, DataType alpha_ = DataType(1)) :
959 function(function_),
960 vector(vector_),
961 space(space_),
962 cubature_factory(cubature_),
963 alpha(alpha_)
964 {
965 }
966 }; // class DomainAssemblyForceFunctionalVectorJob<...>
967
989 template<typename Trafo_, typename Vector_, typename Function_, typename Space_>
991 Vector_& vector, const Function_& function, const Space_& space,
992 const String& cubature, const typename Vector_::DataType alpha = typename Vector_::DataType(1))
993 {
994 XASSERTM(dom_asm.get_trafo() == space.get_trafo(), "domain assembler and space have different trafos");
995 XASSERTM(vector.size() == space.get_num_dofs(), "invalid vector length");
996
998 function, vector, space, cubature, alpha);
999 dom_asm.assemble(job);
1000 }
1001
1019 template<typename BilinearOperator_, typename Matrix_, typename Space_>
1021 {
1022 public:
1023 typedef typename Matrix_::DataType DataType;
1024 typedef typename Matrix_::ValueType ValueType;
1025
1026 static constexpr TrafoTags trafo_config = BilinearOperator_::trafo_config;
1027 static constexpr SpaceTags space_config = BilinearOperator_::test_config | BilinearOperator_::trial_config;
1028
1029 class Task :
1030 public DomainAssemblyBasicMatrixTaskCRTP1<Task, Matrix_, Space_, trafo_config, space_config>
1031 {
1032 protected:
1035
1038
1040 typename BilinearOperator_::template Evaluator<AsmTraits> oper_eval;
1041
1042 public:
1044 BaseClass(job.matrix, job.space, job.cubature_factory, job.alpha),
1046 {
1047 }
1048
1049 void prepare(Index cell)
1050 {
1051 BaseClass::prepare(cell);
1052 oper_eval.prepare(this->trafo_eval);
1053 }
1054
1055 void set_point(typename AsmTraits::TrafoEvalData& tau)
1056 {
1057 oper_eval.set_point(tau);
1058 }
1059
1060 void eval(ValueType& val, const DataType& weight,
1061 typename AsmTraits::TrialBasisData& phi, typename AsmTraits::TestBasisData& psi)
1062 {
1063 val += weight * oper_eval.eval(phi, psi);
1064 }
1065
1066 void finish()
1067 {
1068 oper_eval.finish();
1070 }
1071 }; // class Task
1072
1073 protected:
1075 const BilinearOperator_& bilinear_operator;
1077 Matrix_& matrix;
1079 const Space_& space;
1083 DataType alpha;
1084
1085 public:
1104 explicit DomainAssemblyBilinearOperatorMatrixJob1(const BilinearOperator_& bilinear_operator_,
1105 Matrix_& matrix_, const Space_& space_, const String& cubature_, DataType alpha_ = DataType(1)) :
1106 bilinear_operator(bilinear_operator_),
1107 matrix(matrix_),
1108 space(space_),
1109 cubature_factory(cubature_),
1110 alpha(alpha_)
1111 {
1112 }
1113 }; // class DomainAssemblyBilinearOperatorMatrixJob1<...>
1114
1136 template<typename Trafo_, typename Matrix_, typename BilOp_, typename Space_>
1138 const BilOp_& bilinear_operator, const Space_& space, const String& cubature,
1139 const typename Matrix_::DataType alpha = typename Matrix_::DataType(1))
1140 {
1141 XASSERTM(dom_asm.get_trafo() == space.get_trafo(), "domain assembler and space have different trafos");
1142 XASSERTM(matrix.num_cols() == space.get_num_dofs(), "invalid matrix column count");
1143 XASSERTM(matrix.num_rows() == space.get_num_dofs(), "invalid matrix row count");
1144
1146 bilinear_operator, matrix, space, cubature, alpha);
1147 dom_asm.assemble(job);
1148 }
1149
1170 template<typename BilinearOperator_, typename Matrix_, typename TestSpace_, typename TrialSpace_>
1172 {
1173 public:
1174 typedef typename Matrix_::DataType DataType;
1175 typedef typename Matrix_::ValueType ValueType;
1176
1177 static constexpr TrafoTags trafo_config = BilinearOperator_::trafo_config;
1178 static constexpr SpaceTags test_config = BilinearOperator_::test_config;
1179 static constexpr SpaceTags trial_config = BilinearOperator_::trial_config;
1180
1181 class Task :
1182 public DomainAssemblyBasicMatrixTaskCRTP2<Task, Matrix_, TestSpace_, TrialSpace_, trafo_config, test_config, trial_config>
1183 {
1184 protected:
1187
1190
1192 typename BilinearOperator_::template Evaluator<AsmTraits> oper_eval;
1193
1194 public:
1198 {
1199 }
1200
1201 void prepare(Index cell)
1202 {
1203 BaseClass::prepare(cell);
1204 oper_eval.prepare(this->trafo_eval);
1205 }
1206
1207 void set_point(typename AsmTraits::TrafoEvalData& tau)
1208 {
1209 oper_eval.set_point(tau);
1210 }
1211
1212 void eval(ValueType& val, const DataType& weight,
1213 typename AsmTraits::TrialBasisData& phi, typename AsmTraits::TestBasisData& psi)
1214 {
1215 Tiny::axpy(val, oper_eval.eval(phi, psi), weight);
1216 }
1217
1218 void finish()
1219 {
1220 oper_eval.finish();
1222 }
1223 }; // class Task
1224
1225 protected:
1227 const BilinearOperator_& bilinear_operator;
1229 Matrix_& matrix;
1231 const TestSpace_& test_space;
1233 const TrialSpace_& trial_space;
1237 DataType alpha;
1238
1239 public:
1261 explicit DomainAssemblyBilinearOperatorMatrixJob2(const BilinearOperator_& bilinear_operator_,
1262 Matrix_& matrix_, const TestSpace_& test_space_, const TrialSpace_& trial_space_,
1263 const String& cubature_, DataType alpha_ = DataType(1)) :
1264 bilinear_operator(bilinear_operator_),
1265 matrix(matrix_),
1266 test_space(test_space_),
1267 trial_space(trial_space_),
1268 cubature_factory(cubature_),
1269 alpha(alpha_)
1270 {
1271 }
1272 }; // class DomainAssemblyBilinearOperatorMatrixJob2<...>
1273
1298 template<typename Trafo_, typename Matrix_, typename BilOp_, typename TestSpace_, typename TrialSpace_>
1300 Matrix_& matrix, const BilOp_& bilinear_operator, const TestSpace_& test_space,
1301 const TrialSpace_& trial_space, const String& cubature,
1302 const typename Matrix_::DataType alpha = typename Matrix_::DataType(1))
1303 {
1304 XASSERTM(dom_asm.get_trafo() == test_space.get_trafo(), "domain assembler and test space have different trafos");
1305 XASSERTM(dom_asm.get_trafo() == trial_space.get_trafo(), "domain assembler and trial space have different trafos");
1306 XASSERTM(matrix.num_cols() == trial_space.get_num_dofs(), "invalid matrix column count");
1307 XASSERTM(matrix.num_rows() == test_space.get_num_dofs(), "invalid matrix row count");
1308
1310 bilinear_operator, matrix, test_space, trial_space, cubature, alpha);
1311 dom_asm.assemble(job);
1312 }
1313
1338 template<typename BilinearOperator_, typename Vector_, typename VectorSol_, typename Space_>
1340 {
1341 public:
1342 typedef typename Vector_::DataType DataType;
1343 typedef typename Vector_::ValueType ValueType;
1344
1345 static constexpr TrafoTags trafo_config = BilinearOperator_::trafo_config;
1346 static constexpr SpaceTags space_config = BilinearOperator_::test_config | BilinearOperator_::trial_config;
1347
1348 class Task :
1349 public DomainAssemblyBasicVectorTaskCRTP<Task, Vector_, Space_, trafo_config, space_config>
1350 {
1351 protected:
1354
1357 typedef typename BilinearOperator_::template Evaluator<AsmTraits>::ValueType MatValType;
1358
1360 typename BilinearOperator_::template Evaluator<AsmTraits> oper_eval;
1361
1363 const VectorSol_& vec_sol;
1364
1366 typename VectorSol_::GatherAxpy sol_gather;
1367
1369 typename AsmTraits::template TLocalMatrix<MatValType> local_matrix;
1370 typename AsmTraits::template TLocalVector<ValueType> local_vec_sol;
1371
1372 static void add_local_product(ValueType& y, const MatValType& a, const ValueType& x)
1373 {
1374 if constexpr(std::is_same<MatValType, ValueType>::value)
1375 {
1376 y += a * x;
1377 }
1378 else
1379 {
1380 y.add_mat_vec_mult(a, x);
1381 }
1382 }
1383
1384
1385 public:
1387 BaseClass(job.vector, job.space, job.cubature_factory, job.alpha),
1389 vec_sol(job.vec_sol),
1391 {
1392 }
1393
1394 void prepare(Index cell)
1395 {
1396 BaseClass::prepare(cell);
1397 oper_eval.prepare(this->trafo_eval);
1398 local_vec_sol.format();
1399 sol_gather(local_vec_sol, this->dof_mapping);
1400 }
1401
1402 void set_point(typename AsmTraits::TrafoEvalData& tau)
1403 {
1404 oper_eval.set_point(tau);
1405 }
1406
1407 void eval(MatValType& val, const DataType& weight,
1408 typename AsmTraits::TrialBasisData& phi, typename AsmTraits::TestBasisData& psi)
1409 {
1410 val += weight * oper_eval.eval(phi, psi);
1411 }
1412
1417 {
1418 // format local matrix
1419 local_matrix.format();
1420 this->local_vector.format();
1421
1422 // fetch number of local dofs
1423 const int num_loc_dofs = this->space_eval.get_num_local_dofs();
1424
1425 // loop over all quadrature points and integrate
1426 for(int k(0); k < this->cubature_rule.get_num_points(); ++k)
1427 {
1428 // compute trafo data
1429 this->trafo_eval(this->trafo_data, this->cubature_rule.get_point(k));
1430
1431 // compute basis function data
1432 this->space_eval(this->space_data, this->trafo_data);
1433
1434 // evaluate operator
1435 this->set_point(this->trafo_data);
1436
1437 // test function loop
1438 for(int i(0); i < num_loc_dofs; ++i)
1439 {
1440 // trial function loop
1441 for(int j(0); j < num_loc_dofs; ++j)
1442 {
1443 // evaluate operator and integrate
1444 this->eval(local_matrix(i,j),
1445 this->trafo_data.jac_det * this->cubature_rule.get_weight(k),
1446 this->space_data.phi[j], this->space_data.phi[i]);
1447 // continue with next trial function
1448 }
1449 // continue with next test function
1450 }
1451 // continue with next cubature point
1452 }
1453 // apply to local vector
1454 for(int i(0); i < num_loc_dofs; ++i)
1455 for(int j(0); j < num_loc_dofs; ++j)
1456 add_local_product(this->local_vector(i), this->local_matrix(i,j), local_vec_sol(j));
1457 }
1458
1459 void finish()
1460 {
1461 oper_eval.finish();
1463 }
1464 }; // class Task
1465
1466 protected:
1468 const BilinearOperator_& bilinear_operator;
1470 Vector_& vector;
1472 const VectorSol_& vec_sol;
1474 const Space_& space;
1478 DataType alpha;
1479
1480 public:
1499 explicit DomainAssemblyBilinearOperatorApplyVectorJob1(const BilinearOperator_& bilinear_operator_,
1500 Vector_& vector_, const VectorSol_& vec_sol_, const Space_& space_, const String& cubature_, DataType alpha_ = DataType(1)) :
1501 bilinear_operator(bilinear_operator_),
1502 vector(vector_),
1503 vec_sol(vec_sol_),
1504 space(space_),
1505 cubature_factory(cubature_),
1506 alpha(alpha_)
1507 {
1508 }
1509 }; // class DomainAssemblyBilinearOperatorApplyVectorJob1<...>
1510
1535 template<typename Trafo_, typename Vector_, typename VectorSol_, typename BilOp_, typename Space_>
1537 const VectorSol_& vec_sol, const BilOp_& bilinear_operator, const Space_& space, const String& cubature,
1538 const typename Vector_::DataType alpha = typename Vector_::DataType(1))
1539 {
1540 XASSERTM(dom_asm.get_trafo() == space.get_trafo(), "domain assembler and space have different trafos");
1541 XASSERTM(vector.size() == space.get_num_dofs(), "invalid vector size");
1542
1544 bilinear_operator, vector, vec_sol, space, cubature, alpha);
1545 dom_asm.assemble(job);
1546 }
1547
1565 template<typename DataType_, typename Function_, typename Trafo_, int max_der_>
1567 {
1568 public:
1569 static_assert(Function_::can_value, "function cannot compute values");
1570 static_assert(Function_::can_grad || (max_der_ < 1), "function gradients are required but not available");
1571 static_assert(Function_::can_hess || (max_der_ < 2), "function hessians are required but not available");
1572
1574 typedef DataType_ DataType;
1575
1578
1581
1582 public:
1586 class Task
1587 {
1588 public:
1590 static constexpr bool need_scatter = false;
1592 static constexpr bool need_combine = true;
1593
1594 protected:
1595 static constexpr TrafoTags trafo_config = TrafoTags::img_point | TrafoTags::jac_det;
1597 typedef typename Trafo_::template Evaluator<typename Trafo_::ShapeType, DataType>::Type TrafoEvaluator;
1601 typename TrafoEvaluator::template ConfigTraits<trafo_config>::EvalDataType trafo_data;
1603 typename Assembly::Intern::CubatureTraits<TrafoEvaluator>::RuleType cubature_rule;
1605 typename Function_::template Evaluator<AnalyticEvalTraits> func_eval;
1610
1611 public:
1613 trafo_eval(job._trafo),
1614 trafo_data(),
1615 cubature_rule(Cubature::ctor_factory, job._cubature_factory),
1616 func_eval(job._function),
1617 loc_integral(),
1619 {
1620 }
1621
1622 void prepare(Index cell)
1623 {
1624 trafo_eval.prepare(cell);
1625 }
1626
1627 void assemble()
1628 {
1629 // loop over all quadrature points and integrate
1630 for(int k(0); k < cubature_rule.get_num_points(); ++k)
1631 {
1632 // compute trafo data
1633 trafo_eval(trafo_data, cubature_rule.get_point(k));
1634
1635 // call helper to integrate
1636 Intern::AnaFunIntJobHelper<max_der_>::work(loc_integral,
1637 cubature_rule.get_weight(k) * trafo_data.jac_det, func_eval, trafo_data.img_point);
1638 }
1639 }
1640
1641 void scatter()
1642 {
1643 // nothing to do here
1644 }
1645
1646 void finish()
1647 {
1648 trafo_eval.finish();
1649 }
1650
1651 void combine()
1652 {
1654 }
1655 }; // class Task
1656
1657 protected:
1659 const Trafo_& _trafo;
1661 const Function_& _function;
1666
1667 public:
1680 explicit DomainAssemblyAnalyticFunctionIntegralJob(const Function_& function, const Trafo_& trafo, const String& cubature) :
1681 _trafo(trafo),
1682 _function(function),
1683 _cubature_factory(cubature),
1684 _integral()
1685 {
1686 _integral.max_der = max_der_;
1687 }
1688
1693 {
1694 return _integral;
1695 }
1696 }; // class DomainAssemblyAnalyticFunctionIntegralJob<...>
1697
1717 template<int max_der_, typename DataType_, typename Trafo_, typename Function_>
1719 DomainAssembler<Trafo_>& dom_asm, const Function_& function, const String& cubature)
1720 {
1722 dom_asm.assemble(job);
1723 return job.result();
1724 }
1725
1742 template<typename Vector_, typename Space_, int max_der_>
1744 {
1745 public:
1747 typedef typename Vector_::DataType DataType;
1749 typedef typename Vector_::ValueType ValueType;
1750
1751 typedef typename DiscreteFunctionIntegral<Vector_, Space_>::Type FunctionIntegralType;
1752
1753 public:
1754 class Task
1755 {
1756 public:
1758 static constexpr bool need_scatter = false;
1760 static constexpr bool need_combine = true;
1761
1762 protected:
1763 static constexpr SpaceTags space_tags = SpaceTags::value |
1764 (max_der_ >= 1 ? SpaceTags::grad : SpaceTags::none) |
1765 (max_der_ >= 2 ? SpaceTags::hess : SpaceTags::none);
1766
1770 const Vector_& vector;
1772 const Space_& space;
1788 typename AsmTraits::template TLocalVector<ValueType> local_vector;
1790 typename Vector_::GatherAxpy gather_axpy;
1792 FunctionIntegralType loc_integral;
1794 FunctionIntegralType& job_integral;
1795
1796 public:
1798 vector(job._vector),
1799 space(job._space),
1800 trafo(space.get_trafo()),
1804 cubature_rule(Cubature::ctor_factory, job._cubature_factory),
1805 trafo_data(),
1806 space_data(),
1807 local_vector(),
1809 loc_integral(),
1811 {
1812 }
1813
1814 void prepare(Index cell)
1815 {
1816 // prepare dof mapping
1817 dof_mapping.prepare(cell);
1818
1819 // prepare trafo evaluator
1820 trafo_eval.prepare(cell);
1821
1822 // prepare space evaluator
1823 space_eval.prepare(trafo_eval);
1824 }
1825
1826 void assemble()
1827 {
1828 // format local vector
1829 local_vector.format();
1830
1831 // gather local vector data
1833
1834 // fetch number of local dofs
1835 const int num_loc_dofs = space_eval.get_num_local_dofs();
1836
1837 // loop over all quadrature points and integrate
1838 for(int k(0); k < cubature_rule.get_num_points(); ++k)
1839 {
1840 // compute trafo data
1841 trafo_eval(trafo_data, cubature_rule.get_point(k));
1842
1843 // compute basis function data
1845
1846 // do the dirty work
1847 Intern::DiscFunIntJobHelper<max_der_>::work(loc_integral,
1848 cubature_rule.get_weight(k) * trafo_data.jac_det, space_data, local_vector, num_loc_dofs);
1849 }
1850 }
1851
1852 void scatter()
1853 {
1854 // nothing to do here
1855 }
1856
1857 void finish()
1858 {
1859 trafo_eval.finish();
1860 }
1861
1862 void combine()
1863 {
1865 }
1866 }; // class Task
1867
1868 protected:
1870 const Vector_& _vector;
1872 const Space_& _space;
1876 FunctionIntegralType _integral;
1877
1878 public:
1891 explicit DomainAssemblyDiscreteFunctionIntegralJob(const Vector_& vector, const Space_& space, const String& cubature) :
1892 _vector(vector),
1893 _space(space),
1894 _cubature_factory(cubature),
1895 _integral()
1896 {
1897 _integral.max_der = max_der_;
1898 }
1899
1900 // \returns The integral of the discrete function
1901 FunctionIntegralType& result()
1902 {
1903 return _integral;
1904 }
1905 }; // class DomainAssemblyDiscreteFunctionIntegralJob<...>
1906
1926 template<int max_der_, typename Vector_, typename Trafo_, typename Space_>
1928 DomainAssembler<Trafo_>& dom_asm, const Vector_& vector, const Space_& space, const String& cubature)
1929 {
1930 XASSERTM(dom_asm.get_trafo() == space.get_trafo(), "domain assembler and space have different trafos");
1931 XASSERTM(vector.size() == space.get_num_dofs(), "invalid coefficient vector length");
1933 dom_asm.assemble(job);
1934 return job.result();
1935 }
1936
1959 template<typename Function_, typename Vector_, typename Space_, int max_der_>
1961 {
1962 public:
1964 typedef typename Vector_::DataType DataType;
1966 typedef typename Vector_::ValueType ValueType;
1967
1969 static_assert(Intern::ErrCompatHelper<Function_, Vector_>::valid, "function and vector are incompatible");
1970
1973
1976
1977 public:
1978 class Task
1979 {
1980 public:
1982 static constexpr bool need_scatter = false;
1984 static constexpr bool need_combine = true;
1985
1986 protected:
1987 static constexpr TrafoTags trafo_config = TrafoTags::img_point | TrafoTags::jac_det;
1988 static constexpr SpaceTags space_tags = SpaceTags::value |
1989 (max_der_ >= 1 ? SpaceTags::grad : SpaceTags::none) |
1990 (max_der_ >= 2 ? SpaceTags::hess : SpaceTags::none);
1991
1995 const Vector_& vector;
1997 const Space_& space;
2013 typename AsmTraits::template TLocalVector<ValueType> local_vector;
2015 typename Vector_::GatherAxpy gather_axpy;
2017 typename Function_::template Evaluator<AnalyticEvalTraits> func_eval;
2022
2023 public:
2025 vector(job._vector),
2026 space(job._space),
2027 trafo(space.get_trafo()),
2031 cubature_rule(Cubature::ctor_factory, job._cubature_factory),
2032 trafo_data(),
2033 space_data(),
2034 local_vector(),
2036 func_eval(job._function),
2037 loc_integral(),
2039 {
2040 }
2041
2042 void prepare(Index cell)
2043 {
2044 // prepare dof mapping
2045 dof_mapping.prepare(cell);
2046
2047 // prepare trafo evaluator
2048 trafo_eval.prepare(cell);
2049
2050 // prepare space evaluator
2051 space_eval.prepare(trafo_eval);
2052 }
2053
2054 void assemble()
2055 {
2056 // format local vector
2057 local_vector.format();
2058
2059 // gather local vector data
2061
2062 // fetch number of local dofs
2063 const int num_loc_dofs = space_eval.get_num_local_dofs();
2064
2065 // loop over all quadrature points and integrate
2066 for(int k(0); k < cubature_rule.get_num_points(); ++k)
2067 {
2068 // compute trafo data
2069 trafo_eval(trafo_data, cubature_rule.get_point(k));
2070
2071 // compute basis function data
2073
2074 // do the dirty work
2075 Intern::ErrFunIntJobHelper<max_der_>::work(loc_integral,
2076 cubature_rule.get_weight(k) * trafo_data.jac_det, func_eval, trafo_data.img_point,
2077 space_data, local_vector, num_loc_dofs);
2078 }
2079 }
2080
2081 void scatter()
2082 {
2083 // nothing to do here
2084 }
2085
2086 void finish()
2087 {
2088 trafo_eval.finish();
2089 }
2090
2091 void combine()
2092 {
2094 }
2095 }; // class Task
2096
2097 protected:
2099 const Function_& _function;
2101 const Vector_& _vector;
2103 const Space_& _space;
2108
2109 public:
2125 explicit DomainAssemblyErrorFunctionIntegralJob(const Function_& function, const Vector_& vector, const Space_& space, const String& cubature) :
2126 _function(function),
2127 _vector(vector),
2128 _space(space),
2129 _cubature_factory(cubature),
2130 _integral()
2131 {
2132 _integral.max_der = max_der_;
2133 }
2134
2135 // \returns The integral of the discrete function
2136 FunctionIntegralType& result()
2137 {
2138 return _integral;
2139 }
2140 }; // class DomainAssemblyErrorFunctionIntegralJob<...>
2141
2164 template<int max_der_, typename Function_, typename Vector_, typename Trafo_, typename Space_>
2166 DomainAssembler<Trafo_>& dom_asm, const Function_& function,
2167 const Vector_& vector, const Space_& space, const String& cubature)
2168 {
2169 XASSERTM(dom_asm.get_trafo() == space.get_trafo(), "domain assembler and space have different trafos");
2170 XASSERTM(vector.size() == space.get_num_dofs(), "invalid coefficient vector length");
2172 dom_asm.assemble(job);
2173 return job.result();
2174 }
2175
2176 namespace Intern
2177 {
2178 template<typename DT_, typename IT_, int max_der_>
2180 {
2182 };
2183
2184 template<typename DT_, typename IT_>
2185 struct OutVectorHelper<DT_, IT_, 0>
2186 {
2188 };
2189 }
2190
2214 template<typename Function_, typename Vector_, typename Space_, int max_der_>
2216 {
2217 public:
2219 typedef typename Vector_::DataType DataType;
2221 typedef typename Vector_::ValueType ValueType;
2222
2224 static_assert(Intern::ErrCompatHelper<Function_, Vector_>::valid, "function and vector are incompatible");
2225
2228
2231
2235
2238
2239 public:
2240 class Task
2241 {
2242 public:
2244 static constexpr bool need_scatter = true;
2246 static constexpr bool need_combine = true;
2247
2248 protected:
2249 static constexpr TrafoTags trafo_config = TrafoTags::img_point | TrafoTags::jac_det;
2250 static constexpr SpaceTags space_tags = SpaceTags::value |
2251 (max_der_ >= 1 ? SpaceTags::grad : SpaceTags::none) |
2252 (max_der_ >= 2 ? SpaceTags::hess : SpaceTags::none);
2253
2257 const Vector_& vector;
2259 const Space_& space;
2277 typename AsmTraits::template TLocalVector<ValueType> local_vector;
2279 typename Vector_::GatherAxpy gather_axpy;
2281 typename Function_::template Evaluator<AnalyticEvalTraits> func_eval;
2288
2289 public:
2290 explicit Task(CellErrorFunctionIntegralJob& job) :
2291 vector(job._vector),
2292 space(job._space),
2293 out_vector(job._out_vec),
2294 trafo(space.get_trafo()),
2298 cubature_rule(Cubature::ctor_factory, job._cubature_factory),
2299 trafo_data(),
2300 space_data(),
2301 local_vector(),
2303 func_eval(job._function),
2304 loc_integral(),
2307 {
2308 }
2309
2310 void prepare(Index cell)
2311 {
2312 // prepare dof mapping
2313 dof_mapping.prepare(cell);
2314
2315 // prepare trafo evaluator
2316 trafo_eval.prepare(cell);
2317
2318 // prepare space evaluator
2319 space_eval.prepare(trafo_eval);
2320 }
2321
2322 void assemble()
2323 {
2324 // format local vector
2325 local_vector.format();
2326
2327 // gather local vector data
2329
2330 // fetch number of local dofs
2331 const int num_loc_dofs = space_eval.get_num_local_dofs();
2332
2333 // format cell local integral value
2334 cell_integral.format();
2335
2336 // loop over all quadrature points and integrate
2337 for(int k(0); k < cubature_rule.get_num_points(); ++k)
2338 {
2339 // compute trafo data
2340 trafo_eval(trafo_data, cubature_rule.get_point(k));
2341
2342 // compute basis function data
2344
2345 // do the dirty work
2346 Intern::ErrFunIntJobHelper<max_der_>::work(cell_integral,
2347 cubature_rule.get_weight(k) * trafo_data.jac_det, func_eval, trafo_data.img_point,
2348 space_data, local_vector, num_loc_dofs);
2349 }
2350 // add our cell value
2352 }
2353
2354 void scatter()
2355 {
2357 Memory::TypedView<OutVectorValueType> out_vector_view = out_vector.elements_view_rw();
2358
2359 // get cell index
2360 Index cell = dof_mapping.get_current_cell_index();
2361 if constexpr(max_der_ == 0)
2362 {
2363 out_vector_view[cell] = cell_integral.norm_h0_sqr;
2364 }
2365 else
2366 {
2367 // construct tiny vector
2369 loc_vec[0] = cell_integral.norm_h0_sqr;
2370 loc_vec[1] = cell_integral.norm_h1_sqr;
2371 if constexpr(max_der_ > 1)
2372 loc_vec[2] = cell_integral.norm_h2_sqr;
2373 //scatter the tiny vector
2374 out_vector_view[cell] = loc_vec;
2375 }
2376 }
2377
2378 void finish()
2379 {
2380 trafo_eval.finish();
2381 }
2382
2383 void combine()
2384 {
2386 }
2387 }; // class Task
2388
2389 protected:
2391 const Function_& _function;
2393 const Vector_& _vector;
2395 const Space_& _space;
2402
2403 public:
2419 explicit CellErrorFunctionIntegralJob(const Function_& function, const Vector_& vector, const Space_& space, const String& cubature) :
2420 _function(function),
2421 _vector(vector),
2422 _space(space),
2423 _cubature_factory(cubature),
2424 _integral()
2425 {
2426 _integral.max_der = max_der_;
2427 _out_vec = OutVectorType(_space.get_mesh().get_num_elements());
2428 _out_vec.format();
2429 }
2430
2433 {
2434 FunctionCellIntegralType output(_integral, std::move(_out_vec));
2435 _out_vec = OutVectorType(_space.get_mesh().get_num_elements());
2436 _out_vec.format();
2437 return output;
2438 }
2439 }; // class CellErrorFunctionIntegralJob<...>
2440 } // namespace Assembly
2441} // namespace FEAT
#define XASSERTM(expr, msg)
Assertion macro definition with custom message.
Definition: assertion.hpp:263
Common single-space assembly traits class template.
Definition: asm_traits.hpp:83
TrafoType::template Evaluator< ShapeType, DataType >::Type TrafoEvaluator
trafo evaluator type
Definition: asm_traits.hpp:104
SpaceEvalData::BasisDataType SpaceBasisData
basis function data types
Definition: asm_traits.hpp:148
SpaceEvaluator::template ConfigTraits< space_config >::EvalDataType SpaceEvalData
space evaluation data types
Definition: asm_traits.hpp:142
Intern::CubatureTraits< TrafoEvaluator >::RuleType CubatureRuleType
cubature rule type
Definition: asm_traits.hpp:186
SpaceType::TrafoType TrafoType
trafo type
Definition: asm_traits.hpp:97
SpaceType::DofMappingType DofMapping
dof-mapping types
Definition: asm_traits.hpp:155
TrafoEvaluator::template ConfigTraits< trafo_config >::EvalDataType TrafoEvalData
trafo evaluation data type
Definition: asm_traits.hpp:138
SpaceType::template Evaluator< TrafoEvaluator >::Type SpaceEvaluator
space evaluator types
Definition: asm_traits.hpp:110
Common test-/trial-space assembly traits class template.
Definition: asm_traits.hpp:227
TestSpaceType::DofMappingType TestDofMapping
dof-mapping types
Definition: asm_traits.hpp:291
Intern::CubatureTraits< TrafoEvaluator >::RuleType CubatureRuleType
cubature rule type
Definition: asm_traits.hpp:318
TrafoType::template Evaluator< ShapeType, DataType >::Type TrafoEvaluator
trafo evaluator type
Definition: asm_traits.hpp:246
TestEvalData::BasisDataType TestBasisData
basis function data types
Definition: asm_traits.hpp:286
TestSpaceType::template Evaluator< TrafoEvaluator >::Type TestEvaluator
space evaluator types
Definition: asm_traits.hpp:252
TestSpaceType::TrafoType TrafoType
trafo type
Definition: asm_traits.hpp:239
TestEvaluator::template ConfigTraits< test_config >::EvalDataType TestEvalData
space evaluation data types
Definition: asm_traits.hpp:281
TrafoEvaluator::template ConfigTraits< trafo_config >::EvalDataType TrafoEvalData
trafo evaluation data type
Definition: asm_traits.hpp:277
AsmTraits::CubatureRuleType cubature_rule
the cubature rule used for integration
AsmTraits::template TLocalVector< ValueType > local_vector
the local vector to be assembled
Function_::template Evaluator< AnalyticEvalTraits > func_eval
the function evaluator
AsmTraits::DofMapping dof_mapping
the space dof-mapping
AsmTraits::SpaceEvalData space_data
the space evaluation data
AsmTraits::TrafoEvalData trafo_data
the trafo evaluation data
Vector_::GatherAxpy gather_axpy
the vector gather object
AsmTraits::TrafoEvaluator trafo_eval
the trafo evaluator
static constexpr bool need_scatter
this task doesn't need to scatter
const AsmTraits::TrafoType & trafo
the cubature factory used for integration
const Vector_ & vector
the vector that is to be integrated
AsmTraits::SpaceEvaluator space_eval
the space evaluator
const Space_ & space
the finite element space to be used
Assembly::AsmTraits1< DataType, Space_, trafo_config, space_tags > AsmTraits
our assembly traits
static constexpr bool need_combine
this task needs to combine
Assembly job for the elementwise integration of a analytic vs discrete error function.
OutVectorType _out_vec
the vector of the cell data
CellErrorFunctionIntegralJob(const Function_ &function, const Vector_ &vector, const Space_ &space, const String &cubature)
Constructor.
const Vector_ & _vector
the vector that is to be integrated
Cubature::DynamicFactory _cubature_factory
the cubature factory
Intern::OutVectorHelper< DataType, Index, max_der_ >::VectorType OutVectorType
our output vectortype
Analytic::EvalTraits< DataType, Function_ > AnalyticEvalTraits
declare our analytic eval traits
DiscreteFunctionIntegral< Vector_, Space_ >::Type FunctionIntegralType
make sure that function and vector are compatible
FunctionCellIntegralInfo< FunctionIntegralType, OutVectorType > FunctionCellIntegralType
our cell fucntion integral type
Vector_::DataType DataType
the data-type of the vector
const Function_ & _function
the function to be integrated
FunctionIntegralType _integral
the function integral
const Space_ & _space
the finite element space to be used
Vector_::ValueType ValueType
the value-type of the vector
Domain Integral Assembler class template.
const Trafo_ & get_trafo() const
Returns a reference to the domain assembler's trafo.
void assemble(Job_ &job)
Executes a domain assembly job (in parallel) by (multiple) worker threads.
Assembly::Intern::CubatureTraits< TrafoEvaluator >::RuleType cubature_rule
the cubature rule
static constexpr bool need_scatter
this task doesn't need to scatter
TrafoEvaluator::template ConfigTraits< trafo_config >::EvalDataType trafo_data
trafo eval data type
Trafo_::template Evaluator< typenameTrafo_::ShapeType, DataType >::Type TrafoEvaluator
trafo evaluator
Function_::template Evaluator< AnalyticEvalTraits > func_eval
the function evaluator
Assembly job for the integration of an analytic function.
FunctionIntegralType & result()
Returns the assembled function integral info.
DataType_ DataType
the datatype to be used by the assembly
DomainAssemblyAnalyticFunctionIntegralJob(const Function_ &function, const Trafo_ &trafo, const String &cubature)
Constructor.
Analytic::EvalTraits< DataType, Function_ > AnalyticEvalTraits
declare our analytic eval traits
AnalyticFunctionIntegral< DataType, Function_ >::Type FunctionIntegralType
our function integral type
Basic Matrix assembly task CRTP base-class for identical test-/trial-space.
Matrix_::ScatterAxpy scatter_axpy
the matrix scatter object
static constexpr bool need_scatter
this task needs to scatter
const AsmTraits::TrafoType & trafo
the cubature factory used for integration
const Space_ & space
the test-/trial-space to be used
AsmTraits::TrafoEvaluator trafo_eval
the trafo evaluator
AsmTraits::SpaceEvalData space_data
the space evaluation data
void prepare(Index cell)
Prepares the task for the assembly on a given mesh cell.
Matrix_ & matrix
the matrix that is to be assembled
void finish()
Finishes the assembly on the current cell.
Matrix_::ValueType ValueType
the value-type of the matrix
DomainAssemblyBasicMatrixTaskCRTP1(Matrix_ &matrix_, const Space_ &space_, const Cubature::DynamicFactory &cubature_factory, DataType alpha_)
Constructor.
AsmTraits::CubatureRuleType cubature_rule
the cubature rule used for integration
AsmTraits::template TLocalMatrix< ValueType > local_matrix
the local matrix to be assembled
AsmTraits::TrafoEvalData trafo_data
the trafo evaluation data
AsmTraits::SpaceEvaluator space_eval
the space evaluator
void set_point(typename AsmTraits::TrafoEvalData &tau)
Sets the current cubature point.
void eval(ValueType &val, const DataType &weight, const typename AsmTraits::TrialBasisData &phi, const typename AsmTraits::TestBasisData &psi)
Evaluates the bilinearform for a test-/trial-basis function pair.
AsmTraits::DofMapping dof_mapping
the space dof-mapping
Assembly::AsmTraits1< DataType, Space_, trafo_config_|TrafoTags::jac_det, space_config_ > AsmTraits
our assembly traits
static constexpr bool need_combine
this task has no combine
Matrix_::DataType DataType
the data-type of the matrix
Basic Matrix assembly task CRTP base-class for (possibly different) test-/trial-spaces.
const TestSpace_ & test_space
the test-space to be used
AsmTraits::TestDofMapping test_dof_mapping
the space dof-mappings
void eval(ValueType &val, const DataType &weight, const typename AsmTraits::TrialBasisData &phi, const typename AsmTraits::TestBasisData &psi)
Evaluates the bilinearform for a test-/trial-basis function pair.
Matrix_::ValueType ValueType
the value-type of the matrix
AsmTraits::template TLocalMatrix< ValueType > local_matrix
the local matrix to be assembled
void set_point(typename AsmTraits::TrafoEvalData &tau)
Sets the current cubature point.
static constexpr bool need_combine
this task has no combine
AsmTraits::TestEvalData test_data
the space evaluation data
AsmTraits::CubatureRuleType cubature_rule
the cubature rule used for integration
const TrialSpace_ & trial_space
the trial-space to be used
Assembly::AsmTraits2< DataType, TestSpace_, TrialSpace_, trafo_config_|TrafoTags::jac_det, test_config_, trial_config_ > AsmTraits
our assembly traits
void finish()
Finishes the assembly on the current cell.
AsmTraits::TestEvaluator test_eval
the space evaluators
static constexpr bool need_scatter
this task needs to scatter
DomainAssemblyBasicMatrixTaskCRTP2(Matrix_ &matrix_, const TestSpace_ &test_space_, const TrialSpace_ &trial_space_, const Cubature::DynamicFactory &cubature_factory, DataType alpha_)
Constructor.
void prepare(Index cell)
Prepares the task for the assembly on a given mesh cell.
Matrix_::ScatterAxpy scatter_axpy
the matrix scatter object
Matrix_ & matrix
the matrix that is to be assembled
AsmTraits::TrafoEvalData trafo_data
the trafo evaluation data
AsmTraits::TrafoEvaluator trafo_eval
the trafo evaluator
const AsmTraits::TrafoType & trafo
the cubature factory used for integration
Matrix_::DataType DataType
the data-type of the matrix
DomainAssemblyBasicVectorTaskCRTP(Vector_ &vector_, const Space_ &space_, const Cubature::DynamicFactory &cubature_factory, DataType alpha_)
Constructor.
void finish()
Finishes the assembly on the current cell.
const AsmTraits::TrafoType & trafo
the cubature factory used for integration
const Space_ & space
the test-/trial-space to be used
AsmTraits::SpaceEvaluator space_eval
the space evaluator
AsmTraits::TrafoEvaluator trafo_eval
the trafo evaluator
AsmTraits::CubatureRuleType cubature_rule
the cubature rule used for integration
Vector_::ScatterAxpy scatter_axpy
the vector scatter object
static constexpr bool need_scatter
this task needs to scatter
Vector_::ValueType ValueType
the value-type of the vector
AsmTraits::TrafoEvalData trafo_data
the trafo evaluation data
AsmTraits::template TLocalVector< ValueType > local_vector
the local vector to be assembled
static constexpr bool need_combine
this task has no combine
Assembly::AsmTraits1< DataType, Space_, trafo_config_|TrafoTags::jac_det, space_config_ > AsmTraits
our assembly traits
Vector_::DataType DataType
the data-type of the vector
AsmTraits::DofMapping dof_mapping
the space dof-mapping
void eval(ValueType &val, const DataType &weight, const typename AsmTraits::SpaceBasisData &psi)
Evaluates the linearform for a test-basis function.
AsmTraits::SpaceEvalData space_data
the space evaluation data
Vector_ & vector
the vector that is to be assembled
void set_point(typename AsmTraits::TrafoEvalData &tau)
Sets the current cubature point.
void prepare(Index cell)
Prepares the task for the assembly on a given mesh cell.
VectorSol_::GatherAxpy sol_gather
the gather axpy for the local solution vector
BilinearOperator_::template Evaluator< AsmTraits > oper_eval
the bilinear operator evaluator
DomainAssemblyBasicVectorTaskCRTP< Task, Vector_, Space_, trafo_config, space_config > BaseClass
our base-class typedef
AsmTraits::template TLocalMatrix< MatValType > local_matrix
the local matrix that is used to assemble the local vector
const VectorSol_ & vec_sol
the local solution vector that the bilinear operator is applied to
Vector assembly job for BilinearOperator and identical test-/trial-spaces.
DomainAssemblyBilinearOperatorApplyVectorJob1(const BilinearOperator_ &bilinear_operator_, Vector_ &vector_, const VectorSol_ &vec_sol_, const Space_ &space_, const String &cubature_, DataType alpha_=DataType(1))
Constructor.
const BilinearOperator_ & bilinear_operator
a reference to the bilinear operator that is to be assembled
const Space_ & space
a reference to the finite element space to be used as test-/trial-space
Vector_ & vector
a reference to the vector that is to be assembled
const VectorSol_ & vec_sol
a reference to the vector the biliniear operator is applied on
Cubature::DynamicFactory cubature_factory
the cubature factory to be used for integration
DomainAssemblyBasicMatrixTaskCRTP1< Task, Matrix_, Space_, trafo_config, space_config > BaseClass
our base-class typedef
BilinearOperator_::template Evaluator< AsmTraits > oper_eval
the bilinear operator evaluator
Matrix assembly job for BilinearOperator and identical test-/trial-spaces.
Matrix_ & matrix
a reference to the matrix that is to be assembled
DomainAssemblyBilinearOperatorMatrixJob1(const BilinearOperator_ &bilinear_operator_, Matrix_ &matrix_, const Space_ &space_, const String &cubature_, DataType alpha_=DataType(1))
Constructor.
const BilinearOperator_ & bilinear_operator
a reference to the bilinear operator that is to be assembled
Cubature::DynamicFactory cubature_factory
the cubature factory to be used for integration
const Space_ & space
a reference to the finite element space to be used as test-/trial-space
DomainAssemblyBasicMatrixTaskCRTP2< Task, Matrix_, TestSpace_, TrialSpace_, trafo_config, test_config, trial_config > BaseClass
our base-class typedef
BilinearOperator_::template Evaluator< AsmTraits > oper_eval
the bilinear operator evaluator
Matrix assembly job for BilinearOperator and (possibly different) test-/trial-spaces.
DomainAssemblyBilinearOperatorMatrixJob2(const BilinearOperator_ &bilinear_operator_, Matrix_ &matrix_, const TestSpace_ &test_space_, const TrialSpace_ &trial_space_, const String &cubature_, DataType alpha_=DataType(1))
Constructor.
const TestSpace_ & test_space
a reference to the finite element space to be used as test-space
const BilinearOperator_ & bilinear_operator
a reference to the bilinear operator that is to be assembled
const TrialSpace_ & trial_space
a reference to the finite element space to be used as trial-space
Cubature::DynamicFactory cubature_factory
the cubature factory to be used for integration
Matrix_ & matrix
a reference to the matrix that is to be assembled
AsmTraits::template TLocalVector< ValueType > local_vector
the local vector to be assembled
AsmTraits::CubatureRuleType cubature_rule
the cubature rule used for integration
const AsmTraits::TrafoType & trafo
the cubature factory used for integration
Assembly::AsmTraits1< DataType, Space_, TrafoTags::jac_det, space_tags > AsmTraits
our assembly traits
static constexpr bool need_scatter
this task doesn't need to scatter
Assembly job for the integration of a discrete finite element function.
DomainAssemblyDiscreteFunctionIntegralJob(const Vector_ &vector, const Space_ &space, const String &cubature)
Constructor.
const Vector_ & _vector
the vector that is to be integrated
const Space_ & _space
the finite element space to be used
Assembly::AsmTraits1< DataType, Space_, trafo_config, space_tags > AsmTraits
our assembly traits
AsmTraits::template TLocalVector< ValueType > local_vector
the local vector to be assembled
static constexpr bool need_scatter
this task doesn't need to scatter
AsmTraits::TrafoEvalData trafo_data
the trafo evaluation data
AsmTraits::CubatureRuleType cubature_rule
the cubature rule used for integration
AsmTraits::SpaceEvalData space_data
the space evaluation data
Function_::template Evaluator< AnalyticEvalTraits > func_eval
the function evaluator
const AsmTraits::TrafoType & trafo
the cubature factory used for integration
Assembly job for the integration of a analytic vs discrete error function.
const Vector_ & _vector
the vector that is to be integrated
const Function_ & _function
the function to be integrated
DomainAssemblyErrorFunctionIntegralJob(const Function_ &function, const Vector_ &vector, const Space_ &space, const String &cubature)
Constructor.
const Space_ & _space
the finite element space to be used
Analytic::EvalTraits< DataType, Function_ > AnalyticEvalTraits
declare our analytic eval traits
DiscreteFunctionIntegral< Vector_, Space_ >::Type FunctionIntegralType
make sure that function and vector are compatible
Vector_::ValueType ValueType
the value-type of the vector
Cubature::DynamicFactory _cubature_factory
the cubature factory
AnalyticEvalTraits::ValueType func_value
the function value in the current point
Function_::template Evaluator< AnalyticEvalTraits > func_eval
the function evaluator
DomainAssemblyBasicVectorTaskCRTP< Task, Vector_, Space_, trafo_config, test_config > BaseClass
our base-class typedef
Analytic::EvalTraits< DataType, Function_ > AnalyticEvalTraits
declare our analytic eval traits
Vector assembly job for a force functional represented by an analytic function.
const Function_ & function
a reference to the linear functional that is to be assembled
Vector_ & vector
a reference to the vector that is to be assembled
Cubature::DynamicFactory cubature_factory
the cubature factory to be used for integration
const Space_ & space
a reference to the finite element space to be used as test-/trial-space
DomainAssemblyForceFunctionalVectorJob(const Function_ &function_, Vector_ &vector_, const Space_ &space_, const String &cubature_, DataType alpha_=DataType(1))
Constructor.
LinearFunctional_::template Evaluator< AsmTraits > func_eval
the bilinear operator evaluator
DomainAssemblyBasicVectorTaskCRTP< Task, Vector_, Space_, trafo_config, test_config > BaseClass
our base-class typedef
Vector assembly job for LinearFunctional implementations.
Cubature::DynamicFactory cubature_factory
the cubature factory to be used for integration
Vector_ & vector
a reference to the vector that is to be assembled
DomainAssemblyLinearFunctionalVectorJob(const LinearFunctional_ &linear_functional_, Vector_ &vector_, const Space_ &space_, const String &cubature_, DataType alpha_=DataType(1))
Constructor.
const LinearFunctional_ & linear_functional
a reference to the linear functional that is to be assembled
const Space_ & space
a reference to the finite element space to be used as test-/trial-space
void format()
Reset all elements of the container to a given value or zero if missing.
Definition: container.hpp:831
Blocked Dense data vector class template.
Dense data vector class template.
Typed memory view class.
String class implementation.
Definition: string.hpp:47
Tiny Vector class template.
void assemble_force_function_vector(DomainAssembler< Trafo_ > &dom_asm, Vector_ &vector, const Function_ &function, const Space_ &space, const String &cubature, const typename Vector_::DataType alpha=typename Vector_::DataType(1))
Assembles a force function into a vector.
void assemble_linear_functional_vector(DomainAssembler< Trafo_ > &dom_asm, Vector_ &vector, const LinFunc_ &linear_functional, const Space_ &space, const String &cubature, const typename Vector_::DataType alpha=typename Vector_::DataType(1))
Assembles a linear functional into a vector.
void assemble_bilinear_operator_matrix_2(DomainAssembler< Trafo_ > &dom_asm, Matrix_ &matrix, const BilOp_ &bilinear_operator, const TestSpace_ &test_space, const TrialSpace_ &trial_space, const String &cubature, const typename Matrix_::DataType alpha=typename Matrix_::DataType(1))
Assembles a bilinear operator into a matrix with different test- and trial-spaces.
AnalyticFunctionIntegral< DataType_, Function_ >::Type integrate_analytic_function(DomainAssembler< Trafo_ > &dom_asm, const Function_ &function, const String &cubature)
Assembles the integral of an analytic function.
void assemble_bilinear_operator_matrix_1(DomainAssembler< Trafo_ > &dom_asm, Matrix_ &matrix, const BilOp_ &bilinear_operator, const Space_ &space, const String &cubature, const typename Matrix_::DataType alpha=typename Matrix_::DataType(1))
Assembles a bilinear operator into a matrix with identical test- and trial-spaces.
DiscreteFunctionIntegral< Vector_, Space_ >::Type integrate_error_function(DomainAssembler< Trafo_ > &dom_asm, const Function_ &function, const Vector_ &vector, const Space_ &space, const String &cubature)
Assembles the integral of an (analytic - discrete) error function.
void assemble_bilinear_operator_apply_vector_1(DomainAssembler< Trafo_ > &dom_asm, Vector_ &vector, const VectorSol_ &vec_sol, const BilOp_ &bilinear_operator, const Space_ &space, const String &cubature, const typename Vector_::DataType alpha=typename Vector_::DataType(1))
Assembles the application of a bilinear operator into a vector with identical test- and trial-spaces.
DiscreteFunctionIntegral< Vector_, Space_ >::Type integrate_discrete_function(DomainAssembler< Trafo_ > &dom_asm, const Vector_ &vector, const Space_ &space, const String &cubature)
Assembles the integral of a discrete finite element function.
CUDA_HOST_DEVICE void axpy(T_ &y, const T_ &x, const T_ &alpha)
Performs an AXPY of two scalars.
FEAT namespace.
Definition: adjactor.hpp:12
SpaceTags
Space configuration tags enum.
Definition: eval_tags.hpp:97
@ value
specifies whether the space should supply basis function values
@ hess
specifies whether the space should supply basis function hessians
@ grad
specifies whether the space should supply basis function gradients
std::uint64_t Index
Index data type.
TrafoTags
Trafo configuration tags enum.
Definition: eval_tags.hpp:22
@ img_point
specifies whether the trafo should supply image point coordinates
@ jac_det
specifies whether the trafo should supply jacobian determinants
Helper class to determine the FunctionIntegralInfo type for discrete functions.