Directory: | ./ |
---|---|
File: | DegreeOfFreedom/listUnknown.cpp |
Date: | 2024-04-14 07:32:34 |
Exec | Total | Coverage | |
---|---|---|---|
Lines: | 35 | 46 | 76.1% |
Branches: | 25 | 48 | 52.1% |
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 | // System includes | ||
16 | |||
17 | // External includes | ||
18 | |||
19 | // Project includes | ||
20 | #include "DegreeOfFreedom/listUnknown.hpp" | ||
21 | |||
22 | namespace felisce | ||
23 | { | ||
24 |
1/2✓ Branch 8 taken 1042 times.
✗ Branch 9 not taken.
|
1042 | ListUnknown::ListUnknown() |
25 | { | ||
26 | 1042 | m_sizeOfMask = 0; | |
27 | 1042 | } | |
28 | |||
29 | /***********************************************************************************/ | ||
30 | /***********************************************************************************/ | ||
31 | |||
32 | 740 | void ListUnknown::push_back(PhysicalVariable physicalVariable) | |
33 | { | ||
34 | 740 | m_listUnknown.push_back(physicalVariable); | |
35 |
1/2✓ Branch 2 taken 740 times.
✗ Branch 3 not taken.
|
740 | m_listIdVarOfUnknown.resize(m_listUnknown.size(),-1); |
36 | 740 | } | |
37 | |||
38 | /***********************************************************************************/ | ||
39 | /***********************************************************************************/ | ||
40 | |||
41 | 514 | void ListUnknown::setDefaultMask(const ListVariable& listVariable) | |
42 | { | ||
43 | int idVar; | ||
44 | const Variable* v; | ||
45 | |||
46 |
1/2✓ Branch 1 taken 514 times.
✗ Branch 2 not taken.
|
514 | m_iBlockOfUnknown.push_back(0); |
47 |
2/2✓ Branch 1 taken 740 times.
✓ Branch 2 taken 514 times.
|
1254 | for ( std::size_t iUnknown = 0; iUnknown < m_listUnknown.size(); iUnknown++ ) { |
48 |
1/2✓ Branch 2 taken 740 times.
✗ Branch 3 not taken.
|
740 | idVar = listVariable.getVariableIdList(m_listUnknown[iUnknown]); |
49 |
1/2✓ Branch 1 taken 740 times.
✗ Branch 2 not taken.
|
740 | m_listIdVarOfUnknown.push_back(idVar); |
50 | 740 | v = &listVariable[idVar]; | |
51 | 740 | m_sizeOfMask += v->numComponent(); | |
52 | |||
53 |
1/2✓ Branch 3 taken 740 times.
✗ Branch 4 not taken.
|
740 | m_iBlockOfUnknown.push_back(v->numComponent()+m_iBlockOfUnknown[iUnknown]); |
54 | |||
55 |
1/2✓ Branch 1 taken 740 times.
✗ Branch 2 not taken.
|
740 | m_listUnknownsRows.push_back(iUnknown); |
56 |
1/2✓ Branch 1 taken 740 times.
✗ Branch 2 not taken.
|
740 | m_listUnknownsCols.push_back(iUnknown); |
57 | } | ||
58 | |||
59 |
1/2✓ Branch 1 taken 514 times.
✗ Branch 2 not taken.
|
514 | m_listUnknownsRowsDefault = m_listUnknownsRows; |
60 |
1/2✓ Branch 1 taken 514 times.
✗ Branch 2 not taken.
|
514 | m_listUnknownsColsDefault = m_listUnknownsCols; |
61 | |||
62 | // resizing of the mask | ||
63 |
1/2✓ Branch 1 taken 514 times.
✗ Branch 2 not taken.
|
514 | m_mask.resize(m_sizeOfMask, m_sizeOfMask); |
64 | |||
65 | // default values in the mask | ||
66 |
2/2✓ Branch 0 taken 1647 times.
✓ Branch 1 taken 514 times.
|
2161 | for ( int i = 0; i < m_sizeOfMask; i++) |
67 |
2/2✓ Branch 0 taken 6583 times.
✓ Branch 1 taken 1647 times.
|
8230 | for ( int j = 0; j < m_sizeOfMask; j++) |
68 |
1/2✓ Branch 1 taken 6583 times.
✗ Branch 2 not taken.
|
6583 | m_mask(i,j) = 1; |
69 | 514 | } | |
70 | |||
71 | /***********************************************************************************/ | ||
72 | /***********************************************************************************/ | ||
73 | |||
74 | ✗ | void ListUnknown::setMask( const std::vector<int> & array ) | |
75 | { | ||
76 | ✗ | for ( int i = 0; i < m_sizeOfMask; i++) | |
77 | ✗ | for ( int j = 0; j < m_sizeOfMask; j++) | |
78 | ✗ | m_mask(i,j) = array[ i*m_sizeOfMask + j ]; | |
79 | } | ||
80 | |||
81 | /***********************************************************************************/ | ||
82 | /***********************************************************************************/ | ||
83 | |||
84 | 412100 | int ListUnknown::getUnknownIdList( PhysicalVariable unknown ) | |
85 | { | ||
86 |
1/2✓ Branch 1 taken 614598 times.
✗ Branch 2 not taken.
|
614598 | for ( std::size_t iUnknown = 0; iUnknown < m_listUnknown.size(); iUnknown++) |
87 |
2/2✓ Branch 1 taken 412100 times.
✓ Branch 2 taken 202498 times.
|
614598 | if ( m_listUnknown[iUnknown] == unknown ) |
88 | 412100 | return iUnknown; | |
89 | |||
90 | ✗ | return -1; | |
91 | } | ||
92 | |||
93 | /***********************************************************************************/ | ||
94 | /***********************************************************************************/ | ||
95 | |||
96 | 3060 | int ListUnknown::getUnknownIdList( PhysicalVariable unknown ) const | |
97 | { | ||
98 |
1/2✓ Branch 1 taken 4548 times.
✗ Branch 2 not taken.
|
4548 | for ( std::size_t iUnknown = 0; iUnknown < m_listUnknown.size(); iUnknown++) |
99 |
2/2✓ Branch 1 taken 3060 times.
✓ Branch 2 taken 1488 times.
|
4548 | if ( m_listUnknown[iUnknown] == unknown ) |
100 | 3060 | return iUnknown; | |
101 | |||
102 | ✗ | return -1; | |
103 | } | ||
104 | |||
105 | /***********************************************************************************/ | ||
106 | /***********************************************************************************/ | ||
107 | |||
108 | 514 | void ListUnknown::print(int verbose, std::ostream& outstr) const | |
109 | { | ||
110 |
1/2✗ Branch 0 not taken.
✓ Branch 1 taken 514 times.
|
514 | if (verbose > 1 ) { |
111 | ✗ | outstr << "/====Mask (define connection on unknown. Use to compute matrix skeleton.)======/\n"; | |
112 | ✗ | for ( int i = 0; i < m_sizeOfMask; i++) { | |
113 | ✗ | for ( int j = 0; j < m_sizeOfMask; j++) | |
114 | ✗ | outstr << m_mask(i,j) << " "; | |
115 | ✗ | outstr << std::endl; | |
116 | } | ||
117 | } | ||
118 | 514 | } | |
119 | } | ||
120 | |||
121 |