GemaCoreLib
The GeMA Core library
Loading...
Searching...
No Matches
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{
40public:
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
107 const GmMeshGaussIndex* gaussIndex() const { return _gvs->gaussIndex(); }
108
109protected:
110 int queryIndex(const GmCell* c, int ip) const
111 {
112 assert(ip >= 0 && ip < numPoints(c));
113 return _gvs->pointIndex(c->cellId(), ip);
114 }
115
116protected:
118};
119
120#endif
121
An auxiliary matrix WRAPPER that binds the matrix to a CONST memory area with data already inicialize...
Definition gmMatrix.h:102
An auxiliary vector WRAPPER that binds the vector to a CONST memory area with data already initialize...
Definition gmVector.h:72
An accessor proxy + method for saving a cell in the context.
Definition gmCellAccessor.h:37
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
Base interface for mesh cells.
Definition gmCell.h:88
virtual int cellId() const =0
Returns a number identifying the cell. It should be possible to use this id as an index to GmCellMesh...
The GmGaussAccessor class is a proxy object to a value accessor implementing a more convenient interf...
Definition gmGaussAccessor.h:39
const GmGaussValueSet * _gvs
The value set that owns the value accessor used to translate indices.
Definition gmGaussAccessor.h:117
const GmMeshGaussIndex * gaussIndex() const
Returns the associated Gauss index object.
Definition gmGaussAccessor.h:107
virtual int numPoints(const GmCell *c) const
Returns the number of Gauss / integration points for the given cell.
Definition gmGaussAccessor.h:49
GmGaussAccessor(GmValueAccessor *ac, const GmGaussValueSet *gvs)
Constructor. Takes ownership of the accessor.
Definition gmGaussAccessor.h:42
Inheriting from GmValueSet, this class adds the peculiarities needed for saving values in Gauss point...
Definition gmGaussValueSet.h:35
A Gauss index interface always indexing ALL the elements of a mesh, with support for mesh growing.
Definition gmGaussIndex.h:275
Class responsible for evaluating a UserFunction over a node / cell.
Definition gmUserFunction.h:160
Class used to store the definition of a user function and its parameters.
Definition gmUserFunction.h:82
Interface class for accessing and setting values from an "indexable" collection of values.
Definition gmValueAccessor.h:60
Implementation of the GmCellAccessor proxy class.
#define GMC_API_EXPORT
Macro for controlling if the class is being exported (GEMA_CORE_LIB defined) or imported (GEMA_CORE_L...
Definition gmCoreConfig.h:35
Implementation of the GmElement class.
Declaration of the GmGaussValueSet class.
arma::mat GmMatrix
The basic type for a GeMA matrix object. Currently based on an Armadillo matrix.
Definition gmMatrix.h:38
arma::vec GmVector
The basic type for a GeMA vector object. Currently based on an Armadillo vector.
Definition gmVector.h:34