Xfem
The Xfem Plugin
xfemFactory.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_XFEM_FACTORY_H_
25 #define _GEMA_XFEM_FACTORY_H_
26 
27 #include <QObject>
28 
29 #include <gmpFemPhysicsCommonMaterial.h>
30 #include <gmPluginObjectFactory.h>
31 #include <gmpMaterialModifMohrCoulomb.h>
32 #include <gmpMaterialDruckerPrager.h>
33 #include <gmpMaterialElastic.h>
34 #include <gmSimulationData.h>
35 #include <gmPluginLoader.h>
36 #include <gmpMechanic.h>
37 #include <gmpHydraulic.h>
38 #include <gmpHydraulicFlow.h>
39 #include <gmpMaterialSaturated.h>
40 #include <gmpMaterialInterfaceFlow.h>
41 #include <gmPluginInfo.h>
42 
46 #include "xfemHMCoupled.h"
47 #include "xfemMechanic.h"
48 #include "xfemMaterial.h"
49 #include "xfemProcess.h"
50 #include "xfemMesh.h"
51 
52 #include "xfemVersion.h"
53 
56 {
57  Q_OBJECT
58  Q_PLUGIN_METADATA(IID GmPluginObjectFactoryInterfaceIID)
59  Q_INTERFACES(GmPluginObjectFactory)
60 
61 public:
64 
65  // See comments on the base class method declaration
66  virtual GmPluginObject* instance(QString category, QString objType, GmSimulationData* simulation,
67  QString id, QString description)
68  {
69  assert(category == GM_PLUGIN_MESH || category == GM_PLUGIN_PHYSICS || category == GM_PLUGIN_PROCESS);
70 
71  if(category == GM_PLUGIN_MESH)
72  {
73  if(objType == "mesh")
74  return new XfemGemaMesh(simulation, id, description, logger());
75  else
76  return NULL;
77  }
78  else if(category == GM_PLUGIN_PROCESS)
79  {
80  if(objType == "xfem")
81  return new XfemProcess(simulation, id, description, logger());
82  else
83  return NULL;
84  }
85  else if (category == GM_PLUGIN_PHYSICS)
86  {
87  // If this is the first time that instance() is called, lets register material types
88  static GmpFemPhysicsCommonMaterialFactory matFactory;
89  if (matFactory.numMaterialTypes() == 0)
90  {
91  const GmPluginInfo* ourInfo = simulation->loader()->pluginInfo("Xfem");
92  assert(ourInfo);
93  const QVariantMap& map = ourInfo->attributes().value("constants").value<QVariantMap>().value("materialModels").value<QVariantMap>();
94 
95  // Instance the requested material object
96  //mechanical xfem material
97  matFactory.registerMaterial(map.value("elastic").toInt(), "elastic", XfemMaterial::instance, true);
98  matFactory.registerMaterial(map.value("vonMises").toInt(), "vonMises", XfemMaterial::instance);
99  matFactory.registerMaterial(map.value("druckerPrager").toInt(), "druckerPrager", XfemMaterial::instance);
100  matFactory.registerMaterial(map.value("modifiedMohrCoulomb").toInt(), "modifiedMohrCoulomb", XfemMaterial::instance);
101 
102  //hydraulic xfem material
103  matFactory.registerMaterial(map.value("saturated").toInt(), "saturated", GmpHydraulicMaterialSaturated::instance);
104  matFactory.registerMaterial(map.value("interfaceFlow").toInt(), "interfaceFlow", GmpMaterialInterfaceFlow::instance);
105 
106  //hydroMechanical xfem material
107  matFactory.registerMaterial(map.value("poroElastic").toInt(), "poroElastic", XfemHydroMechanicalMaterial::instance, true);
108  matFactory.registerMaterial(map.value("poroDruckerPrager").toInt(), "poroDruckerPrager", XfemHydroMechanicalMaterial::instance);
109 
110  assert(matFactory.checkTypeMap());
111  }
112 
113  // Instance the requested physics object
114  if (objType == "PlaneStrain")
115  {
116  return new GmpMechanic<XfemMechanic>("PlaneStrain", simulation, id, description, &matFactory, logger());
117  }
118  else if (objType == "PlaneStress")
119  {
120  return new GmpMechanic<XfemMechanic>("PlaneStress", simulation, id, description, &matFactory, logger());
121  }
122  else if (objType == "3D")
123  {
124  return new GmpMechanic<XfemMechanic>("3D", simulation, id, description, &matFactory, logger());
125  }
126  else if (objType == "HydroMechanic")
127  {
128  return new GmpMechanic<XfemHMCoupled>("HydroMechanic", simulation, id, description, &matFactory, logger());
129  }
130  else if (objType == "HydroMechanic3D")
131  {
132  return new GmpMechanic<XfemHMCoupled>("HydroMechanic3D", simulation, id, description, &matFactory, logger());
133  }
134  else if (objType == "embeddedPE")
135  {
136  return new GmpMechanic<XfemMechanicEmbeddedFracture>("embeddedPE", simulation, id, description, &matFactory, logger());
137  }
138  else if (objType == "embeddedPS")
139  {
140  return new GmpMechanic<XfemMechanicEmbeddedFracture>("embeddedPS", simulation, id, description, &matFactory, logger());
141  }
142  else if (objType == "embedded3D")
143  {
144  return new GmpMechanic<XfemMechanicEmbeddedFracture>("embedded3D", simulation, id, description, &matFactory, logger());
145  }
146  else if (objType == "embeddedHydro")
147  {
148  return new GmpHydraulicFlow<XfemHydraulicEmbeddedFracture>("embeddedHydro", simulation, id, description, &matFactory, logger());
149  }
150  else
151  {
152  return NULL;
153  }
154  }
155  return NULL;
156  }
157 
159  virtual const QStringList& versionInfo() const { return XfemVersionInfo(); }
160 
162  virtual const QStringList& depVersionInfo() const { return XfemRevisionDependencies(); }
163 };
164 
165 #endif
166 
Implementation of the Xfem factory plugin.
Definition: xfemFactory.h:55
const GmLogCategory & logger()
const QVariantMap & attributes() const
Declaration of the xfemMechanic classes.
GmPluginInfo * pluginInfo(QString pluginName) const
Declaration of the xfemMaterial classes.
Declaration of the hydroMechanical coupled xfem class.
Declaration of the XfemMesh class.
GmPluginLoader * loader() const
virtual const QStringList & versionInfo() const
Retuns version information for the plugin. See comments on the base class.
Definition: xfemFactory.h:159
Basic class for the XFEM Process plugin object.
Definition: xfemProcess.h:36
Declaration of the xfemHydraulicEmbedded classes.
XfemFactory()
Default constructor.
Definition: xfemFactory.h:63
virtual const QStringList & depVersionInfo() const
Retuns dependency version information for the plugin. See comments on the base class.
Definition: xfemFactory.h:162
Declaration of the XfemProcess class.
static GmpFemPhysicsCommonMaterial * instance(GmSimulationData *simulation, int typeIndex, QString typeName, const GmLogCategory &logger)
A "factory" function used to register the material with the physics material factory.
Definition: xfemHydroMechanicalMaterial.h:58
#define GmPluginObjectFactoryInterfaceIID
Declaration of the xfemHydroMechanicalMaterial classes.
static GmpFemPhysicsCommonMaterial * instance(GmSimulationData *simulation, int typeIndex, QString typeName, const GmLogCategory &logger)
A "factory" function used to register the material with the physics material factory.
Definition: xfemMaterial.h:53
Implementation of the XfemMesh interface based on the standard GeMA mesh plugin.
Definition: xfemMesh.h:214
Declaration of the xfemHydraulicEmbedded classes.