17#ifndef dealii_matrix_free_vector_access_internal_h
18#define dealii_matrix_free_vector_access_internal_h
38 template <
typename VectorType,
39 typename std::enable_if<!has_local_element<VectorType>::value,
40 VectorType>::type * =
nullptr>
41 inline typename VectorType::value_type
52 template <
typename VectorType,
53 typename std::enable_if<!has_local_element<VectorType>::value,
54 VectorType>::type * =
nullptr>
55 inline typename VectorType::value_type &
66 template <
typename VectorType,
67 typename std::enable_if<has_local_element<VectorType>::value,
68 VectorType>::type * =
nullptr>
69 inline typename VectorType::value_type &
72 return vec.local_element(entry);
78 template <
typename VectorType,
79 typename std::enable_if<has_local_element<VectorType>::value,
80 VectorType>::type * =
nullptr>
81 inline typename VectorType::value_type
82 vector_access(
const VectorType &vec,
const unsigned int entry)
84 return vec.local_element(entry);
89 template <
typename VectorType,
90 typename std::enable_if<has_add_local_element<VectorType>::value,
91 VectorType>::type * =
nullptr>
94 const unsigned int entry,
95 const typename VectorType::value_type &val)
97 vec.add_local_element(entry, val);
102 template <
typename VectorType,
103 typename std::enable_if<!has_add_local_element<VectorType>::value,
104 VectorType>::type * =
nullptr>
107 const unsigned int entry,
108 const typename VectorType::value_type &val)
115 template <
typename VectorType,
116 typename std::enable_if<has_add_local_element<VectorType>::value,
117 VectorType>::type * =
nullptr>
121 const typename VectorType::value_type &val)
128 template <
typename VectorType,
129 typename std::enable_if<!has_add_local_element<VectorType>::value,
130 VectorType>::type * =
nullptr>
134 const typename VectorType::value_type &val)
141 template <
typename VectorType,
142 typename std::enable_if<has_set_local_element<VectorType>::value,
143 VectorType>::type * =
nullptr>
146 const unsigned int entry,
147 const typename VectorType::value_type &val)
149 vec.set_local_element(entry, val);
154 template <
typename VectorType,
155 typename std::enable_if<!has_set_local_element<VectorType>::value,
156 VectorType>::type * =
nullptr>
159 const unsigned int entry,
160 const typename VectorType::value_type &val)
173 typename std::enable_if<!has_partitioners_are_compatible<VectorType>::value,
174 VectorType>::type * =
nullptr>
177 const VectorType & vec,
191 typename std::enable_if<has_partitioners_are_compatible<VectorType>::value,
192 VectorType>::type * =
nullptr>
195 const VectorType & vec,
202 "The parallel layout of the given vector is not "
203 "compatible with the parallel partitioning in MatrixFree. "
204 "A potential reason is that you did not use "
205 "MatrixFree::initialize_dof_vector() to get a "
206 "compatible vector. If you did, the dof_handler_index "
207 "used there and the one passed to the constructor of "
208 "FEEvaluation do not match."));
219 template <
typename Number,
typename VectorizedArrayType>
222 template <
typename VectorType>
225 const VectorType & vec,
233 template <
typename VectorNumberType>
242 template <
typename VectorType>
245 const unsigned int dof_index,
247 VectorizedArrayType *dof_values,
248 std::integral_constant<bool, true>)
const
250 const Number *vec_ptr = vec.begin() + dof_index;
251 for (
unsigned int i = 0; i < dofs_per_cell;
252 ++i, vec_ptr += VectorizedArrayType::size())
253 dof_values[i].load(vec_ptr);
258 template <
typename VectorType>
261 const unsigned int dof_index,
262 const VectorType & vec,
263 VectorizedArrayType *dof_values,
264 std::integral_constant<bool, false>)
const
266 for (
unsigned int i = 0; i < dofs_per_cell; ++i)
267 for (
unsigned int v = 0; v < VectorizedArrayType::size(); ++v)
269 vector_access(vec, dof_index + v + i * VectorizedArrayType::size());
274 template <
typename VectorType>
277 const unsigned int * dof_indices,
279 VectorizedArrayType *dof_values,
280 std::integral_constant<bool, true>)
const
290 template <
typename VectorType>
293 const unsigned int * dof_indices,
294 const VectorType & vec,
295 VectorizedArrayType *dof_values,
296 std::integral_constant<bool, false>)
const
298 for (
unsigned int d = 0;
d < dofs_per_cell; ++
d)
299 for (
unsigned int v = 0; v < VectorizedArrayType::size(); ++v)
305 template <
typename Number2>
308 const unsigned int dofs_per_cell,
309 const std::array<Number2 *, VectorizedArrayType::size()> &global_ptr,
310 VectorizedArrayType * dof_values,
311 std::integral_constant<bool, true>)
const
320 template <
typename Number2>
324 const std::array<Number2 *, VectorizedArrayType::size()> &,
325 VectorizedArrayType *,
326 std::integral_constant<bool, false>)
const
335 template <
typename VectorType>
339 const unsigned int constant_offset,
340 VectorizedArrayType &res,
341 std::integral_constant<bool, true>)
const
343 res.gather(vec.begin() + constant_offset, indices);
350 template <
typename VectorType>
353 const VectorType & vec,
354 const unsigned int constant_offset,
355 VectorizedArrayType &res,
356 std::integral_constant<bool, false>)
const
358 for (
unsigned int v = 0; v < VectorizedArrayType::size(); ++v)
364 template <
typename VectorType>
367 const VectorType & vec,
383 template <
typename VectorType>
387 const VectorType & vec,
406 res = VectorizedArrayType();
414 template <
typename Number,
typename VectorizedArrayType>
417 template <
typename VectorType>
419 process_dof(
const unsigned int index, VectorType &vec, Number &res)
const
425 template <
typename VectorNumberType>
434 template <
typename VectorType>
437 const unsigned int dof_index,
439 VectorizedArrayType *dof_values,
440 std::integral_constant<bool, true>)
const
442 Number *vec_ptr = vec.begin() + dof_index;
443 for (
unsigned int i = 0; i < dofs_per_cell;
444 ++i, vec_ptr += VectorizedArrayType::size())
446 VectorizedArrayType tmp;
448 tmp += dof_values[i];
455 template <
typename VectorType>
458 const unsigned int dof_index,
460 VectorizedArrayType *dof_values,
461 std::integral_constant<bool, false>)
const
463 for (
unsigned int i = 0; i < dofs_per_cell; ++i)
464 for (
unsigned int v = 0; v < VectorizedArrayType::size(); ++v)
466 dof_index + v + i * VectorizedArrayType::size(),
472 template <
typename VectorType>
475 const unsigned int * dof_indices,
477 VectorizedArrayType *dof_values,
478 std::integral_constant<bool, true>)
const
481 true, dofs_per_cell, dof_values, dof_indices, vec.begin());
486 template <
typename VectorType>
489 const unsigned int * dof_indices,
491 VectorizedArrayType *dof_values,
492 std::integral_constant<bool, false>)
const
494 for (
unsigned int d = 0;
d < dofs_per_cell; ++
d)
495 for (
unsigned int v = 0; v < VectorizedArrayType::size(); ++v)
501 template <
typename Number2>
504 const unsigned int dofs_per_cell,
505 std::array<Number2 *, VectorizedArrayType::size()> &global_ptr,
506 VectorizedArrayType * dof_values,
507 std::integral_constant<bool, true>)
const
517 template <
typename Number2>
521 std::array<Number2 *, VectorizedArrayType::size()> &,
522 VectorizedArrayType *,
523 std::integral_constant<bool, false>)
const
532 template <
typename VectorType>
536 const unsigned int constant_offset,
537 VectorizedArrayType &res,
538 std::integral_constant<bool, true>)
const
540#if DEAL_II_VECTORIZATION_WIDTH_IN_BITS < 512
541 for (
unsigned int v = 0; v < VectorizedArrayType::size(); ++v)
545 VectorizedArrayType tmp;
546 tmp.gather(vec.begin() + constant_offset, indices);
548 tmp.scatter(indices, vec.begin() + constant_offset);
556 template <
typename VectorType>
560 const unsigned int constant_offset,
561 VectorizedArrayType &res,
562 std::integral_constant<bool, false>)
const
564 for (
unsigned int v = 0; v < VectorizedArrayType::size(); ++v)
570 template <
typename VectorType>
589 template <
typename VectorType>
615 template <
typename Number,
typename VectorizedArrayType>
618 template <
typename VectorType>
620 process_dof(
const unsigned int index, VectorType &vec, Number &res)
const
627 template <
typename VectorNumberType>
636 template <
typename VectorType>
639 const unsigned int dof_index,
641 VectorizedArrayType *dof_values,
642 std::integral_constant<bool, true>)
const
644 Number *vec_ptr = vec.begin() + dof_index;
645 for (
unsigned int i = 0; i < dofs_per_cell;
646 ++i, vec_ptr += VectorizedArrayType::size())
647 dof_values[i].store(vec_ptr);
652 template <
typename VectorType>
655 const unsigned int dof_index,
657 VectorizedArrayType *dof_values,
658 std::integral_constant<bool, false>)
const
660 for (
unsigned int i = 0; i < dofs_per_cell; ++i)
661 for (
unsigned int v = 0; v < VectorizedArrayType::size(); ++v)
662 vector_access(vec, dof_index + v + i * VectorizedArrayType::size()) =
668 template <
typename VectorType>
671 const unsigned int * dof_indices,
673 VectorizedArrayType *dof_values,
674 std::integral_constant<bool, true>)
const
677 false, dofs_per_cell, dof_values, dof_indices, vec.begin());
682 template <
typename VectorType,
bool booltype>
685 const unsigned int * dof_indices,
687 VectorizedArrayType *dof_values,
688 std::integral_constant<bool, false>)
const
690 for (
unsigned int i = 0; i < dofs_per_cell; ++i)
691 for (
unsigned int v = 0; v < VectorizedArrayType::size(); ++v)
697 template <
typename Number2>
700 const unsigned int dofs_per_cell,
701 std::array<Number2 *, VectorizedArrayType::size()> &global_ptr,
702 VectorizedArrayType * dof_values,
703 std::integral_constant<bool, true>)
const
713 template <
typename Number2>
717 std::array<Number2 *, VectorizedArrayType::size()> &,
718 VectorizedArrayType *,
719 std::integral_constant<bool, false>)
const
726 template <
typename VectorType>
730 const unsigned int constant_offset,
731 VectorizedArrayType &res,
732 std::integral_constant<bool, true>)
const
734 res.scatter(indices, vec.begin() + constant_offset);
739 template <
typename VectorType>
743 const unsigned int constant_offset,
744 VectorizedArrayType &res,
745 std::integral_constant<bool, false>)
const
747 for (
unsigned int v = 0; v < VectorizedArrayType::size(); ++v)
753 template <
typename VectorType>
770 template <
typename VectorType>
#define DEAL_II_NAMESPACE_OPEN
#define DEAL_II_NAMESPACE_CLOSE
static ::ExceptionBase & ExcNotImplemented()
#define Assert(cond, exc)
#define AssertDimension(dim1, dim2)
static ::ExceptionBase & ExcMessage(std::string arg1)
SymmetricTensor< 2, dim, Number > d(const Tensor< 2, dim, Number > &F, const Tensor< 2, dim, Number > &dF_dt)
T sum(const T &t, const MPI_Comm &mpi_communicator)
void vector_access_add(VectorType &vec, const unsigned int entry, const typename VectorType::value_type &val)
void vector_access_add_global(VectorType &vec, const types::global_dof_index entry, const typename VectorType::value_type &val)
void check_vector_compatibility(const VectorType &vec, const internal::MatrixFreeFunctions::DoFInfo &dof_info)
VectorType::value_type vector_access(const VectorType &vec, const unsigned int entry)
void vector_access_set(VectorType &vec, const unsigned int entry, const typename VectorType::value_type &val)
std::shared_ptr< const Utilities::MPI::Partitioner > vector_partitioner
void process_dof_gather(const unsigned int *indices, VectorType &vec, const unsigned int constant_offset, VectorizedArrayType &res, std::integral_constant< bool, true >) const
void pre_constraints(const Number &input, Number &res) const
void process_dofs_vectorized_transpose(const unsigned int dofs_per_cell, const unsigned int *dof_indices, VectorType &vec, VectorizedArrayType *dof_values, std::integral_constant< bool, true >) const
void process_dofs_vectorized_transpose(const unsigned int, std::array< Number2 *, VectorizedArrayType::size()> &, VectorizedArrayType *, std::integral_constant< bool, false >) const
void process_empty(VectorizedArrayType &) const
void process_dof(const unsigned int index, VectorType &vec, Number &res) const
void process_dofs_vectorized(const unsigned int dofs_per_cell, const unsigned int dof_index, VectorType &vec, VectorizedArrayType *dof_values, std::integral_constant< bool, true >) const
void post_constraints(const Number &, Number &) const
void process_dofs_vectorized_transpose(const unsigned int dofs_per_cell, const unsigned int *dof_indices, VectorType &vec, VectorizedArrayType *dof_values, std::integral_constant< bool, false >) const
void process_dofs_vectorized_transpose(const unsigned int dofs_per_cell, std::array< Number2 *, VectorizedArrayType::size()> &global_ptr, VectorizedArrayType *dof_values, std::integral_constant< bool, true >) const
void process_dof_gather(const unsigned int *indices, VectorType &vec, const unsigned int constant_offset, VectorizedArrayType &res, std::integral_constant< bool, false >) const
void process_dof(VectorNumberType &global, Number &local) const
void process_dofs_vectorized(const unsigned int dofs_per_cell, const unsigned int dof_index, VectorType &vec, VectorizedArrayType *dof_values, std::integral_constant< bool, false >) const
void process_constraint(const unsigned int index, const Number weight, VectorType &vec, Number &res) const
void process_dof_global(const types::global_dof_index index, VectorType &vec, Number &res) const
void process_dof_gather(const unsigned int *indices, VectorType &vec, const unsigned int constant_offset, VectorizedArrayType &res, std::integral_constant< bool, true >) const
void process_dof_gather(const unsigned int *indices, const VectorType &vec, const unsigned int constant_offset, VectorizedArrayType &res, std::integral_constant< bool, false >) const
void process_dofs_vectorized(const unsigned int dofs_per_cell, const unsigned int dof_index, VectorType &vec, VectorizedArrayType *dof_values, std::integral_constant< bool, true >) const
void pre_constraints(const Number &, Number &res) const
void post_constraints(const Number &sum, Number &write_pos) const
void process_dofs_vectorized_transpose(const unsigned int dofs_per_cell, const unsigned int *dof_indices, const VectorType &vec, VectorizedArrayType *dof_values, std::integral_constant< bool, false >) const
void process_dof_global(const types::global_dof_index index, const VectorType &vec, Number &res) const
void process_dofs_vectorized_transpose(const unsigned int dofs_per_cell, const unsigned int *dof_indices, VectorType &vec, VectorizedArrayType *dof_values, std::integral_constant< bool, true >) const
void process_dofs_vectorized(const unsigned int dofs_per_cell, const unsigned int dof_index, const VectorType &vec, VectorizedArrayType *dof_values, std::integral_constant< bool, false >) const
void process_constraint(const unsigned int index, const Number weight, const VectorType &vec, Number &res) const
void process_dof(const VectorNumberType &global, Number &local) const
void process_dofs_vectorized_transpose(const unsigned int dofs_per_cell, const std::array< Number2 *, VectorizedArrayType::size()> &global_ptr, VectorizedArrayType *dof_values, std::integral_constant< bool, true >) const
void process_empty(VectorizedArrayType &res) const
void process_dofs_vectorized_transpose(const unsigned int, const std::array< Number2 *, VectorizedArrayType::size()> &, VectorizedArrayType *, std::integral_constant< bool, false >) const
void process_dof(const unsigned int index, const VectorType &vec, Number &res) const
void process_dofs_vectorized(const unsigned int dofs_per_cell, const unsigned int dof_index, VectorType &vec, VectorizedArrayType *dof_values, std::integral_constant< bool, true >) const
void process_empty(VectorizedArrayType &) const
void process_dofs_vectorized_transpose(const unsigned int, std::array< Number2 *, VectorizedArrayType::size()> &, VectorizedArrayType *, std::integral_constant< bool, false >) const
void process_dofs_vectorized_transpose(const unsigned int dofs_per_cell, const unsigned int *dof_indices, VectorType &vec, VectorizedArrayType *dof_values, std::integral_constant< bool, false >) const
void process_dof_global(const types::global_dof_index index, VectorType &vec, Number &res) const
void pre_constraints(const Number &, Number &) const
void process_dofs_vectorized_transpose(const unsigned int dofs_per_cell, std::array< Number2 *, VectorizedArrayType::size()> &global_ptr, VectorizedArrayType *dof_values, std::integral_constant< bool, true >) const
void process_dofs_vectorized(const unsigned int dofs_per_cell, const unsigned int dof_index, VectorType &vec, VectorizedArrayType *dof_values, std::integral_constant< bool, false >) const
void process_dofs_vectorized_transpose(const unsigned int dofs_per_cell, const unsigned int *dof_indices, VectorType &vec, VectorizedArrayType *dof_values, std::integral_constant< bool, true >) const
void process_constraint(const unsigned int, const Number, VectorType &, Number &) const
void process_dof(const unsigned int index, VectorType &vec, Number &res) const
void process_dof_gather(const unsigned int *indices, VectorType &vec, const unsigned int constant_offset, VectorizedArrayType &res, std::integral_constant< bool, true >) const
void process_dof_gather(const unsigned int *indices, VectorType &vec, const unsigned int constant_offset, VectorizedArrayType &res, std::integral_constant< bool, false >) const
void post_constraints(const Number &, Number &) const
void process_dof(VectorNumberType &global, Number &local) const
void vectorized_load_and_transpose(const unsigned int n_entries, const Number *in, const unsigned int *offsets, VectorizedArray< Number, width > *out)
void vectorized_transpose_and_store(const bool add_into, const unsigned int n_entries, const VectorizedArray< Number, width > *in, const unsigned int *offsets, Number *out)