GEOSX
SolidMechanicsLagrangianFEM.hpp
Go to the documentation of this file.
1 /*
2  * ------------------------------------------------------------------------------------------------------------
3  * SPDX-License-Identifier: LGPL-2.1-only
4  *
5  * Copyright (c) 2018-2020 Lawrence Livermore National Security LLC
6  * Copyright (c) 2018-2020 The Board of Trustees of the Leland Stanford Junior University
7  * Copyright (c) 2018-2020 TotalEnergies
8  * Copyright (c) 2019- GEOSX Contributors
9  * All rights reserved
10  *
11  * See top level LICENSE, COPYRIGHT, CONTRIBUTORS, NOTICE, and ACKNOWLEDGEMENTS files for details.
12  * ------------------------------------------------------------------------------------------------------------
13  */
14 
19 #ifndef GEOS_PHYSICSSOLVERS_SOLIDMECHANICS_SOLIDMECHANICSLAGRANGIANFEM_HPP_
20 #define GEOS_PHYSICSSOLVERS_SOLIDMECHANICS_SOLIDMECHANICSLAGRANGIANFEM_HPP_
21 
22 #include "codingUtilities/EnumStrings.hpp"
23 #include "common/TimingMacros.hpp"
26 #include "mesh/mpiCommunications/CommunicationTools.hpp"
27 #include "mesh/mpiCommunications/MPI_iCommData.hpp"
28 #include "physicsSolvers/SolverBase.hpp"
29 #include "physicsSolvers/fluidFlow/FlowSolverBase.hpp"
30 
32 
33 namespace geos
34 {
35 
41 class SolidMechanicsLagrangianFEM : public SolverBase
42 {
43 public:
44 
46  static string coupledSolverAttributePrefix() { return "solid"; }
47 
54  {
55  QuasiStatic,
58  };
59 
65  SolidMechanicsLagrangianFEM( const string & name,
66  Group * const parent );
67 
68 
71 
72  SolidMechanicsLagrangianFEM & operator=( SolidMechanicsLagrangianFEM const & ) = delete;
74 
78  virtual ~SolidMechanicsLagrangianFEM() override;
79 
83  static string catalogName() { return "SolidMechanics_LagrangianFEM"; }
87  string getCatalogName() const override { return catalogName(); }
88 
89  virtual void initializePreSubGroups() override;
90 
91  virtual void registerDataOnMesh( Group & meshBodies ) override;
92 
99  virtual
100  real64 solverStep( real64 const & time_n,
101  real64 const & dt,
102  integer const cycleNumber,
103  DomainPartition & domain ) override;
104 
105  virtual
106  real64 explicitStep( real64 const & time_n,
107  real64 const & dt,
108  integer const cycleNumber,
109  DomainPartition & domain ) override;
110 
111  virtual void
112  implicitStepSetup( real64 const & time_n,
113  real64 const & dt,
114  DomainPartition & domain ) override;
115 
116  virtual void
117  setupDofs( DomainPartition const & domain,
118  DofManager & dofManager ) const override;
119 
120  virtual void
121  setupSystem( DomainPartition & domain,
122  DofManager & dofManager,
123  CRSMatrix< real64, globalIndex > & localMatrix,
124  ParallelVector & rhs,
125  ParallelVector & solution,
126  bool const setSparsity = false ) override;
127 
128  virtual void
129  assembleSystem( real64 const time,
130  real64 const dt,
131  DomainPartition & domain,
132  DofManager const & dofManager,
133  CRSMatrixView< real64, globalIndex const > const & localMatrix,
134  arrayView1d< real64 > const & localRhs ) override;
135 
136  virtual void
137  applySystemSolution( DofManager const & dofManager,
138  arrayView1d< real64 const > const & localSolution,
139  real64 const scalingFactor,
140  real64 const dt,
141  DomainPartition & domain ) override;
142 
143  virtual void updateState( DomainPartition & domain ) override
144  {
145  // There should be nothing to update
146  GEOS_UNUSED_VAR( domain );
147  };
148 
149  virtual void applyBoundaryConditions( real64 const time,
150  real64 const dt,
151  DomainPartition & domain,
152  DofManager const & dofManager,
153  CRSMatrixView< real64, globalIndex const > const & localMatrix,
154  arrayView1d< real64 > const & localRhs ) override;
155 
156  virtual real64
157  calculateResidualNorm( real64 const & time_n,
158  real64 const & dt,
159  DomainPartition const & domain,
160  DofManager const & dofManager,
161  arrayView1d< real64 const > const & localRhs ) override;
162 
163  virtual void resetStateToBeginningOfStep( DomainPartition & domain ) override;
164 
165  virtual void implicitStepComplete( real64 const & time,
166  real64 const & dt,
167  DomainPartition & domain ) override;
168 
172  template< typename CONSTITUTIVE_BASE,
173  typename KERNEL_WRAPPER,
174  typename ... PARAMS >
175  real64 assemblyLaunch( MeshLevel & mesh,
176  DofManager const & dofManager,
177  arrayView1d< string const > const & regionNames,
178  string const & materialNamesString,
179  CRSMatrixView< real64, globalIndex const > const & localMatrix,
180  arrayView1d< real64 > const & localRhs,
181  real64 const dt,
182  PARAMS && ... params );
183 
184 
185  template< typename ... PARAMS >
186  real64 explicitKernelDispatch( MeshLevel & mesh,
187  arrayView1d< string const > const & targetRegions,
188  string const & finiteElementName,
189  real64 const dt,
190  std::string const & elementListName );
191 
202  DofManager const & dofManager,
203  DomainPartition & domain,
204  CRSMatrixView< real64, globalIndex const > const & localMatrix,
205  arrayView1d< real64 > const & localRhs );
206 
207  void applyTractionBC( real64 const time,
208  DofManager const & dofManager,
209  DomainPartition & domain,
210  arrayView1d< real64 > const & localRhs );
211 
212  void applyChomboPressure( DofManager const & dofManager,
213  DomainPartition & domain,
214  arrayView1d< real64 > const & localRhs );
215 
216 
217  void applyContactConstraint( DofManager const & dofManager,
218  DomainPartition & domain,
219  CRSMatrixView< real64, globalIndex const > const & localMatrix,
220  arrayView1d< real64 > const & localRhs );
221 
222  virtual real64
223  scalingForSystemSolution( DomainPartition & domain,
224  DofManager const & dofManager,
225  arrayView1d< real64 const > const & localSolution ) override;
226 
227  void enableFixedStressPoromechanicsUpdate();
228 
229  virtual void saveSequentialIterationState( DomainPartition & domain ) override;
230 
231  struct viewKeyStruct : SolverBase::viewKeyStruct
232  {
233  static constexpr char const * newmarkGammaString() { return "newmarkGamma"; }
234  static constexpr char const * newmarkBetaString() { return "newmarkBeta"; }
235  static constexpr char const * massDampingString() { return "massDamping"; }
236  static constexpr char const * stiffnessDampingString() { return "stiffnessDamping"; }
237  static constexpr char const * timeIntegrationOptionString() { return "timeIntegrationOption"; }
238  static constexpr char const * maxNumResolvesString() { return "maxNumResolves"; }
239  static constexpr char const * strainTheoryString() { return "strainTheory"; }
240  static constexpr char const * solidMaterialNamesString() { return "solidMaterialNames"; }
241  static constexpr char const * contactRelationNameString() { return "contactRelationName"; }
242  static constexpr char const * noContactRelationNameString() { return "NOCONTACT"; }
243  static constexpr char const * maxForceString() { return "maxForce"; }
244  static constexpr char const * elemsAttachedToSendOrReceiveNodesString() { return "elemsAttachedToSendOrReceiveNodes"; }
245  static constexpr char const * elemsNotAttachedToSendOrReceiveNodesString() { return "elemsNotAttachedToSendOrReceiveNodes"; }
246  static constexpr char const * surfaceGeneratorNameString() { return "surfaceGeneratorName"; }
247 
248  static constexpr char const * sendOrReceiveNodesString() { return "sendOrReceiveNodes";}
249  static constexpr char const * nonSendOrReceiveNodesString() { return "nonSendOrReceiveNodes";}
250  static constexpr char const * targetNodesString() { return "targetNodes";}
251  static constexpr char const * forceString() { return "Force";}
252  };
253 
254  SortedArray< localIndex > & getElemsAttachedToSendOrReceiveNodes( ElementSubRegionBase & subRegion )
255  {
256  return subRegion.getReference< SortedArray< localIndex > >( viewKeyStruct::elemsAttachedToSendOrReceiveNodesString() );
257  }
258 
259  SortedArray< localIndex > & getElemsNotAttachedToSendOrReceiveNodes( ElementSubRegionBase & subRegion )
260  {
261  return subRegion.getReference< SortedArray< localIndex > >( viewKeyStruct::elemsNotAttachedToSendOrReceiveNodesString() );
262  }
263 
264  real64 & getMaxForce() { return m_maxForce; }
265  real64 const & getMaxForce() const { return m_maxForce; }
266 
267  arrayView1d< ParallelVector > const & getRigidBodyModes() const
268  {
269  return m_rigidBodyModes;
270  }
271 
272  array1d< ParallelVector > & getRigidBodyModes()
273  {
274  return m_rigidBodyModes;
275  }
276 
277 protected:
278  virtual void postProcessInput() override;
279 
280  virtual void initializePostInitialConditionsPreSubGroups() override;
281 
282  virtual void setConstitutiveNamesCallSuper( ElementSubRegionBase & subRegion ) const override;
283 
284  real64 m_newmarkGamma;
285  real64 m_newmarkBeta;
286  real64 m_massDamping;
287  real64 m_stiffnessDamping;
288  TimeIntegrationOption m_timeIntegrationOption;
289  real64 m_maxForce = 0.0;
290  integer m_maxNumResolves;
291  integer m_strainTheory;
292  MPI_iCommData m_iComm;
293  bool m_isFixedStressPoromechanicsUpdate;
294 
297 
298 private:
299 
300  string m_contactRelationName;
301 
302  SolverBase * m_surfaceGenerator;
303  string m_surfaceGeneratorName;
304 };
305 
307  "QuasiStatic",
308  "ImplicitDynamic",
309  "ExplicitDynamic" );
310 
311 //**********************************************************************************************************************
312 //**********************************************************************************************************************
313 //**********************************************************************************************************************
314 
315 
316 template< typename CONSTITUTIVE_BASE,
317  typename KERNEL_WRAPPER,
318  typename ... PARAMS >
319 real64 SolidMechanicsLagrangianFEM::assemblyLaunch( MeshLevel & mesh,
320  DofManager const & dofManager,
321  arrayView1d< string const > const & regionNames,
322  string const & materialNamesString,
323  CRSMatrixView< real64, globalIndex const > const & localMatrix,
324  arrayView1d< real64 > const & localRhs,
325  real64 const dt,
326  PARAMS && ... params )
327 {
329 
330  NodeManager const & nodeManager = mesh.getNodeManager();
331 
332  string const dofKey = dofManager.getKey( fields::solidMechanics::totalDisplacement::key() );
333  arrayView1d< globalIndex const > const & dofNumber = nodeManager.getReference< globalIndex_array >( dofKey );
334 
335  real64 const gravityVectorData[3] = LVARRAY_TENSOROPS_INIT_LOCAL_3( gravityVector() );
336 
337  KERNEL_WRAPPER kernelWrapper( dofNumber,
338  dofManager.rankOffset(),
339  localMatrix,
340  localRhs,
341  dt,
342  gravityVectorData,
343  std::forward< PARAMS >( params )... );
344 
345  return finiteElement::
346  regionBasedKernelApplication< parallelDevicePolicy< >,
347  CONSTITUTIVE_BASE,
348  CellElementSubRegion >( mesh,
349  regionNames,
350  this->getDiscretizationName(),
351  materialNamesString,
352  kernelWrapper );
353 
354 }
355 
356 } /* namespace geos */
357 
358 #endif /* GEOS_PHYSICSSOLVERS_SOLIDMECHANICS_SOLIDMECHANICSLAGRANGIANFEM_HPP_ */
#define GEOS_UNUSED_VAR(...)
Mark an unused variable and silence compiler warnings.
Definition: GeosxMacros.hpp:83
#define GEOS_MARK_FUNCTION
Mark function with both Caliper and NVTX if enabled.
The DoFManager is responsible for allocating global dofs, constructing sparsity patterns,...
Definition: DofManager.hpp:43
globalIndex rankOffset(string const &fieldName) const
string const & getKey(string const &fieldName) const
Return the key used to record the field in the DofManager.
Partition of the decomposed physical domain. It also manages the connexion information to its neighbo...
Class facilitating the representation of a multi-level discretization of a MeshBody.
Definition: MeshLevel.hpp:41
NodeManager const & getNodeManager() const
Get the node manager.
Definition: MeshLevel.hpp:154
The NodeManager class provides an interface to ObjectManagerBase in order to manage node data.
Definition: NodeManager.hpp:45
virtual ~SolidMechanicsLagrangianFEM() override
SolidMechanicsLagrangianFEM(const string &name, Group *const parent)
void applyDisplacementBCImplicit(real64 const time, DofManager const &dofManager, DomainPartition &domain, CRSMatrixView< real64, globalIndex const > const &localMatrix, arrayView1d< real64 > const &localRhs)
array1d< ParallelVector > m_rigidBodyModes
Rigid body modes.
static string coupledSolverAttributePrefix()
String used to form the solverName used to register single-physics solvers in CoupledSolver.
GEOS_DECLTYPE_AUTO_RETURN getReference(LOOKUP_TYPE const &lookup) const
Look up a wrapper and get reference to wrapped object.
Definition: Group.hpp:1252
ArrayView< T, 1 > arrayView1d
Alias for 1D array view.
Definition: DataTypes.hpp:220
LvArray::CRSMatrixView< T, COL_INDEX, localIndex const, LvArray::ChaiBuffer > CRSMatrixView
Alias for CRS Matrix View.
Definition: DataTypes.hpp:350
array1d< globalIndex > globalIndex_array
A 1-dimensional array of geos::globalIndex types.
Definition: DataTypes.hpp:441
ENUM_STRINGS(LinearSolverParameters::SolverType, "direct", "cg", "gmres", "fgmres", "bicgstab", "preconditioner")
Declare strings associated with enumeration values.
std::string string
String type.
Definition: DataTypes.hpp:131
double real64
64-bit floating point type.
Definition: DataTypes.hpp:139
std::int32_t integer
Signed integer type.
Definition: DataTypes.hpp:122
LvArray::CRSMatrix< T, COL_INDEX, localIndex, LvArray::ChaiBuffer > CRSMatrix
Alias for CRS Matrix class.
Definition: DataTypes.hpp:346
LvArray::SortedArray< T, localIndex, LvArray::ChaiBuffer > SortedArray
A sorted array of local indices.
Definition: DataTypes.hpp:307
Array< T, 1 > array1d
Alias for 1D array.
Definition: DataTypes.hpp:216
LAInterface::ParallelVector ParallelVector
Alias for ParallelVector.