FEAT 3
Finite Element Analysis Toolbox
Loading...
Searching...
No Matches
burgers_assembly_job.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/base.hpp>
9#include <kernel/assembly/asm_traits.hpp>
10#include <kernel/cubature/dynamic_factory.hpp>
11#include <kernel/lafem/dense_vector.hpp>
12#include <kernel/lafem/sparse_matrix_bcsr.hpp>
13#include <kernel/lafem/dense_vector_blocked.hpp>
14#include <kernel/global/vector.hpp>
15
16namespace FEAT
17{
18 namespace Assembly
19 {
100 template<typename DataType_, typename Space_, typename ConvVector_>
102 {
103 public:
105 typedef DataType_ DataType;
106
108 typedef Space_ SpaceType;
109
111 typedef ConvVector_ ConvVectorType;
112
115
117 DataType_ nu;
118
120 DataType_ theta;
121
123 DataType_ beta;
124
126 DataType_ frechet_beta;
127
129 DataType_ sd_delta;
130
132 DataType_ sd_nu;
133
135 DataType_ sd_v_norm;
136
138 const ConvVector_& convection_vector;
139
141 const Space_& space;
142
145
147 DataType_ alpha;
148
149 public:
162 explicit BurgersAssemblyJobBase(const ConvVector_& conv_vector, const Space_& space_, const String& cubature) :
163 deformation(false),
164 nu(DataType_(0)),
165 theta(DataType_(0)),
166 beta(DataType_(0)),
167 frechet_beta(DataType_(0)),
168 sd_delta(DataType_(0)),
169 sd_nu(DataType_(0)),
170 sd_v_norm(DataType_(0)),
171 convection_vector(conv_vector),
172 space(space_),
173 cubature_factory(cubature),
174 alpha(DataType_(1))
175 {
176 }
177
187 template<typename IndexType_, int conv_dim_>
189 {
190 const auto* vals = convect.elements();
191 DataType_ r = DataType_(0);
192 for(Index i(0); i < convect.size(); ++i)
193 r = Math::max(r, vals[i].norm_euclid());
194 return r;
195 }
196
209 template<typename LocalVector_, typename Mirror_>
211 {
212 const auto* gate = convect.get_gate();
213 if(gate != nullptr)
214 return gate->max(calc_sd_v_norm(convect.local()));
215 else
216 return calc_sd_v_norm(convect.local());
217 }
218
225 template<typename VectorType_>
226 void set_sd_v_norm(const VectorType_& convect)
227 {
228 this->sd_v_norm = calc_sd_v_norm(convect);
229 }
230 }; // class BurgersAssemblyJobBase<...>
231
257 template<typename Job_, typename DataType_>
259 {
260 public:
262 static constexpr bool need_scatter = true;
264 static constexpr bool need_combine = false;
265
267 typedef DataType_ DataType;
268
270 typedef typename Job_::SpaceType SpaceType;
271
273 typedef typename Job_::ConvVectorType ConvVectorType;
274
276 static constexpr int shape_dim = SpaceType::shape_dim;
277
279 static constexpr int conv_dim = ConvVectorType::BlockSize;
280
283
285 const Job_& job;
286
289
291 const bool deformation;
292
295
298
301
304
307
310
313
316
318 const bool need_diff, need_conv, need_conv_frechet, need_reac, need_streamdiff;
319
321 bool need_loc_v, need_loc_grad_v, need_mean_v, need_local_h;
322
340 typename ConvVectorType::GatherAxpy gather_conv;
341
343 static constexpr int max_local_dofs = AsmTraits::max_local_test_dofs;
344
347
350
353
356
359
362
365
368
369 public:
376 explicit BurgersAssemblyTaskBase(const Job_& job_) :
377 job(job_),
378 tol_eps(Math::sqrt(Math::eps<DataType>())),
380 nu(job_.nu),
381 theta(job_.theta),
382 beta(job_.beta),
384 sd_delta(job_.sd_delta),
385 sd_nu(job_.sd_nu),
386 sd_v_norm(job_.sd_v_norm),
387 alpha(job_.alpha),
388 need_diff(Math::abs(nu) > DataType(0)),
389 need_conv(Math::abs(beta) > DataType(0)),
390 need_conv_frechet(Math::abs(frechet_beta) > DataType(0)),
391 need_reac(Math::abs(theta) > DataType(0)),
392 need_streamdiff((Math::abs(sd_delta) > DataType(0)) && (sd_v_norm > tol_eps)),
393 need_loc_v(need_conv),
394 need_loc_grad_v(need_conv_frechet),
395 need_mean_v(need_streamdiff),
396 need_local_h(need_streamdiff),
397 space(job_.space),
398 trafo(space.get_trafo()),
402 cubature_rule(Cubature::ctor_factory, job_.cubature_factory),
403 trafo_data(),
404 space_data(),
405 gather_conv(job_.convection_vector),
408 loc_v(),
409 mean_v(),
410 loc_grad_v(),
412 barycenter(),
413 local_h(DataType(0)),
415 {
416 // compute reference element barycenter
417 for(int i(0); i < shape_dim; ++i)
419 }
420
427 void prepare(const Index cell)
428 {
429 // prepare dof mapping
430 dof_mapping.prepare(cell);
431
432 // prepare trafo evaluator
433 trafo_eval.prepare(cell);
434
435 // prepare space evaluator
436 space_eval.prepare(trafo_eval);
437
438 // fetch number of local dofs
439 num_local_dofs = space_eval.get_num_local_dofs();
440
441 // gather our local convection dofs
442 local_conv_dofs.format();
444
445 // compute mesh width if necessary
446 if(need_mean_v || need_local_h || need_streamdiff)
447 {
448 // reset local h and delta
450
451 // evaluate trafo and space at barycenter
454
455 // compute velocity at barycenter
456 mean_v.format();
457 for(int i(0); i < num_local_dofs; ++i)
458 mean_v.axpy(space_data.phi[i].value, local_conv_dofs[i]);
459
460 // compute norm of mean velocity
461 const DataType local_norm_v = mean_v.norm_euclid();
462
463 // do we have a non-zero velocity?
464 if(local_norm_v > tol_eps)
465 {
466 // compute local mesh width w.r.t. mean velocity
467 local_h = trafo_eval.width_directed(mean_v) * local_norm_v;
468
469 // compute local Re_T
470 const DataType local_re = (local_norm_v * local_h) / this->sd_nu;
471
472 // compute local delta
473 local_delta = this->sd_delta * (local_h / this->sd_v_norm) * (DataType(2)*local_re) / (DataType(1) + local_re);
474 }
475 }
476 }
477
488 void prepare_point(int cubature_point)
489 {
490 // compute trafo data
491 trafo_eval(trafo_data, cubature_rule.get_point(cubature_point));
492
493 // compute basis function data
495
496 // evaluate convection function and its gradient (if required)
497 if(need_loc_v || need_conv || need_streamdiff)
498 {
499 loc_v.format();
500 for(int i(0); i < num_local_dofs; ++i)
501 {
502 // update velocity value
503 loc_v.axpy(space_data.phi[i].value, local_conv_dofs[i]);
504 }
505 }
506 if(need_loc_grad_v || need_conv_frechet)
507 {
509 for(int i(0); i < num_local_dofs; ++i)
510 {
511 // update velocity gradient
513 }
514 }
515
516 // evaluate streamline diffusion coefficients
517 if(need_streamdiff)
518 {
519 for(int i(0); i < num_local_dofs; ++i)
520 {
521 streamdiff_coeffs[i] = Tiny::dot(loc_v, space_data.phi[i].grad);
522 }
523 }
524 }
525
529 void finish()
530 {
531 // finish evaluators
532 space_eval.finish();
533 trafo_eval.finish();
534
535 // finish dof mapping
536 dof_mapping.finish();
537 }
538
542 void combine()
543 {
544 // nothing to do here
545 }
546 }; // class BurgersAssemblyTaskBase<...>
547
567 template<typename Job_, typename DataType_, int block_size_>
569 public BurgersAssemblyTaskBase<Job_, DataType_>
570 {
571 public:
573
574 typedef DataType_ DataType;
575
578
579 protected:
583 LocalMatrixType local_matrix;
584
585 public:
592 explicit BurgersBlockedAssemblyTaskBase(const Job_& job_) :
593 BaseClass(job_),
594 local_matrix()
595 {
596 }
597
604 void assemble_burgers_point(const DataType weight)
605 {
606 // assemble diffusion matrix?
607 if(this->need_diff)
608 {
609 // assemble gradient-tensor diffusion
610
611 // test function loop
612 for(int i(0); i < this->num_local_dofs; ++i)
613 {
614 // trial function loop
615 for(int j(0); j < this->num_local_dofs; ++j)
616 {
617 // compute scalar value
618 const DataType value = this->nu * weight * Tiny::dot(this->space_data.phi[i].grad, this->space_data.phi[j].grad);
619
620 // update local matrix
621 local_matrix[i][j].add_scalar_main_diag(value);
622 }
623 }
624
625 // assemble deformation tensor?
626 if(this->deformation)
627 {
628 // test function loop
629 for(int i(0); i < this->num_local_dofs; ++i)
630 {
631 // trial function loop
632 for(int j(0); j < this->num_local_dofs; ++j)
633 {
634 // add outer product of grad(phi) and grad(psi)
635 local_matrix[i][j].add_outer_product(this->space_data.phi[j].grad, this->space_data.phi[i].grad, this->nu * weight);
636 }
637 }
638 }
639 }
640
641 // assemble convection?
642 if(this->need_conv)
643 {
644 // test function loop
645 for(int i(0); i < this->num_local_dofs; ++i)
646 {
647 // trial function loop
648 for(int j(0); j < this->num_local_dofs; ++j)
649 {
650 // compute scalar value
651 const DataType value = this->beta * weight * this->space_data.phi[i].value * Tiny::dot(this->loc_v, this->space_data.phi[j].grad);
652
653 // update local matrix
654 local_matrix[i][j].add_scalar_main_diag(value);
655 }
656 }
657 }
658
659 // assemble convection Frechet?
660 if(this->need_conv_frechet)
661 {
662 // test function loop
663 for(int i(0); i < this->num_local_dofs; ++i)
664 {
665 // trial function loop
666 for(int j(0); j < this->num_local_dofs; ++j)
667 {
668 // compute scalar value
669 const DataType value = this->frechet_beta * weight * this->space_data.phi[i].value * this->space_data.phi[j].value;
670
671 // update local matrix
672 local_matrix[i][j].axpy(value, this->loc_grad_v);
673 }
674 }
675 }
676
677 // assemble reaction?
678 if(this->need_reac)
679 {
680 // test function loop
681 for(int i(0); i < this->num_local_dofs; ++i)
682 {
683 // trial function loop
684 for(int j(0); j < this->num_local_dofs; ++j)
685 {
686 // compute scalar value
687 const DataType value = this->theta * weight * this->space_data.phi[i].value * this->space_data.phi[j].value;
688
689 // update local matrix
690 local_matrix[i][j].add_scalar_main_diag(value);
691 }
692 }
693 }
694 }
695
702 void assemble_streamline_diffusion(const DataType weight)
703 {
704 // assemble streamline diffusion?
705 if(this->need_streamdiff && (this->local_delta > this->tol_eps))
706 {
707 // test function loop
708 for(int i(0); i < this->num_local_dofs; ++i)
709 {
710 // trial function loop
711 for(int j(0); j < this->num_local_dofs; ++j)
712 {
713 // compute scalar value
714 const DataType value = this->local_delta * weight * this->streamdiff_coeffs[i] * this->streamdiff_coeffs[j];
715
716 // update local matrix
717 local_matrix[i][j].add_scalar_main_diag(value);
718 }
719 }
720 }
721 }
722
726 void assemble()
727 {
728 local_matrix.format();
729
730 // loop over all quadrature points and integrate
731 for(int point(0); point < this->cubature_rule.get_num_points(); ++point)
732 {
733 // prepare trafo and space for cubature point
734 this->prepare_point(point);
735
736 // precompute cubature weight
737 const DataType weight = this->trafo_data.jac_det * this->cubature_rule.get_weight(point);
738
739 // assemble the Burgers operator
740 this->assemble_burgers_point(weight);
741
742 // assemble the streamline diffusion
743 this->assemble_streamline_diffusion(weight);
744 } // continue with next cubature point
745 }
746 }; // class BurgersBlockedAssemblyTaskBase<...>
747
768 template<typename Matrix_, typename Space_, typename ConvVector_ = typename Matrix_::VectorTypeR>
770 public BurgersAssemblyJobBase<typename Matrix_::DataType, Space_, ConvVector_>
771 {
772 public:
774 typedef Matrix_ MatrixType;
776 typedef typename MatrixType::DataType DataType;
777
780
781 // no nonsense, please
782 static_assert(Matrix_::BlockHeight == Matrix_::BlockWidth, "only square matrix blocks are supported here");
783
785 static constexpr int block_size = Matrix_::BlockHeight;
786
789
790 public:
806 explicit BurgersBlockedMatrixAssemblyJob(Matrix_& matrix_, const ConvVector_& conv_vector,
807 const Space_& space_, const String& cubature_name) :
808 BaseClass(conv_vector, space_, cubature_name),
809 matrix(matrix_)
810 {
811 }
812
813 public:
815 class Task :
816 public BurgersBlockedAssemblyTaskBase<BurgersBlockedMatrixAssemblyJob, DataType, block_size>
817 {
818 public:
820
821 protected:
823 typename MatrixType::ScatterAxpy scatter_matrix;
824
825 public:
827 explicit Task(const BurgersBlockedMatrixAssemblyJob& job_) :
828 BaseClass(job_),
830 {
831 }
832
833 // prepare, assemble and finish are already implemented in the base classes
834
836 void scatter()
837 {
838 this->scatter_matrix(this->local_matrix, this->dof_mapping, this->dof_mapping, this->alpha);
839 }
840 }; // class BurgersBlockedMatrixAssemblyJob::Task
841 }; // class BurgersBlockedMatrixAssemblyJob
842
863 template<typename Vector_, typename Space_, typename ConvVector_ = Vector_>
865 public BurgersAssemblyJobBase<typename Vector_::DataType, Space_, ConvVector_>
866 {
867 public:
869 typedef Vector_ VectorType;
871 typedef typename VectorType::DataType DataType;
872
875
877 static constexpr int block_size = Vector_::BlockSize;
878
881
882 public:
898 explicit BurgersBlockedDiagonalAssemblyJob(Vector_& vector_, const ConvVector_& conv_vector,
899 const Space_& space_, const String& cubature_name) :
900 BaseClass(conv_vector, space_, cubature_name),
901 vector(vector_)
902 {
903 }
904
905 public:
907 class Task :
908 public BurgersBlockedAssemblyTaskBase<BurgersBlockedDiagonalAssemblyJob, DataType, block_size>
909 {
910 public:
912
913 protected:
914 Vector_& vector;
915
916 public:
919 BaseClass(job_),
920 vector(job_.vector)
921 {
922 }
923
924 // prepare, assemble and finish are already implemented in the base classes
925
927 void scatter()
928 {
929 auto* val_vec = vector.elements();
930 for(int loc_i = 0; loc_i < this->dof_mapping.get_num_local_dofs(); ++loc_i)
931 {
932 const Index cur_i = this->dof_mapping.get_index(loc_i);
933 for(int k = 0; k < block_size; ++k)
934 val_vec[cur_i][k] += this->local_matrix[loc_i][loc_i][k][k] * this->alpha;
935 }
936 }
937 }; // class BurgersBlockedMatrixAssemblyJob::Task
938 }; // class BurgersBlockedMatrixAssemblyJob
939
960 template<typename Vector_, typename Space_, typename ConvVector_ = Vector_>
962 public BurgersAssemblyJobBase<typename Vector_::DataType, Space_, ConvVector_>
963 {
964 public:
966 typedef Vector_ VectorType;
968 typedef typename VectorType::DataType DataType;
969
972
974 static constexpr int block_size = Vector_::BlockSize;
975
978
981
982 public:
1003 explicit BurgersBlockedVectorAssemblyJob(Vector_& rhs_vector_, const Vector_& sol_vector_,
1004 const ConvVector_& conv_vector, const Space_& space_, const String& cubature_name) :
1005 BaseClass(conv_vector, space_, cubature_name),
1006 vector_rhs(rhs_vector_),
1007 vector_sol(sol_vector_)
1008 {
1009 XASSERTM(&rhs_vector_ != &sol_vector_, "rhs and solution vectors must not be the same object");
1010 // compare void addresses to avoid warnings in case the classes are different
1011 XASSERTM((void*)&rhs_vector_ != (void*)&conv_vector, "rhs and convection vectors must not be the same object");
1012 }
1013
1014 public:
1016 class Task :
1017 public BurgersBlockedAssemblyTaskBase<BurgersBlockedVectorAssemblyJob, DataType, block_size>
1018 {
1019 public:
1021
1023
1024 protected:
1026 typename VectorType::GatherAxpy gather_vec_sol;
1028 typename VectorType::ScatterAxpy scatter_vec_rhs;
1031
1034
1037
1038 public:
1041 BaseClass(job_),
1044 sol_equals_conv((void*)&job_.vector_sol == (void*)&job_.convection_vector),
1046 local_vector()
1047 {
1048 }
1049
1050 void prepare(const Index cell)
1051 {
1052 BaseClass::prepare(cell);
1053
1054 // gather local solution dofs if required
1055 if(!sol_equals_conv)
1056 {
1057 this->local_sol_dofs.format();
1058 this->gather_vec_sol(this->local_sol_dofs, this->dof_mapping);
1059 }
1060 }
1061
1066 {
1067 local_vector.format();
1068
1069 // compute local vector from local matrix and sol vector dofs
1070 if(!sol_equals_conv)
1071 {
1072 for(int i(0); i < this->num_local_dofs; ++i)
1073 for(int j(0); j < this->num_local_dofs; ++j)
1074 this->local_vector[i].add_mat_vec_mult(this->local_matrix(i,j), this->local_sol_dofs[j]);
1075 }
1076 else
1077 {
1078 for(int i(0); i < this->num_local_dofs; ++i)
1079 for(int j(0); j < this->num_local_dofs; ++j)
1080 this->local_vector[i].add_mat_vec_mult(this->local_matrix(i,j), this->local_conv_dofs[j]);
1081 }
1082 }
1083
1084 void assemble()
1085 {
1086 // assemble the local matrix
1088
1089 // compute the local vector from the matrix
1091 }
1092
1094 void scatter()
1095 {
1096 this->scatter_vec_rhs(this->local_vector, this->dof_mapping, this->alpha);
1097 }
1098 }; // class BurgersBlockedVectorAssemblyJob::Task
1099 }; // class BurgersBlockedVectorAssemblyJob<...>
1100
1117 template<typename Job_, typename DataType_>
1119 public BurgersAssemblyTaskBase<Job_, DataType_>
1120 {
1121 public:
1123
1124 typedef DataType_ DataType;
1125
1128
1129 protected:
1132 LocalMatrixType local_matrix;
1133
1134 public:
1141 explicit BurgersScalarAssemblyTaskBase(const Job_& job_) :
1142 BaseClass(job_),
1143 local_matrix()
1144 {
1145 }
1146
1153 void assemble_burgers_point(const DataType weight)
1154 {
1155 // assemble diffusion matrix?
1156 if(this->need_diff)
1157 {
1158 // assemble gradient-tensor diffusion
1159
1160 // test function loop
1161 for(int i(0); i < this->num_local_dofs; ++i)
1162 {
1163 // trial function loop
1164 for(int j(0); j < this->num_local_dofs; ++j)
1165 {
1166 local_matrix[i][j] += this->nu * weight
1167 * Tiny::dot(this->space_data.phi[i].grad, this->space_data.phi[j].grad);
1168 }
1169 }
1170 }
1171
1172 // assemble convection?
1173 if(this->need_conv)
1174 {
1175 // test function loop
1176 for(int i(0); i < this->num_local_dofs; ++i)
1177 {
1178 // trial function loop
1179 for(int j(0); j < this->num_local_dofs; ++j)
1180 {
1181 local_matrix[i][j] += this->beta * weight
1182 * this->space_data.phi[i].value * Tiny::dot(this->loc_v, this->space_data.phi[j].grad);
1183 }
1184 }
1185 }
1186
1187 // assemble reaction?
1188 if(this->need_reac)
1189 {
1190 // test function loop
1191 for(int i(0); i < this->num_local_dofs; ++i)
1192 {
1193 // trial function loop
1194 for(int j(0); j < this->num_local_dofs; ++j)
1195 {
1196 local_matrix[i][j] += this->theta * weight
1197 * this->space_data.phi[i].value * this->space_data.phi[j].value;
1198 }
1199 }
1200 }
1201 }
1202
1209 void assemble_streamline_diffusion(const DataType weight)
1210 {
1211 // assemble streamline diffusion?
1212 if(this->need_streamdiff && (this->local_delta > this->tol_eps))
1213 {
1214 // test function loop
1215 for(int i(0); i < this->num_local_dofs; ++i)
1216 {
1217 // trial function loop
1218 for(int j(0); j < this->num_local_dofs; ++j)
1219 {
1220 local_matrix[i][j] += this->local_delta * weight
1221 * this->streamdiff_coeffs[i] * this->streamdiff_coeffs[j];
1222 }
1223 }
1224 }
1225 }
1226
1231 {
1232 local_matrix.format();
1233
1234 // loop over all quadrature points and integrate
1235 for(int point(0); point < this->cubature_rule.get_num_points(); ++point)
1236 {
1237 // prepare trafo and space for cubature point
1238 this->prepare_point(point);
1239
1240 // precompute cubature weight
1241 const DataType weight = this->trafo_data.jac_det * this->cubature_rule.get_weight(point);
1242
1243 // assemble the Burgers operator
1244 this->assemble_burgers_point(weight);
1245
1246 // assembles the streamline diffusion stabilization
1247 this->assemble_streamline_diffusion(weight);
1248 } // continue with next cubature point
1249 }
1250 }; // class BurgersScalarAssemblyTaskBase<...>
1251
1272 template<typename Matrix_, typename Space_, typename ConvVector_>
1274 public BurgersAssemblyJobBase<typename Matrix_::DataType, Space_, ConvVector_>
1275 {
1276 public:
1278 typedef Matrix_ MatrixType;
1280 typedef typename MatrixType::DataType DataType;
1281
1284
1287
1288 public:
1304 explicit BurgersScalarMatrixAssemblyJob(Matrix_& matrix_, const ConvVector_& conv_vector,
1305 const Space_& space_, const String& cubature_name) :
1306 BaseClass(conv_vector, space_, cubature_name),
1307 matrix(matrix_)
1308 {
1309 }
1310
1311 public:
1313 class Task :
1314 public BurgersScalarAssemblyTaskBase<BurgersScalarMatrixAssemblyJob, DataType>
1315 {
1316 public:
1318
1319 protected:
1321 typename MatrixType::ScatterAxpy scatter_matrix;
1322
1323 public:
1325 explicit Task(const BurgersScalarMatrixAssemblyJob& job_) :
1326 BaseClass(job_),
1328 {
1329 }
1330
1331 // prepare, assemble and finish are already implemented in the base classes
1332
1334 void scatter()
1335 {
1336 this->scatter_matrix(this->local_matrix, this->dof_mapping, this->dof_mapping, this->alpha);
1337 }
1338 }; // class BurgersScalarMatrixAssemblyJob::Task
1339 }; // class BurgersScalarMatrixAssemblyJob
1340
1361 template<typename Vector_, typename Space_, typename ConvVector_>
1363 public BurgersAssemblyJobBase<typename Vector_::DataType, Space_, ConvVector_>
1364 {
1365 public:
1367 typedef Vector_ VectorType;
1369 typedef typename VectorType::DataType DataType;
1370
1373
1376
1379
1380 public:
1401 explicit BurgersScalarVectorAssemblyJob(Vector_& rhs_vector_, const Vector_& sol_vector_,
1402 const ConvVector_& conv_vector, const Space_& space_, const String& cubature_name) :
1403 BaseClass(conv_vector, space_, cubature_name),
1404 vector_rhs(rhs_vector_),
1405 vector_sol(sol_vector_)
1406 {
1407 XASSERTM(&rhs_vector_ != &sol_vector_, "rhs and solution vectors must not be the same object");
1408 }
1409
1410 public:
1412 class Task :
1413 public BurgersScalarAssemblyTaskBase<BurgersScalarVectorAssemblyJob, DataType>
1414 {
1415 public:
1417
1419
1420 protected:
1422 typename VectorType::GatherAxpy gather_vec_sol;
1424 typename VectorType::ScatterAxpy scatter_vec_rhs;
1425
1428
1431
1432 public:
1434 explicit Task(const BurgersScalarVectorAssemblyJob& job_) :
1435 BaseClass(job_),
1439 local_vector()
1440 {
1441 }
1442
1443 void prepare(const Index cell)
1444 {
1445 BaseClass::prepare(cell);
1446
1447 // gather local solution vector dofs
1448 this->local_sol_dofs.format();
1449 this->gather_vec_sol(this->local_sol_dofs, this->dof_mapping);
1450 }
1451
1456 {
1457 // compute local vector from local matrix and sol vector dofs
1458 this->local_vector.format();
1459 for(int i(0); i < this->num_local_dofs; ++i)
1460 for(int j(0); j < this->num_local_dofs; ++j)
1461 this->local_vector[i] += this->local_matrix(i,j) * this->local_sol_dofs[j];
1462 //this->local_vector.set_mat_vec_mult(this->local_matrix, this->local_sol_dofs);
1463 }
1464
1465 void assemble()
1466 {
1467 // assemble the local matrix
1469
1470 // compute local vector from the matrix
1472 }
1473
1475 void scatter()
1476 {
1477 this->scatter_vec_rhs(this->local_vector, this->dof_mapping, this->alpha);
1478 }
1479 }; // class BurgersScalarVectorAssemblyJob::Task
1480 }; // class BurgersScalarVectorAssemblyJob<...>
1481 } // namespace Assembly
1482} // 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
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
Base class for Burgers assembly jobs.
const ConvVector_ & convection_vector
the convection vector to be used
ConvVector_ ConvVectorType
the convection vector type
DataType_ sd_delta
scaling parameter for streamline diffusion stabilization operator S
static DataType calc_sd_v_norm(const Global::Vector< LocalVector_, Mirror_ > &convect)
Calculates the convection field norm for the streamline diffusion parameter delta_T.
void set_sd_v_norm(const VectorType_ &convect)
Sets the convection field norm for the local streamline diffusion parameter delta_T.
DataType_ beta
scaling parameter for convective operator K
DataType_ frechet_beta
scaling parameter for Frechet derivative of convective operator K'
bool deformation
specifies whether to use the deformation tensor
Cubature::DynamicFactory cubature_factory
the cubature factory to use
BurgersAssemblyJobBase(const ConvVector_ &conv_vector, const Space_ &space_, const String &cubature)
Constructor.
DataType_ nu
scaling parameter for diffusive operator L (aka viscosity)
static DataType calc_sd_v_norm(const LAFEM::DenseVectorBlocked< DataType_, IndexType_, conv_dim_ > &convect)
Calculates the convection field norm for the local streamline diffusion parameter delta_T.
DataType_ DataType
the datatype we use here
DataType_ sd_v_norm
velocity norm for streamline diffusion
const Space_ & space
the test-/trial-space to be used
DataType_ sd_nu
viscosity parameter nu_S for streamline diffusion (usually equal to nu)
DataType_ theta
scaling parameter for reactive operator M
Base class for Burgers assembly tasks.
static constexpr int max_local_dofs
maximum number of local dofs
AsmTraits::CubatureRuleType cubature_rule
the cubature rule used for integration
Tiny::Vector< DataType, shape_dim > barycenter
reference element barycenter
const AsmTraits::TrafoType & trafo
the cubature factory used for integration
const DataType tol_eps
tolerance for checks == 0: sqrt(eps)
void prepare(const Index cell)
Prepares the assembly task for a cell/element.
AsmTraits::TrafoEvaluator trafo_eval
the trafo evaluator
AsmTraits1< DataType, SpaceType, TrafoTags::jac_det, SpaceTags::value|SpaceTags::grad > AsmTraits
our assembly traits
ConvVectorType::GatherAxpy gather_conv
convection vector gather-axpy object
DataType local_delta
local delta for streamline diffusion
const DataType sd_nu
viscosity parameter nu_S for streamline diffusion (usually equal to nu)
const SpaceType & space
the test-/trial-space to be used
void finish()
Finishes the assembly on the current cell.
const DataType alpha
scatter scaling parameter
const DataType sd_delta
scaling parameter for streamline diffusion stabilization operator S
Tiny::Matrix< DataType, conv_dim, conv_dim > loc_grad_v
local convection field gradient
const DataType nu
scaling parameter for diffusive operator L (aka viscosity)
const Job_ & job
a reference to our job object
const DataType theta
scaling parameter for reactive operator M
const bool deformation
specifies whether to use the deformation tensor
Tiny::Vector< DataType, max_local_dofs > streamdiff_coeffs
local streamline diffusion coefficients
BurgersAssemblyTaskBase(const Job_ &job_)
Constructor.
DataType_ DataType
the data type to be used by the assembly
static constexpr bool need_combine
this task doesn't need to combine
static constexpr int conv_dim
the convection vector dimension
Tiny::Vector< Tiny::Vector< DataType, conv_dim >, max_local_dofs > local_conv_dofs
local convection field dofs
int num_local_dofs
actual number of local dofs on current element
AsmTraits::SpaceEvaluator space_eval
the space evaluator
Tiny::Vector< DataType, conv_dim > loc_v
local convection field value
static constexpr bool need_scatter
this task needs to scatter
bool need_loc_v
enable computation of certain quantities
AsmTraits::DofMapping dof_mapping
the space dof-mapping
AsmTraits::TrafoEvalData trafo_data
the trafo evaluation data
const DataType frechet_beta
scaling parameter for Frechet derivative of convective operator K'
DataType local_h
local mesh width for streamline diffusion
const DataType sd_v_norm
velocity norm for streamline diffusion
void prepare_point(int cubature_point)
Prepares the task for a cubature point.
const bool need_diff
keep track what we need to assemble
Job_::ConvVectorType ConvVectorType
the convection vector type
static constexpr int shape_dim
the shape dimension
AsmTraits::SpaceEvalData space_data
the space evaluation data
const DataType beta
scaling parameter for convective operator K
Base class for blocked Burgers assembly tasks.
BurgersBlockedAssemblyTaskBase(const Job_ &job_)
Constructor.
void assemble()
Performs the assembly of the local matrix.
void assemble_streamline_diffusion(const DataType weight)
Assembles the Streamline Diffusion stabilization operator in a single cubature point.
Tiny::Matrix< DataType_, block_size_, block_size_ > MatrixValue
our local matrix data
void assemble_burgers_point(const DataType weight)
Assembles the Burger operator in a single cubature point.
int num_local_dofs
actual number of local dofs on current element
Task(const BurgersBlockedDiagonalAssemblyJob &job_)
constructor
Burgers assembly job for diagonal of block matrix.
VectorType & vector
the matrix to be assembled
BurgersAssemblyJobBase< DataType, Space_, ConvVector_ > BaseClass
our base class
BurgersBlockedDiagonalAssemblyJob(Vector_ &vector_, const ConvVector_ &conv_vector, const Space_ &space_, const String &cubature_name)
Constructor.
MatrixType::ScatterAxpy scatter_matrix
matrix scatter-axpy object
Task(const BurgersBlockedMatrixAssemblyJob &job_)
constructor
Burgers assembly job for block matrix.
BurgersBlockedMatrixAssemblyJob(Matrix_ &matrix_, const ConvVector_ &conv_vector, const Space_ &space_, const String &cubature_name)
Constructor.
MatrixType & matrix
the matrix to be assembled
BurgersAssemblyJobBase< DataType, Space_, ConvVector_ > BaseClass
our base class
void compute_local_vector()
Computes the local vector by multiplying the local matrix by the solution vector.
const bool sol_equals_conv
specifies whether the solution vector and the convection vector are the same object
Task(const BurgersBlockedVectorAssemblyJob &job_)
constructor
Tiny::Vector< Tiny::Vector< DataType, block_size >, max_local_dofs > local_sol_dofs
local solution vector dofs
Tiny::Vector< Tiny::Vector< DataType, block_size >, max_local_dofs > local_vector
local rhs vector dofs
VectorType::ScatterAxpy scatter_vec_rhs
rhs vector scatter-axpy object
VectorType::GatherAxpy gather_vec_sol
sol vector gather-axpy object
Burgers assembly job for block right-hand-side vector.
BurgersBlockedVectorAssemblyJob(Vector_ &rhs_vector_, const Vector_ &sol_vector_, const ConvVector_ &conv_vector, const Space_ &space_, const String &cubature_name)
Constructor.
BurgersAssemblyJobBase< DataType, Space_, ConvVector_ > BaseClass
our base class
VectorType & vector_rhs
the RHS vector to be assembled
const VectorType & vector_sol
the solution vector
Base class for scalar Burgers assembly tasks.
void assemble_burgers_point(const DataType weight)
Assembles the Burger operator in a single cubature point.
void assemble_streamline_diffusion(const DataType weight)
Assembles the Streamline Diffusion stabilization operator in a single cubature point.
BurgersScalarAssemblyTaskBase(const Job_ &job_)
Constructor.
int num_local_dofs
actual number of local dofs on current element
void assemble()
Performs the assembly of the local matrix.
Tiny::Matrix< DataType, max_local_dofs, max_local_dofs > LocalMatrixType
our local matrix data
MatrixType::ScatterAxpy scatter_matrix
matrix scatter-axpy object
Task(const BurgersScalarMatrixAssemblyJob &job_)
constructor
Burgers assembly job for scalar matrix.
BurgersScalarMatrixAssemblyJob(Matrix_ &matrix_, const ConvVector_ &conv_vector, const Space_ &space_, const String &cubature_name)
Constructor.
BurgersAssemblyJobBase< DataType, Space_, ConvVector_ > BaseClass
our base class
MatrixType & matrix
the matrix to be assembled
Tiny::Vector< DataType, max_local_dofs > local_vector
local rhs vector dofs
VectorType::GatherAxpy gather_vec_sol
sol vector gather-axpy object
void compute_local_vector()
Computes the local vector by multiplying the local matrix by the solution vector.
Tiny::Vector< DataType, max_local_dofs > local_sol_dofs
local solution vector dofs
VectorType::ScatterAxpy scatter_vec_rhs
rhs vector scatter-axpy object
Task(const BurgersScalarVectorAssemblyJob &job_)
constructor
Burgers assembly job for scalar right-hand-side vector.
BurgersScalarVectorAssemblyJob(Vector_ &rhs_vector_, const Vector_ &sol_vector_, const ConvVector_ &conv_vector, const Space_ &space_, const String &cubature_name)
Constructor.
const VectorType & vector_sol
the solution vector
VectorType & vector_rhs
the RHS vector to be assembled
BurgersAssemblyJobBase< DataType, Space_, ConvVector_ > BaseClass
our base class
DataType max(DataType x) const
Computes the maximum of a scalar variable over all processes.
Definition: gate.hpp:613
Global vector wrapper class template.
Definition: vector.hpp:68
const GateType * get_gate() const
Returns a const pointer to the internal gate of the vector.
Definition: vector.hpp:149
LocalVector_ & local()
Returns a reference to the internal local LAFEM vector object.
Definition: vector.hpp:122
Blocked Dense data vector class template.
auto elements() const -> const typename Intern::DenseVectorBlockedPerspectiveHelper< DT_, BlockSize_, perspective_ >::Type *
Retrieve a pointer to the data array.
Index size() const
The number of elements.
String class implementation.
Definition: string.hpp:47
Tiny Matrix class template.
CUDA_HOST_DEVICE Matrix & add_scalar_main_diag(DataType alpha)
Adds a value onto the matrix's main diagonal.
CUDA_HOST_DEVICE Matrix & add_outer_product(const Vector< T_, m_, snx_ > &x, const Vector< T_, n_, sny_ > &y, const DataType alpha=DataType(1))
Adds the outer product of two vectors onto the matrix.
CUDA_HOST_DEVICE Matrix & axpy(DataType alpha, const Matrix< T_, m_, n_, sma_, sna_ > &a)
Adds another scaled matrix onto this matrix.
CUDA_HOST_DEVICE void format(DataType alpha=DataType(0))
Formats the matrix.
Tiny Vector class template.
CUDA_HOST_DEVICE void format(DataType alpha=DataType(0))
Formats the vector.
CUDA_HOST_DEVICE Vector & axpy(DataType alpha, const Vector< T_, n_, snx_ > &x)
Adds another scaled vector onto this vector.
CUDA_HOST_DEVICE DataType norm_euclid() const
Computes the euclid norm of this vector.
T_ max(T_ a, T_ b)
Returns the maximum of two values.
Definition: math.hpp:137
CUDA_HOST_DEVICE T_ dot(const T_ &a, const T_ &b)
Computes the dot-product of two scalars.
FEAT namespace.
Definition: adjactor.hpp:12
@ value
specifies whether the space should supply basis function values
std::uint64_t Index
Index data type.
Reference cell traits structure.
Definition: shape.hpp:230