FemProcess
The GeMA Fem Process Plugin
Loading...
Searching...
No Matches
gmpFemPhysics.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_H_
25#define _GEMA_PLUGIN_FEM_PHYSICS_H_
26
27#include <gmPhysics.h>
28#include <gmElementMesh.h>
29#include <gmElement.h>
30
31#include "gmpFemProcessConfig.h"
32#include "gmpFemMatrixSet.h"
33#include "gmpFemVectorSet.h"
34
35class GmElementDof;
36class GmMatrixDof;
40class GmGaussAccessor;
41class GmStateDump;
42
44class GMP_FEM_PROCESS_API_EXPORT GmpFemPhysics : public GmPhysics
45{
46public:
47
55
58 {
59 FEM_PARALLEL_FILL_ELEMENT_DATA = 0x01,
60 FEM_PARALLEL_FILL_ELEMENT_DATA_BC = 0x02,
61 FEM_PARALLEL_FILL_ELEMENT_DATA_EXT_LOADS = 0x04,
62 FEM_PARALLEL_FILL_CONTACT_DATA = 0x08,
63 };
64
65 GmpFemPhysics(GmSimulationData* simulation, QString id, QString description, const GmLogCategory& logger);
66 virtual ~GmpFemPhysics();
67
69 GmElementMesh* mesh() const { return _mesh; }
70
78 const GmCellGroupSet* meshGroupSet() const { return _gs; }
79
83 int numSupportedExternalLoads() const { return _externalLoadGroupSets.size(); }
84
93 const GmCellGroupSet* externalLoadGroupSet(int loadId) const { return _externalLoadGroupSets[loadId]; }
94
97
99 const QMap<QString, const GmContactBoundaryCondition*>& contactBoundaryConditions() const { return _cbcMap; }
100
102 GmDiscontinuitySet* discontinuitySet() const { return _discSet; }
103
111 virtual bool checkPhysicsDependencies(const QVector<GmpFemPhysics*>& physicsList, int index)
112 {
113 Q_UNUSED(physicsList);
114 Q_UNUSED(index);
115 return true;
116 }
117
129 virtual bool dofByElement(bool* fixed = NULL, bool* addOnly = NULL, bool* trackChanges = NULL) const
130 {
131 Q_UNUSED(fixed); Q_UNUSED(addOnly); Q_UNUSED(trackChanges);
132 return false;
133 }
134
158 virtual const GmElementDof* dofMapping(GmCellType type) const = 0;
159
179 virtual const GmElementDof* dofMapping(const GmElement* e) const { return dofMapping(e->type()); }
180
185 virtual Unit dofUnit(int dof) const = 0;
186
188 virtual Unit timeUnit() const = 0;
189
198 {
199 static QList<QPair<int, GmValueAccessor*> > dummyList;
200 return dummyList;
201 }
202
210 virtual bool supportsCellType(GmCellType type) const = 0;
211
216 virtual bool supportsParallel(FemSupportedParallelMethods methodType) const { Q_UNUSED(methodType); return false; }
217
238 virtual bool beforeElementStiffnessLoop(const GmpFemMatrixSet& elemMatrices,
239 const GmpFemVectorSet& elemVectors)
240 {
241 Q_UNUSED(elemMatrices); Q_UNUSED(elemVectors);
242 return true;
243 }
244
249
297 virtual FemResultType fillElementData(const GmElement* e, GmpFemMatrixSet& elemMatrices, GmpFemVectorSet& elemVectors) = 0;
298
303 virtual const QStringList& supportedBcTypes() const
304 {
305 static QStringList dummyList;
306 return dummyList;
307 }
308
313 virtual bool bcAffectsCalc(const GmBoundaryCondition* bc) const
314 {
315 Q_UNUSED(bc);
316 return false;
317 }
318
336 virtual FemResultType fillElementDataForBc(const GmElement* e, const GmBoundaryCondition* bc, int bcIndex, int bcListIndex,
337 int border, GmpFemMatrixSet& elemMatrices, GmpFemVectorSet& elemVectors)
338 {
339 Q_UNUSED(e); Q_UNUSED(bc); Q_UNUSED(bcIndex); Q_UNUSED(bcListIndex); Q_UNUSED(border);
340 Q_UNUSED(elemMatrices); Q_UNUSED(elemVectors);
341 return FEM_ERROR;
342 }
343
361 virtual bool fixedNodalForcesBc(QVector<int>& nodes, QVector<int>&dof, QVector<double>& values) const
362 {
363 Q_UNUSED(nodes); Q_UNUSED(dof); Q_UNUSED(values);
364 return true;
365 }
366
384 virtual bool fixedNodalDofsBc(QVector<int>& nodes, QVector<int>&dof, QVector<double>& values, bool* constantValues) const
385 {
386 Q_UNUSED(nodes); Q_UNUSED(dof); Q_UNUSED(values);
387 *constantValues = true;
388 return true;
389 }
390
396 {
397 static QStringList dummyList;
398 return dummyList;
399 }
400
433 virtual FemResultType fillContactData(const GmContactBoundaryCondition* cbc, int bcIndex1, int bcIndex2,
434 GmMatrixDof& dofMap, GmpFemMatrixSet& matrixSet, GmpFemVectorSet& vecSet)
435 {
436 Q_UNUSED(cbc); Q_UNUSED(bcIndex1); Q_UNUSED(bcIndex2);
437 Q_UNUSED(dofMap); Q_UNUSED(matrixSet); Q_UNUSED(vecSet);
438 return FEM_ERROR;
439 }
440
447 virtual const QStringList& supportedExternalLoads() const
448 {
449 static QStringList dummyList;
450 return dummyList;
451 }
452
465 virtual FemResultType fillElementDataForLoads(const GmElement* e, int loadId, GmpFemVectorSet& elemVectors)
466 {
467 Q_UNUSED(e); Q_UNUSED(loadId); Q_UNUSED(elemVectors);
468 return FEM_ERROR;
469 }
470
483 virtual bool calcDerivedResults(bool nonLinearSolver)
484 {
485 Q_UNUSED(nonLinearSolver);
486 return true;
487 }
488
494 virtual bool supportsStateDumping() { return false; }
495
501 virtual bool addStateItemsToGroup(GmStateDump* state, bool fixedHint, int groupId) { Q_UNUSED(state); Q_UNUSED(fixedHint); Q_UNUSED(groupId); return true; }
502
507 virtual bool fillStateControlMapData(QVariantMap* map) { Q_UNUSED(map); return true; }
508
515 virtual bool stateControlMapDataLoaded(QVariantMap* map) { Q_UNUSED(map); return true; }
516
520 virtual bool stateAboutToBeSaved(GmStateDump* state) { Q_UNUSED(state); return true; }
521
525 virtual bool stateSaved(GmStateDump* state) { Q_UNUSED(state); return true; }
526
530 virtual bool stateAboutToBeLoaded(GmStateDump* state) { Q_UNUSED(state); return true; }
531
535 virtual bool stateLoaded(GmStateDump* state) { Q_UNUSED(state); return true; }
536
537
545 virtual QList<int> changedElements() const { return QList<int>(); }
546
550 virtual void clearChangedElements() {}
551
552 const GmIntegrationRule* elementIntegrationRule(GmCellType type) const;
553 const GmBorderIntegrationRule* borderIntegrationRule (GmCellType type, int borderIndex) const;
554 const GmBorderIntegrationRule* faceIntegrationRule (GmCellType type, int faceIndex) const;
555 const GmBorderIntegrationRule* edgeIntegrationRule (GmCellType type) const;
556
558 int integrationRuleSet() const { return _intRuleSet; }
559
560 bool setIntegrationRuleSet(int ruleSet);
561
562 virtual bool loadPrivateData(LuaTable& table);
563 virtual void printParameters(const GmLogCategory& logger);
564
565protected:
566
575 virtual bool checkMeshDimension(int ndim) = 0;
576
583 virtual bool checkAndLoadPrivateData(LuaTable& table) = 0;
584
596 virtual bool checkAndLoadDofMapping(LuaTable& table) = 0;
597
612 virtual bool checkAndLoadPropertyAccessors(LuaTable& table) = 0;
613
629 virtual bool checkAndLoadAttributeAccessors(LuaTable& nodeTable, LuaTable& cellTable,
630 LuaTable& gaussTable) = 0;
631
645 virtual bool checkAndLoadExternalLoadAccessors(LuaTable& loadsTable) = 0;
646
660 virtual bool checkAndLoadBcAccessors() = 0;
661
676
693
694 GmGaussAccessor* gaussAttributeAccessor(GmElementMesh* mesh, QString stdAttributeName, QString msgDescription,
695 LuaTable& table, Unit desiredUnit, bool required, int type = -1,
696 int nlin = -1, int ncol = -1, int history = -1, bool canBeFunction = true,
697 bool create = false, QString createFormat = "", int createHistory = -1,
698 bool ignoreWarnings = false);
699
704 virtual GmGaussAccessor* createGaussAttributeAccessor(GmElementMesh* mesh, QString id, int snum, bool locked,
705 Unit desiredUnit, const GmLogCategory& logger) const
706 {
707 return mesh->gaussAttributeAccessor(id, snum, locked, desiredUnit, logger);
708 }
709
710
717
723};
724
725
726#endif
727
virtual GmCellType type() const=0
virtual GmGaussAccessor * gaussAttributeAccessor(QString id, Unit desiredUnit, const GmLogCategory &logger) const
virtual void printParameters(const GmLogCategory &logger)
virtual bool loadPrivateData(LuaTable &table)=0
A convenience class that builds a GmMatrixSet with the types given by GmpFemMatrixTypes and also asso...
Definition gmpFemMatrixSet.h:59
Base interface class for FEM Physics type plugins.
Definition gmpFemPhysics.h:45
virtual bool checkAndLoadAttributeAccessors(LuaTable &nodeTable, LuaTable &cellTable, LuaTable &gaussTable)=0
This function is called by loadPrivateData() and should be implemented in derived classes to check if...
virtual const QList< QPair< int, GmValueAccessor * > > & dofForceAttributes() const
Returns a list that associates degrees of freedom handled by this physics with their associated force...
Definition gmpFemPhysics.h:197
virtual bool stateSaved(GmStateDump *state)
Virtual method called just after succesfully completing a save operation on the given state....
Definition gmpFemPhysics.h:525
FemResultType
Result type for local matrix calculation methods.
Definition gmpFemPhysics.h:50
@ FEM_RESULT_OK
The method finished correctly.
Definition gmpFemPhysics.h:51
@ FEM_ERROR_FI
The method finished by unexpected error assembling Fi.
Definition gmpFemPhysics.h:52
@ FEM_ERROR
The method finished due to an unexpected error.
Definition gmpFemPhysics.h:53
const GmCellGroupSet * externalLoadGroupSet(int loadId) const
Returns the element group set used to traverse mesh elements tied to the given external loads id.
Definition gmpFemPhysics.h:93
virtual bool dofByElement(bool *fixed=NULL, bool *addOnly=NULL, bool *trackChanges=NULL) const
Returns false if degrees of freedom are mapped to nodes depending only on the element type,...
Definition gmpFemPhysics.h:129
virtual bool stateControlMapDataLoaded(QVariantMap *map)
Virtual method called just after the solver control map was loaded from the state....
Definition gmpFemPhysics.h:515
virtual bool supportsCellType(GmCellType type) const =0
Returns true if the type is supported by this physics object.
virtual bool fixedNodalForcesBc(QVector< int > &nodes, QVector< int > &dof, QVector< double > &values) const
Method called by the FEM process asking the physics to provide prescribed nodal force values that wil...
Definition gmpFemPhysics.h:361
GmElementMesh * _mesh
The mesh that this physics is bound to.
Definition gmpFemPhysics.h:711
virtual bool calcDerivedResults(bool nonLinearSolver)
Method called after the the system solution asking each physics to calculate derived results based on...
Definition gmpFemPhysics.h:483
virtual bool fillStateControlMapData(QVariantMap *map)
Virtual method called just before the solver control map is saved to the state. Should be used to fil...
Definition gmpFemPhysics.h:507
virtual bool addStateItemsToGroup(GmStateDump *state, bool fixedHint, int groupId)
Initialization method, called once, allowing the object to add its state items to the given group of ...
Definition gmpFemPhysics.h:501
virtual bool checkMeshDimension(int ndim)=0
This function is called by loadPrivateData() to let the phyiscs check if it is compatible with the nu...
virtual bool stateAboutToBeLoaded(GmStateDump *state)
Virtual method called just before starting a load operation on the given state. Returning false abort...
Definition gmpFemPhysics.h:530
virtual Unit timeUnit() const =0
Returns the unit in which the physics handles time. Returns Unit() if not relevant to the physics.
virtual bool supportsParallel(FemSupportedParallelMethods methodType) const
Returns true if this physics object supports multiple calls in parallel (by multiple threads) to the ...
Definition gmpFemPhysics.h:216
virtual bool checkAndLoadExternalLoadAccessors(LuaTable &loadsTable)=0
This function is called by loadPrivateData() and should be implemented in derived classes to check if...
virtual bool stateLoaded(GmStateDump *state)
Virtual method called just after succesfully completing a load operation on the given state....
Definition gmpFemPhysics.h:535
QMap< QString, const GmContactBoundaryCondition * > _cbcMap
A map storing contact boundary conditions associated to this physics, keyed by bc type.
Definition gmpFemPhysics.h:716
virtual bool checkAndLoadBcAccessors()=0
This function is called by loadPrivateData() and should be implemented in derived classes to check if...
virtual bool checkAndLoadPrivateData(LuaTable &table)=0
This function is called by loadPrivateData() to let derived classes check consistency and load values...
virtual bool checkAndLoadPropertyAccessors(LuaTable &table)=0
This function is called by loadPrivateData() and should be implemented in derived classes to check if...
virtual const QStringList & supportedExternalLoads() const
A list with names for the known external load conditions supported by this physics.
Definition gmpFemPhysics.h:447
const GmCellGroupSet * _gs
The element group set used to traverse the mesh elements that form the physics spatial domain.
Definition gmpFemPhysics.h:712
virtual bool checkAndLoadDofMapping(LuaTable &table)=0
This function is called by loadPrivateData() and should be implemented in derived classes to prepare ...
const QMap< QString, const GmBoundaryCondition * > & boundaryConditions() const
Returns a reference to the map storing contact boundary conditions associated to this physics,...
Definition gmpFemPhysics.h:96
virtual const GmElementDof * dofMapping(const GmElement *e) const
Returns the mapping of node degrees of freedom for the given element or NULL if this physics object d...
Definition gmpFemPhysics.h:179
virtual const GmElementDof * dofMapping(GmCellType type) const =0
Returns the mapping of node degrees of freedom for a cell type or NULL if this physics object does no...
virtual bool fixedNodalDofsBc(QVector< int > &nodes, QVector< int > &dof, QVector< double > &values, bool *constantValues) const
Method called by the FEM process asking the physics to provide fixed dof (state variable) values used...
Definition gmpFemPhysics.h:384
FemSupportedParallelMethods
Enum used to specify which physics plugin methods can be called in parallel. Values can be ored toget...
Definition gmpFemPhysics.h:58
virtual void clearChangedElements()
Method called by the assembler to clear the internal list used to track dof changes....
Definition gmpFemPhysics.h:550
virtual GmGaussAccessor * createGaussAttributeAccessor(GmElementMesh *mesh, QString id, int snum, bool locked, Unit desiredUnit, const GmLogCategory &logger) const
A virtual function called by gaussAttributeAccessor() to get the returned Gauss accessor....
Definition gmpFemPhysics.h:704
GmDiscontinuitySet * discontinuitySet() const
Returns the associated discontinuity set, NULL if there is none.
Definition gmpFemPhysics.h:102
QMap< QString, const GmBoundaryCondition * > _bcMap
A map storing boundary conditions associated to this physics, keyed by bc type.
Definition gmpFemPhysics.h:715
QVector< const GmCellGroupSet * > _externalLoadGroupSets
Element group sets for each active external loads or NULL for inactive ones. Indexed in the same orde...
Definition gmpFemPhysics.h:722
virtual bool checkPhysicsDependencies(const QVector< GmpFemPhysics * > &physicsList, int index)
A function called by the Fem solver, at its initialization, to let a physics check that it is compati...
Definition gmpFemPhysics.h:111
virtual FemResultType fillContactData(const GmContactBoundaryCondition *cbc, int bcIndex1, int bcIndex2, GmMatrixDof &dofMap, GmpFemMatrixSet &matrixSet, GmpFemVectorSet &vecSet)
Method called by the FEM process in a similar way as the call to fillElementData() for the physics to...
Definition gmpFemPhysics.h:433
const GmCellGroupSet * meshGroupSet() const
Returns the element group set used to traverse mesh elements belonging to the element groups that tog...
Definition gmpFemPhysics.h:78
virtual FemResultType fillElementDataForLoads(const GmElement *e, int loadId, GmpFemVectorSet &elemVectors)
Method called by the FEM process in a similar way as the call to fillElementData() for the physics to...
Definition gmpFemPhysics.h:465
virtual bool beforeElementStiffnessLoop(const GmpFemMatrixSet &elemMatrices, const GmpFemVectorSet &elemVectors)
Method called by the Fem process to notify the physical object that the assembly process will start.
Definition gmpFemPhysics.h:238
virtual FemResultType fillElementData(const GmElement *e, GmpFemMatrixSet &elemMatrices, GmpFemVectorSet &elemVectors)=0
Method called by the FEM process, during the global matrix / vector assembly procedure to ask a physi...
GmDiscontinuitySet * _discSet
The discontinuity set, NULL if none was associated.
Definition gmpFemPhysics.h:714
virtual bool stateAboutToBeSaved(GmStateDump *state)
Virtual method called just before starting a save operation on the given state. Returning false abort...
Definition gmpFemPhysics.h:520
virtual bool supportsStateDumping()
Method called by the solver to check if this physics supports state dumping and restoring....
Definition gmpFemPhysics.h:494
virtual void afterElementStiffnessLoop()
Method called by the Fem process to notify the physical object that the assembly process has ended.
Definition gmpFemPhysics.h:248
virtual const QStringList & supportedBcTypes() const
A list with names for the known boundary condition types supported by this physics.
Definition gmpFemPhysics.h:303
virtual bool checkAndLoadContactBcAccessors()=0
This function is called by loadPrivateData() and should be implemented in derived classes to check if...
virtual const QStringList & supportedContactBcTypes() const
A list with names for the known contact boundary condition types supported by this physics.
Definition gmpFemPhysics.h:395
virtual Unit dofUnit(int dof) const =0
Returns the unit in which calculated values for the supplied dof are given. Should return Unit() for ...
virtual bool checkAndLoadDiscontinuitySetAccessors(LuaTable &table)=0
This function is called by loadPrivateData() and should be implemented in derived classes to check if...
int numSupportedExternalLoads() const
Returns the number of supported external load types by this physics. Based on the list returned by su...
Definition gmpFemPhysics.h:83
virtual FemResultType fillElementDataForBc(const GmElement *e, const GmBoundaryCondition *bc, int bcIndex, int bcListIndex, int border, GmpFemMatrixSet &elemMatrices, GmpFemVectorSet &elemVectors)
Method called by the FEM process in a similar way as the call to fillElementData() for the physics to...
Definition gmpFemPhysics.h:336
int _intRuleSet
The integration rule set used by this physics.
Definition gmpFemPhysics.h:713
GmElementMesh * mesh() const
Returns the element mesh that this physics object is tied to.
Definition gmpFemPhysics.h:69
virtual QList< int > changedElements() const
Method called by the assembler to obtain the list of elements that had their dofs changed since the p...
Definition gmpFemPhysics.h:545
int integrationRuleSet() const
Returns the integration rule set in use by this physics object.
Definition gmpFemPhysics.h:558
virtual bool bcAffectsCalc(const GmBoundaryCondition *bc) const
Method called by the FEM process asking the physics whether the supplied boundary condition affects t...
Definition gmpFemPhysics.h:313
A convenience class that builds a GmVectorSet with the types given by GmpFemVectorTypes and also asso...
Definition gmpFemVectorSet.h:50
GmCellType
Declaration of the GmpFemMatrixSet class.
Declaration of useful configuration definitions for the plugin library.
Declaration of the GmpFemVectorSet class.