DOLFIN
DOLFIN C++ interface
GraphBuilder.h
1// Copyright (C) 2010-2013 Garth N. Wells
2//
3// This file is part of DOLFIN.
4//
5// DOLFIN is free software: you can redistribute it and/or modify
6// it under the terms of the GNU Lesser General Public License as published by
7// the Free Software Foundation, either version 3 of the License, or
8// (at your option) any later version.
9//
10// DOLFIN is distributed in the hope that it will be useful,
11// but WITHOUT ANY WARRANTY; without even the implied warranty of
12// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13// GNU Lesser General Public License for more details.
14//
15// You should have received a copy of the GNU Lesser General Public License
16// along with DOLFIN. If not, see <http://www.gnu.org/licenses/>.
17//
18// First added: 2010-02-19
19// Last changed: 2013-01-16
20
21#ifndef __GRAPH_BUILDER_H
22#define __GRAPH_BUILDER_H
23
24#include <cstdint>
25#include <utility>
26#include <set>
27#include <boost/unordered_map.hpp>
28#include <vector>
29#include <boost/multi_array.hpp>
30#include <dolfin/common/MPI.h>
31#include "Graph.h"
32
33namespace dolfin
34{
35
36 // Forward declarations
37 class CellType;
38 class GenericDofMap;
39 class Mesh;
40
42
44 {
45
46 public:
47
49 static Graph local_graph(const Mesh& mesh, const GenericDofMap& dofmap0,
50 const GenericDofMap& dofmap1);
51
53 static Graph local_graph(const Mesh& mesh,
54 const std::vector<std::size_t>& coloring_type);
55
57 static Graph local_graph(const Mesh& mesh, std::size_t dim0,
58 std::size_t dim1);
59
63 static
64 std::pair<std::int32_t, std::int32_t>
65 compute_dual_graph(const MPI_Comm mpi_comm,
66 const boost::multi_array<std::int64_t, 2>& cell_vertices,
67 const CellType& cell_type,
68 const std::int64_t num_global_vertices,
69 std::vector<std::vector<std::size_t>>& local_graph,
70 std::set<std::int64_t>& ghost_vertices);
71 private:
72
73 friend class MeshPartitioning;
74
75 typedef std::vector<std::pair<std::vector<std::size_t>, std::int32_t>>
76 FacetCellMap;
77
78 // Compute local part of the dual graph, and return number of
79 // local edges in the graph (undirected)
80 static std::int32_t
81 compute_local_dual_graph(const MPI_Comm mpi_comm,
82 const boost::multi_array<std::int64_t, 2>& cell_vertices,
83 const CellType& cell_type,
84 std::vector<std::vector<std::size_t>>& local_graph,
85 FacetCellMap& facet_cell_map);
86
87 // Compute local part of the dual graph, and return number of
88 // local edges in the graph (undirected)
89 template<int N>
90 static std::int32_t
91 compute_local_dual_graph_keyed(const MPI_Comm mpi_comm,
92 const boost::multi_array<std::int64_t, 2>& cell_vertices,
93 const CellType& cell_type,
94 std::vector<std::vector<std::size_t>>& local_graph,
95 FacetCellMap& facet_cell_map);
96
97 // Build nonlocal part of dual graph for mesh and return number of
98 // non-local edges. Note: GraphBuilder::compute_local_dual_graph
99 // should be called before this function is called.
100 static std::int32_t
101 compute_nonlocal_dual_graph(const MPI_Comm mpi_comm,
102 const boost::multi_array<std::int64_t, 2>& cell_vertices,
103 const CellType& cell_type,
104 const std::int64_t num_global_vertices,
105 std::vector<std::vector<std::size_t>>& local_graph,
106 FacetCellMap& facet_cell_map,
107 std::set<std::int64_t>& ghost_vertices);
108
109 };
110
111}
112
113#endif
Definition: CellType.h:47
This class provides a generic interface for dof maps.
Definition: GenericDofMap.h:50
This class builds a Graph corresponding to various objects.
Definition: GraphBuilder.h:44
static Graph local_graph(const Mesh &mesh, const GenericDofMap &dofmap0, const GenericDofMap &dofmap1)
Build local graph from dofmap.
Definition: GraphBuilder.cpp:45
static std::pair< std::int32_t, std::int32_t > compute_dual_graph(const MPI_Comm mpi_comm, const boost::multi_array< std::int64_t, 2 > &cell_vertices, const CellType &cell_type, const std::int64_t num_global_vertices, std::vector< std::vector< std::size_t > > &local_graph, std::set< std::int64_t > &ghost_vertices)
Definition: GraphBuilder.cpp:157
Definition: MeshPartitioning.h:63
Definition: Mesh.h:84
Definition: adapt.h:30
std::vector< graph_set_type > Graph
Vector of unordered Sets.
Definition: Graph.h:39