7#ifndef KERNEL_ASSEMBLY_BURGERS_CARREAU_ASSEMBLY_JOB_HPP
8#define KERNEL_ASSEMBLY_BURGERS_CARREAU_ASSEMBLY_JOB_HPP 1
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>
103 template<
typename DataType_,
typename Space_,
typename ConvVector_>
156 DataType_
mu_inf, mu_0, lambda, n, a, reg_eps;
187 lambda(DataType_(0.)),
190 reg_eps(DataType_(1e-100))
203 template<
typename IndexType_,
int conv_dim_>
206 const auto* vals = convect.elements();
207 DataType_ r = DataType_(0);
225 template<
typename LocalVector_,
typename Mirror_>
228 const auto* gate = convect.
get_gate();
241 template<
typename VectorType_>
273 template<
typename Job_,
typename DataType_>
295 static constexpr int conv_dim = ConvVectorType::block_size;
331 const bool need_diff, need_conv, need_conv_frechet, need_reac, need_streamdiff, need_carreau, need_carreau_frechet;
334 DataType_
mu_inf, mu_0, lambda, n, a, reg_eps;
414 need_carreau(job_.carreau),
415 need_carreau_frechet(job_.frechet_carreau),
421 reg_eps(job_.reg_eps),
425 need_loc_grad_v(need_conv_frechet || need_carreau),
426 need_mean_v(need_streamdiff),
427 need_local_h(need_streamdiff),
433 cubature_rule(Cubature::ctor_factory, job_.cubature_factory),
478 if(need_mean_v || need_local_h || need_streamdiff)
529 if(
need_loc_v || need_conv || need_streamdiff)
538 if(need_loc_grad_v || need_conv_frechet || need_carreau)
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);
612 template<
typename Job_,
typename DataType_,
int block_size_>
619 typedef DataType_ DataType;
663 const DataType
value = this->nu_loc * weight *
Tiny::dot(this->
space_data.phi[i].grad, this->space_data.phi[j].grad);
684 if(this->need_carreau_frechet)
686 const DataType_ mu_prime = (this->mu_0 - this->
mu_inf) * ((this->n-DataType_(1.0)) / 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);
729 if(this->need_conv_frechet)
800 for(
int point(0); point < this->
cubature_rule.get_num_points(); ++point)
837 template<
typename Matrix_,
typename Space_,
typename ConvVector_ =
typename Matrix_::VectorTypeR>
851 static_assert(Matrix_::block_height == Matrix_::block_width,
"only square matrix blocks are supported here");
876 const Space_& space_,
const String& cubature_name) :
877 BaseClass(conv_vector, space_, cubature_name),
932 template<
typename Vector_,
typename Space_,
typename ConvVector_ = Vector_>
976 const ConvVector_& conv_vector,
const Space_& space_,
const String& cubature_name) :
977 BaseClass(conv_vector, space_, cubature_name),
981 XASSERTM(&rhs_vector_ != &sol_vector_,
"rhs and solution vectors must not be the same object");
983 XASSERTM((
void*)&rhs_vector_ != (
void*)&conv_vector,
"rhs and convection vectors must not be the same object");
1022 void prepare(
const Index cell)
1029 this->local_sol_dofs.
format();
1046 this->local_vector[i].add_mat_vec_mult(this->local_matrix(i,j), this->local_sol_dofs[j]);
1052 this->local_vector[i].add_mat_vec_mult(this->local_matrix(i,j), this->
local_conv_dofs[j]);
1089 template<
typename Job_,
typename DataType_>
1096 typedef DataType_ DataType;
1138 local_matrix[i][j] += this->nu_loc * weight
1153 local_matrix[i][j] += this->
beta * weight
1168 local_matrix[i][j] += this->
theta * weight
1207 for(
int point(0); point < this->
cubature_rule.get_num_points(); ++point)
1244 template<
typename Matrix_,
typename Space_,
typename ConvVector_>
1277 const Space_& space_,
const String& cubature_name) :
1278 BaseClass(conv_vector, space_, cubature_name),
1333 template<
typename Vector_,
typename Space_,
typename ConvVector_>
1374 const ConvVector_& conv_vector,
const Space_& space_,
const String& cubature_name) :
1375 BaseClass(conv_vector, space_, cubature_name),
1379 XASSERTM(&rhs_vector_ != &sol_vector_,
"rhs and solution vectors must not be the same object");
1415 void prepare(
const Index cell)
1420 this->local_sol_dofs.
format();
1430 this->local_vector.
format();
1433 this->local_vector[i] += this->local_matrix(i,j) * this->local_sol_dofs[j];
#define XASSERTM(expr, msg)
Assertion macro definition with custom message.
Common single-space assembly traits class template.
TrafoType::template Evaluator< ShapeType, DataType >::Type TrafoEvaluator
trafo evaluator type
SpaceEvaluator::template ConfigTraits< space_config >::EvalDataType SpaceEvalData
space evaluation data types
Intern::CubatureTraits< TrafoEvaluator >::RuleType CubatureRuleType
cubature rule type
SpaceType::TrafoType TrafoType
trafo type
SpaceType::DofMappingType DofMapping
dof-mapping types
TrafoEvaluator::template ConfigTraits< trafo_config >::EvalDataType TrafoEvalData
trafo evaluation data type
SpaceType::template Evaluator< TrafoEvaluator >::Type SpaceEvaluator
space evaluator types
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
Space_ SpaceType
the space type
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'
DataType_ mu_inf
Carreau Data Parameter.
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
ConvVector_ ConvVectorType
the convection vector type
void set_sd_v_norm(const VectorType_ &convect)
Sets the convection field norm for the local streamline diffusion parameter delta_T.
DataType_ DataType
the datatype we use here
bool carreau
Assemble Carreau coefficient?
Base class for Burgers assembly tasks.
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
void combine()
Finalizes the assembly.
Tiny::Vector< DataType, shape_dim > barycenter
reference element barycenter
void prepare(const Index cell)
Prepares the assembly task for a cell/element.
Job_::SpaceType SpaceType
the space type
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
const Job_ & job
a reference to our job object
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
BurgersCarreauAssemblyTaskBase(const Job_ &job_)
Constructor.
DataType local_delta
local delta for streamline diffusion
static constexpr int shape_dim
the shape dimension
DataType_ gamma_dot
Some local data needed for Carreau.
Tiny::Matrix< DataType, conv_dim, conv_dim > loc_grad_v
local convection field gradient
DataType_ mu_inf
Carreau Data Parameter.
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.
static constexpr int max_local_dofs
maximum number of local dofs
BurgersCarreauBlockedAssemblyTaskBase(const Job_ &job_)
Constructor.
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
void scatter()
scatters the local matrix
Task(const BurgersCarreauBlockedMatrixAssemblyJob &job_)
constructor
Burgers Carreau assembly job for block matrix.
static constexpr int block_size
the block size
MatrixType::DataType DataType
the data type
BurgersCarreauAssemblyJobBase< DataType, Space_, ConvVector_ > BaseClass
our base class
Matrix_ MatrixType
the matrix type
MatrixType & matrix
the matrix to be assembled
BurgersCarreauBlockedMatrixAssemblyJob(Matrix_ &matrix_, const ConvVector_ &conv_vector, const Space_ &space_, const String &cubature_name)
Constructor.
void scatter()
scatters the local vector
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.
VectorType & vector_rhs
the RHS vector to be assembled
BurgersCarreauBlockedVectorAssemblyJob(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::DataType DataType
the data type
BurgersCarreauAssemblyJobBase< DataType, Space_, ConvVector_ > BaseClass
our base class
Vector_ VectorType
the vector type
static constexpr int block_size
the block size
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
static constexpr int max_local_dofs
maximum number of local dofs
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.
BurgersCarreauScalarAssemblyTaskBase(const Job_ &job_)
Constructor.
int num_local_dofs
actual number of local dofs on current element
void scatter()
scatters the local matrix
Task(const BurgersCarreauScalarMatrixAssemblyJob &job_)
constructor
MatrixType::ScatterAxpy scatter_matrix
matrix scatter-axpy object
Burgers Carreau assembly job for scalar matrix.
Matrix_ MatrixType
the matrix type
BurgersCarreauScalarMatrixAssemblyJob(Matrix_ &matrix_, const ConvVector_ &conv_vector, const Space_ &space_, const String &cubature_name)
Constructor.
BurgersCarreauAssemblyJobBase< DataType, Space_, ConvVector_ > BaseClass
our base class
MatrixType & matrix
the matrix to be assembled
MatrixType::DataType DataType
the data type
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
void scatter()
scatters the local vector
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.
VectorType & vector_rhs
the RHS vector to be assembled
const VectorType & vector_sol
the solution vector
BurgersCarreauAssemblyJobBase< DataType, Space_, ConvVector_ > BaseClass
our base class
VectorType::DataType DataType
the data type
Vector_ VectorType
the vector type
DataType max(DataType x) const
Computes the maximum of a scalar variable over all processes.
Global vector wrapper class template.
const GateType * get_gate() const
Returns a const pointer to the internal gate of the vector.
LocalVector_ & local()
Returns a reference to the internal local LAFEM vector object.
Blocked Dense data vector class template.
Index size() const
Returns the size of this vector, i.e. its number of entries.
String class implementation.
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.
T_ pow(T_ x, T_ y)
Returns x raised to the power of y.
T_ max(T_ a, T_ b)
Returns the maximum of two values.
CUDA_HOST_DEVICE T_ dot(const T_ &a, const T_ &b)
Computes the dot-product of two scalars.
@ value
specifies whether the space should supply basis function values
std::uint64_t Index
Index data type.
Reference cell traits structure.