FemProcess
The GeMA Fem Process Plugin
Loading...
Searching...
No Matches
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
36class GmCellAccessor;
37class GmValueAccessor;
38class GmGaussAccessor;
39class GmElement;
40class GmElementMesh;
41
42
44class GMP_FEM_PROCESS_API_EXPORT GmpFemPhysicsCommonMaterial
45{
46public:
50 GmpFemPhysicsCommonMaterial(int typeIndex, QString typeName, const GmLogCategory& logger)
51 :_logger(logger)
52 {
53 _typeIndex = typeIndex;
54 _typeName = typeName;
55 _constModelEvalErrorWarnEnabled = true;
56 }
57
59
61 int typeIndex() const { return _typeIndex; }
62
64 QString typeName() const { return _typeName; }
65
67 const GmLogCategory& logger() const { return _logger; }
68
82 virtual const QVariantMap* materialMetaDataMap() = 0;
83
85 virtual bool vectorPropertyValue(const GmElement* e, GmCellAccessor* propAcc, GmVector& data, const GmVector* coord, int ip) const;
86
94 virtual bool checkLoadedData(const GmElement* e) const
95 {
96 assert(e); Q_UNUSED(e);
97 return true;
98 }
99
100 virtual bool addStateItemsToGroup(GmStateDump* state, GmElementMesh* mesh, bool fixedHint, int groupId);
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 GmCellAccessor* cellAttrAc(int id) const { return _cellAttrAccessors.at(id); }
121
123 GmGaussAccessor* gaussAttrAc(int id) const { return _gaussAttrAccessors.at(id); }
124
126 bool constModelEvalErrorWarnEnabled() const { return _constModelEvalErrorWarnEnabled; }
127
129 void setConstModelEvalErrorWarnEnabled(bool enabled) { _constModelEvalErrorWarnEnabled = enabled; }
130
131protected:
132 friend class GmpFemPhysicsCommon; // Accessors are filled by the physics
133
139
147};
148
156class GMP_FEM_PROCESS_API_EXPORT GmpFemPhysicsCommonMaterialFactory
157{
158public:
160 typedef GmpFemPhysicsCommonMaterial* (*MaterialObjCreator)(GmSimulationData* simulation, int typeIndex, QString typeName, const GmLogCategory& logger);
161
162 void registerMaterial(int typeIndex, QString typeName, MaterialObjCreator instanceFunction, bool defaultMaterial = false);
163
164 GmpFemPhysicsCommonMaterial* instance(GmSimulationData* simulation, QString typeName, const GmLogCategory& logger) const;
165
169 int numMaterialTypes() const { return _factoryMap.size(); }
170
172 QString defaultMaterialType() const { return _defTypeName; }
173
174 int typeIndex(QString typeName) const;
175
176 bool checkTypeMap() const;
177
178private:
181};
182
183
184
185#endif
186
A class that implements several common functions required by GmpFemPhysics.
Definition gmpFemPhysicsCommon.h:41
A simple factory used to register material type names, their numeric indices and their instance funct...
Definition gmpFemPhysicsCommonMaterial.h:157
QString _defTypeName
The default material name.
Definition gmpFemPhysicsCommonMaterial.h:180
QMap< QString, QPair< int, MaterialObjCreator > > _factoryMap
The map associating material names with their instance functions / index numbers.
Definition gmpFemPhysicsCommonMaterial.h:179
int numMaterialTypes() const
Returns the number of materials registered in the factory. Equal to the greatest index number + 1 if ...
Definition gmpFemPhysicsCommonMaterial.h:169
QString defaultMaterialType() const
Returns the name of the default material type.
Definition gmpFemPhysicsCommonMaterial.h:172
A class that implements a common behaviour for physics materials.
Definition gmpFemPhysicsCommonMaterial.h:45
bool constModelEvalErrorWarnEnabled() const
Is the warning on constitutive model evaluation errors enabled?
Definition gmpFemPhysicsCommonMaterial.h:126
GmValueAccessor * nodeAc() const
Returns the accessor for retrieving node coordinates.
Definition gmpFemPhysicsCommonMaterial.h:103
const GmLogCategory & logger() const
Returns the material logger.
Definition gmpFemPhysicsCommonMaterial.h:67
QString typeName() const
Returns the material type name.
Definition gmpFemPhysicsCommonMaterial.h:64
QVector< GmValueAccessor * > _nodeAttrAccessors
List with node attribute accessors.
Definition gmpFemPhysicsCommonMaterial.h:142
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
bool _constModelEvalErrorWarnEnabled
Flag set to false if the user disabled warnings due to errors when evaluating constitutive models.
Definition gmpFemPhysicsCommonMaterial.h:138
GmValueAccessor * _nodeAccessor
An accessor for retrieving node coordinate values.
Definition gmpFemPhysicsCommonMaterial.h:145
virtual const QVariantMap * materialMetaDataMap()=0
Virtual function responsible for returning material associated properties.
void setConstModelEvalErrorWarnEnabled(bool enabled)
Turns on or of the warning returned by constModelEvalErrorWarnEnabled()
Definition gmpFemPhysicsCommonMaterial.h:129
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
int _nodeDim
Node dimension.
Definition gmpFemPhysicsCommonMaterial.h:135
int nodeDim() const
Returns the node dimension (number of node coordinates)
Definition gmpFemPhysicsCommonMaterial.h:106
QVector< GmCellAccessor * > _cellAttrAccessors
List with cell attribute accessors.
Definition gmpFemPhysicsCommonMaterial.h:143
GmCellAccessor * propertyAc(int id) const
Returns the accessor for the given cell property.
Definition gmpFemPhysicsCommonMaterial.h:109
QString _typeName
The material type name.
Definition gmpFemPhysicsCommonMaterial.h:136
virtual bool checkLoadedData(const GmElement *e) const
Additional checking function, called after all attributes and accessors from physicsMetaDataMap() hav...
Definition gmpFemPhysicsCommonMaterial.h:94
QVector< bool > _constantProperties
List with flags defining if the properties in _propertyAccessors can have functions or not.
Definition gmpFemPhysicsCommonMaterial.h:141
int typeIndex() const
Returns the material type index.
Definition gmpFemPhysicsCommonMaterial.h:61
QVector< GmCellAccessor * > _propertyAccessors
List with property accessors.
Definition gmpFemPhysicsCommonMaterial.h:140
QVector< GmGaussAccessor * > _gaussAttrAccessors
List with Gauss attribute accessors.
Definition gmpFemPhysicsCommonMaterial.h:144
const GmLogCategory & _logger
The material logger.
Definition gmpFemPhysicsCommonMaterial.h:137
QVector< int > _savedGaussAccessorIds
The list with gauss accessor ids that need to be saved on addStateItemsToGroup()
Definition gmpFemPhysicsCommonMaterial.h:146
GmCellAccessor * cellAttrAc(int id) const
Returns the accessor for the given cell attribute.
Definition gmpFemPhysicsCommonMaterial.h:120
int _typeIndex
The material type index, used for indexing into the materials vector inside the physics.
Definition gmpFemPhysicsCommonMaterial.h:134
GmGaussAccessor * gaussAttrAc(int id) const
Returns the accessor for the given Gauss attribute.
Definition gmpFemPhysicsCommonMaterial.h:123
GmValueAccessor * nodeAttrAc(int id) const
Returns the accessor for the given node attribute.
Definition gmpFemPhysicsCommonMaterial.h:117
arma::vec GmVector
Declaration of useful configuration definitions for the plugin library.