Nektar++
SubStructuredGraph.h
Go to the documentation of this file.
1///////////////////////////////////////////////////////////////////////////////
2//
3// File: SubStructuredGraph.h
4//
5// For more information, please see: http://www.nektar.info
6//
7// The MIT License
8//
9// Copyright (c) 2006 Division of Applied Mathematics, Brown University (USA),
10// Department of Aeronautics, Imperial College London (UK), and Scientific
11// Computing and Imaging Institute, University of Utah (USA).
12//
13// Permission is hereby granted, free of charge, to any person obtaining a
14// copy of this software and associated documentation files (the "Software"),
15// to deal in the Software without restriction, including without limitation
16// the rights to use, copy, modify, merge, publish, distribute, sublicense,
17// and/or sell copies of the Software, and to permit persons to whom the
18// Software is furnished to do so, subject to the following conditions:
19//
20// The above copyright notice and this permission notice shall be included
21// in all copies or substantial portions of the Software.
22//
23// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
24// OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
25// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
26// THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
27// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
28// FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
29// DEALINGS IN THE SOFTWARE.
30//
31// Description: a collection of classes that facilitates the implementation
32// of the multi-level static condensation routines
33//
34///////////////////////////////////////////////////////////////////////////////
35
36#ifndef MULTIREGIONS_SUBSTRUCTUREDGRAPH_H
37#define MULTIREGIONS_SUBSTRUCTUREDGRAPH_H
38
40
43
44#include <boost/config.hpp>
45#include <boost/graph/adjacency_list.hpp>
46#include <boost/graph/bandwidth.hpp>
47#include <boost/graph/cuthill_mckee_ordering.hpp>
48#include <boost/graph/properties.hpp>
49#include <set>
50#include <vector>
51
53{
54class BottomUpSubStructuredGraph;
55class SubGraph;
56class MultiLevelBisectedGraph;
57class PatchMap;
58
59typedef std::shared_ptr<BottomUpSubStructuredGraph>
61typedef std::shared_ptr<SubGraph> SubGraphSharedPtr;
62typedef std::shared_ptr<MultiLevelBisectedGraph>
64typedef std::shared_ptr<PatchMap> PatchMapSharedPtr;
65
67{
68public:
70 MULTI_REGIONS_EXPORT PatchMap(const int vals);
72 MULTI_REGIONS_EXPORT void SetPatchMap(const int n, const int patchId,
73 const int dofId,
74 const unsigned int bndPatch,
75 const NekDouble sign);
76
77 void SetNewLevelMap(
78 Array<OneD, const unsigned int> numLocalBndCondPerPatch,
79 Array<OneD, const unsigned int> numLocalIntCondPerPatch);
80
82 {
83 return m_patchId;
84 }
85
87 {
88 return m_dofId;
89 }
90
92 {
93 return m_newLevelMap;
94 }
95
97 {
98 return m_bndPatch;
99 }
100
102 {
103 return m_sign;
104 }
105
106protected:
112};
113
115{
116public:
117 MULTI_REGIONS_EXPORT SubGraph(const int nVerts, const int idOffset = 0)
118 : m_nVerts(nVerts), m_idOffset(idOffset)
119 {
120 }
121
123 {
124 }
125
126 inline int GetNverts(void) const
127 {
128 return m_nVerts;
129 }
130
131 inline void SetNverts(const int i)
132 {
133 m_nVerts = i;
134 }
135
136 inline int GetIdOffset(void) const
137 {
138 return m_idOffset;
139 }
140
141 inline void SetIdOffset(const int i)
142 {
143 m_idOffset = i;
144 }
145
146protected:
149};
150
152
154{
155public:
157 MultiLevelBisectedGraphSharedPtr oldLevel, const int nPartition);
160
163 MULTI_REGIONS_EXPORT void DumpNBndDofs(void) const;
165 std::vector<SubGraphSharedPtr> &leaves) const;
169 {
170 return m_daughterGraphs.size();
171 }
172
174 {
175 return m_BndDofs;
176 }
177
178 inline std::vector<MultiLevelBisectedGraphSharedPtr> &GetDaughterGraphs()
179 {
180 return m_daughterGraphs;
181 }
182
183protected:
185 std::vector<MultiLevelBisectedGraphSharedPtr> m_daughterGraphs;
186};
187
189{
190public:
192 MultiLevelBisectedGraphSharedPtr graph, int nPartition = 0,
193 bool globaloffset = false);
196
198
200 Array<OneD, int> &perm, Array<OneD, int> &iperm) const;
201
203 const Array<OneD, const int> &wgts);
204
206 const int leveltomask, Array<OneD, NekDouble> &maskarray) const;
207
209 const int whichlevel) const;
210
212 const int whichlevel, Array<OneD, unsigned int> &outarray) const;
213
214 MULTI_REGIONS_EXPORT int GetInteriorOffset(const int whichlevel,
215 const int patch = 0) const;
216
217 MULTI_REGIONS_EXPORT std::vector<SubGraphSharedPtr> GetInteriorBlocks(
218 const int whichlevel) const;
219
220 MULTI_REGIONS_EXPORT int GetNumGlobalDofs(const int whichlevel) const;
221
223
224 MULTI_REGIONS_EXPORT void Dump() const;
225
226protected:
227 std::vector<SubGraphSharedPtr> m_IntBlocks;
229
230private:
231 void SetBottomUpReordering(Array<OneD, int> &iperm) const;
232
234 {
235 return m_daughterGraph;
236 }
237 inline std::vector<SubGraphSharedPtr> GetInteriorBlocks() const
238 {
239 return m_IntBlocks;
240 }
241};
242
243namespace
244{
245typedef boost::adjacency_list<boost::setS, boost::vecS, boost::undirectedS>
246 BoostGraph;
247}
248
249MULTI_REGIONS_EXPORT void CuthillMckeeReordering(const BoostGraph &graph,
250 Array<OneD, int> &perm,
251 Array<OneD, int> &iperm);
252
254 const BoostGraph &graph, Array<OneD, int> &perm, Array<OneD, int> &iperm,
256 std::set<int> partVerts = std::set<int>(), int mdswitch = 1);
257
258// The parameter MDSWITCH.
259//
260// This parameters defines the maximal size of the smallest patches. If
261// at a certain level, a patch bundles less than MDSWITCH
262// graph-vertices, metis is not going to partition this subgraph any
263// further. Some quick and basis test have shown that 30 seems to be
264// good value. However, this optimal value will probably depend on the
265// polynomial order of the expansion and there is still room for
266// optimisation here.
267
268MULTI_REGIONS_EXPORT void NoReordering(const BoostGraph &graph,
269 Array<OneD, int> &perm,
270 Array<OneD, int> &iperm);
271} // namespace Nektar::MultiRegions
272
273#endif // MULTIREGIONS_SUBSTRUCTUREDGRAPH_H
#define MULTI_REGIONS_EXPORT
#define sign(a, b)
return the sign(b)*a
Definition: Polylib.cpp:47
void GetNintDofsPerPatch(const int whichlevel, Array< OneD, unsigned int > &outarray) const
void ExpandGraphWithVertexWeights(const Array< OneD, const int > &wgts)
std::vector< SubGraphSharedPtr > GetInteriorBlocks() const
BottomUpSubStructuredGraphSharedPtr GetDaughterGraph() const
void SetBottomUpReordering(Array< OneD, int > &iperm) const
int GetInteriorOffset(const int whichlevel, const int patch=0) const
BottomUpSubStructuredGraph(MultiLevelBisectedGraphSharedPtr graph, int nPartition=0, bool globaloffset=false)
void UpdateBottomUpReordering(Array< OneD, int > &perm, Array< OneD, int > &iperm) const
BottomUpSubStructuredGraphSharedPtr m_daughterGraph
void MaskPatches(const int leveltomask, Array< OneD, NekDouble > &maskarray) const
int GetNpatchesWithInterior(const int whichlevel) const
MultiLevelBisectedGraph(MultiLevelBisectedGraphSharedPtr oldLevel, const int nPartition)
std::vector< MultiLevelBisectedGraphSharedPtr > & GetDaughterGraphs()
void CollectLeaves(std::vector< SubGraphSharedPtr > &leaves) const
const SubGraphSharedPtr GetBndDofsGraph() const
std::vector< MultiLevelBisectedGraphSharedPtr > m_daughterGraphs
Array< OneD, const unsigned int > IsBndDof() const
Array< OneD, unsigned int > m_bndPatch
void SetPatchMap(const int n, const int patchId, const int dofId, const unsigned int bndPatch, const NekDouble sign)
void SetNewLevelMap(Array< OneD, const unsigned int > numLocalBndCondPerPatch, Array< OneD, const unsigned int > numLocalIntCondPerPatch)
Array< OneD, const int > GetNewLevelMap() const
Array< OneD, NekDouble > m_sign
Array< OneD, const int > GetDofId() const
Array< OneD, const int > GetPatchId() const
Array< OneD, const NekDouble > GetSign() const
SubGraph(const int nVerts, const int idOffset=0)
void NoReordering(const BoostGraph &graph, Array< OneD, int > &perm, Array< OneD, int > &iperm)
void CuthillMckeeReordering(const BoostGraph &graph, Array< OneD, int > &perm, Array< OneD, int > &iperm)
void MultiLevelBisectionReordering(const BoostGraph &graph, Array< OneD, int > &perm, Array< OneD, int > &iperm, BottomUpSubStructuredGraphSharedPtr &substructgraph, std::set< int > partVerts, int mdswitch)
std::shared_ptr< BottomUpSubStructuredGraph > BottomUpSubStructuredGraphSharedPtr
bool SubGraphWithoutVerts(const SubGraphSharedPtr g)
std::shared_ptr< MultiLevelBisectedGraph > MultiLevelBisectedGraphSharedPtr
std::shared_ptr< SubGraph > SubGraphSharedPtr
std::shared_ptr< PatchMap > PatchMapSharedPtr
double NekDouble