37 #include <boost/container/small_vector.hpp>
41 #include <type_traits>
48 template <
int dim,
int spacedim>
49 inline std::vector<unsigned int>
52 std::vector<unsigned int> shape_function_to_row_table(
61 unsigned int nth_nonzero_component = 0;
66 row + nth_nonzero_component;
67 ++nth_nonzero_component;
72 return shape_function_to_row_table;
79 template <
typename Number,
typename T =
void>
83 value(
const Number &value)
94 template <
typename Number>
97 std::enable_if_t<Differentiation::AD::is_ad_number<Number>::value>>
100 value(
const Number & )
110 template <
int dim,
int spacedim>
113 , cell(typename
Triangulation<dim, spacedim>::cell_iterator(nullptr, -1, -1))
114 , dof_handler(nullptr)
115 , level_dof_access(false)
120 template <
int dim,
int spacedim>
125 , dof_handler(nullptr)
126 , level_dof_access(false)
131 template <
int dim,
int spacedim>
140 template <
int dim,
int spacedim>
151 template <
int dim,
int spacedim>
157 Assert(dof_handler !=
nullptr, ExcNeedsDoFHandler());
159 return dof_handler->n_dofs();
164 template <
int dim,
int spacedim>
165 template <
typename Number>
172 Assert(dof_handler !=
nullptr, ExcNeedsDoFHandler());
174 if (level_dof_access)
190 template <
int dim,
int spacedim>
197 Assert(dof_handler !=
nullptr, ExcNeedsDoFHandler());
201 &cell->get_triangulation(), cell->level(), cell->index(), dof_handler);
204 cell_dofs.get_fe().n_dofs_per_cell());
207 for (
unsigned int i = 0; i < cell_dofs.get_fe().n_dofs_per_cell(); ++i)
216 template <
int dim,
int spacedim>
218 const unsigned int n_q_points,
227 ,
fe(&
fe, typeid(*this).name())
233 ExcMessage(
"There is nothing useful you can do with an FEValues "
234 "object when using a quadrature formula with zero "
235 "quadrature points!"));
241 template <
int dim,
int spacedim>
250 template <
int dim,
int spacedim>
269 template <
typename Number,
typename Number2>
272 const ::Table<2, double> &shape_values,
273 std::vector<Number> &
values)
280 std::fill_n(
values.begin(),
291 for (
unsigned int shape_func = 0; shape_func <
dofs_per_cell; ++shape_func)
293 const Number2
value = dof_values[shape_func];
301 const double *shape_value_ptr = &shape_values(shape_func, 0);
309 template <
int dim,
int spacedim,
typename VectorType>
313 const ::Table<2, double> &shape_values,
315 const std::vector<unsigned int> &shape_function_to_row_table,
317 const bool quadrature_points_fastest =
false,
318 const unsigned int component_multiple = 1)
320 using Number =
typename VectorType::value_type;
322 for (
unsigned int i = 0; i <
values.size(); ++i)
325 typename VectorType::value_type());
334 quadrature_points_fastest ?
values[0].size() :
values.size();
335 const unsigned int n_components =
fe.n_components();
338 const unsigned result_components = n_components * component_multiple;
339 (void)result_components;
340 if (quadrature_points_fastest)
343 for (
unsigned int i = 0; i <
values.size(); ++i)
349 for (
unsigned int i = 0; i <
values.size(); ++i)
356 for (
unsigned int mc = 0; mc < component_multiple; ++mc)
357 for (
unsigned int shape_func = 0; shape_func <
dofs_per_cell;
364 if (::internal::CheckForZero<Number>::value(
value) ==
true)
367 if (
fe.is_primitive(shape_func))
369 const unsigned int comp =
370 fe.system_to_component_index(shape_func).first +
372 const unsigned int row =
373 shape_function_to_row_table[shape_func * n_components + comp];
375 const double *shape_value_ptr = &shape_values(row, 0);
377 if (quadrature_points_fastest)
379 VectorType &values_comp =
values[comp];
382 values_comp[
point] +=
value * (*shape_value_ptr++);
390 for (
unsigned int c = 0; c < n_components; ++c)
392 if (
fe.get_nonzero_components(shape_func)[c] ==
false)
395 const unsigned int row =
396 shape_function_to_row_table[shape_func * n_components + c];
398 const double *shape_value_ptr = &shape_values(row, 0);
399 const unsigned int comp = c + mc * n_components;
401 if (quadrature_points_fastest)
403 VectorType &values_comp =
values[comp];
406 values_comp[
point] +=
value * (*shape_value_ptr++);
420 template <
int order,
int spacedim,
typename Number>
427 const unsigned int dofs_per_cell = shape_derivatives.size()[0];
431 std::fill_n(derivatives.begin(),
442 for (
unsigned int shape_func = 0; shape_func <
dofs_per_cell; ++shape_func)
444 const Number &
value = dof_values[shape_func];
448 if (::internal::CheckForZero<Number>::value(
value) ==
true)
452 &shape_derivatives[shape_func][0];
454 derivatives[
point] +=
value * (*shape_derivative_ptr++);
460 template <
int order,
int dim,
int spacedim,
typename Number>
466 const std::vector<unsigned int> &shape_function_to_row_table,
468 const bool quadrature_points_fastest =
false,
469 const unsigned int component_multiple = 1)
472 for (
unsigned int i = 0; i < derivatives.size(); ++i)
473 std::fill_n(derivatives[i].
begin(),
474 derivatives[i].size(),
485 quadrature_points_fastest ? derivatives[0].size() : derivatives.size();
486 const unsigned int n_components =
fe.n_components();
489 const unsigned result_components = n_components * component_multiple;
490 (void)result_components;
491 if (quadrature_points_fastest)
494 for (
unsigned int i = 0; i < derivatives.size(); ++i)
500 for (
unsigned int i = 0; i < derivatives.size(); ++i)
507 for (
unsigned int mc = 0; mc < component_multiple; ++mc)
508 for (
unsigned int shape_func = 0; shape_func <
dofs_per_cell;
511 const Number &value = dof_values[shape_func + mc *
dofs_per_cell];
515 if (::internal::CheckForZero<Number>::value(value) ==
true)
518 if (
fe.is_primitive(shape_func))
520 const unsigned int comp =
521 fe.system_to_component_index(shape_func).first +
523 const unsigned int row =
524 shape_function_to_row_table[shape_func * n_components + comp];
527 &shape_derivatives[row][0];
529 if (quadrature_points_fastest)
532 derivatives[comp][
point] += value * (*shape_derivative_ptr++);
536 derivatives[
point][comp] += value * (*shape_derivative_ptr++);
539 for (
unsigned int c = 0; c < n_components; ++c)
541 if (
fe.get_nonzero_components(shape_func)[c] ==
false)
544 const unsigned int row =
545 shape_function_to_row_table[shape_func * n_components + c];
548 &shape_derivatives[row][0];
549 const unsigned int comp = c + mc * n_components;
551 if (quadrature_points_fastest)
554 derivatives[comp][
point] +=
555 value * (*shape_derivative_ptr++);
559 derivatives[
point][comp] +=
560 value * (*shape_derivative_ptr++);
567 template <
int spacedim,
typename Number,
typename Number2>
572 std::vector<Number> &laplacians)
578 std::fill_n(laplacians.begin(),
585 for (
unsigned int shape_func = 0; shape_func <
dofs_per_cell; ++shape_func)
587 const Number2 value = dof_values[shape_func];
596 &shape_hessians[shape_func][0];
598 laplacians[
point] += value *
trace(*shape_hessian_ptr++);
604 template <
int dim,
int spacedim,
typename VectorType,
typename Number>
610 const std::vector<unsigned int> &shape_function_to_row_table,
611 std::vector<VectorType> &laplacians,
612 const bool quadrature_points_fastest =
false,
613 const unsigned int component_multiple = 1)
616 for (
unsigned int i = 0; i < laplacians.size(); ++i)
617 std::fill_n(laplacians[i].
begin(),
618 laplacians[i].size(),
619 typename VectorType::value_type());
629 const unsigned int n_components =
fe.n_components();
632 const unsigned result_components = n_components * component_multiple;
633 (void)result_components;
634 if (quadrature_points_fastest)
637 for (
unsigned int i = 0; i < laplacians.size(); ++i)
643 for (
unsigned int i = 0; i < laplacians.size(); ++i)
650 for (
unsigned int mc = 0; mc < component_multiple; ++mc)
651 for (
unsigned int shape_func = 0; shape_func <
dofs_per_cell;
654 const Number &value = dof_values[shape_func + mc *
dofs_per_cell];
658 if (::internal::CheckForZero<Number>::value(value) ==
true)
661 if (
fe.is_primitive(shape_func))
663 const unsigned int comp =
664 fe.system_to_component_index(shape_func).first +
666 const unsigned int row =
667 shape_function_to_row_table[shape_func * n_components + comp];
670 &shape_hessians[row][0];
671 if (quadrature_points_fastest)
673 VectorType &laplacians_comp = laplacians[comp];
676 laplacians_comp[
point] +=
677 value *
trace(*shape_hessian_ptr++);
683 value *
trace(*shape_hessian_ptr++);
686 for (
unsigned int c = 0; c < n_components; ++c)
688 if (
fe.get_nonzero_components(shape_func)[c] ==
false)
691 const unsigned int row =
692 shape_function_to_row_table[shape_func * n_components + c];
695 &shape_hessians[row][0];
696 const unsigned int comp = c + mc * n_components;
698 if (quadrature_points_fastest)
700 VectorType &laplacians_comp = laplacians[comp];
703 laplacians_comp[
point] +=
704 value *
trace(*shape_hessian_ptr++);
709 laplacians[
point][comp] +=
710 value *
trace(*shape_hessian_ptr++);
718 template <
int dim,
int spacedim>
719 template <
typename Number>
723 std::vector<Number> &
values)
const
736 this->finite_element_output.shape_values,
742 template <
int dim,
int spacedim>
743 template <
typename Number>
748 std::vector<Number> &
values)
const
755 boost::container::small_vector<Number, 200> dof_values(
dofs_per_cell);
765 template <
int dim,
int spacedim>
766 template <
typename Number>
783 this->finite_element_output.shape_values,
785 this->finite_element_output.shape_function_to_row_table,
791 template <
int dim,
int spacedim>
792 template <
typename Number>
806 boost::container::small_vector<Number, 200> dof_values(
dofs_per_cell);
813 this->finite_element_output.shape_function_to_row_table,
821 template <
int dim,
int spacedim>
822 template <
typename Number>
828 const bool quadrature_points_fastest)
const
838 boost::container::small_vector<Number, 200> dof_values(
dofs_per_cell);
845 this->finite_element_output.shape_function_to_row_table,
847 quadrature_points_fastest,
853 template <
int dim,
int spacedim>
854 template <
typename Number>
871 this->finite_element_output.shape_gradients,
877 template <
int dim,
int spacedim>
878 template <
typename Number>
890 boost::container::small_vector<Number, 200> dof_values(
dofs_per_cell);
900 template <
int dim,
int spacedim>
901 template <
typename Number>
917 this->finite_element_output.shape_gradients,
919 this->finite_element_output.shape_function_to_row_table,
925 template <
int dim,
int spacedim>
926 template <
typename Number>
932 const bool quadrature_points_fastest)
const
941 boost::container::small_vector<Number, 200> dof_values(
dofs_per_cell);
948 this->finite_element_output.shape_function_to_row_table,
950 quadrature_points_fastest,
956 template <
int dim,
int spacedim>
957 template <
typename Number>
974 this->finite_element_output.shape_hessians,
980 template <
int dim,
int spacedim>
981 template <
typename Number>
993 boost::container::small_vector<Number, 200> dof_values(
dofs_per_cell);
1003 template <
int dim,
int spacedim>
1004 template <
typename Number>
1009 const bool quadrature_points_fastest)
const
1021 this->finite_element_output.shape_hessians,
1023 this->finite_element_output.shape_function_to_row_table,
1025 quadrature_points_fastest);
1030 template <
int dim,
int spacedim>
1031 template <
typename Number>
1037 const bool quadrature_points_fastest)
const
1044 boost::container::small_vector<Number, 200> dof_values(indices.
size());
1051 this->finite_element_output.shape_function_to_row_table,
1053 quadrature_points_fastest,
1059 template <
int dim,
int spacedim>
1060 template <
typename Number>
1064 std::vector<Number> &laplacians)
const
1077 this->finite_element_output.shape_hessians,
1083 template <
int dim,
int spacedim>
1084 template <
typename Number>
1089 std::vector<Number> &laplacians)
const
1096 boost::container::small_vector<Number, 200> dof_values(
dofs_per_cell);
1106 template <
int dim,
int spacedim>
1107 template <
typename Number>
1123 this->finite_element_output.shape_hessians,
1125 this->finite_element_output.shape_function_to_row_table,
1131 template <
int dim,
int spacedim>
1132 template <
typename Number>
1146 boost::container::small_vector<Number, 200> dof_values(indices.
size());
1153 this->finite_element_output.shape_function_to_row_table,
1161 template <
int dim,
int spacedim>
1162 template <
typename Number>
1167 std::vector<std::vector<Number>> &laplacians,
1168 const bool quadrature_points_fastest)
const
1175 boost::container::small_vector<Number, 200> dof_values(indices.
size());
1182 this->finite_element_output.shape_function_to_row_table,
1184 quadrature_points_fastest,
1190 template <
int dim,
int spacedim>
1191 template <
typename Number>
1208 this->finite_element_output.shape_3rd_derivatives,
1214 template <
int dim,
int spacedim>
1215 template <
typename Number>
1227 boost::container::small_vector<Number, 200> dof_values(
dofs_per_cell);
1236 template <
int dim,
int spacedim>
1237 template <
typename Number>
1242 const bool quadrature_points_fastest)
const
1254 this->finite_element_output.shape_3rd_derivatives,
1256 this->finite_element_output.shape_function_to_row_table,
1258 quadrature_points_fastest);
1263 template <
int dim,
int spacedim>
1264 template <
typename Number>
1270 const bool quadrature_points_fastest)
const
1277 boost::container::small_vector<Number, 200> dof_values(indices.
size());
1284 this->finite_element_output.shape_function_to_row_table,
1286 quadrature_points_fastest,
1292 template <
int dim,
int spacedim>
1301 template <
int dim,
int spacedim>
1302 const std::vector<Tensor<1, spacedim>> &
1307 "update_normal_vectors")));
1314 template <
int dim,
int spacedim>
1335 template <
int dim,
int spacedim>
1354 template <
int dim,
int spacedim>
1372 template <
int dim,
int spacedim>
1415 template <
int dim,
int spacedim>
1436 (cell->is_translation_of(
1447 ->direction_flag() != cell->direction_flag())
1456 template <
int dim,
int spacedim>
1465 template <
int dim,
int spacedim>
1470 template <
int dim,
int spacedim>
1476 #include "fe_values_base.inst"
ArrayView< typename std::remove_reference< typename std::iterator_traits< Iterator >::reference >::type, MemorySpaceType > make_array_view(const Iterator begin, const Iterator end)
void get_interpolated_dof_values(const ReadVector< Number > &values, Vector< Number > &interpolated_values, const types::fe_index fe_index=numbers::invalid_fe_index) const
bool is_initialized() const
types::global_dof_index n_dofs_for_dof_handler() const
void get_interpolated_dof_values(const ReadVector< Number > &in, Vector< Number > &out) const
CellSimilarity::Similarity cell_similarity
void get_function_hessians(const ReadVector< Number > &fe_function, std::vector< Tensor< 2, spacedim, Number >> &hessians) const
CellIteratorContainer present_cell
::internal::FEValuesViews::Cache< dim, spacedim > fe_values_views_cache
Triangulation< dim, spacedim >::cell_iterator get_cell() const
boost::signals2::connection tria_listener_mesh_transform
void get_function_values(const ReadVector< Number > &fe_function, std::vector< Number > &values) const
FEValuesBase(const unsigned int n_q_points, const unsigned int dofs_per_cell, const UpdateFlags update_flags, const Mapping< dim, spacedim > &mapping, const FiniteElement< dim, spacedim > &fe)
internal::FEValuesImplementation::MappingRelatedData< dim, spacedim > mapping_output
void get_function_third_derivatives(const ReadVector< Number > &fe_function, std::vector< Tensor< 3, spacedim, Number >> &third_derivatives) const
virtual ~FEValuesBase() override
const SmartPointer< const Mapping< dim, spacedim >, FEValuesBase< dim, spacedim > > mapping
const unsigned int dofs_per_cell
void check_cell_similarity(const typename Triangulation< dim, spacedim >::cell_iterator &cell)
const SmartPointer< const FiniteElement< dim, spacedim >, FEValuesBase< dim, spacedim > > fe
void always_allow_check_for_cell_similarity(const bool allow)
void get_function_laplacians(const ReadVector< Number > &fe_function, std::vector< Number > &laplacians) const
const unsigned int n_quadrature_points
CellSimilarity::Similarity get_cell_similarity() const
const std::vector< Tensor< 1, spacedim > > & get_normal_vectors() const
std::size_t memory_consumption() const
std_cxx20::ranges::iota_view< unsigned int, unsigned int > dof_indices() const
UpdateFlags compute_update_flags(const UpdateFlags update_flags) const
std::unique_ptr< typename Mapping< dim, spacedim >::InternalDataBase > mapping_data
void get_function_gradients(const ReadVector< Number > &fe_function, std::vector< Tensor< 1, spacedim, Number >> &gradients) const
boost::signals2::connection tria_listener_refinement
void invalidate_present_cell()
bool check_for_cell_similarity_allowed
::internal::FEValuesImplementation::FiniteElementRelatedData< dim, spacedim > finite_element_output
std::unique_ptr< typename FiniteElement< dim, spacedim >::InternalDataBase > fe_data
void maybe_invalidate_previous_present_cell(const typename Triangulation< dim, spacedim >::cell_iterator &cell)
const unsigned int max_n_quadrature_points
unsigned int n_dofs_per_cell() const
unsigned int n_components() const
const ComponentMask & get_nonzero_components(const unsigned int i) const
virtual UpdateFlags requires_update_flags(const UpdateFlags update_flags) const =0
unsigned int n_nonzero_components(const unsigned int i) const
virtual UpdateFlags requires_update_flags(const UpdateFlags update_flags) const =0
virtual size_type size() const =0
virtual void extract_subvector_to(const ArrayView< const types::global_dof_index > &indices, ArrayView< Number > &elements) const =0
Triangulation< dim, spacedim > & get_triangulation()
#define DEAL_II_NAMESPACE_OPEN
#define DEAL_II_NAMESPACE_CLOSE
static ::ExceptionBase & ExcInternalError()
static ::ExceptionBase & ExcNotReinited()
#define Assert(cond, exc)
static ::ExceptionBase & ExcNotImplemented()
#define AssertDimension(dim1, dim2)
static ::ExceptionBase & ExcAccessToUninitializedField(std::string arg1)
static ::ExceptionBase & ExcMessage(std::string arg1)
static ::ExceptionBase & ExcNotMultiple(int arg1, int arg2)
TriaIterator< CellAccessor< dim, spacedim > > cell_iterator
@ update_hessians
Second derivatives of shape functions.
@ update_values
Shape function values.
@ update_normal_vectors
Normal vectors.
@ update_3rd_derivatives
Third derivatives of shape functions.
@ update_gradients
Shape function gradients.
std::enable_if_t< std::is_fundamental_v< T >, std::size_t > memory_consumption(const T &t)
Point< spacedim > point(const gp_Pnt &p, const double tolerance=1e-10)
VectorType::value_type * begin(VectorType &V)
void do_function_derivatives(const ArrayView< Number > &dof_values, const ::Table< 2, Tensor< order, spacedim >> &shape_derivatives, std::vector< Tensor< order, spacedim, Number >> &derivatives)
void do_function_laplacians(const ArrayView< Number > &dof_values, const ::Table< 2, Tensor< 2, spacedim >> &shape_hessians, const FiniteElement< dim, spacedim > &fe, const std::vector< unsigned int > &shape_function_to_row_table, std::vector< VectorType > &laplacians, const bool quadrature_points_fastest=false, const unsigned int component_multiple=1)
void do_function_values(const ArrayView< typename VectorType::value_type > &dof_values, const ::Table< 2, double > &shape_values, const FiniteElement< dim, spacedim > &fe, const std::vector< unsigned int > &shape_function_to_row_table, ArrayView< VectorType > values, const bool quadrature_points_fastest=false, const unsigned int component_multiple=1)
void do_function_derivatives(const ArrayView< Number > &dof_values, const ::Table< 2, Tensor< order, spacedim >> &shape_derivatives, const FiniteElement< dim, spacedim > &fe, const std::vector< unsigned int > &shape_function_to_row_table, ArrayView< std::vector< Tensor< order, spacedim, Number >>> derivatives, const bool quadrature_points_fastest=false, const unsigned int component_multiple=1)
void do_function_laplacians(const ArrayView< Number2 > &dof_values, const ::Table< 2, Tensor< 2, spacedim >> &shape_hessians, std::vector< Number > &laplacians)
std::vector< unsigned int > make_shape_function_to_row_table(const FiniteElement< dim, spacedim > &fe)
void do_function_values(const ArrayView< Number2 > &dof_values, const ::Table< 2, double > &shape_values, std::vector< Number > &values)
static const unsigned int invalid_unsigned_int
unsigned int global_dof_index
static constexpr DEAL_II_HOST_DEVICE_ALWAYS_INLINE const T & value(const T &t)
constexpr DEAL_II_HOST Number trace(const SymmetricTensor< 2, dim2, Number > &)