GEOSX
SolidMechanicsMPM.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 GEOSX_PHYSICSSOLVERS_SOLIDMECHANICS_MPM_HPP_
20 #define GEOSX_PHYSICSSOLVERS_SOLIDMECHANICS_MPM_HPP_
21 
22 #include "codingUtilities/EnumStrings.hpp"
23 #include "common/TimingMacros.hpp"
25 #include "kernels/ExplicitMPM.hpp"
27 #include "mesh/mpiCommunications/CommunicationTools.hpp"
28 #include "mesh/mpiCommunications/MPI_iCommData.hpp"
29 #include "physicsSolvers/SolverBase.hpp"
31 #include "MPMSolverFields.hpp"
32 
33 namespace geos
34 {
35 
36 class SpatialPartition;
37 
38 
44 class SolidMechanicsMPM : public SolverBase
45 {
46 public:
47 
54  {
55  QuasiStatic,
58  };
59 
66  {
67  OUTFLOW,
68  SYMMETRY
69  };
70 
76  SolidMechanicsMPM( const string & name,
77  Group * const parent );
78 
79 
80  SolidMechanicsMPM( SolidMechanicsMPM const & ) = delete;
81  SolidMechanicsMPM( SolidMechanicsMPM && ) = default;
82 
83  SolidMechanicsMPM & operator=( SolidMechanicsMPM const & ) = delete;
84  SolidMechanicsMPM & operator=( SolidMechanicsMPM && ) = delete;
85 
89  virtual ~SolidMechanicsMPM() override;
90 
94  static string catalogName() { return "SolidMechanics_MPM"; }
98  string getCatalogName() const override { return catalogName(); }
99 
100  virtual void initializePreSubGroups() override;
101 
102  virtual void registerDataOnMesh( Group & meshBodies ) override final;
103 
110  virtual
111  real64 solverStep( real64 const & time_n,
112  real64 const & dt,
113  integer const cycleNumber,
114  DomainPartition & domain ) override;
115 
116  virtual
117  real64 explicitStep( real64 const & time_n,
118  real64 const & dt,
119  integer const cycleNumber,
120  DomainPartition & domain ) override;
121 
122  virtual void updateState( DomainPartition & domain ) override final
123  {
124  // There should be nothing to update
125  GEOS_UNUSED_VAR( domain );
126  };
127 
133  virtual bool execute( real64 const time_n,
134  real64 const dt,
135  integer const cycleNumber,
136  integer const eventCounter,
137  real64 const eventProgress,
138  DomainPartition & domain ) override;
139 
140 
141  template< typename CONSTITUTIVE_BASE,
142  typename KERNEL_WRAPPER,
143  typename ... PARAMS >
144  void assemblyLaunch( DomainPartition & domain,
145  DofManager const & dofManager,
146  CRSMatrixView< real64, globalIndex const > const & localMatrix,
147  arrayView1d< real64 > const & localRhs,
148  PARAMS && ... params );
149 
150 
151  template< typename ... PARAMS >
152  real64 explicitKernelDispatch( MeshLevel & mesh,
153  arrayView1d< string const > const & targetRegions,
154  string const & finiteElementName,
155  real64 const dt,
156  std::string const & elementListName );
157 
168  struct viewKeyStruct : SolverBase::viewKeyStruct
169  {
170  static constexpr char const * cflFactorString() { return "cflFactor"; }
171  static constexpr char const * timeIntegrationOptionString() { return "timeIntegrationOption"; }
172  static constexpr char const * solidMaterialNamesString() { return "solidMaterialNames"; }
173  static constexpr char const * forceExternalString() { return "externalForce"; }
174  static constexpr char const * forceInternalString() { return "internalForce"; }
175  static constexpr char const * massString() { return "mass"; }
176  static constexpr char const * velocityString() { return "velocity"; }
177  static constexpr char const * momentumString() { return "momentum"; }
178  static constexpr char const * accelerationString() { return "acceleration"; }
179  static constexpr char const * forceContactString() { return "contactForce"; }
180  static constexpr char const * damageString() { return "damage"; }
181  static constexpr char const * damageGradientString() { return "damageGradient"; }
182  static constexpr char const * maxDamageString() { return "maxDamage"; }
183  static constexpr char const * surfaceNormalString() { return "surfaceNormal"; }
184  static constexpr char const * materialPositionString() { return "materialPosition"; }
185 
186  static constexpr char const * boundaryNodesString() { return "boundaryNodes"; }
187  static constexpr char const * bufferNodesString() { return "bufferNodes"; }
188 
189  dataRepository::ViewKey timeIntegrationOption = { timeIntegrationOptionString() };
190  } solidMechanicsViewKeys;
191 
192  void initialize( NodeManager & nodeManager,
193  ParticleManager & particleManager,
194  SpatialPartition & partition );
195 
196  void resizeGrid( SpatialPartition & partition,
197  NodeManager & nodeManager,
198  real64 const dt );
199 
200  void syncGridFields( std::vector< std::string > const & fieldNames,
201  DomainPartition & domain,
202  NodeManager & nodeManager,
203  MeshLevel & mesh,
204  MPI_Op op );
205 
206  void singleFaceVectorFieldSymmetryBC( const int face,
207  arrayView3d< real64 > const & vectorMultiField,
209  Group & nodeSets );
210 
211  void enforceGridVectorFieldSymmetryBC( arrayView3d< real64 > const & vectorMultiField,
213  Group & nodeSets );
214 
215  void applyEssentialBCs( const real64 dt,
216  const real64 time_n,
217  NodeManager & nodeManager );
218 
219  void computeGridSurfaceNormals( ParticleManager & particleManager,
220  NodeManager & nodeManager );
221 
222  void normalizeGridSurfaceNormals( arrayView2d< real64 const > const & gridMass,
223  arrayView3d< real64 > const & gridSurfaceNormal );
224 
225  void computeContactForces( real64 const dt,
226  arrayView2d< real64 const > const & gridMass,
227  arrayView2d< real64 const > const & gridDamage,
228  arrayView2d< real64 const > const & gridMaxDamage,
229  arrayView3d< real64 const > const & gridVelocity,
230  arrayView3d< real64 const > const & gridMomentum,
231  arrayView3d< real64 const > const & gridSurfaceNormal,
232  arrayView3d< real64 const > const & gridMaterialPosition,
233  arrayView3d< real64 > const & gridContactForce );
234 
235  void computePairwiseNodalContactForce( int const & separable,
236  real64 const & dt,
237  real64 const & mA,
238  real64 const & mB,
245  arraySlice1d< real64 const > const xA, // Position of field A
246  arraySlice1d< real64 const > const xB, // Position of field B
247  arraySlice1d< real64 > const fA,
248  arraySlice1d< real64 > const fB );
249 
250  void computeOrthonormalBasis( const real64 * e1, // input "normal" unit vector.
251  real64 * e2, // output "tangential" unit vector.
252  real64 * e3 ); // output "tangential" unit vector.
253 
254  void setGridFieldLabels( NodeManager & nodeManager );
255 
256  void solverProfiling( std::string label );
257 
258  void solverProfilingIf( std::string label, bool condition );
259 
260  real64 computeNeighborList( ParticleManager & particleManager );
261 
262  void optimizeBinSort( ParticleManager & particleManager );
263 
264  real64 kernel( real64 const & r ); // distance from particle to query point
265 
266  void kernelGradient( arraySlice1d< real64 const > const x, // query point
267  std::vector< real64 > & xp, // particle location
268  real64 const & r, // distance from particle to query point
269  real64 * result );
270 
271  real64 computeKernelField( arraySlice1d< real64 const > const x, // query point
272  arrayView2d< real64 const > const xp, // List of neighbor particle locations.
273  arrayView1d< real64 const > const Vp, // List of neighbor particle volumes.
274  arrayView1d< real64 const > const fp ); // scalar field values (e.g. damage) at neighbor particles
275 
276  void computeKernelFieldGradient( arraySlice1d< real64 const > const x, // query point
277  std::vector< std::vector< real64 > > & xp, // List of neighbor particle locations.
278  std::vector< real64 > & Vp, // List of neighbor particle volumes.
279  std::vector< real64 > & fp, // scalar field values (e.g. damage) at neighbor particles
280  arraySlice1d< real64 > const result );
281 
282  void computeKernelVectorGradient( arraySlice1d< real64 const > const x, // query point
283  std::vector< std::vector< real64 > > & xp, // List of neighbor particle locations.
284  std::vector< real64 > & Vp, // List of neighbor particle volumes.
285  std::vector< std::vector< real64 > > & fp, // vector field values (e.g. velocity) at neighbor particles
286  arraySlice2d< real64 > const result );
287 
288  void computeDamageFieldGradient( ParticleManager & particleManager );
289 
290  void updateSurfaceFlagOverload( ParticleManager & particleManager );
291 
292  void projectDamageFieldGradientToGrid( ParticleManager & particleManager,
293  NodeManager & nodeManager );
294 
295  void updateDeformationGradient( real64 dt,
296  ParticleManager & particleManager );
297 
298  void updateConstitutiveModelDependencies( ParticleManager & particleManager );
299 
300  void updateStress( real64 dt,
301  ParticleManager & particleManager );
302 
303  void particleKinematicUpdate( ParticleManager & particleManager );
304 
305  void computeAndWriteBoxAverage( const real64 dt,
306  const real64 time_n,
307  ParticleManager & particleManager );
308 
309  void initializeGridFields( NodeManager & nodeManager );
310 
311  void boundaryConditionUpdate( real64 dt, real64 time_n );
312 
313  void particleToGrid( ParticleManager & particleManager,
314  NodeManager & nodeManager );
315 
316  void gridTrialUpdate( real64 dt,
317  NodeManager & nodeManager );
318 
319  void enforceContact( real64 dt,
320  DomainPartition & domain,
321  ParticleManager & particleManager,
322  NodeManager & nodeManager,
323  MeshLevel & mesh );
324 
325  void interpolateFTable( real64 dt, real64 time_n );
326 
327  void gridToParticle( real64 dt,
328  ParticleManager & particleManager,
329  NodeManager & nodeManager );
330 
331  void updateSolverDependencies( ParticleManager & particleManager );
332 
333  real64 getStableTimeStep( ParticleManager & particleManager );
334 
335  void deleteBadParticles( ParticleManager & particleManager );
336 
337  void printProfilingResults();
338 
339  void computeSurfaceFlags( ParticleManager & particleManager );
340 
341  void computeSphF( ParticleManager & particleManager );
342 
343  // void directionalOverlapCorrection( real64 dt, ParticleManager & particleManager );
344 
345  int evaluateSeparabilityCriterion( localIndex const & A,
346  localIndex const & B,
347  real64 const & damageA,
348  real64 const & damageB,
349  real64 const & maxDamageA,
350  real64 const & maxDamageB );
351 
352  void flagOutOfRangeParticles( ParticleManager & particleManager );
353 
354  void computeRVectors( ParticleManager & particleManager );
355 
356  void cpdiDomainScaling( ParticleManager & particleManager );
357 
358  void resizeMappingArrays( ParticleManager & particleManager );
359 
360  void populateMappingArrays( ParticleManager & particleManager,
361  NodeManager & nodeManager );
362 
363 protected:
364  virtual void postProcessInput() override final;
365 
366  virtual void setConstitutiveNamesCallSuper( ParticleSubRegionBase & subRegion ) const override;
367 
368  std::vector< array2d< localIndex > > m_mappedNodes; // mappedNodes[subregion index][particle index][node index]. dims = {# of subregions,
369  // # of particles, # of nodes a particle on the subregion maps to}
370  std::vector< array2d< real64 > > m_shapeFunctionValues; // mappedNodes[subregion][particle][nodal shape function value]. dims = {# of
371  // subregions, # of particles, # of nodes a particle on the subregion maps to}
372  std::vector< array3d< real64 > > m_shapeFunctionGradientValues; // mappedNodes[subregion][particle][nodal shape function gradient
373  // value][direction]. dims = {# of subregions, # of particles, # of nodes
374  // a particle on the subregion maps to, 3}
375 
376  int m_solverProfiling;
377  std::vector< real64 > m_profilingTimes;
378  std::vector< std::string > m_profilingLabels;
379 
380  TimeIntegrationOption m_timeIntegrationOption;
381  MPI_iCommData m_iComm;
382 
383  int m_prescribedBcTable;
384  array1d< int > m_boundaryConditionTypes; // TODO: Surely there's a way to have just one variable here
385  array2d< real64 > m_bcTable;
386 
387  int m_prescribedBoundaryFTable;
388  Path m_fTablePath;
389  int m_fTableInterpType;
390  array2d< real64 > m_fTable;
391  array1d< real64 > m_domainF;
392  array1d< real64 > m_domainL;
393 
394  int m_boxAverageHistory;
395  int m_reactionHistory;
396 
397  int m_needsNeighborList;
398  real64 m_neighborRadius;
399  int m_binSizeMultiplier;
400 
401  int m_useDamageAsSurfaceFlag;
402 
403  int m_cpdiDomainScaling;
404 
405  real64 m_smallMass;
406 
407  int m_numContactGroups, m_numContactFlags, m_numVelocityFields;
408  real64 m_separabilityMinDamage;
409  int m_treatFullyDamagedAsSingleField;
410  int m_surfaceDetection;
411  int m_damageFieldPartitioning;
412  int m_contactGapCorrection;
413  // int m_directionalOverlapCorrection;
414  real64 m_frictionCoefficient;
415 
416  int m_planeStrain;
417  int m_numDims;
418 
419  array1d< real64 > m_hEl; // Grid spacing in x-y-z
420  array1d< real64 > m_xLocalMin; // Minimum local grid coordinate including ghost nodes
421  array1d< real64 > m_xLocalMax; // Maximum local grid coordinate including ghost nodes
422  array1d< real64 > m_xLocalMinNoGhost; // Minimum local grid coordinate EXCLUDING ghost nodes
423  array1d< real64 > m_xLocalMaxNoGhost; // Maximum local grid coordinate EXCLUDING ghost nodes
424  array1d< real64 > m_xGlobalMin; // Minimum global grid coordinate excluding buffer nodes
425  array1d< real64 > m_xGlobalMax; // Maximum global grid coordinate excluding buffer nodes
426  array1d< real64 > m_partitionExtent; // Length of each edge of partition including buffer and ghost cells
427  array1d< real64 > m_domainExtent; // Length of each edge of global domain excluding buffer cells
428  array1d< int > m_nEl; // Number of elements in each grid direction including buffer and ghost cells
429  array3d< int > m_ijkMap; // Map from indices in each spatial dimension to local node ID
430 
431 private:
432  struct BinKey
433  {
434  localIndex regionIndex;
435  localIndex subRegionIndex;
436  localIndex binIndex;
437 
438  bool operator==( BinKey const & other ) const
439  {
440  return (regionIndex == other.regionIndex && subRegionIndex == other.subRegionIndex && binIndex == other.binIndex);
441  }
442  };
443 
444  struct BinKeyHash
445  {
446  std::size_t operator()( BinKey const & k ) const
447  {
448  using std::size_t;
449  using std::hash;
450 
451  // Compute individual hash values for first,
452  // second and third and combine them using XOR
453  // and bit shifting:
454  return ((std::hash< localIndex >()( k.regionIndex )
455  ^ (std::hash< localIndex >()( k.subRegionIndex ) << 1)) >> 1)
456  ^ (std::hash< localIndex >()( k.binIndex ) << 1);
457  }
458  };
459 
460  virtual void setConstitutiveNames( ParticleSubRegionBase & subRegion ) const override;
461 };
462 
464  "QuasiStatic",
465  "ImplicitDynamic",
466  "ExplicitDynamic" );
467 
469  "Outflow",
470  "Symmetry" );
471 
472 //**********************************************************************************************************************
473 //**********************************************************************************************************************
474 //**********************************************************************************************************************
475 
476 
477 } /* namespace geos */
478 
479 #endif /* GEOSX_PHYSICSSOLVERS_SOLIDMECHANICS_SOLIDMECHANICSLAGRANGIANFEM_HPP_ */
#define GEOS_UNUSED_VAR(...)
Mark an unused variable and silence compiler warnings.
Definition: GeosxMacros.hpp:83
#define GEOS_UNUSED_PARAM(X)
Mark an unused argument and silence compiler warnings.
Definition: GeosxMacros.hpp:71
The DoFManager is responsible for allocating global dofs, constructing sparsity patterns,...
Definition: DofManager.hpp:43
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
The NodeManager class provides an interface to ObjectManagerBase in order to manage node data.
Definition: NodeManager.hpp:45
The ParticleManager class provides an interface to ObjectManagerBase in order to manage ParticleRegio...
Class describing a file Path.
Definition: Path.hpp:32
SolidMechanicsMPM(const string &name, Group *const parent)
string getCatalogName() const override
virtual ~SolidMechanicsMPM() override
virtual bool execute(real64 const time_n, real64 const dt, integer const cycleNumber, integer const eventCounter, real64 const eventProgress, DomainPartition &domain) override
Group::wrapperMap::KeyIndex ViewKey
Type alias for KeyIndexT type used for wrapper lookups.
Definition: Group.hpp:1625
bool operator==(InputFlags const left, InputFlags const right)
Comparison operator for InputFlags enumeration.
Definition: InputFlags.hpp:146
ArrayView< T, 1 > arrayView1d
Alias for 1D array view.
Definition: DataTypes.hpp:220
Array< T, 2, PERMUTATION > array2d
Alias for 2D array.
Definition: DataTypes.hpp:232
LvArray::CRSMatrixView< T, COL_INDEX, localIndex const, LvArray::ChaiBuffer > CRSMatrixView
Alias for CRS Matrix View.
Definition: DataTypes.hpp:350
Array< T, 3, PERMUTATION > array3d
Alias for 3D array.
Definition: DataTypes.hpp:248
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
ArraySlice< T, 2, USD > arraySlice2d
Alias for 2D array slice.
Definition: DataTypes.hpp:240
double real64
64-bit floating point type.
Definition: DataTypes.hpp:139
ArraySlice< T, 1, USD > arraySlice1d
Alias for 1D array slice.
Definition: DataTypes.hpp:224
std::int32_t integer
Signed integer type.
Definition: DataTypes.hpp:122
std::size_t size_t
Unsigned size type.
Definition: DataTypes.hpp:119
ArrayView< T, 2, USD > arrayView2d
Alias for 2D array view.
Definition: DataTypes.hpp:236
GEOSX_LOCALINDEX_TYPE localIndex
Local index type (for indexing objects within an MPI partition).
Definition: DataTypes.hpp:125
Array< T, 1 > array1d
Alias for 1D array.
Definition: DataTypes.hpp:216
ArrayView< T, 3, USD > arrayView3d
Alias for 3D array view.
Definition: DataTypes.hpp:252