SNOWPACK 3.7.0
Solver.h
Go to the documentation of this file.
1/* **********************************************************************************************/
2/* stand-alone */
3/* Derived from RESEARCH VERSION 9.0 */
4/* **********************************************************************************************/
5/* **********************************************************************************/
6/* Copyright WSL Institute for Snow and Avalanche Research SLF-DAVOS */
7/* **********************************************************************************/
8/* This file is part of Snowpack.
9 Snowpack is free software: you can redistribute it and/or modify
10 it under the terms of the GNU General Public License as published by
11 the Free Software Foundation, either version 3 of the License, or
12 (at your option) any later version.
13
14 Snowpack is distributed in the hope that it will be useful,
15 but WITHOUT ANY WARRANTY; without even the implied warranty of
16 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
17 GNU General Public License for more details.
18
19 You should have received a copy of the GNU General Public License
20 along with Snowpack. If not, see <http://www.gnu.org/licenses/>.
21*/
22
23#ifndef SOLVER_H
24#define SOLVER_H
25
26#include <cstddef> //needed for int
27
57typedef struct
58{
61 char **pChunks;
64
65typedef struct
66{
67 int Row0;
68 int Row1;
69 int nCol;
72 int iFloat;
74
75typedef struct
76{
77 int Dim;
78 int *pPerm;
87 double *pUpper;
89
90typedef struct SD_COL_DATA
91{
92 int Col;
95
96typedef struct SD_ROW_DATA
97{
100
101typedef struct
102{
103 int nRow;
104 int *pPerm;
108
113 int nCol;
115
116typedef struct SD_COL_BLOCK_DATA
117{
118 int Col0, Col1;
121
122typedef union
123{
125 struct
126 {
127 int Row0;
128 int Row1;
129 } Any;
130 struct
131 {
132 int Row0;
133 int Row1;
135 } Data;
137
138typedef struct
139{
140 int nRow;
141 int *pPerm;
142
149
160
161typedef struct
162{
163 int nEq;
165
167 union
171 } Mat;
173
174typedef enum SD_MATRIX_WHAT
175{
176 /*
177 * For symbolically factorizing and optimizing the structure of the [L] and [U] matrices
178 * after the connectivity of the matrix [A] has been defined by calling
179 * ds_DefineConnectivity (...)
180 */
182 /*
183 * For numerically factorizing the matrix [A] = [L][U] in to the lower resp. upper
184 * triangular matrices [L] resp. [U] after [A] has been symbolically factorized by calling
185 * ds_Solve(SymbolicFactorize,...) and assembled by calling ds_AssemblLocalMatrix(...) for
186 * each element.
187 */
189 /*
190 * For solving for a new right hand side load vector {B} after the matrix [A] has been
191 * numerically factorized by calling ds_Solve(NumericFactorize,...)
192 */
194 /*
195 * For both numerically factorizing the matrix [A] and solving for a 1st right hand side
196 * vector {B} i.e. is equivalent to the calls ds_Solve(NumericFactorize,...) &
197 * ds_Solve(BackForwardSubst,...)
198 */
200 /*
201 * For resetting all real coefficients of the matrix [A] to zero before reassembling a new
202 * matrix [A] with identical connectivity by calling ds_AssembleLocalMatrix(...) with
203 * changed local element matrices [ElMat] but the same element equations list Eq[...]
204 */
206 /*
207 * For releasing all storage space needed for solving the current problem defined by the
208 * data pointed to by *pMat
209 */
211
213
215//functions that are really used
216
264int ds_DefineConnectivity( SD_MATRIX_DATA *const pMat0, const int& nEq, int Eq[], const int& nEl, const int& Dim );
265
286int ds_Initialize( const int& MatDim, SD_MATRIX_DATA **ppMat );
287
288
324int ds_AssembleMatrix( SD_MATRIX_DATA *pMat0, const int& nEq, int Eq[], const int& Dim, const double *ElMat );
325
333bool ds_Solve(const SD_MATRIX_WHAT& Code, SD_MATRIX_DATA *pMat, double *pX);
334
337#endif
StateType
Definition: Solver.h:159
@ BlockMatrix
Definition: Solver.h:159
@ ConMatrix
Definition: Solver.h:159
@ BlockConMatrix
Definition: Solver.h:159
int ds_DefineConnectivity(SD_MATRIX_DATA *const pMat0, const int &nEq, int Eq[], const int &nEl, const int &Dim)
This function assemble the element connnectivity for one or more elements in order to build a sparse ...
Definition: Solver.cc:1862
int ds_Initialize(const int &MatDim, SD_MATRIX_DATA **ppMat)
This is the first function to be called prior to begin to work with any matrix. The user must gives t...
Definition: Solver.cc:423
SD_MATRIX_WHAT
Definition: Solver.h:175
@ NumericFactorize
Definition: Solver.h:188
@ SymbolicFactorize
Definition: Solver.h:181
@ ResetMatrixData
Definition: Solver.h:205
@ BackForwardSubst
Definition: Solver.h:193
@ ComputeSolution
Definition: Solver.h:199
@ ReleaseMatrixData
Definition: Solver.h:210
int ReleaseConMatrix(SD_CON_MATRIX_DATA *pMat)
Definition: Solver.cc:408
int ds_AssembleMatrix(SD_MATRIX_DATA *pMat0, const int &nEq, int Eq[], const int &Dim, const double *ElMat)
This function assemble the element square matrix [ElMat] for one element with nEq*M x nEq*M real coef...
Definition: Solver.cc:619
int ReleaseBlockMatrix(SD_BLOCK_MATRIX_DATA *pMat)
Release all the data allocated for the numerical factorization algorithm.
Definition: Solver.cc:1849
bool ds_Solve(const SD_MATRIX_WHAT &Code, SD_MATRIX_DATA *pMat, double *pX)
This function calls the solver itself.
Definition: Solver.cc:547
Definition: Solver.h:76
int SizeBlockJump
Definition: Solver.h:84
int * pBlockJump
Definition: Solver.h:85
int * pPerm
Definition: Solver.h:78
double * pUpper
Definition: Solver.h:87
int nRowBlock
Definition: Solver.h:79
int * pSizeColBlock
Definition: Solver.h:83
int nColBlock
Definition: Solver.h:81
int SizeUpper
Definition: Solver.h:86
SD_ROW_BLOCK_DATA * pRowBlock
Definition: Solver.h:80
int Dim
Definition: Solver.h:77
int * pFirstColBlock
Definition: Solver.h:82
The CHUNK_DATA is used to keep track of allocated memory chunks ( block of memory )....
Definition: Solver.h:58
int TotChunkSize
Definition: Solver.h:62
int nChunks
Definition: Solver.h:59
int pChunksSize
Definition: Solver.h:60
char ** pChunks
Definition: Solver.h:61
Definition: Solver.h:117
int Col1
Definition: Solver.h:118
int Col0
Definition: Solver.h:118
struct SD_COL_BLOCK_DATA * Next
Definition: Solver.h:119
Definition: Solver.h:91
struct SD_COL_DATA * Next
Definition: Solver.h:93
int Col
Definition: Solver.h:92
Definition: Solver.h:102
SD_CHUNK_DATA PoolCol
Definition: Solver.h:110
int nRow
Definition: Solver.h:103
int * pPerm
Definition: Solver.h:104
int nFreeCol
Definition: Solver.h:112
SD_ROW_DATA * pRow
Definition: Solver.h:109
int nCol
Definition: Solver.h:113
int * pPermInv
Definition: Solver.h:105
int nSupernode
Definition: Solver.h:106
SD_COL_DATA * FreeCol
Definition: Solver.h:111
int * pSupernode
Definition: Solver.h:107
When the user define a matrix, the software return a pointer to an opaque type i.e....
Definition: Solver.h:162
StateType State
Definition: Solver.h:166
SD_TMP_CON_MATRIX_DATA TmpCon
Definition: Solver.h:169
SD_BLOCK_MATRIX_DATA Block
Definition: Solver.h:170
int nEq
Definition: Solver.h:163
SD_CON_MATRIX_DATA Con
Definition: Solver.h:168
int nDeletedEq
Definition: Solver.h:164
The data structure to store the matrix for numerical factorization is a simple one....
Definition: Solver.h:66
int nColBlock
Definition: Solver.h:70
int nCol
Definition: Solver.h:69
int Row0
Definition: Solver.h:67
int iColBlock
Definition: Solver.h:71
int Row1
Definition: Solver.h:68
int iFloat
Definition: Solver.h:72
Definition: Solver.h:97
SD_COL_DATA * Col
Definition: Solver.h:98
Definition: Solver.h:139
int nRow
Definition: Solver.h:140
int nColBlock
Definition: Solver.h:145
int nRowBlock
Definition: Solver.h:143
int * pPerm
Definition: Solver.h:141
SD_TMP_ROW_BLOCK_DATA * pRowBlock
Definition: Solver.h:144
SD_COL_BLOCK_DATA * FreeColBlock
Definition: Solver.h:147
SD_CHUNK_DATA PoolColBlock
Definition: Solver.h:146
Definition: Solver.h:123
SD_COL_BLOCK_DATA * ColBlock
Definition: Solver.h:134
int Row0
Definition: Solver.h:127
int Row1
Definition: Solver.h:128
SD_ROW_BLOCK_DATA UnusedData
Definition: Solver.h:124