GemaCoreLib
The GeMA Core library
gmGaussAccessor.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_GAUSS_ACCESSOR_H_
25 #define _GEMA_GAUSS_ACCESSOR_H_
26 
27 #include "gmCellAccessor.h"
28 
29 #include "gmElement.h"
30 #include "gmGaussValueSet.h"
31 
32 #include <assert.h>
33 
34 
39 {
40 public:
43  {
44  assert(gvs);
45  _gvs = gvs;
46  }
47 
49  virtual int numPoints(const GmCell* c) const { return _gvs->numPoints(c->cellId()); }
50 
51  // Wrapped functions. For descriptions, see GmValueAccessor documentation
52  virtual const double* valueAt(const GmCell* c, int ip, const GmVector* coord) const
53  {
54  saveCellInContext(c, ip);
55  return _ac->valueAt(queryIndex(c, ip), coord);
56  }
57 
58  virtual double scalarValueAt(const GmCell* c, int ip, const GmVector* coord) const
59  {
60  saveCellInContext(c, ip);
61  return _ac->scalarValueAt(queryIndex(c, ip), coord);
62  }
63 
64  virtual void matrixValueAt(const GmCell* c, int ip, const GmVector* coord, GmCRMatrix& mat) const
65  {
66  saveCellInContext(c, ip);
67  _ac->matrixValueAt(queryIndex(c, ip), coord, mat);
68  }
69 
70  virtual void vectorValueAt(const GmCell* c, int ip, const GmVector* coord, GmCRVector& vec) const
71  {
72  saveCellInContext(c, ip);
73  _ac->vectorValueAt(queryIndex(c, ip), coord, vec);
74  }
75 
76  virtual bool setValue (const GmCell* c, int ip, const double* value) { return _ac->setValue(queryIndex(c, ip), value); }
77  virtual bool setScalarValue (const GmCell* c, int ip, double value) { return _ac->setScalarValue(queryIndex(c, ip), value); }
78  virtual bool setScalarValueAtDim(const GmCell* c, int ip, int dim, double value) { return _ac->setScalarValueAtDim(queryIndex(c, ip), dim, value); }
79  virtual bool setValueAsDef (const GmCell* c, int ip) { return _ac->setValueAsDef(queryIndex(c, ip)); }
80  virtual bool setVectorValue (const GmCell* c, int ip, const GmVector& vec) { return _ac->setVectorValue(queryIndex(c, ip), vec); }
81  virtual bool setMatrixValue (const GmCell* c, int ip, const GmMatrix& mat) { return _ac->setMatrixValue(queryIndex(c, ip), mat); }
82  virtual bool setFunctionValue (const GmCell* c, int ip, GmUserFunction* functionDef) { return _ac->setFunctionValue(queryIndex(c, ip), functionDef); }
83  virtual bool setFunctionValue (const GmCell* c, int ip, GmUserFunctionEvaluator* functionEval) { return _ac->setFunctionValue(queryIndex(c, ip), functionEval); }
84 
85  virtual QString valueStr(const GmCell* c, int ip, bool evalFunctions, bool printDefAsNil,
86  int fieldWidth = 0, char format = 'g', int precision = -1, const GmVector* coord = NULL) const
87  {
88  saveCellInContext(c, ip);
89  return _ac->valueStr(queryIndex(c, ip), evalFunctions, printDefAsNil, fieldWidth, format, precision, coord);
90  }
91 
92  virtual bool setFunctionFromName(const GmCell* c, int ip, QString userFunctionId, QString& err)
93  {
94  return _ac->setFunctionFromName(queryIndex(c, ip), userFunctionId, err);
95  }
96 
97  virtual bool setValueFromVariant(const GmCell* c, int ip, const QVariant& v, bool acceptMissingDimension, QString& err)
98  {
99  return _ac->setValueFromVariant(queryIndex(c, ip), v, acceptMissingDimension, err);
100  }
101 
102  virtual bool isDefValue(const GmCell* c, int ip) const { return _ac->isDefValue(queryIndex(c, ip)); }
103  virtual bool isFunction(const GmCell* c, int ip) const { return _ac->isFunction(queryIndex(c, ip)); }
104  virtual QString functionId(const GmCell* c, int ip) const { return _ac->functionId(queryIndex(c, ip)); }
105 
106 protected:
107  int queryIndex(const GmCell* c, int ip) const
108  {
109  assert(ip >= 0 && ip < numPoints(c));
110  return _gvs->pointIndex(c->cellId(), ip);
111  }
112 
113 protected:
115 };
116 
117 #endif
118 
Implementation of the GmCellAccessor proxy class.
GmGaussAccessor(GmValueAccessor *ac, const GmGaussValueSet *gvs)
Constructor. Takes ownership of the accessor.
Definition: gmGaussAccessor.h:42
Class responsible for evaluating a UserFunction over a node / cell.
Definition: gmUserFunction.h:148
The GmGaussAccessor class is a proxy object to a value accesor implementing a more convenient interfa...
Definition: gmGaussAccessor.h:38
Base interface for mesh cells.
Definition: gmCell.h:81
Declaration of the GmGaussValueSet class.
Inheriting from GmValueSet, this class adds the peculiarities needed for saving values in Gauss point...
Definition: gmGaussValueSet.h:34
Interface class for accessing and setting values from an "indexable" collection of values.
Definition: gmValueAccessor.h:59
virtual int cellId() const =0
Returns a number identifying the cell. It should be possible to use this id as an index to GmCellMesh...
void saveCellInContext(const GmCell *c, int ip) const
A function that given a cell, saves it in the context. The ip parameter should store the integration ...
Definition: gmCellAccessor.h:50
virtual int numPoints(const GmCell *c) const
Returns the number of Gauss / integration points for the given cell.
Definition: gmGaussAccessor.h:49
#define GMC_API_EXPORT
Macro for controling if the class is being exported (GEMA_CORE_LIB defined) or imported (GEMA_CORE_LI...
Definition: gmCoreConfig.h:35
An auxiliary vector WRAPPER that binds the vector to a CONST memory area with data already initialize...
Definition: gmVector.h:69
Implementation of the GmElement class.
arma::vec GmVector
The basic type for a GeMA vector object. Currently based on an Armadillo vector.
Definition: gmVector.h:34
An auxiliary matrix WRAPPER that binds the matrix to a CONST memory area with data already inicialize...
Definition: gmMatrix.h:100
arma::mat GmMatrix
The basic type for a GeMA matrix object. Currently based on an Armadillo matrix.
Definition: gmMatrix.h:38
Class used to store the definition of a user function and its parameters.
Definition: gmUserFunction.h:78
const GmGaussValueSet * _gvs
The value set that owns the value accessor used to translate indices.
Definition: gmGaussAccessor.h:114
An accessor proxy + method for saving a cell in the context.
Definition: gmCellAccessor.h:36