Note: this is documentation for an old release. View the latest documentation at docs.fenicsproject.org/dolfinx/v0.9.0/cpp/doxygen/d3/d8b/Geometry_8h_source.html
DOLFINx 0.6.0
DOLFINx C++ interface
Loading...
Searching...
No Matches
Geometry.h
1// Copyright (C) 2006-2020 Anders Logg and Garth N. Wells
2//
3// This file is part of DOLFINx (https://www.fenicsproject.org)
4//
5// SPDX-License-Identifier: LGPL-3.0-or-later
6
7#pragma once
8
9#include <concepts>
10#include <dolfinx/common/MPI.h>
11#include <dolfinx/fem/CoordinateElement.h>
12#include <dolfinx/graph/AdjacencyList.h>
13#include <functional>
14#include <memory>
15#include <span>
16#include <vector>
17
18namespace dolfinx::common
19{
20class IndexMap;
21}
22
23namespace dolfinx::mesh
24{
25class Topology;
26
29{
30public:
43 template <std::convertible_to<graph::AdjacencyList<std::int32_t>> U,
44 std::convertible_to<std::vector<double>> V,
45 std::convertible_to<std::vector<std::int64_t>> W>
46 Geometry(std::shared_ptr<const common::IndexMap> index_map, U&& dofmap,
47 const fem::CoordinateElement& element, V&& x, int dim,
49 : _dim(dim), _dofmap(std::forward<U>(dofmap)), _index_map(index_map),
50 _cmap(element), _x(std::forward<V>(x)),
51 _input_global_indices(std::forward<W>(input_global_indices))
52 {
53 assert(_x.size() % 3 == 0);
54 if (_x.size() / 3 != _input_global_indices.size())
55 throw std::runtime_error("Geometry size mis-match");
56 }
57
59 Geometry(const Geometry&) = default;
60
62 Geometry(Geometry&&) = default;
63
65 ~Geometry() = default;
66
68 Geometry& operator=(const Geometry&) = delete;
69
72
74 int dim() const;
75
78
80 std::shared_ptr<const common::IndexMap> index_map() const;
81
86 std::span<const double> x() const;
87
93 std::span<double> x();
94
98 const fem::CoordinateElement& cmap() const;
99
101 const std::vector<std::int64_t>& input_global_indices() const;
102
103private:
104 // Geometric dimension
105 int _dim;
106
107 // Map per cell for extracting coordinate data
109
110 // IndexMap for geometry 'dofmap'
111 std::shared_ptr<const common::IndexMap> _index_map;
112
113 // The coordinate element
115
116 // Coordinates for all points stored as a contiguous array (row-major,
117 // column size = 3)
118 std::vector<double> _x;
119
120 // Global indices as provided on Geometry creation
121 std::vector<std::int64_t> _input_global_indices;
122};
123
145create_geometry(MPI_Comm comm, const Topology& topology,
146 const fem::CoordinateElement& element,
148 std::span<const double> x, int dim,
149 const std::function<std::vector<int>(
150 const graph::AdjacencyList<std::int32_t>&)>& reorder_fn
151 = nullptr);
152
153} // namespace dolfinx::mesh
A CoordinateElement manages coordinate mappings for isoparametric cells.
Definition: CoordinateElement.h:32
This class provides a static adjacency list data structure. It is commonly used to store directed gra...
Definition: AdjacencyList.h:27
Geometry stores the geometry imposed on a mesh.
Definition: Geometry.h:29
~Geometry()=default
Destructor.
const graph::AdjacencyList< std::int32_t > & dofmap() const
DOF map.
Definition: Geometry.cpp:21
std::shared_ptr< const common::IndexMap > index_map() const
Index map.
Definition: Geometry.cpp:26
std::span< const double > x() const
Access geometry degrees-of-freedom data (const version).
Definition: Geometry.cpp:33
Geometry(Geometry &&)=default
Move constructor.
Geometry(const Geometry &)=default
Copy constructor.
Geometry(std::shared_ptr< const common::IndexMap > index_map, U &&dofmap, const fem::CoordinateElement &element, V &&x, int dim, W &&input_global_indices)
Constructor of object that holds mesh geometry data.
Definition: Geometry.h:46
int dim() const
Return Euclidean dimension of coordinate system.
Definition: Geometry.cpp:19
Geometry & operator=(Geometry &&)=default
Move Assignment.
const fem::CoordinateElement & cmap() const
The element that describes the geometry map.
Definition: Geometry.cpp:35
const std::vector< std::int64_t > & input_global_indices() const
Global user indices.
Definition: Geometry.cpp:37
Geometry & operator=(const Geometry &)=delete
Copy Assignment.
Topology stores the topology of a mesh, consisting of mesh entities and connectivity (incidence relat...
Definition: Topology.h:43
Miscellaneous classes, functions and types.
Mesh data structures and algorithms on meshes.
Definition: DofMap.h:31
mesh::Geometry create_geometry(MPI_Comm comm, const Topology &topology, const fem::CoordinateElement &element, const graph::AdjacencyList< std::int64_t > &cells, std::span< const double > x, int dim, const std::function< std::vector< int >(const graph::AdjacencyList< std::int32_t > &)> &reorder_fn=nullptr)
Build Geometry from input data.
Definition: Geometry.cpp:44