OGS
ComponentGlobalIndexDict.h
Go to the documentation of this file.
1// SPDX-FileCopyrightText: Copyright (c) OpenGeoSys Community (opengeosys.org)
2// SPDX-License-Identifier: BSD-3-Clause
3
4#pragma once
5
6#include <boost/multi_index/composite_key.hpp>
7#include <boost/multi_index/member.hpp>
8#include <boost/multi_index/ordered_index.hpp>
9#include <boost/multi_index_container.hpp>
10#include <limits>
11#include <utility>
12
13#include "MeshLib/Location.h"
15
16namespace NumLib
17{
19namespace detail
20{
21struct Line
22{
24
25 // Physical component
27
28 // Position in global matrix or vector
30
32 : location(std::move(l)), comp_id(c), global_index(i)
33 {
34 }
35
37 : location(std::move(l)),
38 comp_id(c),
39 global_index(std::numeric_limits<GlobalIndexType>::max())
40 {
41 }
42
44 : location(std::move(l)),
45 comp_id(std::numeric_limits<int>::max()),
46 global_index(std::numeric_limits<GlobalIndexType>::max())
47 {
48 }
49
50 friend std::ostream& operator<<(std::ostream& os, Line const& l)
51 {
52 return os << l.location << ", " << l.comp_id << ", " << l.global_index;
53 }
54};
55
57{
58 bool operator()(Line const& a, Line const& b) const
59 {
60 return a.location < b.location;
61 }
62};
63
65{
66 bool operator()(Line const& a, Line const& b) const
67 {
68 if (a.location < b.location)
69 {
70 return true;
71 }
72 if (b.location < a.location)
73 {
74 return false;
75 }
76
77 // a.loc == b.loc
78 return a.comp_id < b.comp_id;
79 }
80};
81
83{
84};
86{
87};
89{
90};
92{
93};
94
95using ComponentGlobalIndexDict = boost::multi_index::multi_index_container<
96 Line, boost::multi_index::indexed_by<
97 boost::multi_index::ordered_unique<
98 boost::multi_index::tag<ByLocationAndComponent>,
99 boost::multi_index::identity<Line>,
101 boost::multi_index::ordered_non_unique<
102 boost::multi_index::tag<ByLocation>,
103 boost::multi_index::identity<Line>, LineByLocationComparator>,
104 boost::multi_index::ordered_non_unique<
105 boost::multi_index::tag<ByComponent>,
106 boost::multi_index::member<Line, int, &Line::comp_id>>,
107 boost::multi_index::ordered_non_unique<
108 boost::multi_index::tag<ByGlobalIndex>,
109 boost::multi_index::member<Line, GlobalIndexType,
111
112} // namespace detail
113} // namespace NumLib
GlobalMatrix::IndexType GlobalIndexType
boost::multi_index::multi_index_container< Line, boost::multi_index::indexed_by< boost::multi_index::ordered_unique< boost::multi_index::tag< ByLocationAndComponent >, boost::multi_index::identity< Line >, LineByLocationAndComponentComparator >, boost::multi_index::ordered_non_unique< boost::multi_index::tag< ByLocation >, boost::multi_index::identity< Line >, LineByLocationComparator >, boost::multi_index::ordered_non_unique< boost::multi_index::tag< ByComponent >, boost::multi_index::member< Line, int, &Line::comp_id > >, boost::multi_index::ordered_non_unique< boost::multi_index::tag< ByGlobalIndex >, boost::multi_index::member< Line, GlobalIndexType, &Line::global_index > > > > ComponentGlobalIndexDict
bool operator()(Line const &a, Line const &b) const
bool operator()(Line const &a, Line const &b) const
Line(MeshLib::Location l, int c)
friend std::ostream & operator<<(std::ostream &os, Line const &l)
Line(MeshLib::Location l, int c, GlobalIndexType i)