Reference documentation for deal.II version GIT 1e9e64a91d 2022-09-28 19:20:02+00:00
\(\newcommand{\dealvcentcolon}{\mathrel{\mathop{:}}}\) \(\newcommand{\dealcoloneq}{\dealvcentcolon\mathrel{\mkern-1.2mu}=}\) \(\newcommand{\jump}[1]{\left[\!\left[ #1 \right]\!\right]}\) \(\newcommand{\average}[1]{\left\{\!\left\{ #1 \right\}\!\right\}}\)
fe_immersed_values.cc
Go to the documentation of this file.
1 // ---------------------------------------------------------------------
2 //
3 // Copyright (C) 2021 - 2022 by the deal.II authors
4 //
5 // This file is part of the deal.II library.
6 //
7 // The deal.II library is free software; you can use it, redistribute
8 // it, and/or modify it under the terms of the GNU Lesser General
9 // Public License as published by the Free Software Foundation; either
10 // version 2.1 of the License, or (at your option) any later version.
11 // The full text of the license can be found in the file LICENSE.md at
12 // the top level directory of deal.II.
13 //
14 // ---------------------------------------------------------------------
15 
17 
19 
21 
22 
24 namespace NonMatching
25 {
26  template <int dim>
28  const Mapping<dim> & mapping,
29  const FiniteElement<dim> & element,
30  const ImmersedSurfaceQuadrature<dim> &quadrature,
31  const UpdateFlags update_flags)
32  : FEValuesBase<dim, dim>(quadrature.size(),
33  element.dofs_per_cell,
35  mapping,
36  element)
37  , quadrature(quadrature)
38  {
40  }
41 
42 
43 
44  template <int dim>
45  void
47  const typename Triangulation<dim>::cell_iterator &cell)
48  {
49  // Check that mapping and reference cell type are compatible:
50  Assert(this->get_mapping().is_compatible_with(cell->reference_cell()),
51  ExcMessage(
52  "You are trying to call FEImmersedSurfaceValues::reinit() with "
53  " a cell of type " +
54  cell->reference_cell().to_string() +
55  " with a Mapping that is not compatible with it."));
56 
57  // No FE in this cell, so no assertion necessary here.
58  Assert(
59  this->present_cell.is_initialized() == false,
60  ExcMessage(
61  "FEImmersedSurfaceValues::reinit() can only be used for one cell!"));
62 
63  this->present_cell = {cell};
64 
65  // This was the part of the work that is dependent on the actual data type
66  // of the iterator. Now pass on to the function doing the real work.
67  do_reinit();
68  }
69 
70 
71 
72  template <int dim>
73  template <bool level_dof_access>
74  void
77  {
78  // Check that mapping and reference cell type are compatible:
79  Assert(this->get_mapping().is_compatible_with(cell->reference_cell()),
80  ExcMessage(
81  "You are trying to call FEImmersedSurfaceValues::reinit() with "
82  "a cell of type " +
83  cell->reference_cell().to_string() +
84  " with a Mapping that is not compatible with it."));
85 
86  // Assert that the finite elements passed to the constructor and used by the
87  // DoFHandler used by this cell, are the same
88  Assert(static_cast<const FiniteElementData<dim> &>(*this->fe) ==
89  static_cast<const FiniteElementData<dim> &>(cell->get_fe()),
91 
92  Assert(
93  this->present_cell.is_initialized() == false,
94  ExcMessage(
95  "FEImmersedSurfaceValues::reinit() can only be used for one cell!"));
96 
97  this->present_cell = {cell};
98 
99  // This was the part of the work that is dependent on the actual data type
100  // of the iterator. Now pass on to the function doing the real work.
101  do_reinit();
102  }
103 
104 
105 
106  template <int dim>
107  void
109  {
110  // First call the mapping and let it generate the data specific to the
111  // mapping.
112  if (this->update_flags & update_mapping)
113  {
114  this->get_mapping().fill_fe_immersed_surface_values(
115  this->present_cell,
116  quadrature,
117  *this->mapping_data,
118  this->mapping_output);
119  }
120 
121  // Call the finite element and, with the data already filled by the mapping,
122  // let it compute the data for the mapped shape function values, gradients
123  // etc.
124  this->get_fe().fill_fe_values(this->present_cell,
126  this->quadrature,
127  this->get_mapping(),
128  *this->mapping_data,
129  this->mapping_output,
130  *this->fe_data,
131  this->finite_element_output);
132  }
133 
134 
135 
136  template <int dim>
139  const unsigned int function_no,
140  const unsigned int quadrature_point) const
141  {
142  const unsigned int component = 0;
143  return shape_surface_grad_component(function_no,
144  quadrature_point,
145  component);
146  }
147 
148 
149 
150  template <int dim>
153  const unsigned int function_no,
154  const unsigned int quadrature_point,
155  const unsigned int component) const
156  {
157  const Tensor<1, dim> gradient =
158  this->shape_grad_component(function_no, quadrature_point, component);
159  const Tensor<1, dim> &normal = this->normal_vector(quadrature_point);
160 
161  return gradient - (normal * gradient) * normal;
162  }
163 
164 
165 
166  template <int dim>
169  {
170  return quadrature;
171  }
172 
173 
174 
175  template <int dim>
176  inline void
178  {
179  UpdateFlags flags = this->compute_update_flags(update_flags);
180 
181  if ((flags & (update_JxW_values | update_normal_vectors)) != 0u)
183 
184  // Initialize the base classes.
185  if ((flags & update_mapping) != 0u)
186  this->mapping_output.initialize(this->n_quadrature_points, flags);
187  this->finite_element_output.initialize(this->n_quadrature_points,
188  *this->fe,
189  flags);
190 
191  // Then get objects into which the FE and the Mapping can store
192  // intermediate data used across calls to reinit. We can do this in
193  // parallel.
195  std::unique_ptr<typename FiniteElement<dim, dim>::InternalDataBase>>
197  *this->fe,
198  flags,
199  *this->mapping,
200  this->quadrature,
201  this->finite_element_output);
202 
204  mapping_get_data;
205  if ((flags & update_mapping) != 0u)
206  mapping_get_data = Threads::new_task(&Mapping<dim>::get_data,
207  *this->mapping,
208  flags,
209  this->quadrature);
210 
211  this->update_flags = flags;
212 
213  // Then collect answers from the two task above.
214  this->fe_data = std::move(fe_get_data.return_value());
215  if ((flags & update_mapping) != 0u)
216  this->mapping_data = std::move(mapping_get_data.return_value());
217  else
218  this->mapping_data =
219  std::make_unique<typename Mapping<dim>::InternalDataBase>();
220  }
221 
222 
223 #ifndef DOXYGEN
224 # include "fe_immersed_values.inst"
225 #endif
226 
227 } // namespace NonMatching
UpdateFlags update_flags
Definition: fe_values.h:3985
Abstract base class for mapping classes.
Definition: mapping.h:311
void reinit(const typename Triangulation< dim >::cell_iterator &cell)
void initialize(const UpdateFlags update_flags)
Tensor< 1, dim > shape_surface_grad_component(const unsigned int function_no, const unsigned int quadrature_point, const unsigned int component) const
Tensor< 1, dim > shape_surface_grad(const unsigned int function_no, const unsigned int quadrature_point) const
const NonMatching::ImmersedSurfaceQuadrature< dim > & get_quadrature() const
FEImmersedSurfaceValues(const Mapping< dim > &mapping, const FiniteElement< dim > &element, const ImmersedSurfaceQuadrature< dim > &quadrature, const UpdateFlags update_flags)
internal::return_value< RT >::reference_type return_value()
#define DEAL_II_NAMESPACE_OPEN
Definition: config.h:457
#define DEAL_II_NAMESPACE_CLOSE
Definition: config.h:458
#define Assert(cond, exc)
Definition: exceptions.h:1501
static ::ExceptionBase & ExcMessage(std::string arg1)
UpdateFlags
@ update_normal_vectors
Normal vectors.
@ update_JxW_values
Transformed quadrature weights.
@ update_covariant_transformation
Covariant transformation.
@ update_mapping
@ update_default
No update.
Task< RT > new_task(const std::function< RT()> &function)