GemaCoreLib
The GeMA Core library
gmPhysics.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_PHYSICS_H_
25 #define _GEMA_PHYSICS_H_
26 
27 #include "gmPluginObject.h"
28 #include "gmPluginCategory.h"
29 #include "gmUserFunction.h"
30 
31 class GmCellMesh;
32 class GmCellAccessor;
37 class GmDiscontinuitySet;
39 
42 {
43 public:
44  GmPhysics(GmSimulationData* simulation, QString id, QString description, const GmLogCategory& logger);
45  virtual ~GmPhysics();
46 
47  // Comments on the base class
48  virtual const char* pluginCategory() const { return GM_PLUGIN_PHYSICS; }
49 
50  virtual void printParameters(const GmLogCategory& logger);
51 
72  GmCellAccessor* propertyAccessor(GmCellMesh* mesh, QString stdPropertyName, QString msgDescription,
73  LuaTable& table, Unit desiredUnit, bool required,
74  int type = -1, int nlin = -1, int ncol = -1,
75  bool canBeFunction = true, bool ignoreWarnings = false)
76  {
77  return propertyAccessorAux(mesh, stdPropertyName, msgDescription, table, desiredUnit, false,
78  required, type, nlin, ncol, canBeFunction, ignoreWarnings);
79  }
80 
82  GmCellAccessor* extPropertyAccessor(GmCellMesh* mesh, QString stdPropertyName, QString msgDescription,
83  LuaTable& table, Unit desiredUnit, bool required,
84  int type = -1, int nlin = -1, int ncol = -1,
85  bool canBeFunction = true, bool ignoreWarnings = false)
86  {
87  return propertyAccessorAux(mesh, stdPropertyName, msgDescription, table, desiredUnit, true,
88  required, type, nlin, ncol, canBeFunction, ignoreWarnings);
89  }
90 
93  QString msgDescription, LuaTable& table, Unit desiredUnit,
94  bool required, int type = -1, int nlin = -1, int ncol = -1,
95  bool ignoreWarnings = false)
96  {
97  return discontinuityPropertyAccessorAux(discSet, stdPropertyName, msgDescription, table, desiredUnit,
98  false, required, type, nlin, ncol, ignoreWarnings);
99  }
100 
103  QString msgDescription, LuaTable& table, Unit desiredUnit,
104  bool required, int type = -1, int nlin = -1, int ncol = -1,
105  bool ignoreWarnings = false)
106  {
107  return discontinuityPropertyAccessorAux(discSet, stdPropertyName, msgDescription, table, desiredUnit,
108  true, required, type, nlin, ncol, ignoreWarnings);
109  }
110 
111 protected:
112 
113  GmCellAccessor* elementAttributeAccessor(GmCellMesh* mesh, QString stdAttributeName, QString msgDescription,
114  LuaTable& table, Unit desiredUnit, bool required, int type = -1,
115  int nlin = -1, int ncol = -1, int history = -1, bool canBeFunction = true,
116  bool create = false, QString createFormat = "", int createHistory = -1,
117  bool ignoreWarnings = false);
118 
119  GmValueAccessor* nodeAttributeAccessor(GmCellMesh* mesh, QString stdAttributeName, QString msgDescription,
120  LuaTable& table, Unit desiredUnit, bool required, int type = -1,
121  int nlin = -1, int ncol = -1, int history = -1, bool canBeFunction = true,
122  bool create = false, QString createFormat = "", int createHistory = -1,
123  bool ignoreWarnings = false);
124 
125  GmValueAccessor* nodeDataAccessor(GmCellMesh* mesh, QString stdAttributeName, QString msgDescription,
126  LuaTable& table, Unit desiredUnit, bool required, int type = -1,
127  int nlin = -1, int ncol = -1, int history = -1, bool canBeFunction = true,
128  bool ignoreWarnings = false);
129 
130  GmBoundaryConditionAccessor* boundaryAccessor(const GmBoundaryCondition* bc, QString stdPropertyName, QString msgDescription,
131  Unit desiredUnit, bool required, int type = -1,
132  int nlin = -1, int ncol = -1, bool canBeFunction = true, bool ignoreWarnings = false);
133 
134  GmContactBoundaryConditionAccessor* contactAccessor(const GmContactBoundaryCondition* bc, QString stdPropertyName, QString msgDescription,
135  Unit desiredUnit, bool required, int type = -1,
136  int nlin = -1, int ncol = -1, bool canBeFunction = true, bool ignoreWarnings = false);
137 
138  QString dofFromStateVar(const GmCellMesh* mesh, QString stdStateVarName, QString msgDescription,
139  LuaTable& table, QList<int>& dofList, Unit resultUnit, bool required,
140  int type = -1, int nlin = -1, int ncol = -1, bool ignoreWarnings = false);
141 
142 private:
143  GmCellAccessor* propertyAccessorAux(GmCellMesh* mesh, QString stdPropertyName, QString msgDescription,
144  LuaTable& table, Unit desiredUnit, bool acceptsElementAttributes,
145  bool required, int type, int nlin, int ncol, bool canBeFunction,
146  bool ignoreWarnings);
147 
148  GmDiscontinuityAccessor* discontinuityPropertyAccessorAux(GmDiscontinuitySet* discSet, QString stdPropertyName,
149  QString msgDescription, LuaTable& table, Unit desiredUnit,
150  bool acceptsElementAttributes, bool required,
151  int type, int nlin, int ncol, bool ignoreWarnings);
152 };
153 
154 
159 {
160 public:
161  GmPhysicsUserFunctions(GmSimulationData* simulation, QString id, QString description, const GmLogCategory& logger);
162  virtual ~GmPhysicsUserFunctions();
163 
164  // Comments on the base class
165  virtual const char* pluginCategory() const { return GM_PLUGIN_PHYSICS; }
166 
167  // Comments on the base class
168  virtual const char* pluginType() const { return "userFunctions"; }
169 
170  virtual bool loadPrivateData(LuaTable& table);
171  virtual void printParameters(const GmLogCategory& logger);
172 
174  void setMesh(const GmMesh* mesh) { _mesh = mesh; }
175 
177  virtual QStringList functionList() const = 0;
178 
180  virtual GmCUserMethod function(QString funcName) const = 0;
181 
182 protected:
184  const GmMesh* mesh() const { return _mesh; }
185 
186 private:
187  const GmMesh* _mesh;
188 };
189 
190 
191 #endif
192 
A class used to represent a set of contact boundary conditions of the same type, tied to the same mes...
Definition: gmContactBoundaryCondition.h:32
GmDiscontinuityAccessor * discontinuityPropertyAccessor(GmDiscontinuitySet *discSet, QString stdPropertyName, QString msgDescription, LuaTable &table, Unit desiredUnit, bool required, int type=-1, int nlin=-1, int ncol=-1, bool ignoreWarnings=false)
Simmilar to propertyAccessor() but looking for properties in a discontinuity set.
Definition: gmPhysics.h:92
virtual bool loadPrivateData(LuaTable &table)=0
Function called by the model loader to give the object acess to it's private parameters....
Declaration of the GmUserFunction and GmUserFunctionEvaluator classes.
Declaration of the GmPluginObject base class.
bool(GmPhysicsUserFunctions::* GmCUserMethod)(const GmUserFunctionContext *context, double *out)
A pointer to a C function exported from a physics plugin to evaluate the value of some attribute / pr...
Definition: gmUserFunction.h:75
GmCellAccessor * propertyAccessor(GmCellMesh *mesh, QString stdPropertyName, QString msgDescription, LuaTable &table, Unit desiredUnit, bool required, int type=-1, int nlin=-1, int ncol=-1, bool canBeFunction=true, bool ignoreWarnings=false)
An auxilliary function that given a property name, retrieves the accessor for that property.
Definition: gmPhysics.h:72
A class used to represent a set of boundary conditions of the same type, tied to the same mesh.
Definition: gmBoundaryCondition.h:262
virtual const char * pluginCategory() const
Returns the plugin category.
Definition: gmPhysics.h:165
Interface class for accessing and setting values from an "indexable" collection of values.
Definition: gmValueAccessor.h:59
const GmMesh * _mesh
The mesh that this object is bound to.
Definition: gmPhysics.h:187
Auxiliar class used to store the complete set of simulation data.
Definition: gmSimulationData.h:51
Base interface class for Physics type plugins to export user functions that can be used to provide at...
Definition: gmPhysics.h:158
The GmBoundaryConditionAccessor class is a proxy object to a value accesor implementing a more conven...
Definition: gmBoundaryConditionAccessor.h:73
Base interface class for Physics type plugins.
Definition: gmPhysics.h:41
virtual void printParameters(const GmLogCategory &logger)=0
Asks the object to print all of its parameters using the provided logger.
Definition: gmPluginObject.cpp:62
The GmCellAccessor class is a proxy object to a value accesor implementing a more convenient interfac...
Definition: gmCellAccessor.h:66
Base interface class for CellMesh type plugins.
Definition: gmCellMesh.h:39
GmDiscontinuityAccessor * extDiscontinuityPropertyAccessor(GmDiscontinuitySet *discSet, QString stdPropertyName, QString msgDescription, LuaTable &table, Unit desiredUnit, bool required, int type=-1, int nlin=-1, int ncol=-1, bool ignoreWarnings=false)
Simmilar to extPropertyAccessor() but looking for properties/attributes in a discontinuity set.
Definition: gmPhysics.h:102
Declaration of macros for standard plugin categories.
void setMesh(const GmMesh *mesh)
Sets the mesh that this object is bound to.
Definition: gmPhysics.h:174
Base interface class for all object plugins.
Definition: gmPluginObject.h:36
#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
The GmContactBoundaryConditionAccessor class is a proxy object to a value accesor implementing a more...
Definition: gmContactBoundaryConditionAccessor.h:34
Class representing a category with multiple logging levels.
Definition: gmLog.h:58
The GmDiscontinuityAccessor class is a proxy object to a value accesor implementing a more convenient...
Definition: gmDiscontinuityAccessor.h:47
virtual const char * pluginType() const
Returns the string identifying the plugin object type. Should return the SAME string as the one read ...
Definition: gmPhysics.h:168
const GmMesh * mesh() const
Returns the mesh that this object is bound to.
Definition: gmPhysics.h:184
Base interface for providing discontinuity geometry information for spatial indices.
Definition: gmDiscontinuitySet.h:48
#define GM_PLUGIN_PHYSICS
Plugin implements physical methods.
Definition: gmPluginCategory.h:29
virtual const char * pluginCategory() const
Returns the plugin category.
Definition: gmPhysics.h:48
Base interface class for Mesh type plugins.
Definition: gmMesh.h:44
GmCellAccessor * extPropertyAccessor(GmCellMesh *mesh, QString stdPropertyName, QString msgDescription, LuaTable &table, Unit desiredUnit, bool required, int type=-1, int nlin=-1, int ncol=-1, bool canBeFunction=true, bool ignoreWarnings=false)
Simmilar to propertyAccessor() but also looking for the requested property name in the set of element...
Definition: gmPhysics.h:82