FemProcess
The GeMA Fem Process Plugin
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 {
37  //---------------------------------------
38  // No changing bellow this line
39  //---------------------------------------
40  GmpFemVector_NumTypes
41 };
42 
47 class GMP_FEM_PROCESS_API_EXPORT GmpFemVectorSet : public GmVectorSet
48 {
49 public:
51  ~GmpFemVectorSet();
52 
59  {
63  };
64 
65  void clear();
66 
67  bool initTypes (GmpFemVectorMode mode, int numVectors, ...);
68  bool adjustSizes(int globalNumDofs, int globalNumFixedDofs, int maxElemDofs);
69 
70  void addTransposedDofVector(GmpFemVectorTypes type);
71  void addSavedDofVector (GmpFemVectorTypes type);
72 
73  void clearGlobalVectors();
74 
82  {
83  assert((_mode == VECTOR_MATCH_MODE && index(type) >= 0) || (_mode != VECTOR_MATCH_MODE && type == GmpFemVector_Eq));
84  return _globalVectors[tindex(type)]._data;
85  }
86 
88  GmVector& globalVectorFromIndex(int index) const
89  {
90  assert(_mode == VECTOR_MATCH_MODE && index >= 0 && index < _nVectors);
91  return _globalVectors[index]._data;
92  }
93 
103  {
104  assert((_mode == VECTOR_MATCH_MODE && index(type) >= 0) || (_mode != VECTOR_MATCH_MODE && type == GmpFemVector_Eq));
105  return *(_globalVectors[tindex(type)]._transposed);
106  }
107 
113  {
114  assert(_mode == VECTOR_MATCH_MODE && index >= 0 && index < _nVectors);
115  return *(_globalVectors[index]._transposed);
116  }
117 
126  {
127  assert((_mode == VECTOR_MATCH_MODE && index(type) >= 0) || (_mode != VECTOR_MATCH_MODE && type == GmpFemVector_Eq));
128  return _globalVectors[tindex(type)]._saved;
129  }
130 
136  {
137  assert(_mode == VECTOR_MATCH_MODE && index >= 0 && index < _nVectors);
138  return _globalVectors[index]._saved;
139  }
140 
147  {
148  assert(_mode != VECTOR_SINGLE_MODE && index(type) >= 0);
149  return (_mode == VECTOR_MATCH_MODE) ? _globalVectors[index(type)]._data : _printVectors[index(type)];
150  }
151 
156  {
157  assert(_mode != VECTOR_SINGLE_MODE && index >= 0 && index < _nVectors);
158  return (_mode == VECTOR_MATCH_MODE) ? _globalVectors[index]._data : _printVectors[index];
159  }
160 
162  GmpFemVectorMode mode() const { return _mode; }
163 
166 
167 
168 protected:
169 
171  int tindex(GmpFemVectorTypes type) const { return (_mode == VECTOR_MATCH_MODE) ? index(type) : 0; }
172 
174 
177  {
181  bool _hasSaved;
182 
184  GmpFemVectorTypeData() { _transposed = &_data; _hasSaved = false; }
185 
187  ~GmpFemVectorTypeData() { if(_transposed != &_data) delete _transposed; }
188 
190  void zeros()
191  {
192  _data.zeros();
193  _saved.zeros();
194  if(_transposed != &_data)
195  _transposed->zeros();
196  }
197  };
198 
204 
209 };
210 
211 
212 #endif
213 
GmpFemVectorTypes
Predefined names for vectors used in finite element solvers together with control procedures.
Definition: gmpFemVectorSet.h:32
GmVector _saved
The saved fixed dofs vector. Can be empty.
Definition: gmpFemVectorSet.h:180
GmpFemVectorMode
Control mode specifying if the vector set should have one global vector per local vector (MATCH_MODE)...
Definition: gmpFemVectorSet.h:58
GmpFemVectorTypeData()
Constructor.
Definition: gmpFemVectorSet.h:184
GmVector & globalTransposedDofVector(GmpFemVectorTypes type) const
Returns the registered vector, identified by its type in the set, for storing transposed values when ...
Definition: gmpFemVectorSet.h:102
void clear()
int typeFromIndex(int index) const
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:125
Set stores a single "equivalent" global vector.
Definition: gmpFemVectorSet.h:61
The internal force vector Fi in the general equation Fi(u, u', u'') = Fe(t) (u' = du/dt)
Definition: gmpFemVectorSet.h:36
GmVector & globalTransposedDofVectorFromIndex(int index) const
Returns the registered vector, identified by its index in the set, for storing transposed values when...
Definition: gmpFemVectorSet.h:112
GmpFemVectorMode mode() const
Returns the mode defining the global vectors stored by the set.
Definition: gmpFemVectorSet.h:162
A convenience class that builds a GmVectorSet with the types given by GmpFemVectorTypes and also asso...
Definition: gmpFemVectorSet.h:47
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:88
int index(int type) const
GmVector & globalVector(GmpFemVectorTypes type) const
Returns a global Vector identified by its type in the set.
Definition: gmpFemVectorSet.h:81
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:181
GmpFemVectorTypeData * _globalVectors
Vector storing data for global vectors. Will store one data set per included type in the vector set w...
Definition: gmpFemVectorSet.h:203
Set stores one global vector per local vector.
Definition: gmpFemVectorSet.h:60
GmVector & globalDebugPrintVectorFromIndex(int index) const
Returns the auxiliar vector used for storing global vectors matching local ones for debug printing pu...
Definition: gmpFemVectorSet.h:155
void zeros()
Clears all vectors, filling them with zeros.
Definition: gmpFemVectorSet.h:190
GmVector _data
The data vector.
Definition: gmpFemVectorSet.h:178
GmVector * _printVectors
Vector with debug global vectors associated to element local vectors when _mode equals VECTOR_SINGLE_...
Definition: gmpFemVectorSet.h:208
~GmpFemVectorTypeData()
Destructor.
Definition: gmpFemVectorSet.h:187
int tindex(GmpFemVectorTypes type) const
Returns the index in _globalVectors for the given type, accounting for the selected vector mode.
Definition: gmpFemVectorSet.h:171
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:135
Set stores an "equivalent" global vector + another vector per local vector for debug purposes.
Definition: gmpFemVectorSet.h:62
bool initTypes(int numVectors, va_list typeList)
GmVector & globalDebugPrintVector(GmpFemVectorTypes type) const
Returns the auxiliar vector used for storing global vectors matching local ones for debug printing pu...
Definition: gmpFemVectorSet.h:146
GmpFemVectorMode _mode
The mode defining how many global vectors are stored.
Definition: gmpFemVectorSet.h:173
GmpFemVectorTypes femTypeFromIndex(int index) const
Given a vector index, returns its type as a GmpFemVectorTypes. Equivalent to GmVectorSet::typeFromInd...
Definition: gmpFemVectorSet.h:165
The external force vector Fe in the general equation Fi(u, u', u'') = Fe(t) (u' = du/dt)
Definition: gmpFemVectorSet.h:35
arma::vec GmVector
Declaration of usefull configuration definitions for the plugin library.
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:176
GmVector * _transposed
The transposed vector. Either points to _data or to a new vector.
Definition: gmpFemVectorSet.h:179
bool adjustSizes(int maxNodes)