1 // GetDP - Copyright (C) 1997-2021 P. Dular and C. Geuzaine, University of Liege 2 // 3 // See the LICENSE.txt file for license information. Please report all 4 // issues on https://gitlab.onelab.info/getdp/getdp/issues. 5 6 #ifndef DOFDATA_H 7 #define DOFDATA_H 8 9 #include <vector> 10 #include "ListUtils.h" 11 #include "TreeUtils.h" 12 #include "LinAlg.h" 13 14 #define DOF_PRE 1 15 #define DOF_RES 2 16 #define DOF_TMP 3 17 18 struct Solution { 19 int TimeStep ; /* Must be first member of struct (for 20 searching purposes) */ 21 double Time, TimeImag ; 22 int SolutionExist ; 23 double * TimeFunctionValues, ExplicitTimeFunctionValue ; 24 gVector x ; 25 } ; 26 27 struct Dof { 28 int NumType ; /* Key 1 */ 29 int Entity ; /* Key 2 */ 30 int Harmonic ; /* Key 3 */ 31 32 int Type ; 33 34 /* Val must be out of the union (a member with constructor (gScalar with 35 PETSc) is not allowed in a union); Val holds the init value for 36 Type==Unknown, and the assigned value for Type==FixedAssociate. Val is not 37 used for Type==Link. Val2 potentially holds a second init value for 38 Type==Unknown */ 39 gScalar Val, Val2 ; 40 41 union { 42 struct { 43 int NumDof ; /* Equation number - 1st position */ 44 bool NonLocal ; /* Set to true if equation is non-local */ 45 } Unknown ; 46 struct { 47 int NumDof ; /* Equation number (Associate) - 1st position */ 48 int TimeFunctionIndex ; 49 } FixedAssociate ; 50 struct { 51 int EntityRef ; 52 double Coef, Coef2 ; 53 struct Dof * Dof ; 54 } Link ; 55 } Case ; 56 } ; 57 58 /* Dof.Type */ 59 60 /* definitive in preprocessing and processing */ 61 #define DOF_UNKNOWN 1 /* unknown */ 62 #define DOF_FIXED 2 /* spatial fixed */ 63 #define DOF_FIXEDWITHASSOCIATE 3 /* associate */ 64 #define DOF_LINK 7 /* link */ 65 #define DOF_LINKCPLX 8 /* linkcplx */ 66 67 /* definitive in a preprocessing */ 68 #define DOF_UNKNOWN_INIT 5 /* initial condition */ 69 70 /* temporary */ 71 #define DOF_FIXED_SOLVE 4 /* waiting to be fixed by a resolution */ 72 #define DOF_FIXEDWITHASSOCIATE_SOLVE 6 /* waiting to be fixed by a resolution */ 73 74 struct CorrectionSolutions { 75 List_T * Solutions ; 76 } ; 77 78 struct DofData { 79 int Num ; 80 81 int ResolutionIndex, SystemIndex ; 82 int GeoDataIndex ; 83 List_T * FunctionSpaceIndex ; 84 List_T * TimeFunctionIndex ; 85 86 List_T * Pulsation ; 87 int NbrHar ; 88 double * Val_Pulsation ; 89 90 int NbrAnyDof, NbrDof ; 91 Tree_T * DofTree ; 92 List_T * DofList ; 93 94 int * DummyDof ; 95 96 char * SolverDataFileName ; 97 List_T * Solutions ; 98 struct Solution * CurrentSolution ; 99 struct Solution * Save_CurrentSolution ; 100 101 struct { 102 int Flag ; 103 List_T * Save_FullSolutions ; 104 struct Solution * Save_CurrentFullSolution ; 105 List_T * AllSolutions ; 106 } CorrectionSolutions ; 107 108 int Flag_RHS ; // only assemble RHS 109 int Flag_ListOfRHS ; // only assemble list of RHS 110 int Flag_Init[8] ; 111 int Flag_Only ; 112 int Flag_InitOnly[3] ; 113 114 // For recalculating only the matrices that are required 115 List_T *OnlyTheseMatrices ; 116 117 // Flag_Init[0] == 1 || Flag_Init[0] == 2 118 gMatrix A; 119 gVector b; 120 gSolver Solver; 121 122 // Flag_Init[0] == 2 123 gMatrix Jac ; 124 gVector res, dx ; 125 126 // Flag_Init[0] == 3 //kj+++ 127 gVector df; 128 129 // Flag_Init[1,2,3,4,5,6,7] == 1 130 gMatrix M1, M2, M3, M4, M5, M6, M7; 131 gVector m1, m2, m3, m4, m5, m6, m7; 132 List_T *m1s, *m2s, *m3s, *m4s, *m5s, *m6s, *m7s; 133 134 // Flag_Only and Flag_InitOnly[0,1,2] 135 gMatrix A1, A2, A3 ; 136 gVector b1, b2, b3 ; 137 138 // Flag_ListOfRHS 139 std::vector<gVector> ListOfRHS ; 140 int CounterOfRHS, TotalNumberOfRHS ; 141 142 gMatrix A_MH_moving ; 143 gVector b_MH_moving ; 144 145 std::vector<int> NonLocalEquations; 146 } ; 147 148 149 int fcmp_Dof(const void * a, const void * b) ; 150 151 void Dof_InitDofData(struct DofData * DofData_P, int Num, 152 int ResolutionIndex, int SystemIndex, 153 char * Name_SolverDataFile) ; 154 void Dof_FreeDofData(struct DofData * DofData_P) ; 155 156 void Dof_SetCurrentDofData(struct DofData * DofData_P) ; 157 158 void Dof_OpenFile(int Type, char * Name, const char * Mode) ; 159 void Dof_CloseFile(int Type) ; 160 void Dof_FlushFile(int Type) ; 161 162 void Dof_WriteFilePRE0(int Num_Resolution, char * Name_Resolution, int Nbr_DofData) ; 163 void Dof_ReadFilePRE0(int * Num_Resolution, int * Nbr_DofData) ; 164 void Dof_WriteFilePRE(struct DofData * DofData_P) ; 165 void Dof_WriteDofPRE(void * a, void * b) ; 166 void Dof_ReadFilePRE(struct DofData * DofData_P) ; 167 168 void Dof_WriteFileRES0(char * Name_File, int Format) ; 169 void Dof_ReadFileRES0(void) ; 170 void Dof_WriteFileRES(char * Name_File, struct DofData * DofData_P, int Format, 171 double Val_Time, double Val_TimeImag, int Val_TimeStep) ; 172 void Dof_ReadFileRES(List_T * DofData_L, struct DofData * Read_DofData_P, 173 int Read_DofData, double *Time, double *TimeImag, 174 double *TimeStep) ; 175 void Dof_WriteFileRES_ExtendMH(char * Name_File, struct DofData * DofData_P, int Format, 176 int NbrH); 177 void Dof_WriteFileRES_MHtoTime(char * Name_File, struct DofData * DofData_P, 178 int Format, List_T * Time_L); 179 void Dof_WriteFileRES_WithEntityNum(char * Name_File, struct DofData * DofData_P, 180 struct GeoData * GeoData_P0, struct Group * Group_P, 181 bool saveFixed); 182 183 void Dof_TransferDofTreeToList(struct DofData * DofData_P) ; 184 void Dof_InitDofType(struct DofData * DofData_P) ; 185 void Dof_DeleteDofTree(struct DofData * DofData_P) ; 186 187 void Dof_AddFunctionSpaceIndex(int Index_FunctionSpace) ; 188 void Dof_AddTimeFunctionIndex(int Index_TimeFunction) ; 189 void Dof_AddPulsation(struct DofData * DofData_P, double Val_Pulsation) ; 190 191 void Dof_DefineAssignFixedDof(int D1, int D2, int NbrHar, double * Val, 192 int Index_TimeFunction) ; 193 void Dof_DefineInitFixedDof(int D1, int D2, int NbrHar, double * Val, 194 double *Val2, bool NonLocal=false) ; 195 void Dof_DefineAssignSolveDof(int D1, int D2, int NbrHar, int Index_TimeFunction) ; 196 void Dof_DefineInitSolveDof(int D1, int D2, int NbrHar) ; 197 void Dof_DefineLinkDof(int D1, int D2, int NbrHar, double Value[], int D2_Link) ; 198 void Dof_DefineLinkCplxDof(int D1, int D2, int NbrHar, double Value[], int D2_Link) ; 199 void Dof_DefineUnknownDof(int D1, int D2, int NbrHar, bool NonLocal=false) ; 200 void Dof_DefineAssociateDof(int E1, int E2, int D1, int D2, int NbrHar, int init, 201 double * Val) ; 202 void Dof_DefineUnknownDofFromSolveOrInitDof(struct DofData ** DofData_P) ; 203 204 void Dof_NumberUnknownDof(void) ; 205 206 void Dof_UpdateAssignFixedDof(int D1, int D2, int NbrHar, double *Val, double *Val2) ; 207 void Dof_UpdateLinkDof(int D1, int D2, int NbrHar, double Value[], int D2_Link) ; 208 209 void Dof_AssembleInMat(struct Dof * Equ_P, struct Dof * Dof_P, int NbrHar, double * Val, 210 gMatrix * Mat, gVector * Vec, List_T *Vecs=0) ; 211 void Dof_AssembleInVec(struct Dof * Equ_P, struct Dof * Dof_P, int NbrHar, double * Val, 212 struct Solution * OtherSolution, gVector * Vec0, gVector * Vec) ; 213 214 void Dof_TransferSolutionToConstraint(struct DofData * DofData_P) ; 215 void Dof_TransferDof(struct DofData * DofData1_P, struct DofData ** DofData2_P); 216 217 struct Dof * Dof_GetDofStruct(struct DofData * DofData_P, int D1, int D2, int D3) ; 218 gScalar Dof_GetDofValue(struct DofData * DofData_P, struct Dof * Dof_P) ; 219 void Dof_GetRealDofValue(struct DofData * DofData_P, struct Dof * Dof_P, double *d) ; 220 void Dof_GetComplexDofValue(struct DofData * DofData_P, struct Dof * Dof_P, 221 double *d1, double *d2) ; 222 223 void Dof_GetDummies(struct DefineSystem * DefineSystem_P, struct DofData * DofData_P) ; 224 void Dof_InitDofForNoDof(struct Dof * DofForNoDof, int NbrHar) ; 225 226 void Print_DofNumber(struct Dof *Dof_P) ; 227 228 #endif 229