Skip to content

Commit 9575d6f

Browse files
authored
Doc improvements (#3221)
1 parent fb8b272 commit 9575d6f

File tree

5 files changed

+62
-49
lines changed

5 files changed

+62
-49
lines changed

cpp/doc/source/fem.rst

Lines changed: 1 addition & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -79,18 +79,11 @@ Interpolation
7979
.. doxygenfunction:: dolfinx::fem::interpolation_coords
8080
:project: DOLFINx
8181

82-
.. doxygenfunction:: dolfinx::fem::interpolate(Function<T, U> &u, const Function<T, U> &v, std::span<const std::int32_t> cells)
83-
:project: DOLFINx
84-
85-
86-
.. doxygenfunction:: dolfinx::fem::interpolate(Function<T, U>& u, std::span<const T> f, std::array<std::size_t, 2> fshape, std::span<const std::int32_t> cells)
87-
:project: DOLFINx
88-
8982

9083
Sparsity pattern construction
9184
-----------------------------
9285

93-
.. doxygenfunction:: dolfinx::fem::create_sparsity_pattern(const Form<T, double>&)
86+
.. doxygenfunction:: dolfinx::fem::create_sparsity_pattern(const Form<T, U>&)
9487
:project: DOLFINx
9588

9689

cpp/dolfinx/fem/DirichletBC.h

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -244,9 +244,7 @@ std::array<std::vector<std::int32_t>, 2> locate_dofs_geometrical(
244244
}
245245

246246
/// Object for setting (strong) Dirichlet boundary conditions
247-
///
248-
/// \f$u = g \ \text{on} \ G\f$,
249-
///
247+
/// \f[u = g \ \text{on} \ G,\f]
250248
/// where \f$u\f$ is the solution to be computed, \f$g\f$ is a function
251249
/// and \f$G\f$ is a sub domain of the mesh.
252250
///

cpp/dolfinx/fem/DofMap.cpp

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -208,9 +208,15 @@ DofMap DofMap::extract_sub_dofmap(std::span<const int> component) const
208208
//-----------------------------------------------------------------------------
209209
std::pair<DofMap, std::vector<std::int32_t>> DofMap::collapse(
210210
MPI_Comm comm, const mesh::Topology& topology,
211-
const std::function<std::vector<int>(
212-
const graph::AdjacencyList<std::int32_t>&)>& reorder_fn) const
211+
std::function<std::vector<int>(const graph::AdjacencyList<std::int32_t>&)>&&
212+
reorder_fn) const
213213
{
214+
if (!reorder_fn)
215+
{
216+
reorder_fn = [](const graph::AdjacencyList<std::int32_t>& g)
217+
{ return graph::reorder_gps(g); };
218+
}
219+
214220
// Create new dofmap
215221
auto create_subdofmap = [](MPI_Comm comm, auto index_map_bs, auto& layout,
216222
auto& topology, auto& reorder_fn, auto& dmap)

cpp/dolfinx/fem/DofMap.h

Lines changed: 5 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -146,12 +146,11 @@ class DofMap
146146
/// @param[in] reorder_fn Graph re-ordering function to apply to the
147147
/// dof data
148148
/// @return The collapsed dofmap
149-
std::pair<DofMap, std::vector<std::int32_t>> collapse(
150-
MPI_Comm comm, const mesh::Topology& topology,
151-
const std::function<std::vector<int>(
152-
const graph::AdjacencyList<std::int32_t>&)>& reorder_fn
153-
= [](const graph::AdjacencyList<std::int32_t>& g)
154-
{ return graph::reorder_gps(g); }) const;
149+
std::pair<DofMap, std::vector<std::int32_t>>
150+
collapse(MPI_Comm comm, const mesh::Topology& topology,
151+
std::function<std::vector<int>(
152+
const graph::AdjacencyList<std::int32_t>&)>&& reorder_fn
153+
= nullptr) const;
155154

156155
/// @brief Get dofmap data
157156
/// @return The adjacency list with dof indices for each cell

cpp/dolfinx/fem/Form.h

Lines changed: 47 additions & 30 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,7 @@
1111
#include <algorithm>
1212
#include <array>
1313
#include <concepts>
14+
#include <cstdint>
1415
#include <dolfinx/common/IndexMap.h>
1516
#include <dolfinx/common/types.h>
1617
#include <dolfinx/mesh/Mesh.h>
@@ -122,6 +123,9 @@ class Form
122123
/// Scalar type
123124
using scalar_type = T;
124125

126+
/// Geometry type
127+
using geometry_type = U;
128+
125129
/// @brief Create a finite element form.
126130
///
127131
/// @note User applications will normally call a factory function
@@ -153,17 +157,20 @@ class Form
153157
template <typename X>
154158
requires std::is_convertible_v<
155159
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)
167174
: _function_spaces(V), _coefficients(coefficients), _constants(constants),
168175
_mesh(mesh), _needs_facet_permutations(needs_facet_permutations)
169176
{
@@ -191,7 +198,7 @@ class Form
191198
throw std::runtime_error("Integral IDs not sorted");
192199
}
193200

194-
std::vector<integral_data<T, U>>& itg
201+
std::vector<integral_data<scalar_type, geometry_type>>& itg
195202
= _integrals[static_cast<std::size_t>(domain_type)];
196203
for (auto&& [id, kern, e] : data)
197204
itg.emplace_back(id, kern, std::move(e));
@@ -220,23 +227,26 @@ class Form
220227

221228
/// @brief Extract common mesh for the form.
222229
/// @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+
}
224234

225235
/// @brief Function spaces for all arguments.
226236
/// @return Function spaces.
227-
const std::vector<std::shared_ptr<const FunctionSpace<U>>>&
237+
const std::vector<std::shared_ptr<const FunctionSpace<geometry_type>>>&
228238
function_spaces() const
229239
{
230240
return _function_spaces;
231241
}
232242

233243
/// @brief Get the kernel function for integral `i` on given domain
234244
/// 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*)>
240250
kernel(IntegralType type, int i) const
241251
{
242252
const auto& integrals = _integrals[static_cast<std::size_t>(type)];
@@ -325,11 +335,11 @@ class Form
325335
/// @param mesh The mesh the entities are numbered with respect to.
326336
/// @return List of active entities in `mesh` for the given integral.
327337
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
329339
{
330340
// 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>*) {});
333343

334344
std::span<const std::int32_t> entities = domain(type, i);
335345
if (msh_ptr == _mesh)
@@ -370,7 +380,9 @@ class Form
370380
}
371381

372382
/// @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
374386
{
375387
return _coefficients;
376388
}
@@ -397,33 +409,38 @@ class Form
397409
}
398410

399411
/// @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
401414
{
402415
return _constants;
403416
}
404417

405418
private:
406419
// 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;
408422

409423
// Integrals. Array index is
410424
// 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;
412427

413428
// 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;
415431

416432
// 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;
418434

419435
// The mesh
420-
std::shared_ptr<const mesh::Mesh<U>> _mesh;
436+
std::shared_ptr<const mesh::Mesh<geometry_type>> _mesh;
421437

422438
// True if permutation data needs to be passed into these integrals
423439
bool _needs_facet_permutations;
424440

425441
// 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>>
427444
_entity_maps;
428445
}; // namespace dolfinx::fem
429446
} // namespace dolfinx::fem

0 commit comments

Comments
 (0)