deal.II version GIT relicensing-6834-g5b78e6bcdf 2026-10-01 11:20:01+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\}}\)
Loading...
Searching...
No Matches
fe_immersed_values.cc
Go to the documentation of this file.
1// -----------------------------------------------------------------------------
2//
3// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception OR LGPL-2.1-or-later
4// Copyright (C) 2021 - 2025 by the deal.II authors
5//
6// This file is part of the deal.II library.
7//
8// Detailed license information governing the source code and contributions
9// can be found in LICENSE.md and CONTRIBUTING.md at the top level directory.
10//
11// -----------------------------------------------------------------------------
12
14
16
18
19
21namespace NonMatching
22{
23 template <int dim>
25 const Mapping<dim> &mapping,
26 const FiniteElement<dim> &element,
27 const ImmersedSurfaceQuadrature<dim> &quadrature,
28 const UpdateFlags update_flags)
29 : FEValuesBase<dim, dim>(quadrature.size(),
30 element.dofs_per_cell,
32 mapping,
33 element)
34 , quadrature(quadrature)
35 {
37 }
38
39
40
41 template <int dim>
42 void
44 const typename Triangulation<dim>::cell_iterator &cell)
45 {
46 // Check that mapping and reference cell type are compatible:
47 Assert(this->get_mapping().is_compatible_with(cell->reference_cell()),
49 "You are trying to call FEImmersedSurfaceValues::reinit() with "
50 " a cell of type " +
51 cell->reference_cell().to_string() +
52 " with a Mapping that is not compatible with it."));
53
54 // No FE in this cell, so no assertion necessary here.
55 Assert(
56 this->present_cell.is_initialized() == false,
58 "FEImmersedSurfaceValues::reinit() can only be used for one cell!"));
59
60 this->present_cell = {cell};
61
62 // This was the part of the work that is dependent on the actual data type
63 // of the iterator. Now pass on to the function doing the real work.
64 do_reinit();
65 }
66
67
68
69 template <int dim>
70 template <bool level_dof_access>
71 void
74 {
75 // Check that mapping and reference cell type are compatible:
76 Assert(this->get_mapping().is_compatible_with(cell->reference_cell()),
78 "You are trying to call FEImmersedSurfaceValues::reinit() with "
79 "a cell of type " +
80 cell->reference_cell().to_string() +
81 " with a Mapping that is not compatible with it."));
82
83 // Assert that the finite elements passed to the constructor and used by the
84 // DoFHandler used by this cell, are the same
85 Assert(static_cast<const FiniteElementData<dim> &>(*this->fe) ==
86 static_cast<const FiniteElementData<dim> &>(cell->get_fe()),
88
89 Assert(
90 this->present_cell.is_initialized() == false,
92 "FEImmersedSurfaceValues::reinit() can only be used for one cell!"));
93
94 this->present_cell = {cell};
95
96 // This was the part of the work that is dependent on the actual data type
97 // of the iterator. Now pass on to the function doing the real work.
98 do_reinit();
99 }
100
101
102
103 template <int dim>
104 void
106 {
107 // First call the mapping and let it generate the data specific to the
108 // mapping.
109 if (this->update_flags & update_mapping)
110 {
111 this->get_mapping().fill_fe_immersed_surface_values(
112 this->present_cell,
113 quadrature,
114 *this->mapping_data,
115 this->mapping_output);
116 }
117
118 // Call the finite element and, with the data already filled by the mapping,
119 // let it compute the data for the mapped shape function values, gradients
120 // etc.
121 this->get_fe().fill_fe_values(this->present_cell,
123 this->quadrature,
124 this->get_mapping(),
125 *this->mapping_data,
126 this->mapping_output,
127 *this->fe_data,
128 this->finite_element_output);
129 }
130
131
132
133 template <int dim>
136 const unsigned int function_no,
137 const unsigned int quadrature_point) const
138 {
139 const unsigned int component = 0;
140 return shape_surface_grad_component(function_no,
141 quadrature_point,
142 component);
143 }
144
145
146
147 template <int dim>
150 const unsigned int function_no,
151 const unsigned int quadrature_point,
152 const unsigned int component) const
153 {
154 const Tensor<1, dim> gradient =
155 this->shape_grad_component(function_no, quadrature_point, component);
156 const Tensor<1, dim> &normal = this->normal_vector(quadrature_point);
157
158 return gradient - (normal * gradient) * normal;
159 }
160
161
162
163 template <int dim>
166 {
167 return quadrature;
168 }
169
170
171
172 template <int dim>
173 void
175 {
176 UpdateFlags flags = this->compute_update_flags(update_flags);
177
178 if ((flags & (update_JxW_values | update_normal_vectors)) != 0u)
180
181 // Initialize the base classes.
182 if ((flags & update_mapping) != 0u)
183 this->mapping_output.initialize(this->n_quadrature_points, flags);
184 this->finite_element_output.initialize(this->n_quadrature_points,
185 *this->fe,
186 flags);
187
188 // Then get objects into which the FE and the Mapping can store
189 // intermediate data used across calls to reinit. We can do this in
190 // parallel.
192 std::unique_ptr<typename FiniteElement<dim, dim>::InternalDataBase>>
194 *this->fe,
195 flags,
196 *this->mapping,
197 this->quadrature,
198 this->finite_element_output);
199
201 mapping_get_data;
202 if ((flags & update_mapping) != 0u)
203 mapping_get_data = Threads::new_task(&Mapping<dim>::get_data,
204 *this->mapping,
205 flags,
206 this->quadrature);
207
208 this->update_flags = flags;
209
210 // Then collect answers from the two task above.
211 this->fe_data = std::move(fe_get_data.return_value());
212 if ((flags & update_mapping) != 0u)
213 this->mapping_data = std::move(mapping_get_data.return_value());
214 else
215 this->mapping_data =
216 std::make_unique<typename Mapping<dim>::InternalDataBase>();
217 }
218
219
220#ifndef DOXYGEN
221# include "non_matching/fe_immersed_values.inst"
222#endif
223
224} // namespace NonMatching
Abstract base class for mapping classes.
Definition mapping.h:318
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:38
#define DEAL_II_NAMESPACE_CLOSE
Definition config.h:39
#define Assert(cond, exc)
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)
std::size_t size
Definition mpi.cc:733