8#include <kernel/assembly/asm_traits.hpp> 
    9#include <kernel/trafo/inverse_mapping.hpp> 
   10#include <kernel/lafem/dense_vector.hpp> 
   11#include <kernel/lafem/dense_vector_blocked.hpp> 
   12#include <kernel/util/dist.hpp> 
   31    template<
typename DT_, 
int dim_>
 
   36      static constexpr int dim = dim_;
 
   70        for(
const auto& v : 
values)
 
   72        return r / DT_(
values.size());
 
   98        for(
const auto& v : 
values)
 
  105        return (val[0] > DT_(0)) ? (val[1] / val[0]) : DT_(0);
 
  120    template<
typename DT_, 
int dim_>
 
  125      static constexpr int dim = dim_;
 
  159        for(
const auto& v : 
values)
 
  161        r  *= (DT_(1) / DT_(
values.size()));
 
  185        for(
int i(0); i < dim_; ++i)
 
  188        for(
const auto& v : 
values)
 
  190          for(
int i(0); i < dim_; ++i)
 
  196        for(
int i(0); i < dim_; ++i)
 
  200          r *= (DT_(1) / val[0]);
 
  217    template<
typename DT_, 
int dim_i_, 
int dim_j_>
 
  222      static constexpr int dim_i = dim_i_;
 
  223      static constexpr int dim_j = dim_j_;
 
  257        for(
const auto& v : 
values)
 
  259        r  *= (DT_(1) / DT_(
values.size()));
 
  278        DT_ val[1+dim_i_*dim_j_] =
 
  283        for(
int i(0); i < dim_i_; ++i)
 
  285          for(
int j(0); j < dim_j_; ++j)
 
  287            val[i*dim_j_ + j + 1] = DT_(0);
 
  291        for(
const auto& v : 
values)
 
  293          for(
int i(0); i < dim_i_; ++i)
 
  295            for(
int j(0); j < dim_j_; ++j)
 
  297              val[i*dim_j_ + j + 1] += v[i][j];
 
  304        for(
int i(0); i < dim_i_; ++i)
 
  306          for(
int j(0); j < dim_j_; ++j)
 
  308            r[i][j] = val[i*dim_j_ + j + 1];
 
  313          r *= (DT_(1) / val[0]);
 
  378      template<
typename DT_, 
typename DTP_, 
typename IT_, 
int dim_, 
int s_, 
typename Space_>
 
  388        auto inv_map_data = inv_mapping.
unmap_point(point);
 
  410      template<
typename DT_, 
typename DTP_, 
typename IT_, 
int dim_, 
typename Space_>
 
  419        typedef Space_ SpaceType;
 
  423        typedef typename AsmTraits::DataType DataType;
 
  426        const typename AsmTraits::TrafoType& trafo = space.get_trafo();
 
  429        typename AsmTraits::TrafoEvaluator trafo_eval(trafo);
 
  432        typename AsmTraits::SpaceEvaluator space_eval(space);
 
  435        typename AsmTraits::DofMapping dof_mapping(space);
 
  438        typename AsmTraits::TrafoEvalData trafo_data;
 
  441        typename AsmTraits::SpaceEvalData space_data;
 
  444        typename AsmTraits::template TLocalVector<DT_> local_vector;
 
  447        typename VectorType::GatherAxpy gather_axpy(vector);
 
  453        for(std::size_t i(0); i < inv_map_data.
size(); ++i)
 
  459          local_vector.format();
 
  462          dof_mapping.prepare(cell);
 
  465          gather_axpy(local_vector, dof_mapping);
 
  468          dof_mapping.finish();
 
  471          trafo_eval.prepare(cell);
 
  474          space_eval.prepare(trafo_eval);
 
  480          space_eval(space_data, trafo_data);
 
  483          const int num_loc_dofs = space_eval.get_num_local_dofs();
 
  486          DataType 
value = DataType(0);
 
  487          for(
int j(0); j < num_loc_dofs; ++j)
 
  488            value += local_vector[j] * space_data.phi[j].value;
 
  525      template<
typename DT_, 
typename DTP_, 
typename IT_, 
int dim_, 
int s_, 
typename Space_>
 
  535        auto inv_map_data = inv_mapping.
unmap_point(point);
 
  557      template<
typename DT_, 
typename DTP_, 
typename IT_, 
int dim_, 
typename Space_>
 
  566        typedef Space_ SpaceType;
 
  570        typedef typename AsmTraits::DataType DataType;
 
  573        const typename AsmTraits::TrafoType& trafo = space.get_trafo();
 
  576        typename AsmTraits::TrafoEvaluator trafo_eval(trafo);
 
  579        typename AsmTraits::SpaceEvaluator space_eval(space);
 
  582        typename AsmTraits::DofMapping dof_mapping(space);
 
  585        typename AsmTraits::TrafoEvalData trafo_data;
 
  588        typename AsmTraits::SpaceEvalData space_data;
 
  591        static constexpr int max_local_dofs = AsmTraits::max_local_test_dofs;
 
  596        LocalVectorType local_vector;
 
  599        typename VectorType::GatherAxpy gather_axpy(vector);
 
  607        for(std::size_t i(0); i < inv_map_data.
size(); ++i)
 
  613          local_vector.format();
 
  616          dof_mapping.prepare(cell);
 
  619          gather_axpy(local_vector, dof_mapping);
 
  622          dof_mapping.finish();
 
  625          trafo_eval.prepare(cell);
 
  628          space_eval.prepare(trafo_eval);
 
  634          space_eval(space_data, trafo_data);
 
  637          const int num_loc_dofs = space_eval.get_num_local_dofs();
 
  641          for(
int j(0); j < num_loc_dofs; ++j)
 
  642            value.axpy(space_data.phi[j].value, local_vector[j]);
 
  679      template<
typename DT_, 
typename DTP_, 
typename IT_, 
int dim_, 
int s_, 
typename Space_>
 
  689        auto inv_map_data = inv_mapping.
unmap_point(point);
 
  711      template<
typename DT_, 
typename DTP_, 
typename IT_, 
int dim_, 
typename Space_>
 
  720        typedef Space_ SpaceType;
 
  724        typedef typename AsmTraits::DataType DataType;
 
  727        const typename AsmTraits::TrafoType& trafo = space.get_trafo();
 
  730        typename AsmTraits::TrafoEvaluator trafo_eval(trafo);
 
  733        typename AsmTraits::SpaceEvaluator space_eval(space);
 
  736        typename AsmTraits::DofMapping dof_mapping(space);
 
  739        typename AsmTraits::TrafoEvalData trafo_data;
 
  742        typename AsmTraits::SpaceEvalData space_data;
 
  745        static constexpr int max_local_dofs = AsmTraits::max_local_test_dofs;
 
  749        LocalVectorType local_vector;
 
  752        typename VectorType::GatherAxpy gather_axpy(vector);
 
  762        for(std::size_t i(0); i < inv_map_data.
size(); ++i)
 
  768          local_vector.format();
 
  771          dof_mapping.prepare(cell);
 
  774          gather_axpy(local_vector, dof_mapping);
 
  777          dof_mapping.finish();
 
  780          trafo_eval.prepare(cell);
 
  783          space_eval.prepare(trafo_eval);
 
  789          space_eval(space_data, trafo_data);
 
  792          const int num_loc_dofs = space_eval.get_num_local_dofs();
 
  796          for(
int j(0); j < num_loc_dofs; ++j)
 
  799            Tiny::axpy(loc_grad, space_data.phi[j].grad, local_vector[j]);
 
  803          eval_data.
values.push_back(loc_grad);
 
  837      template<
typename DT_, 
typename DTP_, 
typename IT_, 
int dim_, 
int s_, 
typename Space_>
 
  847        auto inv_map_data = inv_mapping.
unmap_point(point);
 
  869      template<
typename DT_, 
typename DTP_, 
typename IT_, 
int dim_, 
typename Space_>
 
  878        typedef Space_ SpaceType;
 
  882        typedef typename AsmTraits::DataType DataType;
 
  885        const typename AsmTraits::TrafoType& trafo = space.get_trafo();
 
  888        typename AsmTraits::TrafoEvaluator trafo_eval(trafo);
 
  891        typename AsmTraits::SpaceEvaluator space_eval(space);
 
  894        typename AsmTraits::DofMapping dof_mapping(space);
 
  897        typename AsmTraits::TrafoEvalData trafo_data;
 
  900        typename AsmTraits::SpaceEvalData space_data;
 
  903        static constexpr int max_local_dofs = AsmTraits::max_local_test_dofs;
 
  908        LocalVectorType local_vector;
 
  911        typename VectorType::GatherAxpy gather_axpy(vector);
 
  921        for(std::size_t i(0); i < inv_map_data.
size(); ++i)
 
  927          local_vector.format();
 
  930          dof_mapping.prepare(cell);
 
  933          gather_axpy(local_vector, dof_mapping);
 
  936          dof_mapping.finish();
 
  939          trafo_eval.prepare(cell);
 
  942          space_eval.prepare(trafo_eval);
 
  948          space_eval(space_data, trafo_data);
 
  951          const int num_loc_dofs = space_eval.get_num_local_dofs();
 
  955          for(
int j(0); j < num_loc_dofs; ++j)
 
  962          eval_data.
values.push_back(loc_grad);
 
Common single-space assembly traits class template.
Discrete function evaluator.
static VectorDiscreteEvalData< DT_, dim_ > eval_fe_gradient(const Tiny::Vector< DTP_, dim_, s_ > &point, const LAFEM::DenseVector< DT_, IT_ > &vector, const Space_ &space)
Evaluates the gradient of a scalar finite-element function in a given point.
static VectorDiscreteEvalData< DT_, dim_ > eval_fe_function(const Tiny::Vector< DTP_, dim_, s_ > &point, const LAFEM::DenseVectorBlocked< DT_, IT_, dim_ > &vector, const Space_ &space)
Evaluates a vector-valued finite-element function in a given point.
static MatrixDiscreteEvalData< DT_, dim_, dim_ > eval_fe_gradient(const Trafo::InverseMappingData< DTP_, dim_, dim_ > &inv_map_data, const LAFEM::DenseVectorBlocked< DT_, IT_, dim_ > &vector, const Space_ &space)
Evaluates the gradient of a vector-valued finite-element function in a given unmapped point.
static ScalarDiscreteEvalData< DT_, dim_ > eval_fe_function(const Trafo::InverseMappingData< DTP_, dim_, dim_ > &inv_map_data, const LAFEM::DenseVector< DT_, IT_ > &vector, const Space_ &space)
Evaluates a scalar finite-element function in a given unmapped point.
static ScalarDiscreteEvalData< DT_, dim_ > eval_fe_function(const Tiny::Vector< DTP_, dim_, s_ > &point, const LAFEM::DenseVector< DT_, IT_ > &vector, const Space_ &space)
Evaluates a scalar finite-element function in a given point.
static MatrixDiscreteEvalData< DT_, dim_, dim_ > eval_fe_gradient(const Tiny::Vector< DTP_, dim_, s_ > &point, const LAFEM::DenseVectorBlocked< DT_, IT_, dim_ > &vector, const Space_ &space)
Evaluates the gradient of a vector-valued finite-element function in a given point.
static VectorDiscreteEvalData< DT_, dim_ > eval_fe_gradient(const Trafo::InverseMappingData< DTP_, dim_, dim_ > &inv_map_data, const LAFEM::DenseVector< DT_, IT_ > &vector, const Space_ &space)
Evaluates the gradient of a scalar finite-element function in a given unmapped point.
static VectorDiscreteEvalData< DT_, dim_ > eval_fe_function(const Trafo::InverseMappingData< DTP_, dim_, dim_ > &inv_map_data, const LAFEM::DenseVectorBlocked< DT_, IT_, dim_ > &vector, const Space_ &space)
Evaluates a vector-valued finite-element function in a given unmapped point.
Discrete evaluation data for matrix-valued functions.
ValueType mean_value_dist(const Dist::Comm &comm) const
Computes the mean function value on a distributed domain.
std::vector< ValueType > values
the vector of values
Tiny::Matrix< DT_, dim_i_, dim_j_ > ValueType
the value type
DT_ DataType
the data type
static constexpr int dim_i
the image dimension
ValueType mean_value() const
Computes the mean function value.
bool empty() const
Checks whether the evaluation data is empty.
Discrete evaluation data for scalar functions.
bool empty() const
Checks whether the evaluation data is empty.
ValueType mean_value_dist(const Dist::Comm &comm) const
Computes the mean function value on a distributed domain.
ValueType mean_value() const
Computes the mean function value.
std::vector< ValueType > values
the vector of values
DT_ DataType
the data type
DataType ValueType
the value type
static constexpr int dim
the image dimension
Discrete evaluation data for vector-valued functions.
static constexpr int dim
the image dimension
Tiny::Vector< DT_, dim_ > ValueType
the value type
std::vector< ValueType > values
the vector of values
DT_ DataType
the data type
bool empty() const
Checks whether the evaluation data is empty.
ValueType mean_value() const
Computes the mean function value.
ValueType mean_value_dist(const Dist::Comm &comm) const
Computes the mean function value on a distributed domain.
void allreduce(const void *sendbuf, void *recvbuf, std::size_t count, const Datatype &datatype, const Operation &op) const
Blocking All-Reduce.
Blocked Dense data vector class template.
Dense data vector class template.
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 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.
Data structure for InverseMapping evaluations.
std::vector< Index > cells
the indices of the cells that intersect with the image point
std::vector< DomainPointType > dom_points
the domain points on each cell that map onto the image point
Inverse Trafo mapping class template.
InvMapDataType unmap_point(const ImagePointType &img_point, bool ignore_failures=false) const
Unmaps a given image point.
const Operation op_sum(MPI_SUM)
Operation wrapper for MPI_SUM.
CUDA_HOST_DEVICE void axpy(T_ &y, const T_ &x, const T_ &alpha)
Performs an AXPY of two scalars.
@ value
specifies whether the space should supply basis function values
std::uint64_t Index
Index data type.
@ dom_point
specifies whether the trafo should supply domain point coordinates