Note: this is documentation for an old release. View the latest documentation at docs.fenicsproject.org/dolfinx/v0.9.0/cpp/doxygen/d9/d31/Mesh_8h_source.html
DOLFINx 0.6.0
DOLFINx C++ interface
Loading...
Searching...
No Matches
Mesh.h
1// Copyright (C) 2006-2020 Anders Logg, Chris Richardson 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 "Geometry.h"
10#include "Topology.h"
11#include "utils.h"
12#include <concepts>
13#include <dolfinx/common/MPI.h>
14#include <string>
15#include <utility>
16
17namespace dolfinx::fem
18{
19class CoordinateElement;
20}
21
22namespace dolfinx::graph
23{
24template <typename T>
25class AdjacencyList;
26}
27
28namespace dolfinx::mesh
29{
30
33class Mesh
34{
35public:
40 template <std::convertible_to<Topology> U, std::convertible_to<Geometry> V>
41 Mesh(MPI_Comm comm, U&& topology, V&& geometry)
42 : _topology(std::forward<U>(topology)),
43 _geometry(std::forward<V>(geometry)), _comm(comm)
44 {
45 // Do nothing
46 }
47
50 Mesh(const Mesh& mesh) = default;
51
54 Mesh(Mesh&& mesh) = default;
55
57 ~Mesh() = default;
58
59 // Assignment operator
60 Mesh& operator=(const Mesh& mesh) = delete;
61
64 Mesh& operator=(Mesh&& mesh) = default;
65
66 // TODO: Is there any use for this? In many situations one has to get the
67 // topology of a const Mesh, which is done by Mesh::topology_mutable. Note
68 // that the python interface (calls Mesh::topology()) may still rely on it.
72
75 const Topology& topology() const;
76
80
84
87 const Geometry& geometry() const;
88
91 MPI_Comm comm() const;
92
94 std::string name = "mesh";
95
96private:
97 // Mesh topology:
98 // TODO: This is mutable because of the current memory management within
99 // mesh::Topology. It allows to obtain a non-const Topology from a
100 // const mesh (via Mesh::topology_mutable()).
101 //
102 mutable Topology _topology;
103
104 // Mesh geometry
105 Geometry _geometry;
106
107 // MPI communicator
108 dolfinx::MPI::Comm _comm;
109};
110
130Mesh create_mesh(MPI_Comm comm, const graph::AdjacencyList<std::int64_t>& cells,
131 const fem::CoordinateElement& element,
132 std::span<const double> x, std::array<std::size_t, 2> xshape,
133 GhostMode ghost_mode);
134
136Mesh create_mesh(MPI_Comm comm, const graph::AdjacencyList<std::int64_t>& cells,
137 const fem::CoordinateElement& element,
138 std::span<const double> x, std::array<std::size_t, 2> xshape,
139 const CellPartitionFunction& cell_partitioner);
140
148std::tuple<Mesh, std::vector<std::int32_t>, std::vector<std::int32_t>,
149 std::vector<std::int32_t>>
150create_submesh(const Mesh& mesh, int dim,
151 std::span<const std::int32_t> entities);
152
153} // namespace dolfinx::mesh
A duplicate MPI communicator and manage lifetime of the communicator.
Definition: MPI.h:42
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
A Mesh consists of a set of connected and numbered mesh topological entities, and geometry data.
Definition: Mesh.h:34
Mesh & operator=(Mesh &&mesh)=default
Assignment move operator.
Mesh(const Mesh &mesh)=default
Copy constructor.
Mesh(Mesh &&mesh)=default
Move constructor.
std::string name
Name.
Definition: Mesh.h:94
Mesh(MPI_Comm comm, U &&topology, V &&geometry)
Create a mesh.
Definition: Mesh.h:41
~Mesh()=default
Destructor.
MPI_Comm comm() const
Mesh MPI communicator.
Definition: Mesh.cpp:473
Geometry & geometry()
Get mesh geometry.
Definition: Mesh.cpp:469
Topology & topology()
Get mesh topology.
Definition: Mesh.cpp:463
Topology & topology_mutable() const
Get mesh topology if one really needs the mutable version.
Definition: Mesh.cpp:467
Topology stores the topology of a mesh, consisting of mesh entities and connectivity (incidence relat...
Definition: Topology.h:43
Finite element method functionality.
Definition: assemble_matrix_impl.h:25
Graph data structures and algorithms.
Definition: dofmapbuilder.h:25
Mesh data structures and algorithms on meshes.
Definition: DofMap.h:31
GhostMode
Enum for different partitioning ghost modes.
Definition: utils.h:29
Mesh create_mesh(MPI_Comm comm, const graph::AdjacencyList< std::int64_t > &cells, const fem::CoordinateElement &element, std::span< const double > x, std::array< std::size_t, 2 > xshape, GhostMode ghost_mode)
Create a mesh using the default partitioner.
Definition: Mesh.cpp:59
std::function< graph::AdjacencyList< std::int32_t >(MPI_Comm comm, int nparts, int tdim, const graph::AdjacencyList< std::int64_t > &cells)> CellPartitionFunction
Signature for the cell partitioning function. The function should compute the destination rank for ce...
Definition: utils.h:55
std::tuple< Mesh, std::vector< std::int32_t >, std::vector< std::int32_t >, std::vector< std::int32_t > > create_submesh(const Mesh &mesh, int dim, std::span< const std::int32_t > entities)
Create a new mesh consisting of a subset of entities in a mesh.
Definition: Mesh.cpp:192