GEOSX
ParticleSubRegionBase.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_MESH_PARTICLESUBREGIONBASE_HPP_
20 #define GEOSX_MESH_PARTICLESUBREGIONBASE_HPP_
21 
22 #include "mesh/ParticleType.hpp"
24 #include "mesh/mpiCommunications/CommunicationTools.hpp"
25 #include "mesh/mpiCommunications/MPI_iCommData.hpp"
26 #include "constitutive/solid/SolidBase.hpp"
27 #include "ToParticleRelation.hpp"
28 
29 namespace geos
30 {
31 
32 class ParticleManager;
33 class MeshLevel;
34 
35 namespace constitutive
36 {
37 class ConstitutiveBase;
38 }
39 
46 {
47 public:
48 
53 
59  ParticleSubRegionBase( string const & name, dataRepository::Group * const parent );
60 
65 
67 
72 
77  bool hasRVectors() const
78  { return m_hasRVectors; }
79 
86 
92  { return m_particleID; }
93 
98  { return m_particleID; }
99 
105  { return m_particleGroup; }
106 
111  { return m_particleGroup; }
112 
118  { return m_particleSurfaceFlag; }
119 
124  { return m_particleSurfaceFlag; }
125 
131  { return m_particleDamage; }
132 
137  { return m_particleDamage; }
138 
139 
145  { return m_particleStrengthScale; }
146 
151  { return m_particleStrengthScale; }
152 
153 
159  { return m_particleRank; }
160 
165  { return m_particleRank; }
166 
172  { return m_particleCenter; }
173 
178  { return m_particleCenter; }
179 
184  void setParticleCenter( array2d< real64 > particleCenter )
185  { m_particleCenter = particleCenter; }
186 
192  { return m_particleVelocity; }
193 
198  { return m_particleVelocity; }
199 
205  { return m_particleMaterialDirection; }
206 
211  { return m_particleMaterialDirection; }
212 
218  { return m_particleVolume; }
219 
224  { return m_particleVolume; }
225 
231  { return m_particleRVectors; }
232 
237  { return m_particleRVectors; }
238 
244  { return m_constitutiveModels; }
245 
250  { return m_constitutiveModels; }
251 
258  template< typename T = constitutive::ConstitutiveBase >
259  T const & getConstitutiveModel( string const & name ) const
260  { return m_constitutiveModels.getGroup< T >( name ); }
261 
265  template< typename T = constitutive::ConstitutiveBase >
266  T & getConstitutiveModel( string const & name )
267  { return m_constitutiveModels.getGroup< T >( name ); }
268 
274  { return m_particleType; }
275 
280  virtual void setParticleType( ParticleType const particleType )
281  { m_particleType = particleType; }
282 
288  { return m_numVerticesPerParticle; }
289 
294  virtual void setNumberOfVerticesPerParticle( ParticleType const particleType )
295  {
296  switch( particleType )
297  {
299  {
301  break;
302  }
303  case ParticleType::CPDI:
304  {
306  break;
307  }
308  default:
309  {
310  GEOS_ERROR( "Particle type \"" << m_particleType << "\" is not yet supported." );
311  break;
312  }
313  }
314  }
315 
321  { return m_neighborList; }
322 
328  { return m_neighborList; }
329 
331 
337  {
339  static constexpr char const * particleIDString() { return "particleID"; }
340 
342  static constexpr char const * particleGroupString() { return "particleGroup"; }
343 
345  static constexpr char const * particleSurfaceFlagString() { return "particleSurfaceFlag"; }
346 
348  static constexpr char const * particleDamageString() { return "particleDamage"; }
349 
351  static constexpr char const * particleStrengthScaleString() { return "particleStrengthScale"; }
352 
354  static constexpr char const * particleRankString() { return "particleRank"; }
355 
357  static constexpr char const * particleCenterString() { return "particleCenter"; }
358 
360  static constexpr char const * particleVelocityString() { return "particleVelocity"; }
361 
363  static constexpr char const * particleMaterialDirectionString() { return "particleMaterialDirection"; }
364 
366  static constexpr char const * particleVolumeString() { return "particleVolume"; }
367 
369  static constexpr char const * particleRVectorsString() { return "particleRVectors"; }
370  };
371 
377  {
379  static constexpr auto constitutiveModelsString() { return "ConstitutiveModels"; }
380  };
381 
389  unsigned int particlePack( buffer_type & buffer,
390  arrayView1d< localIndex > const & localIndices,
391  bool doPack ) const;
392 
399  void particleUnpack( buffer_type & buffer,
400  int const & startingIndex,
401  int const & numberOfIncomingParticles );
402 
407  void erase( std::set< localIndex > const & indicesToErase );
408 
413 
419  {
420  return m_activeParticleIndices.toView();
421  }
422 
426  void updateMaps();
427 
428 private:
430  dataRepository::Group m_constitutiveModels;
431 
432 protected:
435 
438 
441 
444 
447 
450 
453 
456 
459 
462 
465 
468 
471 
474 
477 
480 
481 };
482 
483 
484 } /* namespace geos */
485 
486 #endif /* GEOSX_MESH_PARTICLESUBREGIONBASE_HPP_ */
#define GEOS_ERROR(msg)
Raise a hard error and terminate the program.
Definition: Logger.hpp:122
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:333
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
Array< T, 3, PERMUTATION > array3d
Alias for 3D array.
Definition: DataTypes.hpp:248
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:156
LvArray::SortedArray< T, localIndex, LvArray::ChaiBuffer > SortedArray
A sorted array of local indices.
Definition: DataTypes.hpp:307
LvArray::SortedArrayView< T, localIndex, LvArray::ChaiBuffer > SortedArrayView
A sorted array view of local indices.
Definition: DataTypes.hpp:311
ArrayView< T, 2, USD > arrayView2d
Alias for 2D array view.
Definition: DataTypes.hpp:236
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
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()