GEOS
SolidMechanicsMPM.hpp
Go to the documentation of this file.
1 /*
2  * ------------------------------------------------------------------------------------------------------------
3  * SPDX-License-Identifier: LGPL-2.1-only
4  *
5  * Copyright (c) 2016-2024 Lawrence Livermore National Security LLC
6  * Copyright (c) 2018-2024 TotalEnergies
7  * Copyright (c) 2018-2024 The Board of Trustees of the Leland Stanford Junior University
8  * Copyright (c) 2023-2024 Chevron
9  * Copyright (c) 2019- GEOS/GEOSX Contributors
10  * All rights reserved
11  *
12  * See top level LICENSE, COPYRIGHT, CONTRIBUTORS, NOTICE, and ACKNOWLEDGEMENTS files for details.
13  * ------------------------------------------------------------------------------------------------------------
14  */
15 
20 #ifndef GEOS_PHYSICSSOLVERS_SOLIDMECHANICS_MPM_HPP_
21 #define GEOS_PHYSICSSOLVERS_SOLIDMECHANICS_MPM_HPP_
22 
24 #include "common/TimingMacros.hpp"
26 #include "kernels/ExplicitMPM.hpp"
27 #include "mesh/mpiCommunications/CommunicationTools.hpp"
28 #include "mesh/mpiCommunications/MPI_iCommData.hpp"
31 #include "MPMSolverFields.hpp"
32 
33 namespace geos
34 {
35 
36 class SpatialPartition;
37 
38 
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  string_array const & targetRegions,
154  string const & finiteElementName,
155  real64 const dt,
156  std::string const & elementListName );
157 
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 postInputInitialization() override final;
365 
366  std::vector< array2d< localIndex > > m_mappedNodes; // mappedNodes[subregion index][particle index][node index]. dims = {# of subregions,
367  // # of particles, # of nodes a particle on the subregion maps to}
368  std::vector< array2d< real64 > > m_shapeFunctionValues; // mappedNodes[subregion][particle][nodal shape function value]. dims = {# of
369  // subregions, # of particles, # of nodes a particle on the subregion maps to}
370  std::vector< array3d< real64 > > m_shapeFunctionGradientValues; // mappedNodes[subregion][particle][nodal shape function gradient
371  // value][direction]. dims = {# of subregions, # of particles, # of nodes
372  // a particle on the subregion maps to, 3}
373 
374  int m_solverProfiling;
375  std::vector< real64 > m_profilingTimes;
376  std::vector< std::string > m_profilingLabels;
377 
378  TimeIntegrationOption m_timeIntegrationOption;
379 
380  int m_prescribedBcTable;
381  array1d< int > m_boundaryConditionTypes; // TODO: Surely there's a way to have just one variable here
382  array2d< real64 > m_bcTable;
383 
384  int m_prescribedBoundaryFTable;
385  Path m_fTablePath;
386  int m_fTableInterpType;
387  array2d< real64 > m_fTable;
388  array1d< real64 > m_domainF;
389  array1d< real64 > m_domainL;
390 
391  int m_boxAverageHistory;
392  int m_reactionHistory;
393 
394  int m_needsNeighborList;
395  real64 m_neighborRadius;
396  int m_binSizeMultiplier;
397 
398  int m_useDamageAsSurfaceFlag;
399 
400  int m_cpdiDomainScaling;
401 
402  real64 m_smallMass;
403 
404  int m_numContactGroups, m_numContactFlags, m_numVelocityFields;
405  real64 m_separabilityMinDamage;
406  int m_treatFullyDamagedAsSingleField;
407  int m_surfaceDetection;
408  int m_damageFieldPartitioning;
409  int m_contactGapCorrection;
410  // int m_directionalOverlapCorrection;
411  real64 m_frictionCoefficient;
412 
413  int m_planeStrain;
414  int m_numDims;
415 
416  array1d< real64 > m_hEl; // Grid spacing in x-y-z
417  array1d< real64 > m_xLocalMin; // Minimum local grid coordinate including ghost nodes
418  array1d< real64 > m_xLocalMax; // Maximum local grid coordinate including ghost nodes
419  array1d< real64 > m_xLocalMinNoGhost; // Minimum local grid coordinate EXCLUDING ghost nodes
420  array1d< real64 > m_xLocalMaxNoGhost; // Maximum local grid coordinate EXCLUDING ghost nodes
421  array1d< real64 > m_xGlobalMin; // Minimum global grid coordinate excluding buffer nodes
422  array1d< real64 > m_xGlobalMax; // Maximum global grid coordinate excluding buffer nodes
423  array1d< real64 > m_partitionExtent; // Length of each edge of partition including buffer and ghost cells
424  array1d< real64 > m_domainExtent; // Length of each edge of global domain excluding buffer cells
425  array1d< int > m_nEl; // Number of elements in each grid direction including buffer and ghost cells
426  array3d< int > m_ijkMap; // Map from indices in each spatial dimension to local node ID
427 
428 private:
429  struct BinKey
430  {
431  localIndex regionIndex;
432  localIndex subRegionIndex;
433  localIndex binIndex;
434 
435  bool operator==( BinKey const & other ) const
436  {
437  return (regionIndex == other.regionIndex && subRegionIndex == other.subRegionIndex && binIndex == other.binIndex);
438  }
439  };
440 
441  struct BinKeyHash
442  {
443  std::size_t operator()( BinKey const & k ) const
444  {
445  using std::size_t;
446  using std::hash;
447 
448  // Compute individual hash values for first,
449  // second and third and combine them using XOR
450  // and bit shifting:
451  return ((std::hash< localIndex >()( k.regionIndex )
452  ^ (std::hash< localIndex >()( k.subRegionIndex ) << 1)) >> 1)
453  ^ (std::hash< localIndex >()( k.binIndex ) << 1);
454  }
455  };
456 
457  void setParticlesConstitutiveNames( ParticleSubRegionBase & subRegion ) const;
458 };
459 
461  "QuasiStatic",
462  "ImplicitDynamic",
463  "ExplicitDynamic" );
464 
466  "Outflow",
467  "Symmetry" );
468 
469 //**********************************************************************************************************************
470 //**********************************************************************************************************************
471 //**********************************************************************************************************************
472 
473 
474 } /* namespace geos */
475 
476 #endif /* GEOS_PHYSICSSOLVERS_SOLIDMECHANICS_SOLIDMECHANICSLAGRANGIANFEM_HPP_ */
#define GEOS_UNUSED_VAR(...)
Mark an unused variable and silence compiler warnings.
Definition: GeosxMacros.hpp:84
#define GEOS_UNUSED_PARAM(X)
Mark an unused argument and silence compiler warnings.
Definition: GeosxMacros.hpp:72
The DoFManager is responsible for allocating global dofs, constructing sparsity patterns,...
Definition: DofManager.hpp:44
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:42
The NodeManager class provides an interface to ObjectManagerBase in order to manage node data.
Definition: NodeManager.hpp:46
The ParticleManager class provides an interface to ObjectManagerBase in order to manage ParticleRegio...
Class describing a file Path.
Definition: Path.hpp:33
Base class for all physics solvers.
virtual void postInputInitialization() override final
SolidMechanicsMPM(const string &name, Group *const parent)
string getCatalogName() const override
virtual ~SolidMechanicsMPM() override
virtual void registerDataOnMesh(Group &meshBodies) override final
Register wrappers that contain data on the mesh objects.
virtual void initializePreSubGroups() override
Called by Initialize() prior to initializing sub-Groups.
virtual bool execute(real64 const time_n, real64 const dt, integer const cycleNumber, integer const eventCounter, real64 const eventProgress, DomainPartition &domain) override
void initialize()
Run initialization functions on this and all subgroups.
virtual void updateState(DomainPartition &domain) override final
Recompute all dependent quantities from primary variables (including constitutive models)
virtual real64 explicitStep(real64 const &time_n, real64 const &dt, integer const cycleNumber, DomainPartition &domain) override
Entry function for an explicit time integration step.
virtual real64 solverStep(real64 const &time_n, real64 const &dt, integer const cycleNumber, DomainPartition &domain) override
entry function to perform a solver step
Group::wrapperMap::KeyIndex ViewKey
Type alias for KeyIndexT type used for wrapper lookups.
Definition: Group.hpp:1664
bool operator==(InputFlags const left, InputFlags const right)
Comparison operator for InputFlags enumeration.
Definition: InputFlags.hpp:147
ArrayView< T, 1 > arrayView1d
Alias for 1D array view.
Definition: DataTypes.hpp:180
Array< T, 2, PERMUTATION > array2d
Alias for 2D array.
Definition: DataTypes.hpp:192
LvArray::CRSMatrixView< T, COL_INDEX, localIndex const, LvArray::ChaiBuffer > CRSMatrixView
Alias for CRS Matrix View.
Definition: DataTypes.hpp:310
Array< T, 3, PERMUTATION > array3d
Alias for 3D array.
Definition: DataTypes.hpp:208
ENUM_STRINGS(LinearSolverParameters::SolverType, "direct", "cg", "gmres", "fgmres", "bicgstab", "preconditioner")
Declare strings associated with enumeration values.
std::string string
String type.
Definition: DataTypes.hpp:91
ArraySlice< T, 2, USD > arraySlice2d
Alias for 2D array slice.
Definition: DataTypes.hpp:200
double real64
64-bit floating point type.
Definition: DataTypes.hpp:99
GEOS_LOCALINDEX_TYPE localIndex
Local index type (for indexing objects within an MPI partition).
Definition: DataTypes.hpp:85
ArraySlice< T, 1, USD > arraySlice1d
Alias for 1D array slice.
Definition: DataTypes.hpp:184
std::int32_t integer
Signed integer type.
Definition: DataTypes.hpp:82
std::size_t size_t
Unsigned size type.
Definition: DataTypes.hpp:79
ArrayView< T, 2, USD > arrayView2d
Alias for 2D array view.
Definition: DataTypes.hpp:196
std::vector< string > string_array
A 1-dimensional array of geos::string types.
Definition: DataTypes.hpp:393
Array< T, 1 > array1d
Alias for 1D array.
Definition: DataTypes.hpp:176
ArrayView< T, 3, USD > arrayView3d
Alias for 3D array view.
Definition: DataTypes.hpp:212
Structure to hold scoped key names.