File: fe_nothing.cc

package info (click to toggle)
deal.ii 9.7.1-4
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid
  • size: 326,024 kB
  • sloc: cpp: 440,899; ansic: 77,337; python: 3,307; perl: 1,041; sh: 1,022; xml: 252; makefile: 97; javascript: 14
file content (338 lines) | stat: -rw-r--r-- 10,116 bytes parent folder | download
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
// ------------------------------------------------------------------------
//
// SPDX-License-Identifier: LGPL-2.1-or-later
// Copyright (C) 2009 - 2025 by the deal.II authors
//
// This file is part of the deal.II library.
//
// Part of the source code is dual licensed under Apache-2.0 WITH
// LLVM-exception OR LGPL-2.1-or-later. Detailed license information
// governing the source code and code contributions can be found in
// LICENSE.md and CONTRIBUTING.md at the top level directory of deal.II.
//
// ------------------------------------------------------------------------


#include <deal.II/fe/fe_nothing.h>

#include <memory>

DEAL_II_NAMESPACE_OPEN


template <int dim, int spacedim>
FE_Nothing<dim, spacedim>::FE_Nothing(const ReferenceCell &type,
                                      const unsigned int   n_components,
                                      const bool           dominate)
  : FiniteElement<dim, spacedim>(
      FiniteElementData<dim>(std::vector<unsigned>(dim + 1, 0),
                             type,
                             n_components,
                             0,
                             FiniteElementData<dim>::unknown),
      std::vector<bool>(),
      std::vector<ComponentMask>())
  , dominate(dominate)
{
  Assert(n_components >= 1,
         ExcMessage("A finite element needs to have at least one "
                    "vector component."));

  // in most other elements we have to set up all sorts of stuff
  // here. there isn't much that we have to do here; in particular,
  // we can simply leave the restriction and prolongation matrices
  // empty since their proper size is in fact zero given that the
  // element here has no degrees of freedom
}



template <int dim, int spacedim>
FE_Nothing<dim, spacedim>::FE_Nothing(const unsigned int n_components,
                                      const bool         dominate)
  : FE_Nothing<dim, spacedim>(ReferenceCells::get_hypercube<dim>(),
                              n_components,
                              dominate)
{}



template <int dim, int spacedim>
std::unique_ptr<FiniteElement<dim, spacedim>>
FE_Nothing<dim, spacedim>::clone() const
{
  return std::make_unique<FE_Nothing<dim, spacedim>>(*this);
}



template <int dim, int spacedim>
std::string
FE_Nothing<dim, spacedim>::get_name() const
{
  std::ostringstream namebuf;
  namebuf << "FE_Nothing<" << Utilities::dim_string(dim, spacedim) << ">(";

  std::vector<std::string> name_components;
  if (this->reference_cell() != ReferenceCells::get_hypercube<dim>())
    name_components.push_back(this->reference_cell().to_string());
  if (this->n_components() > 1)
    name_components.push_back(std::to_string(this->n_components()));
  if (dominate)
    name_components.emplace_back("dominating");

  for (const std::string &comp : name_components)
    {
      namebuf << comp;
      if (comp != name_components.back())
        namebuf << ", ";
    }
  namebuf << ")";

  return namebuf.str();
}



template <int dim, int spacedim>
UpdateFlags
FE_Nothing<dim, spacedim>::requires_update_flags(const UpdateFlags flags) const
{
  return flags;
}



template <int dim, int spacedim>
double
FE_Nothing<dim, spacedim>::shape_value(const unsigned int /*i*/,
                                       const Point<dim> & /*p*/) const
{
  Assert(false, ExcMessage("This element has no shape functions."));
  return 0;
}



template <int dim, int spacedim>
std::unique_ptr<typename FiniteElement<dim, spacedim>::InternalDataBase>
FE_Nothing<dim, spacedim>::get_data(
  const UpdateFlags /*update_flags*/,
  const Mapping<dim, spacedim> & /*mapping*/,
  const Quadrature<dim> & /*quadrature*/,
  dealii::internal::FEValuesImplementation::FiniteElementRelatedData<dim,
                                                                     spacedim>
    & /*output_data*/) const
{
  // Create a default data object.  Normally we would then
  // need to resize things to hold the appropriate numbers
  // of dofs, but in this case all data fields are empty.
  return std::make_unique<
    typename FiniteElement<dim, spacedim>::InternalDataBase>();
}



template <int dim, int spacedim>
void
FE_Nothing<dim, spacedim>::fill_fe_values(
  const typename Triangulation<dim, spacedim>::cell_iterator &,
  const CellSimilarity::Similarity,
  const Quadrature<dim> &,
  const Mapping<dim, spacedim> &,
  const typename Mapping<dim, spacedim>::InternalDataBase &,
  const internal::FEValuesImplementation::MappingRelatedData<dim, spacedim> &,
  const typename FiniteElement<dim, spacedim>::InternalDataBase &,
  dealii::internal::FEValuesImplementation::FiniteElementRelatedData<dim,
                                                                     spacedim>
    &) const
{
  // leave data fields empty
}



template <int dim, int spacedim>
void
FE_Nothing<dim, spacedim>::fill_fe_face_values(
  const typename Triangulation<dim, spacedim>::cell_iterator &,
  const unsigned int,
  const hp::QCollection<dim - 1> &,
  const Mapping<dim, spacedim> &,
  const typename Mapping<dim, spacedim>::InternalDataBase &,
  const internal::FEValuesImplementation::MappingRelatedData<dim, spacedim> &,
  const typename FiniteElement<dim, spacedim>::InternalDataBase &,
  dealii::internal::FEValuesImplementation::FiniteElementRelatedData<dim,
                                                                     spacedim>
    &) const
{
  // leave data fields empty
}



template <int dim, int spacedim>
void
FE_Nothing<dim, spacedim>::fill_fe_subface_values(
  const typename Triangulation<dim, spacedim>::cell_iterator &,
  const unsigned int,
  const unsigned int,
  const Quadrature<dim - 1> &,
  const Mapping<dim, spacedim> &,
  const typename Mapping<dim, spacedim>::InternalDataBase &,
  const internal::FEValuesImplementation::MappingRelatedData<dim, spacedim> &,
  const typename FiniteElement<dim, spacedim>::InternalDataBase &,
  dealii::internal::FEValuesImplementation::FiniteElementRelatedData<dim,
                                                                     spacedim>
    &) const
{
  // leave data fields empty
}



template <int dim, int spacedim>
bool
FE_Nothing<dim, spacedim>::is_dominating() const
{
  return dominate;
}



template <int dim, int spacedim>
FiniteElementDomination::Domination
FE_Nothing<dim, spacedim>::compare_for_domination(
  const FiniteElement<dim, spacedim> &fe,
  const unsigned int                  codim) const
{
  Assert(codim <= dim, ExcImpossibleInDim(dim));

  if (!dominate)
    // if FE_Nothing does not dominate, there are no requirements
    return FiniteElementDomination::no_requirements;
  else if (dynamic_cast<const FE_Nothing<dim> *>(&fe) != nullptr)
    // if it does and the other is FE_Nothing, either can dominate
    return FiniteElementDomination::either_element_can_dominate;
  else
    // otherwise we dominate whatever FE is provided
    return FiniteElementDomination::this_element_dominates;
}



template <int dim, int spacedim>
std::vector<std::pair<unsigned int, unsigned int>>
FE_Nothing<dim, spacedim>::hp_vertex_dof_identities(
  const FiniteElement<dim, spacedim> & /*fe_other*/) const
{
  // the FE_Nothing has no
  // degrees of freedom, so there
  // are no equivalencies to be
  // recorded
  return std::vector<std::pair<unsigned int, unsigned int>>();
}


template <int dim, int spacedim>
std::vector<std::pair<unsigned int, unsigned int>>
FE_Nothing<dim, spacedim>::hp_line_dof_identities(
  const FiniteElement<dim, spacedim> & /*fe_other*/) const
{
  // the FE_Nothing has no
  // degrees of freedom, so there
  // are no equivalencies to be
  // recorded
  return std::vector<std::pair<unsigned int, unsigned int>>();
}


template <int dim, int spacedim>
std::vector<std::pair<unsigned int, unsigned int>>
FE_Nothing<dim, spacedim>::hp_quad_dof_identities(
  const FiniteElement<dim, spacedim> & /*fe_other*/,
  const unsigned int) const
{
  // the FE_Nothing has no
  // degrees of freedom, so there
  // are no equivalencies to be
  // recorded
  return std::vector<std::pair<unsigned int, unsigned int>>();
}


template <int dim, int spacedim>
bool
FE_Nothing<dim, spacedim>::hp_constraints_are_implemented() const
{
  return true;
}



template <int dim, int spacedim>
void
FE_Nothing<dim, spacedim>::get_interpolation_matrix(
  const FiniteElement<dim, spacedim> & /*source_fe*/,
  FullMatrix<double> &interpolation_matrix) const
{
  // Since this element has no dofs,
  // the interpolation matrix is necessarily empty.
  Assert(interpolation_matrix.m() == 0,
         ExcDimensionMismatch(interpolation_matrix.m(), 0));
  Assert(interpolation_matrix.n() == 0,
         ExcDimensionMismatch(interpolation_matrix.n(), 0));
}



template <int dim, int spacedim>
void
FE_Nothing<dim, spacedim>::get_face_interpolation_matrix(
  const FiniteElement<dim, spacedim> & /*source_fe*/,
  FullMatrix<double> &interpolation_matrix,
  const unsigned int) const
{
  // since this element has no face dofs, the
  // interpolation matrix is necessarily empty
  Assert(interpolation_matrix.m() == 0,
         ExcDimensionMismatch(interpolation_matrix.m(), 0));
  Assert(interpolation_matrix.n() == 0,
         ExcDimensionMismatch(interpolation_matrix.m(), 0));
}



template <int dim, int spacedim>
void
FE_Nothing<dim, spacedim>::get_subface_interpolation_matrix(
  const FiniteElement<dim, spacedim> & /*source_fe*/,
  const unsigned int /*index*/,
  FullMatrix<double> &interpolation_matrix,
  const unsigned int) const
{
  // since this element has no face dofs, the
  // interpolation matrix is necessarily empty
  Assert(interpolation_matrix.m() == 0,
         ExcDimensionMismatch(interpolation_matrix.m(), 0));
  Assert(interpolation_matrix.n() == 0,
         ExcDimensionMismatch(interpolation_matrix.m(), 0));
}



template <int dim, int spacedim>
std::pair<Table<2, bool>, std::vector<unsigned int>>
FE_Nothing<dim, spacedim>::get_constant_modes() const
{
  // since this element has no dofs, there are no constant modes
  return {Table<2, bool>{}, std::vector<unsigned int>{}};
}



// explicit instantiations
#include "fe/fe_nothing.inst"


DEAL_II_NAMESPACE_CLOSE