Loading...
Searching...
No Matches
LocalMeshData.h
// Copyright (C) 2008 Ola Skavhaug
//
// 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 Anders Logg, 2008-2009.
//
// First added: 2008-11-28
// Last changed: 2013-02-18
//
// Modified by Anders Logg, 2008-2009.
// Modified by Kent-Andre Mardal, 2011.
#ifndef __LOCAL_MESH_DATA_H
#define __LOCAL_MESH_DATA_H
#include <cstdint>
#include <map>
#include <vector>
#include <boost/multi_array.hpp>
#include <dolfin/common/MPI.h>
#include <dolfin/common/Variable.h>
#include "CellType.h"
namespace dolfin
{
class Mesh;
class LocalMeshData : public Variable
{
public:
explicit LocalMeshData(const MPI_Comm mpi_comm);
explicit LocalMeshData(const Mesh& mesh);
~LocalMeshData();
void check() const;
std::string str(bool verbose) const;
void clear();
void extract_mesh_data(const Mesh& mesh);
void broadcast_mesh_data(const MPI_Comm mpi_comm);
void receive_mesh_data(const MPI_Comm mpi_comm);
void reorder();
struct Geometry
{
Geometry() : dim(-1), num_global_vertices(-1) {}
int dim;
std::int64_t num_global_vertices;
boost::multi_array<double, 2> vertex_coordinates;
std::vector<std::int64_t> vertex_indices;
void clear()
{
dim = -1;
num_global_vertices = -1;
vertex_coordinates.resize(boost::extents[0][0]);
vertex_indices.clear();
}
void unpack_vertex_coordinates(const std::vector<double>& values);
};
Geometry geometry;
struct Topology
{
Topology() : dim(-1), num_global_cells(-1) {}
int dim;
std::int64_t num_global_cells;
int num_vertices_per_cell;
boost::multi_array<std::int64_t, 2> cell_vertices;
std::vector<std::int64_t> global_cell_indices;
std::vector<int> cell_partition;
std::vector<std::size_t> cell_weight;
// FIXME: this should replace the need for num_vertices_per_cell
// and tdim
CellType::Type cell_type;
void clear()
{
dim = -1;
num_global_cells = -1;
num_vertices_per_cell = -1;
cell_vertices.resize(boost::extents[0][0]);
global_cell_indices.clear();
cell_partition.clear();
cell_weight.clear();
}
void unpack_cell_vertices(const std::vector<std::int64_t>& values);
};
Topology topology;
std::map<std::size_t, std::vector<std::pair<std::pair<std::size_t,
std::size_t>, std::size_t>>> domain_data;
MPI_Comm mpi_comm() const
{ return _mpi_comm.comm(); }
private:
// MPI communicator
dolfin::MPI::Comm _mpi_comm;
};
}
#endif
dolfin::CellType::Type
Type
Enum for different cell types.
Definition CellType.h:51
dolfin::LocalMeshData::geometry
Geometry geometry
Geometry data.
Definition LocalMeshData.h:127
dolfin::LocalMeshData::mpi_comm
MPI_Comm mpi_comm() const
Return MPI communicator.
Definition LocalMeshData.h:186
dolfin::LocalMeshData::domain_data
std::map< std::size_t, std::vector< std::pair< std::pair< std::size_t, std::size_t >, std::size_t > > > domain_data
Mesh domain data [dim](line, (cell_index, local_index, value)).
Definition LocalMeshData.h:183
dolfin::LocalMeshData::topology
Topology topology
Holder for topology data.
Definition LocalMeshData.h:179
dolfin::LocalMeshData::broadcast_mesh_data
void broadcast_mesh_data(const MPI_Comm mpi_comm)
Definition LocalMeshData.cpp:171
dolfin::LocalMeshData::str
std::string str(bool verbose) const
Return informal string representation (pretty-print).
Definition LocalMeshData.cpp:69
dolfin::LocalMeshData::clear
void clear()
Clear all data.
Definition LocalMeshData.cpp:118
dolfin::LocalMeshData::receive_mesh_data
void receive_mesh_data(const MPI_Comm mpi_comm)
Receive mesh data from main process.
Definition LocalMeshData.cpp:251
dolfin::LocalMeshData::LocalMeshData
LocalMeshData(const MPI_Comm mpi_comm)
Create empty local mesh data.
Definition LocalMeshData.cpp:36
dolfin::LocalMeshData::~LocalMeshData
~LocalMeshData()
Destructor.
Definition LocalMeshData.cpp:55
dolfin::LocalMeshData::check
void check() const
Definition LocalMeshData.cpp:60
dolfin::LocalMeshData::extract_mesh_data
void extract_mesh_data(const Mesh &mesh)
Copy data from mesh.
Definition LocalMeshData.cpp:125
dolfin::LocalMeshData::reorder
void reorder()
Reorder cell data.
Definition LocalMeshData.cpp:327
dolfin::MPI::Comm
Definition MPI.h:77
dolfin::Mesh
Definition Mesh.h:84
dolfin::Variable::Variable
Variable()
Create unnamed variable.
Definition Variable.cpp:31
dolfin
Definition adapt.h:30
dolfin::LocalMeshData::Geometry
Holder for geometry data.
Definition LocalMeshData.h:96
dolfin::LocalMeshData::Geometry::vertex_coordinates
boost::multi_array< double, 2 > vertex_coordinates
Coordinates for all vertices stored on local processor.
Definition LocalMeshData.h:107
dolfin::LocalMeshData::Geometry::Geometry
Geometry()
Constructor.
Definition LocalMeshData.h:98
dolfin::LocalMeshData::Geometry::vertex_indices
std::vector< std::int64_t > vertex_indices
Definition LocalMeshData.h:111
dolfin::LocalMeshData::Geometry::unpack_vertex_coordinates
void unpack_vertex_coordinates(const std::vector< double > &values)
Unpack received vertex coordinates.
Definition LocalMeshData.cpp:295
dolfin::LocalMeshData::Geometry::clear
void clear()
Clear data.
Definition LocalMeshData.h:114
dolfin::LocalMeshData::Geometry::dim
int dim
Geometric dimension.
Definition LocalMeshData.h:101
dolfin::LocalMeshData::Geometry::num_global_vertices
std::int64_t num_global_vertices
Global number of vertices.
Definition LocalMeshData.h:104
dolfin::LocalMeshData::Topology
Holder for topology data.
Definition LocalMeshData.h:131
dolfin::LocalMeshData::Topology::global_cell_indices
std::vector< std::int64_t > global_cell_indices
Global cell numbers for all cells stored on local processor.
Definition LocalMeshData.h:148
dolfin::LocalMeshData::Topology::cell_weight
std::vector< std::size_t > cell_weight
Optional weight for each cell for partitioning.
Definition LocalMeshData.h:154
dolfin::LocalMeshData::Topology::num_global_cells
std::int64_t num_global_cells
Global number of cells.
Definition LocalMeshData.h:139
dolfin::LocalMeshData::Topology::cell_vertices
boost::multi_array< std::int64_t, 2 > cell_vertices
Global vertex indices for all cells stored on local processor.
Definition LocalMeshData.h:145
dolfin::LocalMeshData::Topology::cell_type
CellType::Type cell_type
Cell type.
Definition LocalMeshData.h:159
dolfin::LocalMeshData::Topology::clear
void clear()
Clear data.
Definition LocalMeshData.h:162
dolfin::LocalMeshData::Topology::dim
int dim
Topological dimension.
Definition LocalMeshData.h:136
dolfin::LocalMeshData::Topology::Topology
Topology()
Constructor.
Definition LocalMeshData.h:133
dolfin::LocalMeshData::Topology::num_vertices_per_cell
int num_vertices_per_cell
Number of vertices per cell.
Definition LocalMeshData.h:142
dolfin::LocalMeshData::Topology::unpack_cell_vertices
void unpack_cell_vertices(const std::vector< std::int64_t > &values)
Unpack received cell vertices.
Definition LocalMeshData.cpp:310
dolfin::LocalMeshData::Topology::cell_partition
std::vector< int > cell_partition
Optional process owner for each cell in global_cell_indices.
Definition LocalMeshData.h:151