GemaCoreLib
The GeMA Core library
gmBoundaryConditionAccessor.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_BOUNDARYCONDITION_ACCESSOR_H_
25 #define _GEMA_BOUNDARYCONDITION_ACCESSOR_H_
26 
27 #include "gmAccessorProxy.h"
28 #include "gmValueSetEvalContext.h"
29 
30 #include "gmBoundaryCondition.h"
31 
32 #include <assert.h>
33 
34 
39 {
40 public:
42 
43  bool setValue (int bcIndex, const double* value) { return _ac->setValue(bcIndex, value); }
44  bool setScalarValue (int bcIndex, double value) { return _ac->setScalarValue(bcIndex, value); }
45  bool setScalarValueAtDim(int bcIndex, int dim, double value) { return _ac->setScalarValueAtDim(bcIndex, dim, value); }
46  bool setValueAsDef (int bcIndex) { return _ac->setValueAsDef(bcIndex); }
47  bool setFunctionValue (int bcIndex, GmUserFunction* functionDef) { return _ac->setFunctionValue(bcIndex, functionDef); }
48  bool setFunctionValue (int bcIndex, GmUserFunctionEvaluator* functionEval) { return _ac->setFunctionValue(bcIndex, functionEval); }
49  bool setFunctionFromName(int bcIndex, QString userFunctionId, QString& err) { return _ac->setFunctionFromName(bcIndex, userFunctionId, err); }
50 
51  bool setValueFromVariant(int bcIndex, const QVariant& v, bool acceptMissingDimension, QString& err)
52  {
53  return _ac->setValueFromVariant(bcIndex, v, acceptMissingDimension, err);
54  }
55 
56  bool isDefValue(int bcIndex) const { return _ac->isDefValue(bcIndex); }
57  bool isFunction(int bcIndex) const { return _ac->isFunction(bcIndex); }
58  QString functionId(int bcIndex) const { return _ac->functionId(bcIndex); }
59 
60 protected:
62  void saveDataInContext(int dataIndex) const
63  {
64  GmValueSetEvalContext* context = _ac->evalContext();
65  if(context)
66  context->setDataIndex(dataIndex);
67  }
68 };
69 
74 {
75 public:
78  {
79  assert(bc);
80  _bc = bc;
81  }
82 
83  // Wrapped functions. For descriptions, see GmValueAccessor documentation
84  const double* valueAt(int bcIndex, int listIndex, const GmVector* coord) const
85  {
86  saveDataInContext(dataIndex(bcIndex, listIndex));
87  return _ac->valueAt(bcIndex, coord);
88  }
89 
90  const double* value(int bcIndex, int listIndex) const { return valueAt(bcIndex, listIndex, NULL); }
91 
92  double scalarValueAt(int bcIndex, int listIndex, const GmVector* coord) const
93  {
94  saveDataInContext(dataIndex(bcIndex, listIndex));
95  return _ac->scalarValueAt(bcIndex, coord);
96  }
97 
98  double scalarValue(int bcIndex, int listIndex) const { return scalarValueAt(bcIndex, listIndex, NULL); }
99 
100  void matrixValueAt(int bcIndex, int listIndex, const GmVector* coord, GmCRMatrix& mat) const
101  {
102  saveDataInContext(dataIndex(bcIndex, listIndex));
103  _ac->matrixValueAt(bcIndex, coord, mat);
104  }
105 
106  void matrixValue(int bcIndex, int listIndex, GmCRMatrix& mat) const { matrixValueAt(bcIndex, listIndex, NULL, mat); }
107 
108  void vectorValueAt(int bcIndex, int listIndex, const GmVector* coord, GmCRVector& vec) const
109  {
110  saveDataInContext(dataIndex(bcIndex, listIndex));
111  _ac->vectorValueAt(bcIndex, coord, vec);
112  }
113 
114  void vectorValue(int bcIndex, int listIndex, GmCRVector& vec) const { vectorValueAt(bcIndex, listIndex, NULL, vec); }
115 
116  QString valueStr(int bcIndex, int listIndex, bool evalFunctions, bool printDefAsNil,
117  int fieldWidth = 0, char format = 'g', int precision = -1, const GmVector* coord = NULL) const
118  {
119  saveDataInContext(dataIndex(bcIndex, listIndex));
120  return _ac->valueStr(bcIndex, evalFunctions, printDefAsNil, fieldWidth, format, precision, coord);
121  }
122 
123 protected:
124  int dataIndex(int bcIndex, int listIndex) const { return _bc->appPointIndex(bcIndex, listIndex); }
125 
126 private:
128 };
129 
130 #endif
131 
A helper class with common code between GmBoundaryConditionAccessor and GmContactBoundaryConditionAcc...
Definition: gmBoundaryConditionAccessor.h:38
void saveDataInContext(int dataIndex) const
A function that given a node / cell index, saves it in the context.
Definition: gmBoundaryConditionAccessor.h:62
Class responsible for evaluating a UserFunction over a node / cell.
Definition: gmUserFunction.h:148
void setDataIndex(int dataIndex)
Saves the node / cell over which values will be calculated. Ghost indices should be linear indices.
Definition: gmValueSetEvalContext.h:81
A class used to represent a set of boundary conditions of the same type, tied to the same mesh.
Definition: gmBoundaryCondition.h:262
Interface class for accessing and setting values from an "indexable" collection of values.
Definition: gmValueAccessor.h:59
The GmBoundaryConditionAccessor class is a proxy object to a value accesor implementing a more conven...
Definition: gmBoundaryConditionAccessor.h:73
Declaration of the GmBoundaryCondition class.
GmAccessorProxy(GmValueAccessor *ac)
Constructor. Takes ownership of the accessor.
Definition: gmAccessorProxy.h:42
GmBoundaryConditionAccessor(GmValueAccessor *ac, const GmBoundaryCondition *bc)
Constructor. Takes ownership of the accessor.
Definition: gmBoundaryConditionAccessor.h:77
Declaration of the GmValueSetEvalContext class.
#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
Auxiliar class used to store the needed information to translate an user function id / user function ...
Definition: gmValueSetEvalContext.h:45
arma::vec GmVector
The basic type for a GeMA vector object. Currently based on an Armadillo vector.
Definition: gmVector.h:34
const GmBoundaryCondition * _bc
The boundary condition that owns the value accessor used to translate indices.
Definition: gmBoundaryConditionAccessor.h:127
An auxiliary matrix WRAPPER that binds the matrix to a CONST memory area with data already inicialize...
Definition: gmMatrix.h:100
Class used to store the definition of a user function and its parameters.
Definition: gmUserFunction.h:78
Implementation of the GmAccessorProxy class Moved from gmCellAccessor.h.
Helper class with common code for several classes that wrap a value accessor, provinding a slitly dif...
Definition: gmAccessorProxy.h:38