Loading...
Searching...
No Matches
Mesh.h
// Copyright (C) 2006-2023 Anders Logg, Chris Richardson and Garth N. Wells
//
// This file is part of DOLFINx (https://www.fenicsproject.org)
//
// SPDX-License-Identifier: LGPL-3.0-or-later
#pragma once
#include "Geometry.h"
#include <concepts>
#include <dolfinx/common/MPI.h>
#include <string>
namespace dolfinx::mesh
{
class Topology;
template <std::floating_point T>
class Mesh
{
public:
using geometry_type = Geometry<T>;
template <typename V>
requires std::is_convertible_v<std::remove_cvref_t<V>, Geometry<T>>
Mesh(MPI_Comm comm, std::shared_ptr<Topology> topology, V&& geometry)
: _topology(std::move(topology)), _geometry(std::forward<V>(geometry)),
_comm(comm)
{
// Do nothing
}
Mesh(const Mesh& mesh) = default;
Mesh(Mesh&& mesh) = default;
~Mesh() = default;
// Assignment operator
Mesh& operator=(const Mesh& mesh) = delete;
Mesh& operator=(Mesh&& mesh) = default;
// TODO: Is there any use for this? In many situations one has to get
// the topology of a const Mesh, which is done by
// Mesh::topology_mutable. Note that the python interface (calls
// Mesh::topology()) may still rely on it.
std::shared_ptr<Topology> topology() { return _topology; }
std::shared_ptr<const Topology> topology() const { return _topology; }
std::shared_ptr<Topology> topology_mutable() const { return _topology; }
Geometry<T>& geometry() { return _geometry; }
const Geometry<T>& geometry() const { return _geometry; }
MPI_Comm comm() const { return _comm.comm(); }
std::string name = "mesh";
private:
// Mesh topology
// Note: This is non-const because of the current memory management
// within mesh::Topology. It allows to obtain a non-const Topology
// from a const mesh (via Mesh::topology_mutable()).
std::shared_ptr<Topology> _topology;
// Mesh geometry
Geometry<T> _geometry;
// MPI communicator
dolfinx::MPI::Comm _comm;
};
template <typename V>
Mesh(MPI_Comm, std::shared_ptr<Topology>, V)
-> Mesh<typename std::remove_cvref_t<typename V::value_type>>;
} // namespace dolfinx::mesh
dolfinx::MPI::Comm
A duplicate MPI communicator and manage lifetime of the communicator.
Definition MPI.h:42
dolfinx::mesh::Geometry
Geometry stores the geometry imposed on a mesh.
Definition Geometry.h:34
dolfinx::mesh::Mesh
A Mesh consists of a set of connected and numbered mesh topological entities, and geometry data.
Definition Mesh.h:23
dolfinx::mesh::Mesh::topology_mutable
std::shared_ptr< Topology > topology_mutable() const
Get mesh topology if one really needs the mutable version.
Definition Mesh.h:77
dolfinx::mesh::Mesh::geometry
const Geometry< T > & geometry() const
Get mesh geometry (const version).
Definition Mesh.h:85
dolfinx::mesh::Mesh::topology
std::shared_ptr< Topology > topology()
Get mesh topology.
Definition Mesh.h:69
dolfinx::mesh::Mesh::operator=
Mesh & operator=(Mesh &&mesh)=default
dolfinx::mesh::Mesh::Mesh
Mesh(const Mesh &mesh)=default
dolfinx::mesh::Mesh::geometry
Geometry< T > & geometry()
Get mesh geometry.
Definition Mesh.h:81
dolfinx::mesh::Mesh::Mesh
Mesh(MPI_Comm comm, std::shared_ptr< Topology > topology, V &&geometry)
Create a Mesh.
Definition Mesh.h:38
dolfinx::mesh::Mesh::Mesh
Mesh(Mesh &&mesh)=default
dolfinx::mesh::Mesh::name
std::string name
Name.
Definition Mesh.h:92
dolfinx::mesh::Mesh::geometry_type
Geometry< T > geometry_type
Value type.
Definition Mesh.h:26
dolfinx::mesh::Mesh::~Mesh
~Mesh()=default
Destructor.
dolfinx::mesh::Mesh::comm
MPI_Comm comm() const
Mesh MPI communicator.
Definition Mesh.h:89
dolfinx::mesh::Mesh::topology
std::shared_ptr< const Topology > topology() const
Get mesh topology (const version).
Definition Mesh.h:73
dolfinx::mesh::Topology
Topology stores the topology of a mesh, consisting of mesh entities and connectivity (incidence relat...
Definition Topology.h:41
dolfinx::mesh
Mesh data structures and algorithms on meshes.
Definition DofMap.h:32