Loading...
Searching...
No Matches
Mesh.h
// Copyright (C) 2006-2016 Anders Logg
//
// This file is part of DOLFIN.
//
// DOLFIN is free software: you can redistribute it and/or modify
// it under the terms of the GNU Lesser General Public License as published by
// the Free Software Foundation, either version 3 of the License, or
// (at your option) any later version.
//
// DOLFIN is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
// GNU Lesser General Public License for more details.
//
// You should have received a copy of the GNU Lesser General Public License
// along with DOLFIN. If not, see <http://www.gnu.org/licenses/>.
//
// Modified by Johan Hoffman 2007
// Modified by Magnus Vikstrøm 2007
// Modified by Garth N. Wells 2007-2015
// Modified by Niclas Jansson 2008
// Modified by Kristoffer Selim 2008
// Modified by Andre Massing 2009-2010
// Modified by Marie E. Rognes 2012
// Modified by Mikael Mortensen 2012
// Modified by Jan Blechta 2013
// Modified by Cecile Daversin-Catty 2018
#ifndef __MESH_H
#define __MESH_H
#include <memory>
#include <string>
#include <utility>
#include <dolfin/common/Hierarchical.h>
#include <dolfin/common/MPI.h>
#include <dolfin/common/Variable.h>
#include "MeshData.h"
#include "MeshDomains.h"
#include "MeshGeometry.h"
#include "MeshConnectivity.h"
#include "MeshTopology.h"
namespace dolfin
{
class BoundaryMesh;
class CellType;
class Expression;
class GenericFunction;
class LocalMeshData;
class MeshEntity;
class Point;
class SubDomain;
class BoundingBoxTree;
class Mesh : public Variable, public Hierarchical<Mesh>
{
public:
Mesh();
Mesh(MPI_Comm comm);
Mesh(const Mesh& mesh);
explicit Mesh(std::string filename);
Mesh(MPI_Comm comm, std::string filename);
Mesh(MPI_Comm comm, LocalMeshData& local_mesh_data);
~Mesh();
const Mesh& operator=(const Mesh& mesh);
std::size_t num_vertices() const
{ return _topology.size(0); }
std::size_t num_edges() const
{ return _topology.size(1); }
std::size_t num_faces() const
{ return _topology.size(2); }
std::size_t num_facets() const
{ return _topology.size(_topology.dim() - 1); }
std::size_t num_cells() const
{ return _topology.size(_topology.dim()); }
std::size_t num_entities(std::size_t d) const
{ return _topology.size(d); }
std::vector<double>& coordinates()
{ return _geometry.x(); }
const std::vector<double>& coordinates() const
{ return _geometry.x(); }
const std::vector<unsigned int>& cells() const
{ return _topology(_topology.dim(), 0)(); }
std::size_t num_entities_global(std::size_t dim) const
{ return _topology.size_global(dim); }
MeshTopology& topology()
{ return _topology; }
const MeshTopology& topology() const
{ return _topology; }
MeshGeometry& geometry()
{ return _geometry; }
const MeshGeometry& geometry() const
{ return _geometry; }
MeshDomains& domains()
{ return _domains; }
const MeshDomains& domains() const
{ return _domains; }
std::shared_ptr<BoundingBoxTree> bounding_box_tree() const;
MeshData& data();
const MeshData& data() const;
CellType& type()
{ dolfin_assert(_cell_type); return *_cell_type; }
const CellType& type() const
{ dolfin_assert(_cell_type); return *_cell_type; }
std::size_t init(std::size_t dim) const;
void init(std::size_t d0, std::size_t d1) const;
void init() const;
void init_global(std::size_t dim) const;
void clean();
void order();
bool ordered() const;
Mesh renumber_by_color() const;
void scale(double factor);
void translate(const Point& point);
void rotate(double angle, std::size_t axis=2);
void rotate(double angle, std::size_t axis, const Point& point);
void smooth(std::size_t num_iterations=1);
void smooth_boundary(std::size_t num_iterations=1,
bool harmonic_smoothing=true);
void snap_boundary(const SubDomain& sub_domain,
bool harmonic_smoothing=true);
const std::vector<std::size_t>& color(std::string coloring_type) const;
const std::vector<std::size_t>&
color(std::vector<std::size_t> coloring_type) const;
double hmin() const;
double hmax() const;
double rmin() const;
double rmax() const;
std::size_t hash() const;
std::string str(bool verbose) const;
const std::vector<int>& cell_orientations() const;
void init_cell_orientations(const Expression& global_normal);
MPI_Comm mpi_comm() const
{ return _mpi_comm.comm(); }
std::string ghost_mode() const;
// Friend in fem_utils.h
friend Mesh create_mesh(Function& coordinates);
void build_mapping(std::shared_ptr<const Mesh> other) const;
private:
// Friends
friend class MeshEditor;
friend class TopologyComputation;
friend class MeshPartitioning;
// Mesh topology
mutable MeshTopology _topology;
// Mesh geometry
MeshGeometry _geometry;
// Mesh domains
MeshDomains _domains;
// Auxiliary mesh data
MeshData _data;
// Bounding box tree used to compute collisions between the mesh
// and other objects. The tree is initialized to a zero pointer
// and is allocated and built when bounding_box_tree() is called.
mutable std::shared_ptr<BoundingBoxTree> _tree;
// Cell type
std::unique_ptr<CellType> _cell_type;
// True if mesh has been ordered
mutable bool _ordered;
// Orientation of cells relative to a global direction
std::vector<int> _cell_orientations;
// MPI communicator
dolfin::MPI::Comm _mpi_comm;
// Ghost mode used for partitioning
std::string _ghost_mode;
};
}
#endif
dolfin::BoundaryMesh
Definition BoundaryMesh.h:40
dolfin::BoundingBoxTree
Definition BoundingBoxTree.h:41
dolfin::CellType
Definition CellType.h:47
dolfin::Expression
Definition Expression.h:50
dolfin::Function
Definition Function.h:66
dolfin::GenericFunction
Definition GenericFunction.h:54
dolfin::Hierarchical< Mesh >::Hierarchical
Hierarchical(Mesh &self)
Definition Hierarchical.h:48
dolfin::LocalMeshData
This class stores mesh data on a local processor corresponding to a portion of a (larger) global mesh...
Definition LocalMeshData.h:59
dolfin::MPI::Comm
Definition MPI.h:77
dolfin::MeshData
Definition MeshData.h:59
dolfin::MeshDomains
Definition MeshDomains.h:42
dolfin::MeshEntity
Definition MeshEntity.h:43
dolfin::MeshGeometry
MeshGeometry stores the geometry imposed on a mesh.
Definition MeshGeometry.h:40
dolfin::MeshTopology
Definition MeshTopology.h:53
dolfin::Mesh
Definition Mesh.h:84
dolfin::Mesh::rmax
double rmax() const
Definition Mesh.cpp:386
dolfin::Mesh::num_faces
std::size_t num_faces() const
Definition Mesh.h:151
dolfin::Mesh::scale
void scale(double factor)
Definition Mesh.cpp:281
dolfin::Mesh::ordered
bool ordered() const
Definition Mesh.cpp:264
dolfin::Mesh::operator=
const Mesh & operator=(const Mesh &mesh)
Definition Mesh.cpp:105
dolfin::Mesh::build_mapping
void build_mapping(std::shared_ptr< const Mesh > other) const
Definition Mesh.cpp:492
dolfin::Mesh::Mesh
Mesh()
Create empty mesh.
Definition Mesh.cpp:59
dolfin::Mesh::geometry
const MeshGeometry & geometry() const
Definition Mesh.h:241
dolfin::Mesh::domains
const MeshDomains & domains() const
Definition Mesh.h:255
dolfin::Mesh::clean
void clean()
Definition Mesh.cpp:239
dolfin::Mesh::hash
std::size_t hash() const
Definition Mesh.cpp:395
dolfin::Mesh::topology
MeshTopology & topology()
Definition Mesh.h:220
dolfin::Mesh::data
MeshData & data()
Definition Mesh.cpp:129
dolfin::Mesh::cells
const std::vector< unsigned int > & cells() const
Definition Mesh.h:202
dolfin::Mesh::init_cell_orientations
void init_cell_orientations(const Expression &global_normal)
Definition Mesh.cpp:442
dolfin::Mesh::~Mesh
~Mesh()
Destructor.
Definition Mesh.cpp:100
dolfin::Mesh::num_vertices
std::size_t num_vertices() const
Definition Mesh.h:135
dolfin::Mesh::type
const CellType & type() const
Get mesh cell type (const version).
Definition Mesh.h:288
dolfin::Mesh::num_edges
std::size_t num_edges() const
Definition Mesh.h:143
dolfin::Mesh::rmin
double rmin() const
Definition Mesh.cpp:377
dolfin::Mesh::create_mesh
friend Mesh create_mesh(Function &coordinates)
dolfin::Mesh::mpi_comm
MPI_Comm mpi_comm() const
Definition Mesh.h:498
dolfin::Mesh::init
void init() const
Compute all entities and connectivity.
Definition Mesh.cpp:221
dolfin::Mesh::init_global
void init_global(std::size_t dim) const
Compute global indices for entity dimension dim.
Definition Mesh.cpp:233
dolfin::Mesh::str
std::string str(bool verbose) const
Definition Mesh.cpp:409
dolfin::Mesh::domains
MeshDomains & domains()
Definition Mesh.h:248
dolfin::Mesh::num_cells
std::size_t num_cells() const
Definition Mesh.h:167
dolfin::Mesh::coordinates
std::vector< double > & coordinates()
Definition Mesh.h:186
dolfin::Mesh::smooth_boundary
void smooth_boundary(std::size_t num_iterations=1, bool harmonic_smoothing=true)
Definition Mesh.cpp:306
dolfin::Mesh::type
CellType & type()
Definition Mesh.h:284
dolfin::Mesh::order
void order()
Definition Mesh.cpp:252
dolfin::Mesh::translate
void translate(const Point &point)
Definition Mesh.cpp:286
dolfin::Mesh::ghost_mode
std::string ghost_mode() const
Definition Mesh.cpp:483
dolfin::Mesh::snap_boundary
void snap_boundary(const SubDomain &sub_domain, bool harmonic_smoothing=true)
Definition Mesh.cpp:311
dolfin::Mesh::topology
const MeshTopology & topology() const
Definition Mesh.h:227
dolfin::Mesh::hmax
double hmax() const
Definition Mesh.cpp:368
dolfin::Mesh::num_facets
std::size_t num_facets() const
Definition Mesh.h:159
dolfin::Mesh::hmin
double hmin() const
Definition Mesh.cpp:359
dolfin::Mesh::coordinates
const std::vector< double > & coordinates() const
Definition Mesh.h:194
dolfin::Mesh::color
const std::vector< std::size_t > & color(std::string coloring_type) const
Definition Mesh.cpp:316
dolfin::Mesh::geometry
MeshGeometry & geometry()
Definition Mesh.h:234
dolfin::Mesh::num_entities
std::size_t num_entities(std::size_t d) const
Definition Mesh.h:178
dolfin::Mesh::num_entities_global
std::size_t num_entities_global(std::size_t dim) const
Definition Mesh.h:213
dolfin::Mesh::renumber_by_color
Mesh renumber_by_color() const
Definition Mesh.cpp:274
dolfin::Mesh::bounding_box_tree
std::shared_ptr< BoundingBoxTree > bounding_box_tree() const
Definition Mesh.cpp:347
dolfin::Mesh::smooth
void smooth(std::size_t num_iterations=1)
Definition Mesh.cpp:301
dolfin::Mesh::rotate
void rotate(double angle, std::size_t axis=2)
Definition Mesh.cpp:291
dolfin::Mesh::cell_orientations
const std::vector< int > & cell_orientations() const
Definition Mesh.cpp:437
dolfin::Point
Definition Point.h:41
dolfin::SubDomain
Definition SubDomain.h:43
dolfin::Variable::Variable
Variable()
Create unnamed variable.
Definition Variable.cpp:31
dolfin
Definition adapt.h:30