FemProcess
The GeMA Fem Process Plugin
Loading...
Searching...
No Matches
gmpFemVectorSet.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_VECTOR_SET_H_
25#define _GEMA_PLUGIN_FEM_VECTOR_SET_H_
26
27#include "gmpFemProcessConfig.h"
28
29#include <gmVectorSet.h>
30
33{
38
39 //---------------------------------------
40 // No changing below this line
41 //---------------------------------------
42 GmpFemVector_NumTypes
43};
44
49class GMP_FEM_PROCESS_API_EXPORT GmpFemVectorSet : public GmVectorSet
50{
51public:
54
66
67 void clear();
68
69 bool initTypes (GmpFemVectorMode mode, int numVectors, ...);
70 bool adjustSizes(int globalNumDofs, int globalNumFixedDofs, int maxElemDofs);
71
72 void addTransposedDofVector(GmpFemVectorTypes type);
73 void addSavedDofVector (GmpFemVectorTypes type);
74
75 void clearGlobalVectors();
76
84 {
85 assert((_mode == VECTOR_MATCH_MODE && index(type) >= 0) || (_mode != VECTOR_MATCH_MODE && type == GmpFemVector_Eq));
86 return _globalVectors[tindex(type)]._data;
87 }
88
91 {
92 assert(_mode == VECTOR_MATCH_MODE && index >= 0 && index < _nVectors);
93 return _globalVectors[index]._data;
94 }
95
105 {
106 assert((_mode == VECTOR_MATCH_MODE && index(type) >= 0) || (_mode != VECTOR_MATCH_MODE && type == GmpFemVector_Eq));
107 return *(_globalVectors[tindex(type)]._transposed);
108 }
109
115 {
116 assert(_mode == VECTOR_MATCH_MODE && index >= 0 && index < _nVectors);
117 return *(_globalVectors[index]._transposed);
118 }
119
128 {
129 assert((_mode == VECTOR_MATCH_MODE && index(type) >= 0) || (_mode != VECTOR_MATCH_MODE && type == GmpFemVector_Eq));
130 return _globalVectors[tindex(type)]._saved;
131 }
132
138 {
139 assert(_mode == VECTOR_MATCH_MODE && index >= 0 && index < _nVectors);
140 return _globalVectors[index]._saved;
141 }
142
149 {
150 assert(_mode != VECTOR_SINGLE_MODE && index(type) >= 0);
151 return (_mode == VECTOR_MATCH_MODE) ? _globalVectors[index(type)]._data : _printVectors[index(type)];
152 }
153
158 {
159 assert(_mode != VECTOR_SINGLE_MODE && index >= 0 && index < _nVectors);
160 return (_mode == VECTOR_MATCH_MODE) ? _globalVectors[index]._data : _printVectors[index];
161 }
162
164 GmpFemVectorMode mode() const { return _mode; }
165
168
169
170protected:
171
173 int tindex(GmpFemVectorTypes type) const { return (_mode == VECTOR_MATCH_MODE) ? index(type) : 0; }
174
176
179 {
184
186 GmpFemVectorTypeData() { _transposed = &_data; _hasSaved = false; }
187
189 ~GmpFemVectorTypeData() { if(_transposed != &_data) delete _transposed; }
190
192 void zeros()
193 {
194 _data.zeros();
195 _saved.zeros();
196 if(_transposed != &_data)
197 _transposed->zeros();
198 }
199 };
200
206
211};
212
213
214#endif
215
bool initTypes(int numVectors, va_list typeList)
int index(int type) const
bool adjustSizes(int maxNodes)
int typeFromIndex(int index) const
void clear()
A convenience class that builds a GmVectorSet with the types given by GmpFemVectorTypes and also asso...
Definition gmpFemVectorSet.h:50
GmVector & globalDebugPrintVectorFromIndex(int index) const
Returns the auxiliar vector used for storing global vectors matching local ones for debug printing pu...
Definition gmpFemVectorSet.h:157
GmpFemVectorMode _mode
The mode defining how many global vectors are stored.
Definition gmpFemVectorSet.h:175
GmVector & globalDebugPrintVector(GmpFemVectorTypes type) const
Returns the auxiliar vector used for storing global vectors matching local ones for debug printing pu...
Definition gmpFemVectorSet.h:148
GmVector & globalSavedDofVector(GmpFemVectorTypes type) const
Returns the registered vector, identified by its type in the set, for storing saved values for fixed ...
Definition gmpFemVectorSet.h:127
GmpFemVectorTypes femTypeFromIndex(int index) const
Given a vector index, returns its type as a GmpFemVectorTypes. Equivalent to GmVectorSet::typeFromInd...
Definition gmpFemVectorSet.h:167
GmpFemVectorMode mode() const
Returns the mode defining the global vectors stored by the set.
Definition gmpFemVectorSet.h:164
GmVector & globalTransposedDofVectorFromIndex(int index) const
Returns the registered vector, identified by its index in the set, for storing transposed values when...
Definition gmpFemVectorSet.h:114
GmVector & globalTransposedDofVector(GmpFemVectorTypes type) const
Returns the registered vector, identified by its type in the set, for storing transposed values when ...
Definition gmpFemVectorSet.h:104
GmpFemVectorMode
Control mode specifying if the vector set should have one global vector per local vector (MATCH_MODE)...
Definition gmpFemVectorSet.h:61
@ VECTOR_MATCH_MODE
Set stores one global vector per local vector.
Definition gmpFemVectorSet.h:62
@ VECTOR_SINGLE_MODE
Set stores a single "equivalent" global vector.
Definition gmpFemVectorSet.h:63
@ VECTOR_SINGLE_DEBUG_MODE
Set stores an "equivalent" global vector + another vector per local vector for debug purposes.
Definition gmpFemVectorSet.h:64
GmVector & globalVectorFromIndex(int index) const
Returns a global Vector identified by its index in the set. Can NOT be used for "single" or "single d...
Definition gmpFemVectorSet.h:90
GmVector * _printVectors
Vector with debug global vectors associated to element local vectors when _mode equals VECTOR_SINGLE_...
Definition gmpFemVectorSet.h:210
int tindex(GmpFemVectorTypes type) const
Returns the index in _globalVectors for the given type, accounting for the selected vector mode.
Definition gmpFemVectorSet.h:173
GmpFemVectorTypeData * _globalVectors
Vector storing data for global vectors. Will store one data set per included type in the vector set w...
Definition gmpFemVectorSet.h:205
GmVector & globalSavedDofVectorFromIndex(int index) const
Returns the registered vector, identified by its index in the set, for storing saved values for fixed...
Definition gmpFemVectorSet.h:137
GmVector & globalVector(GmpFemVectorTypes type) const
Returns a global Vector identified by its type in the set.
Definition gmpFemVectorSet.h:83
arma::vec GmVector
Declaration of useful configuration definitions for the plugin library.
GmpFemVectorTypes
Predefined names for vectors used in finite element solvers together with control procedures.
Definition gmpFemVectorSet.h:33
@ GmpFemVector_RHS
The right hand side vector in the general equation.
Definition gmpFemVectorSet.h:37
@ GmpFemVector_Fe
The external force vector Fe in the general equation Fi(u, u', u'') = Fe(t) (u' = du/dt)
Definition gmpFemVectorSet.h:35
@ GmpFemVector_Fi
The internal force vector Fi in the general equation Fi(u, u', u'') = Fe(t) (u' = du/dt)
Definition gmpFemVectorSet.h:36
@ GmpFemVector_Eq
The equivalent force vector when merging values into a single global vector.
Definition gmpFemVectorSet.h:34
Aux structure storing the vectors associated with a vector type.
Definition gmpFemVectorSet.h:179
bool _hasSaved
Flag used to distinguish if an empty _saved vector is due to no saved vector or to a 0 fixed dof sett...
Definition gmpFemVectorSet.h:183
GmVector _data
The data vector.
Definition gmpFemVectorSet.h:180
GmVector _saved
The saved fixed dofs vector. Can be empty.
Definition gmpFemVectorSet.h:182
void zeros()
Clears all vectors, filling them with zeros.
Definition gmpFemVectorSet.h:192
~GmpFemVectorTypeData()
Destructor.
Definition gmpFemVectorSet.h:189
GmVector * _transposed
The transposed vector. Either points to _data or to a new vector.
Definition gmpFemVectorSet.h:181
GmpFemVectorTypeData()
Constructor.
Definition gmpFemVectorSet.h:186