8#include <kernel/assembly/asm_traits.hpp>
9#include <kernel/lafem/dense_vector.hpp>
10#include <kernel/lafem/dense_vector_blocked.hpp>
11#include <kernel/lafem/power_vector.hpp>
12#include <kernel/util/tiny_algebra.hpp>
13#include <kernel/util/dist.hpp>
22 template<
typename Vector_>
35 template<
typename DataType_,
int dim_>
39 static constexpr int dim = dim_;
109 DataType_ verr[2*dim_+4] =
116 for(
int i(0); i < dim_; ++i)
128 for(
int i(0); i < dim_; ++i)
155 for(
int i(0); i < dim_; ++i)
159 for(
int i(0); i < dim_; ++i)
172 for(
int i(0); i < dim_; ++i)
178 for(
int i(0); i < dim_; ++i)
201 template<
typename DT_,
int sm_,
int sn_>
209 template<
typename DT_,
int sm_,
int sn_>
236 template<
typename DataType_,
typename IndexType_,
int dim_,
typename Space_>
239 const Space_& space,
const String& cubature_name)
242 return compute(vector, space, cubature_factory);
260 template<
typename DataType_,
typename IndexType_,
int dim_,
typename Space_>
266 static_assert(Space_::shape_dim == dim_,
"invalid velocity field dimension");
269 typedef Space_ SpaceType;
277 typedef typename AsmTraits::DataType DataType;
280 typename AsmTraits::CubatureRuleType cubature_rule(Cubature::ctor_factory, cubature_factory);
283 const typename AsmTraits::TrafoType& trafo = space.get_trafo();
286 typename AsmTraits::TrafoEvaluator trafo_eval(trafo);
289 typename AsmTraits::SpaceEvaluator space_eval(space);
290 typedef typename AsmTraits::SpaceEvaluator SpaceEvaluator;
293 typename AsmTraits::DofMapping dof_mapping(space);
296 typename AsmTraits::TrafoEvalData trafo_data;
299 typename AsmTraits::SpaceEvalData space_data;
302 Intern::MultiGather<VectorType> multi_gather(vector);
317 for(
typename AsmTraits::CellIterator cell(trafo_eval.begin()); cell != trafo_eval.end(); ++cell)
320 dof_mapping.prepare(cell);
324 multi_gather.gather(basis_val, dof_mapping);
327 dof_mapping.finish();
330 trafo_eval.prepare(cell);
333 space_eval.prepare(trafo_eval);
336 int num_loc_dofs = space_eval.get_num_local_dofs();
339 for(
int k(0); k < cubature_rule.get_num_points(); ++k)
342 trafo_eval(trafo_data, cubature_rule.get_point(k));
345 space_eval(space_data, trafo_data);
350 for(
int i(0); i < num_loc_dofs; ++i)
352 for(
int bi(0); bi < dim_; ++bi)
354 val[bi] += basis_val[bi][i] * space_data.phi[i].value;
356 for(
int bj(0); bj < dim_; ++bj)
359 jac[bi][bj] += basis_val[bi][i] * space_data.phi[i].grad[bj];
365 DataType omega = trafo_data.jac_det * cubature_rule.get_weight(k);
368 for(
int i(0); i < dim_; ++i)
381 info.
vorticity += omega * calc_vorticity(jac);
394 for(
int i(0); i < dim_; ++i)
427 template<
typename DataType_,
typename IndexType_,
int dim_,
typename Space_>
430 const Space_& space,
const String& cubature_name)
433 return compute(vector, space, cubature_factory);
451 template<
typename DataType_,
typename IndexType_,
int dim_,
typename Space_>
457 static_assert(Space_::shape_dim == dim_,
"invalid velocity field dimension");
460 XASSERTM(vector.
size() == space.get_num_dofs(),
"invalid vector size");
463 typedef Space_ SpaceType;
471 typedef typename AsmTraits::DataType DataType;
474 typename AsmTraits::CubatureRuleType cubature_rule(Cubature::ctor_factory, cubature_factory);
477 const typename AsmTraits::TrafoType& trafo = space.get_trafo();
480 typename AsmTraits::TrafoEvaluator trafo_eval(trafo);
483 typename AsmTraits::SpaceEvaluator space_eval(space);
484 typedef typename AsmTraits::SpaceEvaluator SpaceEvaluator;
487 typename AsmTraits::DofMapping dof_mapping(space);
490 typename AsmTraits::TrafoEvalData trafo_data;
493 typename AsmTraits::SpaceEvalData space_data;
496 typename VectorType::GatherAxpy gather(vector);
511 for(
typename AsmTraits::CellIterator cell(trafo_eval.begin()); cell != trafo_eval.end(); ++cell)
514 dof_mapping.prepare(cell);
518 gather(basis_val, dof_mapping);
521 dof_mapping.finish();
524 trafo_eval.prepare(cell);
527 space_eval.prepare(trafo_eval);
530 const int num_loc_dofs = space_eval.get_num_local_dofs();
533 for(
int k(0); k < cubature_rule.get_num_points(); ++k)
536 trafo_eval(trafo_data, cubature_rule.get_point(k));
539 space_eval(space_data, trafo_data);
544 for(
int i(0); i < num_loc_dofs; ++i)
546 val.
axpy(space_data.phi[i].value, basis_val[i]);
552 const DataType omega = trafo_data.jac_det * cubature_rule.get_weight(k);
555 for(
int i(0); i < dim_; ++i)
568 info.
vorticity += omega * calc_vorticity(jac);
581 for(
int i(0); i < dim_; ++i)
603 template<
typename DT_,
typename IT_,
int dim_>
604 struct MultiGather<LAFEM::PowerVector<LAFEM::DenseVector<DT_, IT_>, dim_> >
606 typedef MultiGather<LAFEM::PowerVector<LAFEM::DenseVector<DT_, IT_>, dim_-1> > RestClass;
609 RestClass _rest_gather;
612 _first_gather(vector.first()), _rest_gather(vector.rest())
616 template<
int m_,
int n_,
int sm_,
int sn_,
typename DofMapping_>
618 Tiny::Matrix<DT_, m_, n_, sm_, sn_>& vals,
619 const DofMapping_& dof_mapping,
622 _first_gather(vals[offset], dof_mapping);
623 _rest_gather.gather(vals, dof_mapping, offset+1);
627 template<
typename DT_,
typename IT_>
628 struct MultiGather<LAFEM::PowerVector<LAFEM::DenseVector<DT_, IT_>, 1> >
630 typename LAFEM::DenseVector<DT_, IT_>::GatherAxpy _first_gather;
632 MultiGather(
const LAFEM::PowerVector<LAFEM::DenseVector<DT_, IT_>, 1>& vector) :
633 _first_gather(vector.first())
637 template<
int m_,
int n_,
int sm_,
int sn_,
typename DofMapping_>
639 Tiny::Matrix<DT_, m_, n_, sm_, sn_>& vals,
640 const DofMapping_& dof_mapping,
643 _first_gather(vals[offset], dof_mapping);
#define XASSERTM(expr, msg)
Assertion macro definition with custom message.
Common single-space assembly traits class template.
Velocity field analyser class.
static VelocityInfo< DataType_, dim_ > compute(const LAFEM::PowerVector< LAFEM::DenseVector< DataType_, IndexType_ >, dim_ > &vector, const Space_ &space, const String &cubature_name)
Performs the analysis of a velocity field.
static VelocityInfo< DataType_, dim_ > compute(const LAFEM::DenseVectorBlocked< DataType_, IndexType_, dim_ > &vector, const Space_ &space, const Cubature::DynamicFactory &cubature_factory)
Performs the analysis of a velocity field.
static VelocityInfo< DataType_, dim_ > compute(const LAFEM::DenseVectorBlocked< DataType_, IndexType_, dim_ > &vector, const Space_ &space, const String &cubature_name)
Performs the analysis of a velocity field.
static VelocityInfo< DataType_, dim_ > compute(const LAFEM::PowerVector< LAFEM::DenseVector< DataType_, IndexType_ >, dim_ > &vector, const Space_ &space, const Cubature::DynamicFactory &cubature_factory)
Performs the analysis of a velocity field.
void allreduce(const void *sendbuf, void *recvbuf, std::size_t count, const Datatype &datatype, const Operation &op) const
Blocking All-Reduce.
Gather-Axpy operation for DenseVector.
Blocked Dense data vector class template.
Index size() const
The number of elements.
Dense data vector class template.
Power-Vector meta class template.
String class implementation.
String pad_back(size_type len, char c=' ') const
Pads the back of the string up to a desired length.
Tiny Matrix class template.
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 DataType trace() const
Returns the trace of the 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.
const Operation op_sum(MPI_SUM)
Operation wrapper for MPI_SUM.
T_ sqrt(T_ x)
Returns the square-root of a value.
T_ sqr(T_ x)
Returns the square of a value.
CUDA_HOST_DEVICE T_ dot(const T_ &a, const T_ &b)
Computes the dot-product of two scalars.
String stringify_fp_sci(DataType_ value, int precision=0, int width=0, bool sign=false)
Prints a floating point value to a string in scientific notation.
Velocity field information structure.
String format_string(int precision=0, std::size_t pad_size=10u, char pad_char='.') const
Formats the velocity information as a string.
Tiny::Vector< DataType_, dim_ > norm_h0_comp
Velocity field components H0-norm.
DataType_ norm_h0
Velocity field H0-norm.
DataType_ norm_h1
Velocity field H1-semi-norm.
DataType_ vorticity
Velocity field vorticity H0-norm.
friend std::ostream & operator<<(std::ostream &os, const VelocityInfo &vi)
prints the info to an output stream
static constexpr int dim
The dimension of the analysed velocity field.
Tiny::Vector< DataType_, dim_ > norm_h1_comp
Velocity field components H1-semi-norm.
DataType_ divergence
Velocity field divergence H0-norm.
void synchronize(const Dist::Comm &comm)
Synchronizes the velocity information over a communicator.
VelocityInfo()
default CTOR