FemProcess
The GeMA Fem Process Plugin
Loading...
Searching...
No Matches
gmpFemMatrixSet.h
Go to the documentation of this file.
1/************************************************************************
2**
3** Copyright (C) 2014 by Carlos Augusto Teixera Mendes
4** All rights reserved.
5**
6** This file is part of the "GeMA" software. It's use should respect
7** the terms in the license agreement that can be found together
8** with this source code.
9** It is provided AS IS, with NO WARRANTY OF ANY KIND,
10** INCLUDING THE WARRANTY OF DESIGN, MERCHANTABILITY AND FITNESS FOR
11** A PARTICULAR PURPOSE.
12**
13************************************************************************/
14
24#ifndef _GEMA_PLUGIN_FEM_MATRIX_SET_H_
25#define _GEMA_PLUGIN_FEM_MATRIX_SET_H_
26
27#include "gmpFemProcessConfig.h"
28#include "gmpFemVectorSet.h"
29
30#include <gmMatrixSet.h>
31#include <gmSolverMatrix.h>
32
33class GmNumSolver;
34class GmSolverMatrix;
35
37
40{
45 // GmpFemMatrix_M, //!< The M matrix in the general equation M u" + C u' + K u = f
46
47 //---------------------------------------
48 // No changing below this line
49 //---------------------------------------
50 GmpFemMatrix_NumTypes
51};
52
53
58class GMP_FEM_PROCESS_API_EXPORT GmpFemMatrixSet : public GmMatrixSet
59{
60public:
63
75
76 void clear();
77
78 bool initTypes (const GmNumSolver* solver, GmpFemMatrixMode mode, int numMatrices, ...);
79 bool adjustSizes(int globalNumDofs, int maxElemDofs, bool sparseLayoutChanged);
80
85 void setNumThreads(int nthreads) { assert(_nthreads >= -1); _nthreads = nthreads; }
86
87 void setTransposedDofVector(GmpFemMatrixTypes type, GmpFemVectorTypes vectorType);
88
89 void clearGlobalMatrices(bool keepSparseLayout);
90
91 bool supportsBatchInsert() const;
92 bool beginBatchInsert(size_t expectedEntries = 0);
93 bool endBatchInsert(bool discardData);
94
95 bool supportsSparseLayouts() const;
96 GmSparseMatrixLayoutBuilder* layoutBuilder() const;
97 bool emptyLayout() const;
98
100 bool supportsParallelAdd() const { return _parallelSupport; }
101
103 bool needsLocking() const { return _needsLock; }
104
112 {
113 assert((_mode == MATRIX_MATCH_MODE && index(type) >= 0) || (_mode != MATRIX_MATCH_MODE && type == GmpFemMatrix_Eq));
114 return _globalMatrices[tindex(type)]._data;
115 }
116
119 {
120 assert(_mode == MATRIX_MATCH_MODE && index >= 0 && index < _nMatrices);
121 return _globalMatrices[index]._data;
122 }
123
135 {
136 assert((_mode == MATRIX_MATCH_MODE && index(type) >= 0) || (_mode != MATRIX_MATCH_MODE && type == GmpFemMatrix_Eq));
137 return _globalMatrices[tindex(type)]._transposed;
138 }
139
147 int transposedDofVectorFromIndex(int index) const
148 {
149 assert(_mode == MATRIX_MATCH_MODE && index >= 0 && index < _nMatrices);
150 return _globalMatrices[index]._transposed;
151 }
152
159 {
160 assert(_mode != MATRIX_SINGLE_MODE && index(type) >= 0);
161 return (_mode == MATRIX_MATCH_MODE) ? _globalMatrices[index(type)]._data : _printMatrices[index(type)];
162 }
163
168 {
169 assert(_mode != MATRIX_SINGLE_MODE && index >= 0 && index < _nMatrices);
170 return (_mode == MATRIX_MATCH_MODE) ? _globalMatrices[index]._data : _printMatrices[index];
171 }
172
174 GmpFemMatrixMode mode() const { return _mode; }
175
178
179
180protected:
181
183 int tindex(GmpFemMatrixTypes type) const { return (_mode == MATRIX_MATCH_MODE) ? index(type) : 0; }
184
188
191
194 {
197
199 GmpFemMatrixTypeData() { _data = NULL; _transposed = -1; }
200
202 ~GmpFemMatrixTypeData() { delete _data; }
203 };
204
210
215};
216
217
218#endif
219
bool initTypes(int numMatrices, va_list typeList)
int typeFromIndex(int index) const
bool adjustSizes(int maxNodes)
void clear()
int index(int type) const
A convenience class that builds a GmMatrixSet with the types given by GmpFemMatrixTypes and also asso...
Definition gmpFemMatrixSet.h:59
int tindex(GmpFemMatrixTypes type) const
Returns the index in _globalMatrices for the given type, accounting for the selected matrix mode.
Definition gmpFemMatrixSet.h:183
bool _parallelSupport
Do solver matrices support parallel assembling ?
Definition gmpFemMatrixSet.h:189
GmpFemMatrixMode _mode
The mode defining how many global matrices are stored.
Definition gmpFemMatrixSet.h:185
int transposedDofVectorFromIndex(int index) const
Returns the registered vector type for storing transposed values when reducing a matrix due to fixed ...
Definition gmpFemMatrixSet.h:147
void setNumThreads(int nthreads)
Sets the number of threads used by sparse matrices in batch/layout operations. Default is the number ...
Definition gmpFemMatrixSet.h:85
int transposedDofVector(GmpFemMatrixTypes type) const
Returns the registered vector type for storing transposed values when reducing a matrix due to fixed ...
Definition gmpFemMatrixSet.h:134
GmSolverMatrix * globalDebugPrintMatrix(GmpFemMatrixTypes type) const
Returns the auxiliar matrix used for storing global matrices matching local ones for debug printing p...
Definition gmpFemMatrixSet.h:158
GmpFemMatrixMode mode() const
Returns the mode defining the global matrices stored by the set.
Definition gmpFemMatrixSet.h:174
GmpFemMatrixTypeData * _globalMatrices
Vector storing data for global matrices. Will store one data set per included type in the matrix set ...
Definition gmpFemMatrixSet.h:209
GmSolverMatrix * globalDebugPrintMatrixFromIndex(int index) const
Returns the auxiliar matrix used for storing global matrices matching local ones for debug printing p...
Definition gmpFemMatrixSet.h:167
GmSolverMatrix ** _printMatrices
Vector with debug global matrices associated to element local matrices when _mode equals MATRIX_SINGL...
Definition gmpFemMatrixSet.h:214
GmSolverMatrix * globalMatrix(GmpFemMatrixTypes type) const
Returns a global matrix identified by its type in the set.
Definition gmpFemMatrixSet.h:111
GmSolverMatrix * globalMatrixFromIndex(int index) const
Returns a global matrix identified by its index in the set. Can NOT be used for "single" or "single d...
Definition gmpFemMatrixSet.h:118
bool supportsParallelAdd() const
Returns true if the solver matrices support parallel assembling (supportedParallelAddMode() !...
Definition gmpFemMatrixSet.h:100
bool _needsLock
Do solver matrices needs external locking for parallel assembling ?
Definition gmpFemMatrixSet.h:190
GmpFemMatrixTypes femTypeFromIndex(int index) const
Given a matrix index, returns its type as a GmpFemMatrixTypes. Equivalent to GmMatrixSet::typeFromInd...
Definition gmpFemMatrixSet.h:177
GmpFemMatrixMode
Control mode specifying if the matrix set should have one global matrix per local matrix (MATCH_MODE)...
Definition gmpFemMatrixSet.h:70
@ MATRIX_SINGLE_MODE
Set stores a single "equivalent" global matrix.
Definition gmpFemMatrixSet.h:72
@ MATRIX_SINGLE_DEBUG_MODE
Set stores an "equivalent" global matrix + another matrix per local matrix for debug purposes.
Definition gmpFemMatrixSet.h:73
@ MATRIX_MATCH_MODE
Set stores one global matrix per local matrix.
Definition gmpFemMatrixSet.h:71
const GmNumSolver * _solver
The solver used to create global matrices.
Definition gmpFemMatrixSet.h:186
bool needsLocking() const
Returns true if the solver matrices needs external locking for parallel assembling (supportedParallel...
Definition gmpFemMatrixSet.h:103
int _nthreads
The configured number of threads that should be used by sparse matrices in batch mode/layout operatio...
Definition gmpFemMatrixSet.h:187
GmpFemMatrixTypes
Predefined names for matrices used in finite element solvers together with control procedures.
Definition gmpFemMatrixSet.h:40
@ GmpFemMatrix_Eq
The equivalent matrix when merging values into a single global matrix.
Definition gmpFemMatrixSet.h:41
@ GmpFemMatrix_C
The C matrix in the general equation M u" + C u' + K u = f (u" = d2u/dt2)
Definition gmpFemMatrixSet.h:43
@ GmpFemMatrix_K
The K matrix in the general equation M u" + C u' + K u = f (u' = du/dt)
Definition gmpFemMatrixSet.h:42
@ GmpFemMatrix_Keq
The Keq matrix is the equivalent stifness matrix (left hand side matrix)
Definition gmpFemMatrixSet.h:44
Declaration of useful configuration definitions for the plugin library.
Declaration of the GmpFemVectorSet class.
GmpFemVectorTypes
Predefined names for vectors used in finite element solvers together with control procedures.
Definition gmpFemVectorSet.h:33
Aux structure storing the matrix associated with a matrix type.
Definition gmpFemMatrixSet.h:194
~GmpFemMatrixTypeData()
Destructor.
Definition gmpFemMatrixSet.h:202
GmSolverMatrix * _data
The data matrix.
Definition gmpFemMatrixSet.h:195
GmpFemMatrixTypeData()
Constructor.
Definition gmpFemMatrixSet.h:199
int _transposed
The type of the associated transposed dofs vector or -1 if no vector was associated with this type.
Definition gmpFemMatrixSet.h:196