GCC Code Coverage Report


Directory: ./
File: DegreeOfFreedom/listUnknown.hpp
Date: 2024-04-14 07:32:34
Exec Total Coverage
Lines: 17 21 81.0%
Branches: 3 6 50.0%

Line Branch Exec Source
1 // ______ ______ _ _ _____ ______
2 // | ____| ____| | (_)/ ____| | ____|
3 // | |__ | |__ | | _| (___ ___| |__
4 // | __| | __| | | | |\___ \ / __| __|
5 // | | | |____| |____| |____) | (__| |____
6 // |_| |______|______|_|_____/ \___|______|
7 // Finite Elements for Life Sciences and Engineering
8 //
9 // License: LGL2.1 License
10 // FELiScE default license: LICENSE in root folder
11 //
12 // Main authors: J. Foulon & J-F. Gerbeau
13 //
14
15 #ifndef LISTUNKNOWN_H
16 #define LISTUNKNOWN_H
17
18 // System includes
19 #include <ostream>
20
21 // External includes
22
23 // Project includes
24 #include "Core/felisce.hpp"
25 #include "DegreeOfFreedom/listVariable.hpp"
26
27 namespace felisce
28 {
29 /*!
30 \class ListUnknown
31 \author J. Foulon & J-F Gerbeau
32 \date 26/11/2011
33 \brief Class containing a list of unknown of a linear system.
34 */
35
36 class ListUnknown
37 {
38 public:
39 typedef boost::numeric::ublas::matrix<int> interactionsOnUnknown;
40
41 //!Constructor.
42 ListUnknown();
43
44 //! Add physicalVariable to list of unknown
45 void push_back(PhysicalVariable physicalVariable);
46
47 //! Return number of unknowns.
48 681239649 std::size_t size() const {
49 681239649 return m_listUnknown.size();
50 }
51
52 //! Determine sizeOdMask.
53 void setDefaultMask(const ListVariable& listVariable);
54
55 //! Function to define specific connection on unknown.
56 /*!
57 \brief array contains all value of the mask by line
58 ex: \f$ \left (
59 \begin{array}{cccc}
60 & Vx & Vy & P \\
61 Vx & 1 & 0 & 1 \\
62 Vy & 0 & 1 & 1 \\
63 P & 1 & 1 & 0 \\
64 \end{array}
65 \right ) \f$
66 array = [ 1, 0, 1, 0, 1, 1, 1, 1, 0 ]
67 */
68
69 /*! Fill the mask with 0 or 1 value to define interaction on variable's conponents.
70 \param[in] array contains value for the mask (0 or 1) if variable are connected.
71 */
72 void setMask( const std::vector<int> & array );
73
74 //! Get start of the block in elementary matrix associate to the unknown.
75 1007092 int getBlockPosition(int iUnknown, int iComp) {
76
3/6
✓ Branch 0 taken 1007092 times.
✗ Branch 1 not taken.
✗ Branch 3 not taken.
✓ Branch 4 taken 1007092 times.
✗ Branch 5 not taken.
✓ Branch 6 taken 1007092 times.
1007092 FEL_ASSERT( iUnknown >= 0 && iUnknown < int(m_iBlockOfUnknown.size()) );
77 1007092 return m_iBlockOfUnknown[iUnknown]+iComp;
78 }
79
80 void print(int verbose = 0, std::ostream& outstr = std::cout) const;
81
82 //! Access function
83 //=================
84 //! Return id of the variable associate to the unknown.
85 201648639 inline const int & idVariable(const std::size_t iUnknown) const {
86 201648639 return m_listIdVarOfUnknown[iUnknown];
87 }
88
89 92752009 inline int & idVariable(const std::size_t iUnknown) {
90 92752009 return m_listIdVarOfUnknown[iUnknown];
91 }
92
93 inline const interactionsOnUnknown & mask() const {
94 return m_mask;
95 }
96
97 338703364 inline interactionsOnUnknown & mask() {
98 338703364 return m_mask;
99 }
100
101 inline const std::vector<int>& getUnknownsRows() const {
102 return m_listUnknownsRows;
103 }
104
105 inline const std::vector<int>& getUnknownsCols() const {
106 return m_listUnknownsCols;
107 }
108
109 198837034 inline std::vector<int>& getUnknownsRows() {
110 198837034 return m_listUnknownsRows;
111 }
112
113 52750978 inline std::vector<int>& getUnknownsCols() {
114 52750978 return m_listUnknownsCols;
115 }
116
117 inline void setUnknownsRows(const std::vector<int>& listUnknown) {
118 m_listUnknownsRows = listUnknown;
119 }
120
121 inline void setUnknownsCols(const std::vector<int>& listUnknown) {
122 m_listUnknownsCols = listUnknown;
123 }
124
125 inline void setUnknownsRows() {
126 m_listUnknownsRows = m_listUnknownsRowsDefault;
127 }
128
129 inline void setUnknownsCols() {
130 m_listUnknownsCols = m_listUnknownsColsDefault;
131 }
132
133
134 /*!
135 \brief Find the position of one unknown in the std::vector with its name.
136 Useful to generalize Felisce Library utilisation.
137 \param[in] unknown name of the unknown research
138 */
139 int getUnknownIdList( PhysicalVariable unknown );
140
141 /*!
142 \brief Find the position of one unknown in the std::vector with its name.
143 Useful to generalize Felisce Library utilisation.
144 \param[in] unknown name of the unknown research
145 */
146 int getUnknownIdList( PhysicalVariable unknown ) const;
147
148 //Operators.
149 //==========
150 1057 PhysicalVariable& operator[](int i) {
151 1057 return m_listUnknown[i];
152 }
153
154 private:
155 std::vector<PhysicalVariable> m_listUnknown;
156 std::vector<int> m_listIdVarOfUnknown;
157 //! List f unknown for rows and columns
158 std::vector<int> m_listUnknownsRows;
159 std::vector<int> m_listUnknownsCols;
160 std::vector<int> m_listUnknownsRowsDefault;
161 std::vector<int> m_listUnknownsColsDefault;
162 //! Locate start of the block in elementary matrix associate to the unknown.
163 std::vector<int> m_iBlockOfUnknown;
164 //! small matrice to define interaction on variables. Useful to define matrix's patern.
165 interactionsOnUnknown m_mask;
166 //! sum of variable components. ex: Variable velocity with 2 components and pressure with 1 component so sizeOfMask equal 3.
167 int m_sizeOfMask;
168 };
169 }
170
171 #endif
172
173