SNOWPACK 20251207.15ac3588
Physically based, energy balance snow cover model
Loading...
Searching...
No Matches
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
89
90typedef struct SD_COL_DATA
91{
92 int Col;
95
96typedef struct SD_ROW_DATA
97{
100
115
121
122typedef union
123{
125 struct
126 {
127 int Row0;
128 int Row1;
129 } Any;
130 struct
131 {
132 int Row0;
133 int Row1;
134 SD_COL_BLOCK_DATA *ColBlock;
135 } Data;
137
149
160
161typedef struct
162{
163 int nEq;
165
167 union
168 { SD_CON_MATRIX_DATA Con;
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
SD_CHUNK_DATA PoolCol
Definition Solver.h:110
struct SD_COL_DATA * Next
Definition Solver.h:93
int nRow
Definition Solver.h:140
int SizeBlockJump
Definition Solver.h:84
int nColBlock
Definition Solver.h:145
int * pBlockJump
Definition Solver.h:85
StateType State
Definition Solver.h:166
StateType
Definition Solver.h:159
@ BlockMatrix
Definition Solver.h:159
@ ConMatrix
Definition Solver.h:159
@ BlockConMatrix
Definition Solver.h:159
int Col1
Definition Solver.h:118
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:1861
int nRow
Definition Solver.h:103
int TotChunkSize
Definition Solver.h:62
int nColBlock
Definition Solver.h:70
int nRowBlock
Definition Solver.h:143
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:422
int nChunks
Definition Solver.h:59
int * pPerm
Definition Solver.h:78
double * pUpper
Definition Solver.h:87
int * pPerm
Definition Solver.h:141
int nCol
Definition Solver.h:69
int nRowBlock
Definition Solver.h:79
int * pSizeColBlock
Definition Solver.h:83
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 * pPerm
Definition Solver.h:104
int nColBlock
Definition Solver.h:81
int SizeUpper
Definition Solver.h:86
int nEq
Definition Solver.h:163
int Col0
Definition Solver.h:118
int ReleaseConMatrix(SD_CON_MATRIX_DATA *pMat)
Definition Solver.cc:407
SD_TMP_ROW_BLOCK_DATA * pRowBlock
Definition Solver.h:144
int Row0
Definition Solver.h:67
SD_COL_BLOCK_DATA * FreeColBlock
Definition Solver.h:147
SD_ROW_BLOCK_DATA * pRowBlock
Definition Solver.h:80
int iColBlock
Definition Solver.h:71
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:618
int nFreeCol
Definition Solver.h:112
int Dim
Definition Solver.h:77
int Col
Definition Solver.h:92
int ReleaseBlockMatrix(SD_BLOCK_MATRIX_DATA *pMat)
Release all the data allocated for the numerical factorization algorithm.
Definition Solver.cc:1848
int Row1
Definition Solver.h:68
SD_CHUNK_DATA PoolColBlock
Definition Solver.h:146
SD_COL_DATA * Col
Definition Solver.h:98
int nDeletedEq
Definition Solver.h:164
struct SD_COL_BLOCK_DATA * Next
Definition Solver.h:119
SD_ROW_DATA * pRow
Definition Solver.h:109
int nCol
Definition Solver.h:113
int * pPermInv
Definition Solver.h:105
bool ds_Solve(const SD_MATRIX_WHAT &Code, SD_MATRIX_DATA *pMat, double *pX)
This function calls the solver itself.
Definition Solver.cc:546
SD_ROW_BLOCK_DATA UnusedData
Definition Solver.h:124
int pChunksSize
Definition Solver.h:60
int nSupernode
Definition Solver.h:106
int iFloat
Definition Solver.h:72
char ** pChunks
Definition Solver.h:61
SD_COL_DATA * FreeCol
Definition Solver.h:111
int * pFirstColBlock
Definition Solver.h:82
int * pSupernode
Definition Solver.h:107
Definition Solver.h:76
The CHUNK_DATA is used to keep track of allocated memory chunks ( block of memory )....
Definition Solver.h:58
Definition Solver.h:117
Definition Solver.h:91
Definition Solver.h:102
When the user define a matrix, the software return a pointer to an opaque type i.e....
Definition Solver.h:162
The data structure to store the matrix for numerical factorization is a simple one....
Definition Solver.h:66
Definition Solver.h:97
Definition Solver.h:139
Definition Solver.h:123