FEAT 3
Finite Element Analysis Toolbox
Loading...
Searching...
No Matches
burgers_carreau_assembly_job.hpp
1// FEAT3: Finite Element Analysis Toolbox, Version 3
2// Copyright (C) 2010 - 2023 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#ifndef KERNEL_ASSEMBLY_BURGERS_CARREAU_ASSEMBLY_JOB_HPP
8#define KERNEL_ASSEMBLY_BURGERS_CARREAU_ASSEMBLY_JOB_HPP 1
9
10#include <kernel/assembly/base.hpp>
11#include <kernel/assembly/asm_traits.hpp>
12#include <kernel/cubature/dynamic_factory.hpp>
13#include <kernel/lafem/dense_vector.hpp>
14#include <kernel/lafem/sparse_matrix_bcsr.hpp>
15#include <kernel/lafem/dense_vector_blocked.hpp>
16#include <kernel/global/vector.hpp>
17
18namespace FEAT
19{
20 namespace Assembly
21 {
103 template<typename DataType_, typename Space_, typename ConvVector_>
105 {
106 public:
108 typedef DataType_ DataType;
109
111 typedef Space_ SpaceType;
112
114 typedef ConvVector_ ConvVectorType;
115
118
120 DataType_ nu;
121
123 DataType_ theta;
124
126 DataType_ beta;
127
129 DataType_ frechet_beta;
130
132 DataType_ sd_delta;
133
135 DataType_ sd_nu;
136
138 DataType_ sd_v_norm;
139
141 const ConvVector_& convection_vector;
142
144 const Space_& space;
145
148
151
154
156 DataType_ mu_inf, mu_0, lambda, n, a, reg_eps;
157
158 public:
171 explicit BurgersCarreauAssemblyJobBase(const ConvVector_& conv_vector, const Space_& space_, const String& cubature) :
172 deformation(false),
173 nu(DataType_(0)),
174 theta(DataType_(0)),
175 beta(DataType_(0)),
176 frechet_beta(DataType_(0)),
177 sd_delta(DataType_(0)),
178 sd_nu(DataType_(0)),
179 sd_v_norm(DataType_(0)),
180 convection_vector(conv_vector),
181 space(space_),
182 cubature_factory(cubature),
183 carreau(false),
184 frechet_carreau(false),
185 mu_inf(DataType_(0.)),
186 mu_0(DataType_(0.)),
187 lambda(DataType_(0.)),
188 n(DataType_(0.)),
189 a(DataType_(0.)),
190 reg_eps(DataType_(1e-100))
191 {
192 }
193
203 template<typename IndexType_, int conv_dim_>
205 {
206 const auto* vals = convect.elements();
207 DataType_ r = DataType_(0);
208 for(Index i(0); i < convect.size(); ++i)
209 r = Math::max(r, vals[i].norm_euclid());
210 return r;
211 }
212
225 template<typename LocalVector_, typename Mirror_>
227 {
228 const auto* gate = convect.get_gate();
229 if(gate != nullptr)
230 return gate->max(calc_sd_v_norm(convect.local()));
231 else
232 return calc_sd_v_norm(convect.local());
233 }
234
241 template<typename VectorType_>
242 void set_sd_v_norm(const VectorType_& convect)
243 {
244 this->sd_v_norm = calc_sd_v_norm(convect);
245 }
246 }; // class BurgersCarreauAssemblyJobBase<...>
247
273 template<typename Job_, typename DataType_>
275 {
276 public:
278 static constexpr bool need_scatter = true;
280 static constexpr bool need_combine = false;
281
283 typedef DataType_ DataType;
284
286 typedef typename Job_::SpaceType SpaceType;
287
289 typedef typename Job_::ConvVectorType ConvVectorType;
290
292 static constexpr int shape_dim = SpaceType::shape_dim;
293
295 static constexpr int conv_dim = ConvVectorType::BlockSize;
296
299
301 const Job_& job;
302
305
307 const bool deformation;
308
311
314
317
320
323
326
329
331 const bool need_diff, need_conv, need_conv_frechet, need_reac, need_streamdiff, need_carreau, need_carreau_frechet;
332
334 DataType_ mu_inf, mu_0, lambda, n, a, reg_eps;
335
337 DataType_ gamma_dot, nu_loc;
338
340 bool need_loc_v, need_loc_grad_v, need_mean_v, need_local_h;
341
359 typename ConvVectorType::GatherAxpy gather_conv;
360
362 static constexpr int max_local_dofs = AsmTraits::max_local_test_dofs;
363
366
369
372
375
378
381
384
387
390
391 public:
398 explicit BurgersCarreauAssemblyTaskBase(const Job_& job_) :
399 job(job_),
400 tol_eps(Math::sqrt(Math::eps<DataType>())),
402 nu(job_.nu),
403 theta(job_.theta),
404 beta(job_.beta),
406 sd_delta(job_.sd_delta),
407 sd_nu(job_.sd_nu),
408 sd_v_norm(job_.sd_v_norm),
409 need_diff(Math::abs(nu) > DataType(0)),
410 need_conv(Math::abs(beta) > DataType(0)),
411 need_conv_frechet(Math::abs(frechet_beta) > DataType(0)),
412 need_reac(Math::abs(theta) > DataType(0)),
413 need_streamdiff((Math::abs(sd_delta) > DataType(0)) && (sd_v_norm > tol_eps)),
414 need_carreau(job_.carreau),
415 need_carreau_frechet(job_.frechet_carreau),
416 mu_inf(job_.mu_inf),
417 mu_0(job_.mu_0),
418 lambda(job_.lambda),
419 n(job_.n),
420 a(job_.a),
421 reg_eps(job_.reg_eps),
422 gamma_dot(),
423 nu_loc(),
424 need_loc_v(need_conv),
425 need_loc_grad_v(need_conv_frechet || need_carreau),
426 need_mean_v(need_streamdiff),
427 need_local_h(need_streamdiff),
428 space(job_.space),
429 trafo(space.get_trafo()),
433 cubature_rule(Cubature::ctor_factory, job_.cubature_factory),
434 trafo_data(),
435 space_data(),
436 gather_conv(job_.convection_vector),
439 loc_v(),
440 mean_v(),
441 loc_grad_v(),
444 barycenter(),
445 local_h(DataType(0)),
447 {
448 // compute reference element barycenter
449 for(int i(0); i < shape_dim; ++i)
451 }
452
459 void prepare(const Index cell)
460 {
461 // prepare dof mapping
462 dof_mapping.prepare(cell);
463
464 // prepare trafo evaluator
465 trafo_eval.prepare(cell);
466
467 // prepare space evaluator
468 space_eval.prepare(trafo_eval);
469
470 // fetch number of local dofs
471 num_local_dofs = space_eval.get_num_local_dofs();
472
473 // gather our local convection dofs
474 local_conv_dofs.format();
476
477 // compute mesh width if necessary
478 if(need_mean_v || need_local_h || need_streamdiff)
479 {
480 // reset local h and delta
482
483 // evaluate trafo and space at barycenter
486
487 // compute velocity at barycenter
488 mean_v.format();
489 for(int i(0); i < num_local_dofs; ++i)
490 mean_v.axpy(space_data.phi[i].value, local_conv_dofs[i]);
491
492 // compute norm of mean velocity
493 const DataType local_norm_v = mean_v.norm_euclid();
494
495 // do we have a non-zero velocity?
496 if(local_norm_v > tol_eps)
497 {
498 // compute local mesh width w.r.t. mean velocity
499 local_h = trafo_eval.width_directed(mean_v) * local_norm_v;
500
501 // compute local Re_T
502 const DataType local_re = (local_norm_v * local_h) / this->sd_nu;
503
504 // compute local delta
505 local_delta = this->sd_delta * (local_h / this->sd_v_norm) * (DataType(2)*local_re) / (DataType(1) + local_re);
506 }
507 }
508 }
509
520 void prepare_point(int cubature_point)
521 {
522 // compute trafo data
523 trafo_eval(trafo_data, cubature_rule.get_point(cubature_point));
524
525 // compute basis function data
527
528 // evaluate convection function and its gradient (if required)
529 if(need_loc_v || need_conv || need_streamdiff)
530 {
531 loc_v.format();
532 for(int i(0); i < num_local_dofs; ++i)
533 {
534 // update velocity value
535 loc_v.axpy(space_data.phi[i].value, local_conv_dofs[i]);
536 }
537 }
538 if(need_loc_grad_v || need_conv_frechet || need_carreau)
539 {
541 for(int i(0); i < num_local_dofs; ++i)
542 {
543 // update velocity gradient
545 }
546 }
547
548 // evaluate streamline diffusion coefficients
549 if(need_streamdiff)
550 {
551 for(int i(0); i < num_local_dofs; ++i)
552 {
553 streamdiff_coeffs[i] = Tiny::dot(loc_v, space_data.phi[i].grad);
554 }
555 }
556
557 //default to 1, only assemble if carreau is needed...
558 gamma_dot = DataType_(1.);
559 //default to nu
560 nu_loc = nu;
561 if(need_carreau)
562 {
566 nu_loc = this->mu_inf + (this->mu_0 - this->mu_inf) * Math::pow((DataType_(1.0)
567 + Math::pow(this->lambda * this->gamma_dot, this->a)), (this->n-DataType(1.0)) / this->a);
568 }
569 }
570
574 void finish()
575 {
576 // finish evaluators
577 space_eval.finish();
578 trafo_eval.finish();
579
580 // finish dof mapping
581 dof_mapping.finish();
582 }
583
587 void combine()
588 {
589 // nothing to do here
590 }
591 }; // class BurgersCarreauAssemblyTaskBase<...>
592
612 template<typename Job_, typename DataType_, int block_size_>
614 public BurgersCarreauAssemblyTaskBase<Job_, DataType_>
615 {
616 public:
618
619 typedef DataType_ DataType;
620
623
624 protected:
628 LocalMatrixType local_matrix;
629
630 public:
637 explicit BurgersCarreauBlockedAssemblyTaskBase(const Job_& job_) :
638 BaseClass(job_),
639 local_matrix()
640 {
641 }
642
649 void assemble_burgers_point(const DataType weight)
650 {
651 // assemble diffusion matrix?
652 if(this->need_diff)
653 {
654 // assemble gradient-tensor diffusion
655
656 // test function loop
657 for(int i(0); i < this->num_local_dofs; ++i)
658 {
659 // trial function loop
660 for(int j(0); j < this->num_local_dofs; ++j)
661 {
662 // compute scalar value
663 const DataType value = this->nu_loc * weight * Tiny::dot(this->space_data.phi[i].grad, this->space_data.phi[j].grad);
664
665 // update local matrix
666 local_matrix[i][j].add_scalar_main_diag(value);
667 }
668 }
669
670 // assemble deformation tensor?
671 if(this->deformation)
672 {
673 // test function loop
674 for(int i(0); i < this->num_local_dofs; ++i)
675 {
676 // trial function loop
677 for(int j(0); j < this->num_local_dofs; ++j)
678 {
679 // add outer product of grad(phi) and grad(psi)
680 local_matrix[i][j].add_outer_product(this->space_data.phi[j].grad, this->space_data.phi[i].grad, this->nu_loc * weight);
681 }
682 }
683 // frechet carreau term "only" makes sense in defo formulation
684 if(this->need_carreau_frechet)
685 {
686 const DataType_ mu_prime = (this->mu_0 - this->mu_inf) * ((this->n-DataType_(1.0)) / this->a) *
687 Math::pow( DataType(1.0) + Math::pow(this->lambda * this->gamma_dot, this->a), ((this->n-DataType_(1.0) - this->a) / this->a)) *
688 this->a * this->lambda * Math::pow(this->lambda * this->gamma_dot, this->a-DataType(1.0));
689 const DataType fac = mu_prime / (this->gamma_dot + this->reg_eps);
690 //std::cout << fac ;
691 // test function loop
692 for(int i(0); i < this->num_local_dofs; ++i)
693 {
694 Tiny::Vector<DataType, this->conv_dim> du_grad_phi;
695 du_grad_phi.set_mat_vec_mult(this->strain_rate_tensor_2, this->space_data.phi[i].grad);
696
697 // trial function loop
698 for(int j(0); j < this->num_local_dofs; ++j)
699 {
700 Tiny::Vector<DataType, this->conv_dim> du_grad_psi;
701 du_grad_psi.set_mat_vec_mult(this->strain_rate_tensor_2, this->space_data.phi[j].grad);
702 // add outer product of grad(phi) and grad(psi)
703 local_matrix[i][j].add_outer_product(du_grad_phi, du_grad_psi, fac * weight);
704 }
705 }
706 }
707 }
708 }
709
710 // assemble convection?
711 if(this->need_conv)
712 {
713 // test function loop
714 for(int i(0); i < this->num_local_dofs; ++i)
715 {
716 // trial function loop
717 for(int j(0); j < this->num_local_dofs; ++j)
718 {
719 // compute scalar value
720 const DataType value = this->beta * weight * this->space_data.phi[i].value * Tiny::dot(this->loc_v, this->space_data.phi[j].grad);
721
722 // update local matrix
723 local_matrix[i][j].add_scalar_main_diag(value);
724 }
725 }
726 }
727
728 // assemble convection Frechet?
729 if(this->need_conv_frechet)
730 {
731 // test function loop
732 for(int i(0); i < this->num_local_dofs; ++i)
733 {
734 // trial function loop
735 for(int j(0); j < this->num_local_dofs; ++j)
736 {
737 // compute scalar value
738 const DataType value = this->frechet_beta * weight * this->space_data.phi[i].value * this->space_data.phi[j].value;
739
740 // update local matrix
741 local_matrix[i][j].axpy(value, this->loc_grad_v);
742 }
743 }
744 }
745
746 // assemble reaction?
747 if(this->need_reac)
748 {
749 // test function loop
750 for(int i(0); i < this->num_local_dofs; ++i)
751 {
752 // trial function loop
753 for(int j(0); j < this->num_local_dofs; ++j)
754 {
755 // compute scalar value
756 const DataType value = this->theta * weight * this->space_data.phi[i].value * this->space_data.phi[j].value;
757
758 // update local matrix
759 local_matrix[i][j].add_scalar_main_diag(value);
760 }
761 }
762 }
763 }
764
771 void assemble_streamline_diffusion(const DataType weight)
772 {
773 // assemble streamline diffusion?
774 if(this->need_streamdiff && (this->local_delta > this->tol_eps))
775 {
776 // test function loop
777 for(int i(0); i < this->num_local_dofs; ++i)
778 {
779 // trial function loop
780 for(int j(0); j < this->num_local_dofs; ++j)
781 {
782 // compute scalar value
783 const DataType value = this->local_delta * weight * this->streamdiff_coeffs[i] * this->streamdiff_coeffs[j];
784
785 // update local matrix
786 local_matrix[i][j].add_scalar_main_diag(value);
787 }
788 }
789 }
790 }
791
795 void assemble()
796 {
797 local_matrix.format();
798
799 // loop over all quadrature points and integrate
800 for(int point(0); point < this->cubature_rule.get_num_points(); ++point)
801 {
802 // prepare trafo and space for cubature point
803 this->prepare_point(point);
804
805 // precompute cubature weight
806 const DataType weight = this->trafo_data.jac_det * this->cubature_rule.get_weight(point);
807
808 // assemble the Burgers operator
809 this->assemble_burgers_point(weight);
810
811 // assemble the streamline diffusion
812 this->assemble_streamline_diffusion(weight);
813 } // continue with next cubature point
814 }
815 }; // class BurgersCarreauBlockedAssemblyTaskBase<...>
816
837 template<typename Matrix_, typename Space_, typename ConvVector_ = typename Matrix_::VectorTypeR>
839 public BurgersCarreauAssemblyJobBase<typename Matrix_::DataType, Space_, ConvVector_>
840 {
841 public:
843 typedef Matrix_ MatrixType;
845 typedef typename MatrixType::DataType DataType;
846
849
850 // no nonsense, please
851 static_assert(Matrix_::BlockHeight == Matrix_::BlockWidth, "only square matrix blocks are supported here");
852
854 static constexpr int block_size = Matrix_::BlockHeight;
855
858
859 public:
875 explicit BurgersCarreauBlockedMatrixAssemblyJob(Matrix_& matrix_, const ConvVector_& conv_vector,
876 const Space_& space_, const String& cubature_name) :
877 BaseClass(conv_vector, space_, cubature_name),
878 matrix(matrix_)
879 {
880 }
881
882 public:
884 class Task :
885 public BurgersCarreauBlockedAssemblyTaskBase<BurgersCarreauBlockedMatrixAssemblyJob, DataType, block_size>
886 {
887 public:
889
890 protected:
892 typename MatrixType::ScatterAxpy scatter_matrix;
893
894 public:
897 BaseClass(job_),
899 {
900 }
901
902 // prepare, assemble and finish are already implemented in the base classes
903
905 void scatter()
906 {
907 this->scatter_matrix(this->local_matrix, this->dof_mapping, this->dof_mapping);
908 }
909 }; // class BurgersCarreauBlockedMatrixAssemblyJob::Task
910 }; // class BurgersCarreauBlockedMatrixAssemblyJob
911
932 template<typename Vector_, typename Space_, typename ConvVector_ = Vector_>
934 public BurgersCarreauAssemblyJobBase<typename Vector_::DataType, Space_, ConvVector_>
935 {
936 public:
938 typedef Vector_ VectorType;
940 typedef typename VectorType::DataType DataType;
941
944
946 static constexpr int block_size = Vector_::BlockSize;
947
950
953
954 public:
975 explicit BurgersCarreauBlockedVectorAssemblyJob(Vector_& rhs_vector_, const Vector_& sol_vector_,
976 const ConvVector_& conv_vector, const Space_& space_, const String& cubature_name) :
977 BaseClass(conv_vector, space_, cubature_name),
978 vector_rhs(rhs_vector_),
979 vector_sol(sol_vector_)
980 {
981 XASSERTM(&rhs_vector_ != &sol_vector_, "rhs and solution vectors must not be the same object");
982 // compare void addresses to avoid warnings in case the classes are different
983 XASSERTM((void*)&rhs_vector_ != (void*)&conv_vector, "rhs and convection vectors must not be the same object");
984 }
985
986 public:
988 class Task :
989 public BurgersCarreauBlockedAssemblyTaskBase<BurgersCarreauBlockedVectorAssemblyJob, DataType, block_size>
990 {
991 public:
993
995
996 protected:
998 typename VectorType::GatherAxpy gather_vec_sol;
1000 typename VectorType::ScatterAxpy scatter_vec_rhs;
1003
1006
1009
1010 public:
1013 BaseClass(job_),
1016 sol_equals_conv((void*)&job_.vector_sol == (void*)&job_.convection_vector),
1018 local_vector()
1019 {
1020 }
1021
1022 void prepare(const Index cell)
1023 {
1024 BaseClass::prepare(cell);
1025
1026 // gather local solution dofs if required
1027 if(!sol_equals_conv)
1028 {
1029 this->local_sol_dofs.format();
1030 this->gather_vec_sol(this->local_sol_dofs, this->dof_mapping);
1031 }
1032 }
1033
1038 {
1039 local_vector.format();
1040
1041 // compute local vector from local matrix and sol vector dofs
1042 if(!sol_equals_conv)
1043 {
1044 for(int i(0); i < this->num_local_dofs; ++i)
1045 for(int j(0); j < this->num_local_dofs; ++j)
1046 this->local_vector[i].add_mat_vec_mult(this->local_matrix(i,j), this->local_sol_dofs[j]);
1047 }
1048 else
1049 {
1050 for(int i(0); i < this->num_local_dofs; ++i)
1051 for(int j(0); j < this->num_local_dofs; ++j)
1052 this->local_vector[i].add_mat_vec_mult(this->local_matrix(i,j), this->local_conv_dofs[j]);
1053 }
1054 }
1055
1056 void assemble()
1057 {
1058 // assemble the local matrix
1060
1061 // compute the local vector from the matrix
1063 }
1064
1066 void scatter()
1067 {
1068 this->scatter_vec_rhs(this->local_vector, this->dof_mapping);
1069 }
1070 }; // class BurgersCarreauBlockedVectorAssemblyJob::Task
1071 }; // class BurgersCarreauBlockedVectorAssemblyJob<...>
1072
1089 template<typename Job_, typename DataType_>
1091 public BurgersCarreauAssemblyTaskBase<Job_, DataType_>
1092 {
1093 public:
1095
1096 typedef DataType_ DataType;
1097
1100
1101 protected:
1104 LocalMatrixType local_matrix;
1105
1106 public:
1113 explicit BurgersCarreauScalarAssemblyTaskBase(const Job_& job_) :
1114 BaseClass(job_),
1115 local_matrix()
1116 {
1117 }
1118
1125 void assemble_burgers_point(const DataType weight)
1126 {
1127 // assemble diffusion matrix?
1128 if(this->need_diff)
1129 {
1130 // assemble gradient-tensor diffusion
1131
1132 // test function loop
1133 for(int i(0); i < this->num_local_dofs; ++i)
1134 {
1135 // trial function loop
1136 for(int j(0); j < this->num_local_dofs; ++j)
1137 {
1138 local_matrix[i][j] += this->nu_loc * weight
1139 * Tiny::dot(this->space_data.phi[i].grad, this->space_data.phi[j].grad);
1140 }
1141 }
1142 }
1143
1144 // assemble convection?
1145 if(this->need_conv)
1146 {
1147 // test function loop
1148 for(int i(0); i < this->num_local_dofs; ++i)
1149 {
1150 // trial function loop
1151 for(int j(0); j < this->num_local_dofs; ++j)
1152 {
1153 local_matrix[i][j] += this->beta * weight
1154 * this->space_data.phi[i].value * Tiny::dot(this->loc_v, this->space_data.phi[j].grad);
1155 }
1156 }
1157 }
1158
1159 // assemble reaction?
1160 if(this->need_reac)
1161 {
1162 // test function loop
1163 for(int i(0); i < this->num_local_dofs; ++i)
1164 {
1165 // trial function loop
1166 for(int j(0); j < this->num_local_dofs; ++j)
1167 {
1168 local_matrix[i][j] += this->theta * weight
1169 * this->space_data.phi[i].value * this->space_data.phi[j].value;
1170 }
1171 }
1172 }
1173 }
1174
1181 void assemble_streamline_diffusion(const DataType weight)
1182 {
1183 // assemble streamline diffusion?
1184 if(this->need_streamdiff && (this->local_delta > this->tol_eps))
1185 {
1186 // test function loop
1187 for(int i(0); i < this->num_local_dofs; ++i)
1188 {
1189 // trial function loop
1190 for(int j(0); j < this->num_local_dofs; ++j)
1191 {
1192 local_matrix[i][j] += this->local_delta * weight
1193 * this->streamdiff_coeffs[i] * this->streamdiff_coeffs[j];
1194 }
1195 }
1196 }
1197 }
1198
1203 {
1204 local_matrix.format();
1205
1206 // loop over all quadrature points and integrate
1207 for(int point(0); point < this->cubature_rule.get_num_points(); ++point)
1208 {
1209 // prepare trafo and space for cubature point
1210 this->prepare_point(point);
1211
1212 // precompute cubature weight
1213 const DataType weight = this->trafo_data.jac_det * this->cubature_rule.get_weight(point);
1214
1215 // assemble the Burgers operator
1216 this->assemble_burgers_point(weight);
1217
1218 // assembles the streamline diffusion stabilization
1219 this->assemble_streamline_diffusion(weight);
1220 } // continue with next cubature point
1221 }
1222 }; // class BurgersCarreauScalarAssemblyTaskBase<...>
1223
1244 template<typename Matrix_, typename Space_, typename ConvVector_>
1246 public BurgersCarreauAssemblyJobBase<typename Matrix_::DataType, Space_, ConvVector_>
1247 {
1248 public:
1250 typedef Matrix_ MatrixType;
1252 typedef typename MatrixType::DataType DataType;
1253
1256
1259
1260 public:
1276 explicit BurgersCarreauScalarMatrixAssemblyJob(Matrix_& matrix_, const ConvVector_& conv_vector,
1277 const Space_& space_, const String& cubature_name) :
1278 BaseClass(conv_vector, space_, cubature_name),
1279 matrix(matrix_)
1280 {
1281 }
1282
1283 public:
1285 class Task :
1286 public BurgersCarreauScalarAssemblyTaskBase<BurgersCarreauScalarMatrixAssemblyJob, DataType>
1287 {
1288 public:
1290
1291 protected:
1293 typename MatrixType::ScatterAxpy scatter_matrix;
1294
1295 public:
1298 BaseClass(job_),
1300 {
1301 }
1302
1303 // prepare, assemble and finish are already implemented in the base classes
1304
1306 void scatter()
1307 {
1308 this->scatter_matrix(this->local_matrix, this->dof_mapping, this->dof_mapping);
1309 }
1310 }; // class BurgersCarreauScalarMatrixAssemblyJob::Task
1311 }; // class BurgersCarreauScalarMatrixAssemblyJob
1312
1333 template<typename Vector_, typename Space_, typename ConvVector_>
1335 public BurgersCarreauAssemblyJobBase<typename Vector_::DataType, Space_, ConvVector_>
1336 {
1337 public:
1339 typedef Vector_ VectorType;
1341 typedef typename VectorType::DataType DataType;
1342
1345
1348
1351
1352 public:
1373 explicit BurgersCarreauScalarVectorAssemblyJob(Vector_& rhs_vector_, const Vector_& sol_vector_,
1374 const ConvVector_& conv_vector, const Space_& space_, const String& cubature_name) :
1375 BaseClass(conv_vector, space_, cubature_name),
1376 vector_rhs(rhs_vector_),
1377 vector_sol(sol_vector_)
1378 {
1379 XASSERTM(&rhs_vector_ != &sol_vector_, "rhs and solution vectors must not be the same object");
1380 }
1381
1382 public:
1384 class Task :
1385 public BurgersCarreauScalarAssemblyTaskBase<BurgersCarreauScalarVectorAssemblyJob, DataType>
1386 {
1387 public:
1389
1391
1392 protected:
1394 typename VectorType::GatherAxpy gather_vec_sol;
1396 typename VectorType::ScatterAxpy scatter_vec_rhs;
1397
1400
1403
1404 public:
1407 BaseClass(job_),
1411 local_vector()
1412 {
1413 }
1414
1415 void prepare(const Index cell)
1416 {
1417 BaseClass::prepare(cell);
1418
1419 // gather local solution vector dofs
1420 this->local_sol_dofs.format();
1421 this->gather_vec_sol(this->local_sol_dofs, this->dof_mapping);
1422 }
1423
1428 {
1429 // compute local vector from local matrix and sol vector dofs
1430 this->local_vector.format();
1431 for(int i(0); i < this->num_local_dofs; ++i)
1432 for(int j(0); j < this->num_local_dofs; ++j)
1433 this->local_vector[i] += this->local_matrix(i,j) * this->local_sol_dofs[j];
1434 //this->local_vector.set_mat_vec_mult(this->local_matrix, this->local_sol_dofs);
1435 }
1436
1437 void assemble()
1438 {
1439 // assemble the local matrix
1441
1442 // compute local vector from the matrix
1444 }
1445
1447 void scatter()
1448 {
1449 this->scatter_vec_rhs(this->local_vector, this->dof_mapping);
1450 }
1451 }; // class BurgersCarreauScalarVectorAssemblyJob::Task
1452 }; // class BurgersCarreauScalarVectorAssemblyJob<...>
1453 } // namespace Assembly
1454} // namespace FEAT
1455
1456#endif // KERNEL_ASSEMBLY_BURGERS_CARREAU_ASSEMBLY_JOB_HPP
#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 Careau assembly jobs.
static DataType calc_sd_v_norm(const Global::Vector< LocalVector_, Mirror_ > &convect)
Calculates the convection field norm for the streamline diffusion parameter delta_T.
DataType_ sd_nu
viscosity parameter nu_S for streamline diffusion (usually equal to nu)
const Space_ & space
the test-/trial-space to be used
DataType_ theta
scaling parameter for reactive operator M
DataType_ nu
scaling parameter for diffusive operator L (aka viscosity)
Cubature::DynamicFactory cubature_factory
the cubature factory to use
DataType_ beta
scaling parameter for convective operator K
BurgersCarreauAssemblyJobBase(const ConvVector_ &conv_vector, const Space_ &space_, const String &cubature)
Constructor.
const ConvVector_ & convection_vector
the convection vector to be used
bool frechet_carreau
Assemble full Jacobian for Carreau?
DataType_ sd_delta
scaling parameter for streamline diffusion stabilization operator S
DataType_ frechet_beta
scaling parameter for Frechet derivative of convective operator K'
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_ sd_v_norm
velocity norm for streamline diffusion
bool deformation
specifies whether to use the deformation tensor
void set_sd_v_norm(const VectorType_ &convect)
Sets the convection field norm for the local streamline diffusion parameter delta_T.
const DataType frechet_beta
scaling parameter for Frechet derivative of convective operator K'
AsmTraits::DofMapping dof_mapping
the space dof-mapping
Job_::ConvVectorType ConvVectorType
the convection vector type
static constexpr int max_local_dofs
maximum number of local dofs
const bool deformation
specifies whether to use the deformation tensor
const DataType sd_v_norm
velocity norm for streamline diffusion
void finish()
Finishes the assembly on the current cell.
AsmTraits::TrafoEvaluator trafo_eval
the trafo evaluator
const DataType sd_delta
scaling parameter for streamline diffusion stabilization operator S
const DataType beta
scaling parameter for convective operator K
AsmTraits::SpaceEvaluator space_eval
the space evaluator
static constexpr bool need_combine
this task doesn't need to combine
DataType_ DataType
the data type to be used by the assembly
const bool need_diff
keep track what we need to assemble
const DataType theta
scaling parameter for reactive operator M
Tiny::Vector< DataType, shape_dim > barycenter
reference element barycenter
void prepare(const Index cell)
Prepares the assembly task for a cell/element.
DataType local_h
local mesh width for streamline diffusion
Tiny::Vector< DataType, conv_dim > loc_v
local convection field value
const DataType tol_eps
tolerance for checks == 0: sqrt(eps)
Tiny::Vector< Tiny::Vector< DataType, conv_dim >, max_local_dofs > local_conv_dofs
local convection field dofs
Tiny::Matrix< DataType, conv_dim, conv_dim > strain_rate_tensor_2
strain rate tensor
AsmTraits::SpaceEvalData space_data
the space evaluation data
ConvVectorType::GatherAxpy gather_conv
convection vector gather-axpy object
AsmTraits::TrafoEvalData trafo_data
the trafo evaluation data
AsmTraits1< DataType, SpaceType, TrafoTags::jac_det, SpaceTags::value|SpaceTags::grad > AsmTraits
our assembly traits
const AsmTraits::TrafoType & trafo
the cubature factory used for integration
const SpaceType & space
the test-/trial-space to be used
const DataType sd_nu
viscosity parameter nu_S for streamline diffusion (usually equal to nu)
static constexpr int conv_dim
the convection vector dimension
bool need_loc_v
enable computation of certain quantities
int num_local_dofs
actual number of local dofs on current element
static constexpr bool need_scatter
this task needs to scatter
AsmTraits::CubatureRuleType cubature_rule
the cubature rule used for integration
Tiny::Vector< DataType, max_local_dofs > streamdiff_coeffs
local streamline diffusion coefficients
DataType local_delta
local delta for streamline diffusion
DataType_ gamma_dot
Some local data needed for Carreau.
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)
void prepare_point(int cubature_point)
Prepares the task for a cubature point.
Base class for blocked Burgers Carreau assembly tasks.
void assemble_burgers_point(const DataType weight)
Assembles the Burger operator in a single cubature point.
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.
int num_local_dofs
actual number of local dofs on current element
Tiny::Matrix< DataType_, block_size_, block_size_ > MatrixValue
our local matrix data
MatrixType::ScatterAxpy scatter_matrix
matrix scatter-axpy object
Task(const BurgersCarreauBlockedMatrixAssemblyJob &job_)
constructor
BurgersCarreauAssemblyJobBase< DataType, Space_, ConvVector_ > BaseClass
our base class
BurgersCarreauBlockedMatrixAssemblyJob(Matrix_ &matrix_, const ConvVector_ &conv_vector, const Space_ &space_, const String &cubature_name)
Constructor.
VectorType::ScatterAxpy scatter_vec_rhs
rhs vector scatter-axpy object
void compute_local_vector()
Computes the local vector by multiplying the local matrix by the solution vector.
VectorType::GatherAxpy gather_vec_sol
sol vector gather-axpy object
Task(const BurgersCarreauBlockedVectorAssemblyJob &job_)
constructor
Tiny::Vector< Tiny::Vector< DataType, block_size >, max_local_dofs > local_vector
local rhs vector dofs
Tiny::Vector< Tiny::Vector< DataType, block_size >, max_local_dofs > local_sol_dofs
local solution vector dofs
const bool sol_equals_conv
specifies whether the solution vector and the convection vector are the same object
Burgers Carreau assembly job for block right-hand-side vector.
BurgersCarreauBlockedVectorAssemblyJob(Vector_ &rhs_vector_, const Vector_ &sol_vector_, const ConvVector_ &conv_vector, const Space_ &space_, const String &cubature_name)
Constructor.
BurgersCarreauAssemblyJobBase< DataType, Space_, ConvVector_ > BaseClass
our base class
Base class for scalar Burgers Carreau assembly tasks.
void assemble()
Performs the assembly of the local matrix.
Tiny::Matrix< DataType, max_local_dofs, max_local_dofs > LocalMatrixType
our local matrix data
void assemble_streamline_diffusion(const DataType weight)
Assembles the Streamline Diffusion stabilization operator in a single cubature point.
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 BurgersCarreauScalarMatrixAssemblyJob &job_)
constructor
MatrixType::ScatterAxpy scatter_matrix
matrix scatter-axpy object
BurgersCarreauScalarMatrixAssemblyJob(Matrix_ &matrix_, const ConvVector_ &conv_vector, const Space_ &space_, const String &cubature_name)
Constructor.
BurgersCarreauAssemblyJobBase< DataType, Space_, ConvVector_ > BaseClass
our base class
Task(const BurgersCarreauScalarVectorAssemblyJob &job_)
constructor
void compute_local_vector()
Computes the local vector by multiplying the local matrix by the solution vector.
VectorType::GatherAxpy gather_vec_sol
sol vector gather-axpy object
Tiny::Vector< DataType, max_local_dofs > local_vector
local rhs vector dofs
Tiny::Vector< DataType, max_local_dofs > local_sol_dofs
local solution vector dofs
VectorType::ScatterAxpy scatter_vec_rhs
rhs vector scatter-axpy object
Burgers Carreau assembly job for scalar right-hand-side vector.
BurgersCarreauScalarVectorAssemblyJob(Vector_ &rhs_vector_, const Vector_ &sol_vector_, const ConvVector_ &conv_vector, const Space_ &space_, const String &cubature_name)
Constructor.
BurgersCarreauAssemblyJobBase< 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:619
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:148
LocalVector_ & local()
Returns a reference to the internal local LAFEM vector object.
Definition: vector.hpp:121
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:46
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 & set_transpose(const Matrix< T_, n_, m_, sma_, sna_ > &a)
Sets this matrix to the transpose of another 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.
CUDA_HOST_DEVICE DataType norm_frobenius() const
Returns the Frobenius norm of 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_ sqrt(T_ x)
Returns the square-root of a value.
Definition: math.hpp:300
T_ pow(T_ x, T_ y)
Returns x raised to the power of y.
Definition: math.hpp:643
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