DOLFINx
DOLFINx C++ interface
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 <dolfinx/common/MPI.h>
10#include <dolfinx/fem/CoordinateElement.h>
11#include <dolfinx/graph/AdjacencyList.h>
12#include <functional>
13#include <memory>
14#include <vector>
15#include <xtl/xspan.hpp>
16
17namespace dolfinx::common
18{
19class IndexMap;
20}
21
22namespace dolfinx::mesh
23{
24class Topology;
25
28{
29public:
42 template <typename AdjacencyList32, typename Array, typename Vector64>
43 Geometry(const std::shared_ptr<const common::IndexMap>& index_map,
44 AdjacencyList32&& dofmap, const fem::CoordinateElement& element,
45 Array&& x, int dim, Vector64&& input_global_indices)
46 : _dim(dim), _dofmap(std::forward<AdjacencyList32>(dofmap)),
47 _index_map(index_map), _cmap(element), _x(std::forward<Array>(x)),
48 _input_global_indices(std::forward<Vector64>(input_global_indices))
49 {
50 assert(_x.size() % 3 == 0);
51 if (_x.size() / 3 != _input_global_indices.size())
52 throw std::runtime_error("Geometry size mis-match");
53 }
54
56 Geometry(const Geometry&) = default;
57
59 Geometry(Geometry&&) = default;
60
62 ~Geometry() = default;
63
65 Geometry& operator=(const Geometry&) = delete;
66
69
71 int dim() const;
72
75
77 std::shared_ptr<const common::IndexMap> index_map() const;
78
83 xtl::span<const double> x() const;
84
90 xtl::span<double> x();
91
95 const fem::CoordinateElement& cmap() const;
96
98 const std::vector<std::int64_t>& input_global_indices() const;
99
100private:
101 // Geometric dimension
102 int _dim;
103
104 // Map per cell for extracting coordinate data
106
107 // IndexMap for geometry 'dofmap'
108 std::shared_ptr<const common::IndexMap> _index_map;
109
110 // The coordinate element
112
113 // Coordinates for all points stored as a contiguous array (row-major,
114 // column size = 3)
115 std::vector<double> _x;
116
117 // Global indices as provided on Geometry creation
118 std::vector<std::int64_t> _input_global_indices;
119};
120
141create_geometry(MPI_Comm comm, const Topology& topology,
142 const fem::CoordinateElement& element,
144 const xtl::span<const double>& x, int dim,
145 const std::function<std::vector<int>(
146 const graph::AdjacencyList<std::int32_t>&)>& reorder_fn
147 = nullptr);
148
149} // namespace dolfinx::mesh
Definition: CoordinateElement.h:31
This class provides a static adjacency list data structure. It is commonly used to store directed gra...
Definition: AdjacencyList.h:46
Geometry stores the geometry imposed on a mesh.
Definition: Geometry.h:28
~Geometry()=default
Destructor.
Geometry(const std::shared_ptr< const common::IndexMap > &index_map, AdjacencyList32 &&dofmap, const fem::CoordinateElement &element, Array &&x, int dim, Vector64 &&input_global_indices)
Constructor.
Definition: Geometry.h:43
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
Geometry(Geometry &&)=default
Move constructor.
Geometry(const Geometry &)=default
Copy constructor.
xtl::span< const double > x() const
Access geometry degrees-of-freedom data (const version).
Definition: Geometry.cpp:33
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:57
Miscellaneous classes, functions and types.
Mesh data structures and algorithms on meshes.
Definition: DofMap.h:30
mesh::Geometry create_geometry(MPI_Comm comm, const Topology &topology, const fem::CoordinateElement &element, const graph::AdjacencyList< std::int64_t > &cells, const xtl::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