GEOS
ParticleSubRegionBase.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 Total, S.A
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_MESH_PARTICLESUBREGIONBASE_HPP_
21 #define GEOS_MESH_PARTICLESUBREGIONBASE_HPP_
22 
23 #include "mesh/ParticleType.hpp"
25 #include "mesh/mpiCommunications/CommunicationTools.hpp"
26 #include "mesh/mpiCommunications/MPI_iCommData.hpp"
27 #include "constitutive/solid/SolidBase.hpp"
28 #include "ToParticleRelation.hpp"
29 
30 namespace geos
31 {
32 
33 class ParticleManager;
34 class MeshLevel;
35 
36 namespace constitutive
37 {
38 class ConstitutiveBase;
39 }
40 
47 {
48 public:
49 
54 
60  ParticleSubRegionBase( string const & name, dataRepository::Group * const parent );
61 
66 
68 
73 
78  bool hasRVectors() const
79  { return m_hasRVectors; }
80 
87 
93  { return m_particleID; }
94 
99  { return m_particleID; }
100 
106  { return m_particleGroup; }
107 
112  { return m_particleGroup; }
113 
119  { return m_particleSurfaceFlag; }
120 
125  { return m_particleSurfaceFlag; }
126 
132  { return m_particleDamage; }
133 
138  { return m_particleDamage; }
139 
140 
146  { return m_particleStrengthScale; }
147 
152  { return m_particleStrengthScale; }
153 
154 
160  { return m_particleRank; }
161 
166  { return m_particleRank; }
167 
173  { return m_particleCenter; }
174 
179  { return m_particleCenter; }
180 
185  void setParticleCenter( array2d< real64 > particleCenter )
186  { m_particleCenter = particleCenter; }
187 
193  { return m_particleVelocity; }
194 
199  { return m_particleVelocity; }
200 
206  { return m_particleMaterialDirection; }
207 
212  { return m_particleMaterialDirection; }
213 
219  { return m_particleVolume; }
220 
225  { return m_particleVolume; }
226 
232  { return m_particleRVectors; }
233 
238  { return m_particleRVectors; }
239 
245  { return m_constitutiveModels; }
246 
251  { return m_constitutiveModels; }
252 
259  template< typename T = constitutive::ConstitutiveBase >
260  T const & getConstitutiveModel( string const & name ) const
261  { return m_constitutiveModels.getGroup< T >( name ); }
262 
266  template< typename T = constitutive::ConstitutiveBase >
267  T & getConstitutiveModel( string const & name )
268  { return m_constitutiveModels.getGroup< T >( name ); }
269 
275  { return m_particleType; }
276 
281  virtual void setParticleType( ParticleType const particleType )
282  { m_particleType = particleType; }
283 
289  { return m_numVerticesPerParticle; }
290 
295  virtual void setNumberOfVerticesPerParticle( ParticleType const particleType )
296  {
297  switch( particleType )
298  {
300  {
302  break;
303  }
304  case ParticleType::CPDI:
305  {
307  break;
308  }
309  default:
310  {
311  GEOS_ERROR( "Particle type \"" << m_particleType << "\" is not yet supported." );
312  break;
313  }
314  }
315  }
316 
322  { return m_neighborList; }
323 
329  { return m_neighborList; }
330 
332 
338  {
340  static constexpr char const * particleIDString() { return "particleID"; }
341 
343  static constexpr char const * particleGroupString() { return "particleGroup"; }
344 
346  static constexpr char const * particleSurfaceFlagString() { return "particleSurfaceFlag"; }
347 
349  static constexpr char const * particleDamageString() { return "particleDamage"; }
350 
352  static constexpr char const * particleStrengthScaleString() { return "particleStrengthScale"; }
353 
355  static constexpr char const * particleRankString() { return "particleRank"; }
356 
358  static constexpr char const * particleCenterString() { return "particleCenter"; }
359 
361  static constexpr char const * particleVelocityString() { return "particleVelocity"; }
362 
364  static constexpr char const * particleMaterialDirectionString() { return "particleMaterialDirection"; }
365 
367  static constexpr char const * particleVolumeString() { return "particleVolume"; }
368 
370  static constexpr char const * particleRVectorsString() { return "particleRVectors"; }
371  };
372 
378  {
380  static constexpr auto constitutiveModelsString() { return "ConstitutiveModels"; }
381  };
382 
390  unsigned int particlePack( buffer_type & buffer,
391  arrayView1d< localIndex > const & localIndices,
392  bool doPack ) const;
393 
400  void particleUnpack( buffer_type & buffer,
401  int const & startingIndex,
402  int const & numberOfIncomingParticles );
403 
408  void erase( std::set< localIndex > const & indicesToErase );
409 
414 
420  {
421  return m_activeParticleIndices.toView();
422  }
423 
427  void updateMaps();
428 
429 private:
431  dataRepository::Group m_constitutiveModels;
432 
433 protected:
436 
439 
442 
445 
448 
451 
454 
457 
460 
463 
466 
469 
472 
475 
478 
481 
482 };
483 
484 
485 } /* namespace geos */
486 
487 #endif /* GEOS_MESH_PARTICLESUBREGIONBASE_HPP_ */
#define GEOS_ERROR(msg)
Raise a hard error and terminate the program.
Definition: Logger.hpp:157
The ObjectManagerBase is the base object of all object managers in the mesh data hierachy.
void setHasRVectors(bool hasRVectors)
Set whether particle has r-vectors.
arrayView1d< real64 const > getParticleVolume() const
Get the current volume of each particle in this subregion.
OrderedVariableToManyParticleRelation m_neighborList
Neighbor list.
arrayView1d< globalIndex const > getParticleID() const
Get the global ID of each particle in this subregion.
arrayView2d< real64 > getParticleCenter()
Get the center of each particle in this subregion.
arrayView1d< int > getParticleSurfaceFlag()
Get the contact group of each particle in this subregion.
arrayView2d< real64 const > getParticleMaterialDirection() const
Get the material direction of each particle in this subregion.
void particleUnpack(buffer_type &buffer, int const &startingIndex, int const &numberOfIncomingParticles)
Unpacks the data of particles on this subregion.
arrayView1d< real64 > getParticleVolume()
Get the current volume of each particle in this subregion.
OrderedVariableToManyParticleRelation const & neighborList() const
Provide an immutable accessor to the particle neighbor list.
arrayView3d< real64 > getParticleRVectors()
Get the r-vectors of each particle in this subregion.
arrayView1d< int const > getParticleSurfaceFlag() const
Get the contact group of each particle in this subregion.
int m_numVerticesPerParticle
The number of vertices each particle has.
arrayView2d< real64 const > getParticleVelocity() const
Get the velocity of each particle in this subregion.
array1d< globalIndex > m_particleID
Member level field for the particle global ID.
arrayView2d< real64 const > getParticleCenter() const
Get the center of each particle in this subregion.
arrayView1d< int const > getParticleGroup() const
Get the contact group of each particle in this subregion.
void setActiveParticleIndices()
Identifies the local indices of non-ghost particles.
array3d< real64 > m_particleRVectors
current half-R-vectors (center to face)
T const & getConstitutiveModel(string const &name) const
Get a pointer to the constitutive model.
void setParticleCenter(array2d< real64 > particleCenter)
Set the center of each particle in this subregion.
array2d< real64 > m_particleVelocity
Member level field for the particle velocity.
bool m_hasRVectors
Boolean indicating whether the particle subregion contains particles needing r-vectors defining their...
T & getConstitutiveModel(string const &name)
Get a pointer to the constitutive model.
arrayView2d< real64 > getParticleVelocity()
Get the velocity of each particle in this subregion.
void updateMaps()
Updates the globalToLocal and localToGlobal maps.
arrayView2d< real64 > getParticleMaterialDirection()
Get the material direction of each particle in this subregion.
virtual void setParticleType(ParticleType const particleType)
Set the type of particle in this subregion.
ParticleType getParticleType() const
Get the type of particle in this subregion.
arrayView1d< real64 const > getParticleStrengthScale() const
Get the strength scale of each particle in this subregion.
arrayView1d< int const > getParticleRank() const
Get the ghost rank of each particle in this subregion.
bool hasRVectors() const
Get whether particle has r-vectors.
array1d< real64 > m_particleDamage
Member level field for the particle damage.
SortedArrayView< localIndex const > const activeParticleIndices() const
Returns the local indices of all non-ghost particles.
arrayView1d< real64 const > getParticleDamage() const
Get the damage of each particle in this subregion.
~ParticleSubRegionBase()
Destructor.
ParticleType m_particleType
Type of particles in this subregion.
array1d< int > m_particleGroup
Member level field for the particle contact group.
array2d< real64 > m_particleCenter
Member level field for the particle center.
int numberOfVerticesPerParticle() const
Get the number of vertices for particles in this subregion.
arrayView1d< int > getParticleGroup()
Get the contact group of each particle in this subregion.
array1d< real64 > m_particleStrengthScale
Member level field for the particle strength scale.
OrderedVariableToManyParticleRelation & neighborList()
Get a mutable accessor to the particle neighbor list.
arrayView1d< real64 > getParticleStrengthScale()
Get the strength scale of each particle in this subregion.
array1d< int > m_particleRank
Member level field for particle ghost ranks.
void erase(std::set< localIndex > const &indicesToErase)
Erases particle field data at the provided local indices.
virtual void setNumberOfVerticesPerParticle(ParticleType const particleType)
Set the number of vertices for particles in this subregion.
array2d< real64 > m_particleMaterialDirection
Member level field for the particle material direction.
arrayView1d< int > getParticleRank()
Get the ghost rank of each particle in this subregion.
unsigned int particlePack(buffer_type &buffer, arrayView1d< localIndex > const &localIndices, bool doPack) const
Packs the data of particles on this subregion.
array1d< real64 > m_particleVolume
Member level field for the current particle volume.
SortedArray< localIndex > m_activeParticleIndices
Indices of particles that are not ghosts.
ParticleSubRegionBase(string const &name, dataRepository::Group *const parent)
Constructor for this class.
array1d< int > m_particleSurfaceFlag
Member level field for the particle surface flag.
arrayView3d< real64 const > getParticleRVectors() const
Get the r-vectors of each particle in this subregion.
arrayView1d< real64 > getParticleDamage()
Get the damage of each particle in this subregion.
arrayView1d< globalIndex > getParticleID()
Get the global ID of each particle in this subregion.
dataRepository::Group const & getConstitutiveModels() const
Get the group in which the constitutive models of this subregion are registered.
dataRepository::Group & getConstitutiveModels()
Get the group in which the constitutive models of this subregion are registered.
T & getGroup(KEY const &key)
Return a reference to a sub-group of the current Group.
Definition: Group.hpp:336
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
Array< T, 3, PERMUTATION > array3d
Alias for 3D array.
Definition: DataTypes.hpp:208
ParticleType
Denotes type of particle shape/interpolation scheme.
@ SinglePoint
Single-point (delta dirac characteristic function)
@ CPDI
Convected particle domain interpolation, parallelepiped domain.
std::vector< buffer_unit_type > buffer_type
Type of storage for communication buffers.
Definition: DataTypes.hpp:116
LvArray::SortedArray< T, localIndex, LvArray::ChaiBuffer > SortedArray
A sorted array of local indices.
Definition: DataTypes.hpp:267
LvArray::SortedArrayView< T, localIndex, LvArray::ChaiBuffer > SortedArrayView
A sorted array view of local indices.
Definition: DataTypes.hpp:271
ArrayView< T, 2, USD > arrayView2d
Alias for 2D array view.
Definition: DataTypes.hpp:196
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
struct to serve as a container for group strings and keys
struct to serve as a container for variable strings and keys
struct to serve as a container for group strings and keys
A struct to serve as a container for variable strings and keys.
static constexpr char const * particleCenterString()
static constexpr char const * particleStrengthScaleString()
static constexpr char const * particleRVectorsString()
static constexpr char const * particleVolumeString()
static constexpr char const * particleMaterialDirectionString()
static constexpr char const * particleDamageString()
static constexpr char const * particleSurfaceFlagString()
static constexpr char const * particleVelocityString()
static constexpr char const * particleGroupString()
static constexpr char const * particleIDString()
static constexpr char const * particleRankString()