FemProcess
The GeMA Fem Process Plugin
gmpFemPhysicsCommonMaterial.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_PHYSICS_COMMON_MATERIAL_H_
25 #define _GEMA_PLUGIN_FEM_PHYSICS_COMMON_MATERIAL_H_
26 
27 #include "gmpFemProcessConfig.h"
28 
29 #include <gmVector.h>
30 #include <QVariant>
31 #include <QVector>
32 #include <QMap>
33 #include <QPair>
34 #include <GmStateDump.h>
35 
36 class GmCellAccessor;
37 class GmValueAccessor;
38 class GmGaussAccessor;
39 class GmElement;
40 class GmElementMesh;
41 
42 
44 class GMP_FEM_PROCESS_API_EXPORT GmpFemPhysicsCommonMaterial
45 {
46 public:
50  GmpFemPhysicsCommonMaterial(int typeIndex, QString typeName, const GmLogCategory& logger)
51  :_logger(logger)
52  {
53  _typeIndex = typeIndex;
54  _typeName = typeName;
55  }
56 
57  virtual ~GmpFemPhysicsCommonMaterial();
58 
60  int typeIndex() const { return _typeIndex; }
61 
63  QString typeName() const { return _typeName; }
64 
66  const GmLogCategory& logger() const { return _logger; }
67 
81  virtual const QVariantMap* materialMetaDataMap() = 0;
82 
84  virtual bool vectorPropertyValue(const GmElement* e, GmCellAccessor* propAcc, GmVector& data, const GmVector* coord, int ip) const;
85 
93  virtual bool checkLoadedData(const GmElement* e) const
94  {
95  assert(e); Q_UNUSED(e);
96  return true;
97  }
98 
99  virtual bool addStateItemsToGroup(GmStateDump* state, GmElementMesh* mesh, bool fixedHint, int groupId);
100 
101 
103  GmValueAccessor* nodeAc() const { return _nodeAccessor; }
104 
106  int nodeDim() const { return _nodeDim; }
107 
109  GmCellAccessor* propertyAc(int id) const { return _propertyAccessors.at(id); }
110 
114  bool constantProperty(int id) const { return _constantProperties.at(id); }
115 
117  GmValueAccessor* nodeAttrAc(int id) const { return _nodeAttrAccessors.at(id); }
118 
120  GmGaussAccessor* gaussAttrAc(int id) const { return _gaussAttrAccessors.at(id); }
121 
122 protected:
123  friend class GmpFemPhysicsCommon; // Accessors are filled by the physics
124 
126  int _nodeDim;
129 
136 };
137 
145 class GMP_FEM_PROCESS_API_EXPORT GmpFemPhysicsCommonMaterialFactory
146 {
147 public:
149  typedef GmpFemPhysicsCommonMaterial* (*MaterialObjCreator)(GmSimulationData* simulation, int typeIndex, QString typeName, const GmLogCategory& logger);
150 
151  void registerMaterial(int typeIndex, QString typeName, MaterialObjCreator instanceFunction, bool defaultMaterial = false);
152 
153  GmpFemPhysicsCommonMaterial* instance(GmSimulationData* simulation, QString typeName, const GmLogCategory& logger) const;
154 
158  int numMaterialTypes() const { return _factoryMap.size(); }
159 
161  QString defaultMaterialType() const { return _defTypeName; }
162 
163  int typeIndex(QString typeName) const;
164 
165  bool checkTypeMap() const;
166 
167 private:
170 };
171 
172 
173 
174 #endif
175 
virtual bool checkLoadedData(const GmElement *e) const
Additional checking function, called after all attributes and accessors from physicsMetaDataMap() hav...
Definition: gmpFemPhysicsCommonMaterial.h:93
QString _typeName
The material type name.
Definition: gmpFemPhysicsCommonMaterial.h:127
A class that implements several common functions required by GmpFemPhysics.
Definition: gmpFemPhysicsCommon.h:40
int nodeDim() const
Returns the node dimension (number of node coordinates)
Definition: gmpFemPhysicsCommonMaterial.h:106
GmGaussAccessor * gaussAttrAc(int id) const
Returns the accessor for the given Gauss attribute.
Definition: gmpFemPhysicsCommonMaterial.h:120
QVector< bool > _constantProperties
List with flags defining if the properties in _propertyAccessors can have functions or not.
Definition: gmpFemPhysicsCommonMaterial.h:131
GmValueAccessor * nodeAc() const
Returns the accessor for retrieving node coordinates.
Definition: gmpFemPhysicsCommonMaterial.h:103
int _typeIndex
The material type index, used for indexing into the materials vector inside the physics.
Definition: gmpFemPhysicsCommonMaterial.h:125
QString _defTypeName
The default material name.
Definition: gmpFemPhysicsCommonMaterial.h:169
GmValueAccessor * _nodeAccessor
An accessor for retrieving node coordinate values.
Definition: gmpFemPhysicsCommonMaterial.h:134
A simple factory used to register material type names, their numeric indices and their instance funct...
Definition: gmpFemPhysicsCommonMaterial.h:145
QVector< GmCellAccessor * > _propertyAccessors
List with property accessors.
Definition: gmpFemPhysicsCommonMaterial.h:130
int _nodeDim
Node dimension.
Definition: gmpFemPhysicsCommonMaterial.h:126
GmValueAccessor * nodeAttrAc(int id) const
Returns the accessor for the given node attribute.
Definition: gmpFemPhysicsCommonMaterial.h:117
const GmLogCategory & logger() const
Returns the material logger.
Definition: gmpFemPhysicsCommonMaterial.h:66
QString defaultMaterialType() const
Returns the name of the default material type.
Definition: gmpFemPhysicsCommonMaterial.h:161
QVector< GmGaussAccessor * > _gaussAttrAccessors
List with Gauss attribute accessors.
Definition: gmpFemPhysicsCommonMaterial.h:133
QVector< int > _savedGaussAccessorIds
The list with gauss accessor ids that need to be saved on addStateItemsToGroup()
Definition: gmpFemPhysicsCommonMaterial.h:135
const GmLogCategory & _logger
The material logger.
Definition: gmpFemPhysicsCommonMaterial.h:128
bool constantProperty(int id) const
Returns true if the given cell property is not a function (so its value is unique for an element and ...
Definition: gmpFemPhysicsCommonMaterial.h:114
QMap< QString, QPair< int, MaterialObjCreator > > _factoryMap
The map associating material names with their instance functions / index numbers.
Definition: gmpFemPhysicsCommonMaterial.h:168
int typeIndex() const
Returns the material type index.
Definition: gmpFemPhysicsCommonMaterial.h:60
int numMaterialTypes() const
Returns the number of materials registered in the factory. Equal to the greatest index number + 1 if ...
Definition: gmpFemPhysicsCommonMaterial.h:158
GmpFemPhysicsCommonMaterial(int typeIndex, QString typeName, const GmLogCategory &logger)
Common material constructor. Receives its type name and index in order for a class to be able to hand...
Definition: gmpFemPhysicsCommonMaterial.h:50
QString typeName() const
Returns the material type name.
Definition: gmpFemPhysicsCommonMaterial.h:63
A class that implements a common behaviour for physics materials.
Definition: gmpFemPhysicsCommonMaterial.h:44
GmCellAccessor * propertyAc(int id) const
Returns the accessor for the given cell property.
Definition: gmpFemPhysicsCommonMaterial.h:109
arma::vec GmVector
Declaration of usefull configuration definitions for the plugin library.
QVector< GmValueAccessor * > _nodeAttrAccessors
List with node attribute accessors.
Definition: gmpFemPhysicsCommonMaterial.h:132