11
11
#include < algorithm>
12
12
#include < array>
13
13
#include < concepts>
14
+ #include < cstdint>
14
15
#include < dolfinx/common/IndexMap.h>
15
16
#include < dolfinx/common/types.h>
16
17
#include < dolfinx/mesh/Mesh.h>
@@ -122,6 +123,9 @@ class Form
122
123
// / Scalar type
123
124
using scalar_type = T;
124
125
126
+ // / Geometry type
127
+ using geometry_type = U;
128
+
125
129
// / @brief Create a finite element form.
126
130
// /
127
131
// / @note User applications will normally call a factory function
@@ -153,17 +157,20 @@ class Form
153
157
template <typename X>
154
158
requires std::is_convertible_v<
155
159
std::remove_cvref_t <X>,
156
- std::map<IntegralType, std::vector<integral_data<T, U>>>>
157
- Form (const std::vector<std::shared_ptr<const FunctionSpace<U>>>& V,
158
- X&& integrals,
159
- const std::vector<std::shared_ptr<const Function<scalar_type, U>>>&
160
- coefficients,
161
- const std::vector<std::shared_ptr<const Constant<scalar_type>>>&
162
- constants,
163
- bool needs_facet_permutations,
164
- const std::map<std::shared_ptr<const mesh::Mesh<U>>,
165
- std::span<const std::int32_t >>& entity_maps,
166
- std::shared_ptr<const mesh::Mesh<U>> mesh = nullptr )
160
+ std::map<IntegralType, std::vector<integral_data<
161
+ scalar_type, geometry_type>>>>
162
+ Form (
163
+ const std::vector<std::shared_ptr<const FunctionSpace<geometry_type>>>& V,
164
+ X&& integrals,
165
+ const std::vector<
166
+ std::shared_ptr<const Function<scalar_type, geometry_type>>>&
167
+ coefficients,
168
+ const std::vector<std::shared_ptr<const Constant<scalar_type>>>&
169
+ constants,
170
+ bool needs_facet_permutations,
171
+ const std::map<std::shared_ptr<const mesh::Mesh<geometry_type>>,
172
+ std::span<const std::int32_t >>& entity_maps,
173
+ std::shared_ptr<const mesh::Mesh<geometry_type>> mesh = nullptr )
167
174
: _function_spaces(V), _coefficients(coefficients), _constants(constants),
168
175
_mesh (mesh), _needs_facet_permutations(needs_facet_permutations)
169
176
{
@@ -191,7 +198,7 @@ class Form
191
198
throw std::runtime_error (" Integral IDs not sorted" );
192
199
}
193
200
194
- std::vector<integral_data<T, U >>& itg
201
+ std::vector<integral_data<scalar_type, geometry_type >>& itg
195
202
= _integrals[static_cast <std::size_t >(domain_type)];
196
203
for (auto && [id, kern, e] : data)
197
204
itg.emplace_back (id, kern, std::move (e));
@@ -220,23 +227,26 @@ class Form
220
227
221
228
// / @brief Extract common mesh for the form.
222
229
// / @return The mesh.
223
- std::shared_ptr<const mesh::Mesh<U>> mesh () const { return _mesh; }
230
+ std::shared_ptr<const mesh::Mesh<geometry_type>> mesh () const
231
+ {
232
+ return _mesh;
233
+ }
224
234
225
235
// / @brief Function spaces for all arguments.
226
236
// / @return Function spaces.
227
- const std::vector<std::shared_ptr<const FunctionSpace<U >>>&
237
+ const std::vector<std::shared_ptr<const FunctionSpace<geometry_type >>>&
228
238
function_spaces () const
229
239
{
230
240
return _function_spaces;
231
241
}
232
242
233
243
// / @brief Get the kernel function for integral `i` on given domain
234
244
// / type.
235
- // / @param[in] type Integral type
236
- // / @param[in] i Domain identifier (index)
237
- // / @return Function to call for tabulate_tensor
238
- std::function<void (T *, const T *, const T*, const U*, const int *,
239
- const uint8_t *)>
245
+ // / @param[in] type Integral type.
246
+ // / @param[in] i Domain identifier (index).
247
+ // / @return Function to call for ` tabulate_tensor`.
248
+ std::function<void (scalar_type *, const scalar_type *, const scalar_type *,
249
+ const geometry_type*, const int *, const uint8_t *)>
240
250
kernel (IntegralType type, int i) const
241
251
{
242
252
const auto & integrals = _integrals[static_cast <std::size_t >(type)];
@@ -325,11 +335,11 @@ class Form
325
335
// / @param mesh The mesh the entities are numbered with respect to.
326
336
// / @return List of active entities in `mesh` for the given integral.
327
337
std::vector<std::int32_t > domain (IntegralType type, int i,
328
- const mesh::Mesh<U >& mesh) const
338
+ const mesh::Mesh<geometry_type >& mesh) const
329
339
{
330
340
// Hack to avoid passing shared pointer to this function
331
- std::shared_ptr<const mesh::Mesh<U >> msh_ptr (&mesh,
332
- [](const mesh::Mesh<U >*) {});
341
+ std::shared_ptr<const mesh::Mesh<geometry_type >> msh_ptr (
342
+ &mesh, [](const mesh::Mesh<geometry_type >*) {});
333
343
334
344
std::span<const std::int32_t > entities = domain (type, i);
335
345
if (msh_ptr == _mesh)
@@ -370,7 +380,9 @@ class Form
370
380
}
371
381
372
382
// / @brief Access coefficients.
373
- const std::vector<std::shared_ptr<const Function<T, U>>>& coefficients () const
383
+ const std::vector<
384
+ std::shared_ptr<const Function<scalar_type, geometry_type>>>&
385
+ coefficients () const
374
386
{
375
387
return _coefficients;
376
388
}
@@ -397,33 +409,38 @@ class Form
397
409
}
398
410
399
411
// / @brief Access constants.
400
- const std::vector<std::shared_ptr<const Constant<T>>>& constants () const
412
+ const std::vector<std::shared_ptr<const Constant<scalar_type>>>&
413
+ constants () const
401
414
{
402
415
return _constants;
403
416
}
404
417
405
418
private:
406
419
// Function spaces (one for each argument)
407
- std::vector<std::shared_ptr<const FunctionSpace<U>>> _function_spaces;
420
+ std::vector<std::shared_ptr<const FunctionSpace<geometry_type>>>
421
+ _function_spaces;
408
422
409
423
// Integrals. Array index is
410
424
// static_cast<std::size_t(IntegralType::foo)
411
- std::array<std::vector<integral_data<T, U>>, 4 > _integrals;
425
+ std::array<std::vector<integral_data<scalar_type, geometry_type>>, 4 >
426
+ _integrals;
412
427
413
428
// Form coefficients
414
- std::vector<std::shared_ptr<const Function<T, U>>> _coefficients;
429
+ std::vector<std::shared_ptr<const Function<scalar_type, geometry_type>>>
430
+ _coefficients;
415
431
416
432
// Constants associated with the Form
417
- std::vector<std::shared_ptr<const Constant<T >>> _constants;
433
+ std::vector<std::shared_ptr<const Constant<scalar_type >>> _constants;
418
434
419
435
// The mesh
420
- std::shared_ptr<const mesh::Mesh<U >> _mesh;
436
+ std::shared_ptr<const mesh::Mesh<geometry_type >> _mesh;
421
437
422
438
// True if permutation data needs to be passed into these integrals
423
439
bool _needs_facet_permutations;
424
440
425
441
// Entity maps (see Form documentation)
426
- std::map<std::shared_ptr<const mesh::Mesh<U>>, std::vector<std::int32_t >>
442
+ std::map<std::shared_ptr<const mesh::Mesh<geometry_type>>,
443
+ std::vector<std::int32_t >>
427
444
_entity_maps;
428
445
}; // namespace dolfinx::fem
429
446
} // namespace dolfinx::fem
0 commit comments