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, S. Smaldone |
13 |
|
|
// |
14 |
|
|
|
15 |
|
|
#ifndef _CVGRAPHINTERFACE_HPP |
16 |
|
|
#define _CVGRAPHINTERFACE_HPP |
17 |
|
|
|
18 |
|
|
// System includes |
19 |
|
|
#include <cstdio> |
20 |
|
|
#include <iostream> |
21 |
|
|
|
22 |
|
|
// External includes |
23 |
|
|
|
24 |
|
|
// Project includes |
25 |
|
|
#include "Core/felisce.hpp" |
26 |
|
|
#include "DegreeOfFreedom/dof.hpp" |
27 |
|
|
#include "DegreeOfFreedom/listVariable.hpp" |
28 |
|
|
#include "PETScInterface/petscVector.hpp" |
29 |
|
|
#include "Core/shared_pointers.hpp" |
30 |
|
|
|
31 |
|
|
namespace felisce |
32 |
|
|
{ |
33 |
|
|
|
34 |
|
|
/* |
35 |
|
|
Class to manage interface for coupled problems. |
36 |
|
|
|
37 |
|
|
*** Exemple de fichier de parametres: |
38 |
|
|
[interface] |
39 |
|
|
type = 'Dirichlet Neumann' |
40 |
|
|
listOfNode = 'inlet.match outlet.match' |
41 |
|
|
variable = 'velocity velocity' |
42 |
|
|
component = 'Comp123 Comp123' |
43 |
|
|
|
44 |
|
|
|
45 |
|
|
*** Initialisation des classes ListOfInterface / Interface |
46 |
|
|
(dans le meme esprit que listOfBoundaryCondition / BoundaryCondition) |
47 |
|
|
|
48 |
|
|
dans Interface: on a en particulier 2 conteneurs: |
49 |
|
|
std::vector<int> m_listSupportOfDOF |
50 |
|
|
std::vector<int> m_listDof |
51 |
|
|
std::vector<double> m_listValue |
52 |
|
|
|
53 |
|
|
*** Dans NSModel.cpp, |
54 |
|
|
après l'appel |
55 |
|
|
m_linearProblem[0]->applyBC(FelisceParam::instance().essentialBoundaryConditionsMethod, m_rankProc); |
56 |
|
|
et juste avant m_linearProblem[0]->solve(m_rankProc, m_numProc); |
57 |
|
|
On parcourt les interfaces, |
58 |
|
|
si le type de l'interface[i[ est Neummann on ne fait rien |
59 |
|
|
si le type de l'interface[i] est Dirichlet: |
60 |
|
|
Mettre une boucle du type de celle qui est dans applyBC: |
61 |
|
|
for(felInt iDofBC = 0; iDofBC < m_listDof.size(); iDofBC++){ |
62 |
|
|
iabis[0] = m_listDof[iDofBC]; |
63 |
|
|
ia[0] = iabis[0]; |
64 |
|
|
ia2[0] = iabis[0]; |
65 |
|
|
AOPetscToApplication(m_ao,1,ia2); |
66 |
|
|
if (m_dofPart[ia2[0]] == rank){ |
67 |
|
|
ic[0] = 1; |
68 |
|
|
ISGlobalToLocalMappingApply(m_mappingNodes,IS_GTOLM_MASK,1,ia2,ic,iabis); |
69 |
|
|
felInt rowSize = m_dof.iCSR()[iabis[0]+1] - m_dof.iCSR()[iabis[0]]; |
70 |
|
|
// REMPLACER -> |
71 |
|
|
for ( felInt iCol = 0; iCol < rowSize; iCol++) { |
72 |
|
|
ic[0] = m_dof.jCSR()[m_dof.iCSR()[iabis[0]] + iCol]; |
73 |
|
|
AOApplicationToPetsc(m_ao,1,ic); |
74 |
|
|
ib[iCol] = ic[0]; |
75 |
|
|
value[iCol] = 0.; |
76 |
|
|
if ( ia2[0] == m_dof.jCSR()[m_dof.iCSR()[iabis[0]] + iCol] ) |
77 |
|
|
value[iCol] = 1.; |
78 |
|
|
} |
79 |
|
|
// <-- Par simplement : Mettre sur la diagonale la valeur deja presente * TGV |
80 |
|
|
// et IDEM pour le second membre |
81 |
|
|
int size = 1; |
82 |
|
|
if( (flagMatrixRHS == FlagMatrixRHS::matrix_and_rhs) || (flagMatrixRHS == FlagMatrixRHS::only_matrix)) |
83 |
|
|
m_Matrix[0].setValues(size,ia,rowSize,ib,value,INSERT_VALUES); |
84 |
|
|
if( (flagMatrixRHS == FlagMatrixRHS::matrix_and_rhs) || (flagMatrixRHS == FlagMatrixRHS::only_rhs)) |
85 |
|
|
_RHS.setValue(*ia,idBCAndValue[*itDofBC],INSERT_VALUES); |
86 |
|
|
} |
87 |
|
|
} |
88 |
|
|
|
89 |
|
|
Que faire pour le cas Neumann ? |
90 |
|
|
|
91 |
|
|
S'inspirer de ce qui est fait dans LinearProblem::defineBC() |
92 |
|
|
pour les conditions aux limites de lumpedModelBC dans le cas où FelisceParam::instance().model == "NS" |
93 |
|
|
i.e. on ajoute une BC de type Neumann |
94 |
|
|
Remarque: ce ne sera donc plus nécessaire de préciser dans le fichier de paramètre la "BoundaryCondition" sur l'interface. |
95 |
|
|
|
96 |
|
|
*/ |
97 |
|
|
|
98 |
|
|
class CVGraphInterface |
99 |
|
|
{ |
100 |
|
|
public: |
101 |
|
|
/// Pointer definition of CVGraphInterface |
102 |
|
|
FELISCE_CLASS_POINTER_DEFINITION(CVGraphInterface); |
103 |
|
|
|
104 |
|
|
// Empty constructor. Setting pointers to NULL and integers to 0. |
105 |
|
|
CVGraphInterface(); |
106 |
|
|
|
107 |
|
|
// Destructor |
108 |
|
|
~CVGraphInterface(); |
109 |
|
|
|
110 |
|
|
// Reading from .match file |
111 |
|
|
// This function read the .match file and store the ids in m_listOfNodeInInterface |
112 |
|
|
// than, after having computed the number of dof at the interface, it allocates two vectors |
113 |
|
|
// m_listOfValuesInInterface and m_StoredSolution. |
114 |
|
|
void initialize(ListVariable* listVariable, const std::string& fileName); |
115 |
|
|
|
116 |
|
|
// Moving from supportDof (as they are stored in the match file) to the dofs. |
117 |
|
|
void identifyIdDof(Dof& dof); |
118 |
|
|
|
119 |
|
|
// Impose the entire solution at the interface |
120 |
|
|
void ImposeSolution(double* ImpValue); |
121 |
|
|
|
122 |
|
|
// Store the entire solution at the interface. To apply after model.formward() |
123 |
|
|
void StoreSolution(double* StoringValue); |
124 |
|
|
|
125 |
|
|
// Impose the solution corresponding to the variable with idVariable and a computed variable needed by the users |
126 |
|
|
// Split the values in the std::vector of solution and the vector of a variable computed by the user |
127 |
|
|
void ImposeSolutionAndComputedVariable(double* ImpValue, int idVariable); |
128 |
|
|
|
129 |
|
|
// Extract the entire solution at the interface |
130 |
|
|
void ExtractSolution(PetscVector& VecOfSol, double* valueDofInterface); |
131 |
|
|
|
132 |
|
|
// Extract only the solution corresponding to the variable with idVariable |
133 |
|
|
void ExtractSolution(PetscVector& VecOfSol, double* valueDofInterface, int idVariable); |
134 |
|
|
|
135 |
|
|
// Extract the solution with idVariable and a specific variable computed by the user |
136 |
|
|
void ExtractSolutionAndComputedVariable(PetscVector& VecOfSol, std::vector<double>& VecComputedVar, |
137 |
|
|
double* valueDofInterface, int idVariable); |
138 |
|
|
|
139 |
|
|
void print(int verbose=0, std::ostream& c=std::cout) const; |
140 |
|
|
|
141 |
|
|
felInt totalNumberOfNode() const { |
142 |
|
|
return m_totalNumberOfNode; |
143 |
|
|
} |
144 |
|
|
|
145 |
|
|
double* TotSolToImpose() { |
146 |
|
|
return m_TotSolToImpose; |
147 |
|
|
} |
148 |
|
|
|
149 |
|
|
double* StoredSolution() { |
150 |
|
|
return m_StoredSolution; |
151 |
|
|
} |
152 |
|
|
|
153 |
|
|
double* SolutionToImpose() { |
154 |
|
|
return m_SolutionToImpose; |
155 |
|
|
} |
156 |
|
|
|
157 |
|
✗ |
double* ComputedVariableToImpose() { |
158 |
|
✗ |
return m_ComputedVariableToImpose; |
159 |
|
|
} |
160 |
|
|
|
161 |
|
✗ |
felInt* listOfDofInInterface() { |
162 |
|
✗ |
return m_listOfDofInInterface; |
163 |
|
|
} |
164 |
|
|
|
165 |
|
|
felInt* listOfDofInInterfaceForVariable(int iVariable); |
166 |
|
|
|
167 |
|
|
void identifyIdDofForVariable(); |
168 |
|
|
|
169 |
|
|
felInt TotNumDofOnInterface() const { |
170 |
|
|
return m_TotNumDofOnInterface; |
171 |
|
|
} |
172 |
|
|
|
173 |
|
✗ |
felInt SizeListOfDofForVariable() const { |
174 |
|
✗ |
return m_SizeListOfDofForVariable; |
175 |
|
|
} |
176 |
|
|
|
177 |
|
|
double* listOfValuesInInterface() { |
178 |
|
|
return m_listOfValuesInInterface; |
179 |
|
|
} |
180 |
|
|
|
181 |
|
|
private: |
182 |
|
|
felInt m_totalNumberOfNode = 0; |
183 |
|
|
int m_numberOfDofBySupport = 0; |
184 |
|
|
ListVariable* m_listVariable = nullptr; |
185 |
|
|
felInt* m_listOfNodeInInterface = nullptr; |
186 |
|
|
double* m_TotSolToImpose = nullptr; |
187 |
|
|
double* m_StoredSolution = nullptr; |
188 |
|
|
double* m_SolutionToImpose = nullptr; |
189 |
|
|
double* m_ComputedVariableToImpose = nullptr; |
190 |
|
|
felInt* m_listOfDofInInterface = nullptr; |
191 |
|
|
felInt m_TotNumDofOnInterface = 0; |
192 |
|
|
double* m_listOfValuesInInterface = nullptr; |
193 |
|
|
felInt m_SizeListOfDofForVariable = 0; |
194 |
|
|
felInt** m_listOfDofForVariable = nullptr; |
195 |
|
|
}; |
196 |
|
|
|
197 |
|
|
} |
198 |
|
|
|
199 |
|
|
#endif |
200 |
|
|
|