GEOS
ParticleManager.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_PARTICLEREGIONMANAGER_HPP
21 #define GEOS_MESH_PARTICLEREGIONMANAGER_HPP
22 
23 #include "generators/ParticleBlock.hpp"
25 #include "constitutive/ConstitutiveManager.hpp"
26 #include "ParticleRegion.hpp"
27 #include "ParticleSubRegion.hpp"
30 
31 namespace geos
32 {
33 
34 class MeshManager;
35 class DomainPartition;
36 
43 {
44 public:
45 
50  {
52  static constexpr auto particleRegionsGroup() { return "particleRegionsGroup"; }
53  };
54 
59  template< typename VIEWTYPE >
61 
67  template< typename VIEWTYPE >
69 
75  template< typename VIEWTYPE >
77 
82  template< typename VIEWTYPE >
84 
90  template< typename VIEWTYPE >
92 
97  template< typename CONSTITUTIVE_TYPE >
99 
104  static string catalogName()
105  { return "ParticleManager"; }
106 
111  virtual string getCatalogName() const override final
112  { return ParticleManager::catalogName(); }
113 
119  ParticleManager( string const & name, Group * const parent );
120 
124  virtual ~ParticleManager() override;
125 
130  template< typename T = ParticleSubRegionBase >
132  {
133  localIndex numParticle = 0;
134  this->forParticleSubRegions< T >( [&]( ParticleSubRegionBase const & particleSubRegion )
135  {
136  numParticle += particleSubRegion.size();
137  } );
138  return numParticle;
139  }
140 
141 // void Initialize( ){}
142 
147  void generateMesh( ParticleBlockManagerABC & particleBlockManager );
148 
155  virtual Group * createChild( string const & childKey, string const & childName ) override;
156 // virtual void ReadXMLsub( xmlWrapper::xmlNode const & targetNode ) override;
157 
161  virtual void expandObjectCatalogs() override;
162 
169  virtual void setSchemaDeviations( xmlWrapper::xmlNode schemaRoot,
170  xmlWrapper::xmlNode schemaParent,
171  integer documentationType ) override;
172 
173  using Group::resize;
174 
181  void resize( integer_array const & numParticles,
182  string_array const & regionNames,
183  string_array const & particleTypes );
184 
188  virtual void setMaxGlobalIndex() override final;
189 
194  subGroupMap const & getRegions() const
195  {
196  return this->getGroup( groupKeyStruct::particleRegionsGroup() ).getSubGroups();
197  }
198 
204  {
205  return this->getGroup( groupKeyStruct::particleRegionsGroup() ).getSubGroups();
206  }
207 
213  template< typename T=ParticleRegionBase, typename KEY_TYPE=void >
214  T const & getRegion( KEY_TYPE const & key ) const
215  {
216  return this->getGroup( groupKeyStruct::particleRegionsGroup() ).getGroup< T >( key );
217  }
218 
224  template< typename T=ParticleRegionBase, typename KEY_TYPE=void >
225  T & getRegion( KEY_TYPE const & key )
226  {
227  return this->getGroup( groupKeyStruct::particleRegionsGroup() ).getGroup< T >( key );
228  }
229 
236  template< typename T=ParticleRegionBase >
237  bool hasRegion( string const & name ) const
238  {
239  return this->getGroup( groupKeyStruct::particleRegionsGroup() ).hasGroup< T >( name );
240  }
241 
247  {
248  return this->getRegions().size();
249  }
250 
256 
263  template< typename REGIONTYPE = ParticleRegionBase, typename ... REGIONTYPES, typename LAMBDA >
264  void forParticleRegions( LAMBDA && lambda )
265  {
266  this->getGroup( groupKeyStruct::particleRegionsGroup() ).forSubGroups< REGIONTYPE, REGIONTYPES... >( std::forward< LAMBDA >( lambda ) );
267  }
268 
275  template< typename REGIONTYPE = ParticleRegionBase, typename ... REGIONTYPES, typename LAMBDA >
276  void forParticleRegions( LAMBDA && lambda ) const
277  {
278  this->getGroup( groupKeyStruct::particleRegionsGroup() ).forSubGroups< REGIONTYPE, REGIONTYPES... >( std::forward< LAMBDA >( lambda ) );
279  }
280 
289  template< typename REGIONTYPE = ParticleRegionBase, typename ... REGIONTYPES, typename LOOKUP_CONTAINER, typename LAMBDA >
290  void forParticleRegions( LOOKUP_CONTAINER const & targetRegions, LAMBDA && lambda )
291  {
292  this->getGroup( groupKeyStruct::particleRegionsGroup() ).forSubGroups< REGIONTYPE, REGIONTYPES... >( targetRegions, std::forward< LAMBDA >( lambda ) );
293  }
294 
303  template< typename REGIONTYPE = ParticleRegionBase, typename ... REGIONTYPES, typename LOOKUP_CONTAINER, typename LAMBDA >
304  void forParticleRegions( LOOKUP_CONTAINER const & targetRegions, LAMBDA && lambda ) const
305  {
306  this->getGroup( groupKeyStruct::particleRegionsGroup() ).forSubGroups< REGIONTYPE, REGIONTYPES... >( targetRegions, std::forward< LAMBDA >( lambda ) );
307  }
308 
314  template< typename LAMBDA >
315  void forParticleRegionsComplete( LAMBDA lambda ) const
316  {
317  forParticleRegionsComplete< ParticleRegion >( std::forward< LAMBDA >( lambda ) );
318  }
319 
325  template< typename LAMBDA >
326  void forParticleRegionsComplete( LAMBDA lambda )
327  {
328  forParticleRegionsComplete< ParticleRegion >( std::forward< LAMBDA >( lambda ) );
329  }
330 
337  template< typename REGIONTYPE, typename ... REGIONTYPES, typename LAMBDA >
338  void forParticleRegionsComplete( LAMBDA lambda )
339  {
340  for( localIndex er=0; er<this->numRegions(); ++er )
341  {
342  ParticleRegionBase & particleRegion = this->getRegion( er );
343 
344  Group::applyLambdaToContainer< REGIONTYPE, REGIONTYPES... >( particleRegion, [&]( auto & castedRegion )
345  {
346  lambda( er, castedRegion );
347  } );
348  }
349  }
350 
357  template< typename REGIONTYPE, typename ... REGIONTYPES, typename LAMBDA >
358  void forParticleRegionsComplete( LAMBDA lambda ) const
359  {
360  for( localIndex er=0; er<this->numRegions(); ++er )
361  {
362  ParticleRegionBase const & particleRegion = this->getRegion( er );
363 
364  Group::applyLambdaToContainer< REGIONTYPE, REGIONTYPES... >( particleRegion, [&]( auto const & castedRegion )
365  {
366  lambda( er, castedRegion );
367  } );
368  }
369  }
370 
378  template< typename LOOKUP_CONTAINER, typename LAMBDA >
379  void forParticleRegionsComplete( LOOKUP_CONTAINER const & targetRegions, LAMBDA lambda ) const
380  {
381  forParticleRegionsComplete< ParticleRegion >( targetRegions, std::forward< LAMBDA >( lambda ) );
382  }
383 
391  template< typename LOOKUP_CONTAINER, typename LAMBDA >
392  void forParticleRegionsComplete( LOOKUP_CONTAINER const & targetRegions, LAMBDA lambda )
393  {
394  forParticleRegionsComplete< ParticleRegion >( targetRegions, std::forward< LAMBDA >( lambda ) );
395  }
396 
405  template< typename REGIONTYPE, typename ... REGIONTYPES, typename LOOKUP_CONTAINER, typename LAMBDA >
406  void forParticleRegionsComplete( LOOKUP_CONTAINER const & targetRegions, LAMBDA lambda )
407  {
408  forParticleRegions< REGIONTYPE, REGIONTYPES... >( targetRegions, [&] ( localIndex const targetIndex,
409  auto & particleRegion )
410  {
411  lambda( targetIndex, particleRegion.getIndexInParent(), particleRegion );
412  } );
413  }
414 
423  template< typename REGIONTYPE, typename ... REGIONTYPES, typename LOOKUP_CONTAINER, typename LAMBDA >
424  void forParticleRegionsComplete( LOOKUP_CONTAINER const & targetRegions, LAMBDA lambda ) const
425  {
426  forParticleRegions< REGIONTYPE, REGIONTYPES... >( targetRegions, [&] ( localIndex const targetIndex,
427  auto const & particleRegion )
428  {
429  lambda( targetIndex, particleRegion.getIndexInParent(), particleRegion );
430  } );
431  }
432 
438  template< typename LAMBDA >
439  void forParticleSubRegions( LAMBDA && lambda )
440  {
441  forParticleSubRegions< ParticleSubRegion >( std::forward< LAMBDA >( lambda ) );
442  }
443 
450  template< typename LAMBDA >
451  void forParticleSubRegions( LAMBDA && lambda ) const
452  {
453  forParticleSubRegions< ParticleSubRegion >( std::forward< LAMBDA >( lambda ) );
454  }
455 
463  template< typename LOOKUP_CONTAINER, typename LAMBDA >
464  void forParticleSubRegions( LOOKUP_CONTAINER const & targetRegions, LAMBDA && lambda )
465  {
466  forParticleSubRegions< ParticleSubRegion >( targetRegions, std::forward< LAMBDA >( lambda ) );
467  }
468 
476  template< typename LOOKUP_CONTAINER, typename LAMBDA >
477  void forParticleSubRegions( LOOKUP_CONTAINER const & targetRegions, LAMBDA && lambda ) const
478  {
479  forParticleSubRegions< ParticleSubRegion >( targetRegions, std::forward< LAMBDA >( lambda ) );
480  }
481 
488  template< typename SUBREGIONTYPE, typename ... SUBREGIONTYPES, typename LAMBDA >
489  void forParticleSubRegions( LAMBDA && lambda )
490  {
491  forParticleSubRegionsComplete< SUBREGIONTYPE, SUBREGIONTYPES... >(
492  [lambda = std::forward< LAMBDA >( lambda )]( localIndex const,
493  localIndex const,
495  auto & subRegion )
496  {
497  lambda( subRegion );
498  }
499  );
500  }
501 
508  template< typename SUBREGIONTYPE, typename ... SUBREGIONTYPES, typename LAMBDA >
509  void forParticleSubRegions( LAMBDA && lambda ) const
510  {
511  forParticleSubRegionsComplete< SUBREGIONTYPE, SUBREGIONTYPES... >(
512  [lambda = std::forward< LAMBDA >( lambda )]( localIndex const,
513  localIndex const,
514  ParticleRegionBase const &,
515  auto const & subRegion )
516  {
517  lambda( subRegion );
518  } );
519  }
520 
529  template< typename SUBREGIONTYPE, typename ... SUBREGIONTYPES, typename LOOKUP_CONTAINER, typename LAMBDA >
530  void forParticleSubRegions( LOOKUP_CONTAINER const & targetRegions, LAMBDA && lambda )
531  {
532  forParticleSubRegionsComplete< SUBREGIONTYPE, SUBREGIONTYPES... >( targetRegions,
533  [lambda = std::forward< LAMBDA >( lambda )]( localIndex const targetIndex,
534  localIndex const,
535  localIndex const,
537  auto & subRegion )
538  {
539  lambda( targetIndex, subRegion );
540  } );
541  }
542 
551  template< typename SUBREGIONTYPE, typename ... SUBREGIONTYPES, typename LOOKUP_CONTAINER, typename LAMBDA >
552  void forParticleSubRegions( LOOKUP_CONTAINER const & targetRegions, LAMBDA && lambda ) const
553  {
554  forParticleSubRegionsComplete< SUBREGIONTYPE, SUBREGIONTYPES... >( targetRegions,
555  [lambda = std::forward< LAMBDA >( lambda )]( localIndex const targetIndex,
556  localIndex const,
557  localIndex const,
558  ParticleRegionBase const &,
559  auto const & subRegion )
560  {
561  lambda( targetIndex, subRegion );
562  } );
563  }
564 
570  template< typename LAMBDA >
571  void forParticleSubRegionsComplete( LAMBDA && lambda ) const
572  {
573  forParticleSubRegionsComplete< ParticleSubRegion >( std::forward< LAMBDA >( lambda ) );
574  }
575 
581  template< typename LAMBDA >
582  void forParticleSubRegionsComplete( LAMBDA && lambda )
583  {
584  forParticleSubRegionsComplete< ParticleSubRegion >( std::forward< LAMBDA >( lambda ) );
585  }
586 
594  template< typename LOOKUP_CONTAINER, typename LAMBDA >
595  void forParticleSubRegionsComplete( LOOKUP_CONTAINER const & targetRegions, LAMBDA && lambda )
596  {
597  forParticleSubRegionsComplete< ParticleSubRegion >( targetRegions, std::forward< LAMBDA >( lambda ) );
598  }
599 
607  template< typename LOOKUP_CONTAINER, typename LAMBDA >
608  void forParticleSubRegionsComplete( LOOKUP_CONTAINER const & targetRegions, LAMBDA && lambda ) const
609  {
610  forParticleSubRegionsComplete< ParticleSubRegion >( targetRegions, std::forward< LAMBDA >( lambda ) );
611  }
612 
619  template< typename SUBREGIONTYPE, typename ... SUBREGIONTYPES, typename LAMBDA >
620  void forParticleSubRegionsComplete( LAMBDA && lambda )
621  {
622  for( localIndex er=0; er<this->numRegions(); ++er )
623  {
624  ParticleRegionBase & particleRegion = this->getRegion( er );
625 
626  for( localIndex esr=0; esr<particleRegion.numSubRegions(); ++esr )
627  {
628  ParticleSubRegionBase & subRegion = particleRegion.getSubRegion( esr );
629 
630  Group::applyLambdaToContainer< SUBREGIONTYPE, SUBREGIONTYPES... >( subRegion, [&]( auto & castedSubRegion )
631  {
632  lambda( er, esr, particleRegion, castedSubRegion );
633  } );
634  }
635  }
636  }
637 
644  template< typename SUBREGIONTYPE, typename ... SUBREGIONTYPES, typename LAMBDA >
645  void forParticleSubRegionsComplete( LAMBDA && lambda ) const
646  {
647  for( localIndex er=0; er<this->numRegions(); ++er )
648  {
649  ParticleRegionBase const & particleRegion = this->getRegion( er );
650 
651  for( localIndex esr=0; esr<particleRegion.numSubRegions(); ++esr )
652  {
653  ParticleSubRegionBase const & subRegion = particleRegion.getSubRegion( esr );
654 
655  Group::applyLambdaToContainer< SUBREGIONTYPE, SUBREGIONTYPES... >( subRegion, [&]( auto const & castedSubRegion )
656  {
657  lambda( er, esr, particleRegion, castedSubRegion );
658  } );
659  }
660  }
661  }
662 
671  template< typename SUBREGIONTYPE, typename ... SUBREGIONTYPES, typename LOOKUP_CONTAINER, typename LAMBDA >
672  void forParticleSubRegionsComplete( LOOKUP_CONTAINER const & targetRegions, LAMBDA && lambda )
673  {
674  forParticleRegions( targetRegions, [&] ( localIndex const targetIndex, ParticleRegionBase & particleRegion )
675  {
676  localIndex const er = particleRegion.getIndexInParent();
677 
678  if( er>-1 )
679  {
680  for( localIndex esr=0; esr<particleRegion.numSubRegions(); ++esr )
681  {
682  ParticleSubRegionBase & subRegion = particleRegion.getSubRegion( esr );
683 
684  Group::applyLambdaToContainer< SUBREGIONTYPE, SUBREGIONTYPES... >( subRegion, [&]( auto & castedSubRegion )
685  {
686  lambda( targetIndex, er, esr, particleRegion, castedSubRegion );
687  } );
688  }
689  }
690  } );
691  }
692 
701  template< typename SUBREGIONTYPE, typename ... SUBREGIONTYPES, typename LOOKUP_CONTAINER, typename LAMBDA >
702  void forParticleSubRegionsComplete( LOOKUP_CONTAINER const & targetRegions, LAMBDA && lambda ) const
703  {
704  forParticleRegions( targetRegions, [&] ( localIndex const targetIndex, ParticleRegionBase const & particleRegion )
705  {
706  localIndex const er = particleRegion.getIndexInParent();
707 
708  if( er>-1 )
709  {
710  for( localIndex esr=0; esr<particleRegion.numSubRegions(); ++esr )
711  {
712  ParticleSubRegionBase const & subRegion = particleRegion.getSubRegion( esr );
713 
714  Group::applyLambdaToContainer< SUBREGIONTYPE, SUBREGIONTYPES... >( subRegion, [&]( auto const & castedSubRegion )
715  {
716  lambda( targetIndex, er, esr, particleRegion, castedSubRegion );
717  } );
718  }
719  }
720  } );
721  }
722 
723 
730  template< typename FIELD_TRAIT >
731  ParticleViewAccessor< traits::ViewTypeConst< typename FIELD_TRAIT::type > >
732  constructFieldAccessor( string const & neighborName = string() ) const;
733 
741  template< typename VIEWTYPE, typename LHS=VIEWTYPE >
742  ParticleViewAccessor< LHS >
743  constructViewAccessor( string const & name, string const & neighborName = string() ) const;
744 
752  template< typename VIEWTYPE, typename LHS=VIEWTYPE >
753  ParticleViewAccessor< LHS >
754  constructViewAccessor( string const & name, string const & neighborName = string() );
755 
765  template< typename T, int NDIM, typename PERM = defaultLayout< NDIM > >
766  ParticleViewAccessor< ArrayView< T const, NDIM, getUSD< PERM > > >
767  constructArrayViewAccessor( string const & name, string const & neighborName = string() ) const;
768 
776  template< typename VIEWTYPE >
777  ParticleViewAccessor< ReferenceWrapper< VIEWTYPE > >
778  constructReferenceAccessor( string const & viewName, string const & neighborName = string() ) const;
779 
787  template< typename VIEWTYPE >
788  ParticleViewAccessor< ReferenceWrapper< VIEWTYPE > >
789  constructReferenceAccessor( string const & viewName, string const & neighborName = string() );
790 
798  template< typename VIEWTYPE, typename LHS=VIEWTYPE >
799  MaterialViewAccessor< LHS >
800  constructFullMaterialViewAccessor( string const & viewName,
801  constitutive::ConstitutiveManager const & cm ) const;
802 
810  template< typename VIEWTYPE, typename LHS=VIEWTYPE >
811  MaterialViewAccessor< LHS >
812  constructFullMaterialViewAccessor( string const & viewName,
813  constitutive::ConstitutiveManager const & cm );
814 
825  template< typename FIELD_TRAIT >
826  ParticleViewAccessor< traits::ViewTypeConst< typename FIELD_TRAIT::type > >
828  arrayView1d< string const > const & materialNames,
829  bool const allowMissingViews = false ) const;
830 
840  template< typename MATERIAL_TYPE, typename FIELD_TRAIT >
841  ParticleViewAccessor< traits::ViewTypeConst< typename FIELD_TRAIT::type > >
842  constructMaterialFieldAccessor( bool const allowMissingViews = false ) const;
843 
855  template< typename VIEWTYPE, typename LHS=VIEWTYPE >
856  ParticleViewAccessor< LHS >
857  constructMaterialViewAccessor( string const & viewName,
858  arrayView1d< string const > const & regionNames,
859  string const & materialKeyName,
860  bool const allowMissingViews = false ) const;
861 
873  template< typename VIEWTYPE, typename LHS=VIEWTYPE >
874  ParticleViewAccessor< LHS >
875  constructMaterialViewAccessor( string const & viewName,
876  arrayView1d< string const > const & regionNames,
877  string const & materialKeyName,
878  bool const allowMissingViews = false );
879 
891  template< typename T, int NDIM, typename PERM = defaultLayout< NDIM > >
892  ParticleViewAccessor< ArrayView< T const, NDIM, getUSD< PERM > > >
893  constructMaterialArrayViewAccessor( string const & viewName,
894  arrayView1d< string const > const & regionNames,
895  string const & materialKeyName,
896  bool const allowMissingViews = false ) const;
897 
906  template< typename MATERIALTYPE, typename VIEWTYPE, typename LHS=VIEWTYPE >
907  ParticleViewAccessor< LHS >
908  constructMaterialViewAccessor( string const & viewName ) const;
909 
920  template< typename MATERIALTYPE, typename T, int NDIM, typename PERM = defaultLayout< NDIM > >
921  ParticleViewAccessor< ArrayView< T const, NDIM, getUSD< PERM > > >
922  constructMaterialArrayViewAccessor( string const & viewName ) const;
923 
930  template< typename CONSTITUTIVE_TYPE >
931  ConstitutiveRelationAccessor< CONSTITUTIVE_TYPE >
932  constructFullConstitutiveAccessor( constitutive::ConstitutiveManager const & cm ) const;
933 
934 
941  template< typename CONSTITUTIVE_TYPE >
942  ConstitutiveRelationAccessor< CONSTITUTIVE_TYPE >
943  constructFullConstitutiveAccessor( constitutive::ConstitutiveManager const & cm );
944 
945  using Group::packSize;
946  using Group::pack;
950 
957  int PackSize( string_array const & wrapperNames,
958  ParticleViewAccessor< arrayView1d< localIndex > > const & packList ) const;
959 
967  int Pack( buffer_unit_type * & buffer,
968  string_array const & wrapperNames,
969  ParticleViewAccessor< arrayView1d< localIndex > > const & packList ) const;
970 
973 
980  int Unpack( buffer_unit_type const * & buffer,
982 
989  int Unpack( buffer_unit_type const * & buffer,
991 
998 
1006  ParticleViewAccessor< arrayView1d< localIndex > > const & packList ) const;
1007 
1014  int UnpackGlobalMaps( buffer_unit_type const * & buffer,
1016 
1020  void updateMaps();
1021 
1022 
1023 private:
1024 
1032  template< bool DOPACK >
1033  int PackPrivate( buffer_unit_type * & buffer,
1034  string_array const & wrapperNames,
1035  ParticleViewAccessor< arrayView1d< localIndex > > const & viewAccessor ) const;
1036 
1043  template< bool DOPACK >
1044  int PackGlobalMapsPrivate( buffer_unit_type * & buffer,
1045  ParticleViewAccessor< arrayView1d< localIndex > > const & viewAccessor ) const;
1046 
1053  template< typename T >
1054  int unpackPrivate( buffer_unit_type const * & buffer,
1055  T & packList );
1056 
1060  ParticleManager( const ParticleManager & );
1061 
1066  ParticleManager & operator=( const ParticleManager & );
1067 
1068 };
1069 
1070 
1071 template< typename VIEWTYPE, typename LHS >
1073 ParticleManager::constructViewAccessor( string const & viewName, string const & neighborName ) const
1074 {
1075  ParticleViewAccessor< LHS > viewAccessor;
1076  viewAccessor.resize( numRegions() );
1077  for( typename dataRepository::indexType kReg=0; kReg<numRegions(); ++kReg )
1078  {
1079  ParticleRegionBase const & particleRegion = getRegion( kReg );
1080  viewAccessor[kReg].resize( particleRegion.numSubRegions() );
1081 
1082  for( typename dataRepository::indexType kSubReg = 0; kSubReg < particleRegion.numSubRegions(); ++kSubReg )
1083  {
1084  Group const * group = &particleRegion.getSubRegion( kSubReg );
1085 
1086  if( !neighborName.empty() )
1087  {
1088  group = &group->getGroup( ObjectManagerBase::groupKeyStruct::neighborDataString() ).getGroup( neighborName );
1089  }
1090 
1091  dataRepository::Wrapper< VIEWTYPE > const * const wrapper = group->getWrapperPointer< VIEWTYPE >( viewName );
1092  if( wrapper )
1093  {
1094  viewAccessor[kReg][kSubReg] = wrapper->reference();
1095  }
1096  }
1097  }
1098  return viewAccessor;
1099 }
1100 
1101 
1102 template< typename VIEWTYPE, typename LHS >
1104 ParticleManager::constructViewAccessor( string const & viewName, string const & neighborName )
1105 {
1106  ParticleViewAccessor< LHS > viewAccessor;
1107  viewAccessor.resize( numRegions() );
1108  for( typename dataRepository::indexType kReg=0; kReg<numRegions(); ++kReg )
1109  {
1110  ParticleRegionBase & particleRegion = getRegion( kReg );
1111  viewAccessor[kReg].resize( particleRegion.numSubRegions() );
1112 
1113  for( typename dataRepository::indexType kSubReg = 0; kSubReg < particleRegion.numSubRegions(); ++kSubReg )
1114  {
1115  Group * group = &particleRegion.getSubRegion( kSubReg );
1116 
1117  if( !neighborName.empty() )
1118  {
1119  group = &group->getGroup( ObjectManagerBase::groupKeyStruct::neighborDataString() ).getGroup( neighborName );
1120  }
1121 
1122  dataRepository::Wrapper< VIEWTYPE > * const wrapper = group->getWrapperPointer< VIEWTYPE >( viewName );
1123  if( wrapper )
1124  {
1125  viewAccessor[kReg][kSubReg] = wrapper->reference();
1126  }
1127  }
1128  }
1129  return viewAccessor;
1130 }
1131 
1132 template< typename FIELD_TRAIT >
1134 ParticleManager::constructFieldAccessor( string const & neighborName ) const
1135 {
1136  return constructViewAccessor< typename FIELD_TRAIT::type,
1137  traits::ViewTypeConst< typename FIELD_TRAIT::type > >( FIELD_TRAIT::key(), neighborName );
1138 }
1139 
1140 template< typename T, int NDIM, typename PERM >
1142 ParticleManager::constructArrayViewAccessor( string const & name, string const & neighborName ) const
1143 {
1144  return constructViewAccessor< Array< T, NDIM, PERM >,
1146  >( name, neighborName );
1147 }
1148 
1149 template< typename VIEWTYPE >
1151 ParticleManager::constructReferenceAccessor( string const & viewName, string const & neighborName ) const
1152 {
1154  viewAccessor.resize( numRegions() );
1155  for( typename dataRepository::indexType kReg=0; kReg<numRegions(); ++kReg )
1156  {
1157  ParticleRegionBase const & particleRegion = getRegion( kReg );
1158  viewAccessor[kReg].resize( particleRegion.numSubRegions() );
1159 
1160  for( typename dataRepository::indexType kSubReg=0; kSubReg<particleRegion.numSubRegions(); ++kSubReg )
1161  {
1162  Group const * group = &particleRegion.getSubRegion( kSubReg );
1163 
1164  if( !neighborName.empty() )
1165  {
1166  group = &group->getGroup( ObjectManagerBase::groupKeyStruct::neighborDataString() ).getGroup( neighborName );
1167  }
1168 
1169  if( group->hasWrapper( viewName ) )
1170  {
1171  viewAccessor[kReg][kSubReg].set( group->getReference< VIEWTYPE >( viewName ) );
1172  }
1173  }
1174  }
1175  return viewAccessor;
1176 }
1177 
1178 template< typename VIEWTYPE >
1180 ParticleManager::constructReferenceAccessor( string const & viewName, string const & neighborName )
1181 {
1183  viewAccessor.resize( numRegions() );
1184  for( typename dataRepository::indexType kReg=0; kReg<numRegions(); ++kReg )
1185  {
1186  ParticleRegionBase & particleRegion = getRegion( kReg );
1187  viewAccessor[kReg].resize( particleRegion.numSubRegions() );
1188 
1189  for( typename dataRepository::indexType kSubReg=0; kSubReg<particleRegion.numSubRegions(); ++kSubReg )
1190  {
1191  Group * group = &particleRegion.getSubRegion( kSubReg );
1192 
1193  if( !neighborName.empty() )
1194  {
1195  group = &group->getGroup( ObjectManagerBase::groupKeyStruct::neighborDataString() ).getGroup( neighborName );
1196  }
1197 
1198  if( group->hasWrapper( viewName ) )
1199  {
1200  viewAccessor[kReg][kSubReg].set( group->getReference< VIEWTYPE >( viewName ) );
1201  }
1202  }
1203  }
1204  return viewAccessor;
1205 }
1206 
1207 template< typename VIEWTYPE, typename LHS >
1210  constitutive::ConstitutiveManager const & cm ) const
1211 {
1212  MaterialViewAccessor< LHS > accessor;
1213  accessor.resize( numRegions() );
1214  for( localIndex kReg=0; kReg<numRegions(); ++kReg )
1215  {
1216  ParticleRegionBase const & particleRegion = getRegion( kReg );
1217  accessor[kReg].resize( particleRegion.numSubRegions() );
1218 
1219  for( localIndex kSubReg=0; kSubReg<particleRegion.numSubRegions(); ++kSubReg )
1220  {
1221  ParticleSubRegionBase const & subRegion = particleRegion.getSubRegion( kSubReg );
1222  dataRepository::Group const & constitutiveGroup = subRegion.getConstitutiveModels();
1223 
1224  accessor[kReg][kSubReg].resize( cm.numSubGroups() );
1225 
1226  for( localIndex matIndex=0; matIndex<cm.numSubGroups(); ++matIndex )
1227  {
1228  string const & constitutiveName = cm.getGroup( matIndex ).getName();
1229  dataRepository::Group const * const constitutiveRelation = constitutiveGroup.getGroupPointer( constitutiveName );
1230  if( constitutiveRelation != nullptr )
1231  {
1232  dataRepository::Wrapper< VIEWTYPE > const * const wrapper = constitutiveRelation->getWrapperPointer< VIEWTYPE >( viewName );
1233  if( wrapper )
1234  {
1235  accessor[kReg][kSubReg][matIndex] = wrapper->reference();
1236  }
1237  }
1238  }
1239  }
1240  }
1241  return accessor;
1242 }
1243 
1244 template< typename VIEWTYPE, typename LHS >
1247  constitutive::ConstitutiveManager const & cm )
1248 {
1249  MaterialViewAccessor< LHS > accessor;
1250  accessor.resize( numRegions() );
1251  for( localIndex kReg=0; kReg<numRegions(); ++kReg )
1252  {
1253  ParticleRegionBase & particleRegion = getRegion( kReg );
1254  accessor[kReg].resize( particleRegion.numSubRegions() );
1255 
1256  for( localIndex kSubReg=0; kSubReg<particleRegion.numSubRegions(); ++kSubReg )
1257  {
1258  ParticleSubRegionBase & subRegion = particleRegion.getSubRegion( kSubReg );
1259  dataRepository::Group & constitutiveGroup = subRegion.getConstitutiveModels();
1260 
1261  accessor[kReg][kSubReg].resize( cm.numSubGroups() );
1262 
1263  for( localIndex matIndex=0; matIndex<cm.numSubGroups(); ++matIndex )
1264  {
1265  string const & constitutiveName = cm.getGroup( matIndex ).getName();
1266  dataRepository::Group * const constitutiveRelation = constitutiveGroup.getGroupPointer( constitutiveName );
1267  if( constitutiveRelation != nullptr )
1268  {
1269  dataRepository::Wrapper< VIEWTYPE > * const wrapper = constitutiveRelation->getWrapperPointer< VIEWTYPE >( viewName );
1270  if( wrapper )
1271  {
1272  accessor[kReg][kSubReg][matIndex] = wrapper->reference();
1273  }
1274  }
1275  }
1276  }
1277  }
1278  return accessor;
1279 }
1280 
1281 template< typename VIEWTYPE, typename LHS >
1284  arrayView1d< string const > const & regionNames,
1285  string const & materialKeyName,
1286  bool const allowMissingViews ) const
1287 {
1288  ParticleViewAccessor< LHS > accessor;
1289 
1290  // Resize the accessor to all regions and subregions
1291  accessor.resize( numRegions() );
1292  for( localIndex kReg = 0; kReg < numRegions(); ++kReg )
1293  {
1294  accessor[kReg].resize( getRegion( kReg ).numSubRegions() );
1295  }
1296 
1297  subGroupMap const & regionMap = getRegions();
1298 
1299  // Loop only over regions named and populate according to given material names
1300  for( localIndex k = 0; k < regionNames.size(); ++k )
1301  {
1302  localIndex const er = regionMap.getIndex( regionNames[k] );
1303  if( er >=0 )
1304  {
1305  GEOS_ERROR_IF_EQ_MSG( er, subGroupMap::KeyIndex::invalid_index, "Region not found: " << regionNames[k] );
1306  ParticleRegionBase const & region = getRegion( er );
1307 
1308  region.forParticleSubRegionsIndex( [&]( localIndex const esr,
1309  ParticleSubRegionBase const & subRegion )
1310  {
1311  string const & materialName = subRegion.getReference< string >( materialKeyName );
1312  dataRepository::Group const & constitutiveRelation = subRegion.getConstitutiveModel( materialName );
1313 
1314  dataRepository::Wrapper< VIEWTYPE > const * const wrapper = constitutiveRelation.getWrapperPointer< VIEWTYPE >( viewName );
1315  if( wrapper )
1316  {
1317  accessor[er][esr] = wrapper->reference();
1318  }
1319  else
1320  {
1321  GEOS_ERROR_IF( !allowMissingViews, "Material " << materialKeyName[k] << " does not contain " << viewName );
1322  }
1323  } );
1324  }
1325  }
1326  return accessor;
1327 }
1328 
1329 template< typename VIEWTYPE, typename LHS >
1332  arrayView1d< string const > const & regionNames,
1333  string const & materialKeyName,
1334  bool const allowMissingViews )
1335 {
1336  ParticleViewAccessor< LHS > accessor;
1337 
1338  // Resize the accessor to all regions and subregions
1339  accessor.resize( numRegions() );
1340  for( localIndex kReg = 0; kReg < numRegions(); ++kReg )
1341  {
1342  accessor[kReg].resize( getRegion( kReg ).numSubRegions() );
1343  }
1344 
1345  subGroupMap const & regionMap = getRegions();
1346 
1347  // Loop only over regions named and populate according to given material names
1348  for( localIndex k = 0; k < regionNames.size(); ++k )
1349  {
1350  localIndex const er = regionMap.getIndex( regionNames[k] );
1351  if( er >=0 )
1352  {
1353  GEOS_ERROR_IF_EQ_MSG( er, subGroupMap::KeyIndex::invalid_index, "Region not found: " << regionNames[k] );
1354  ParticleRegionBase & region = getRegion( er );
1355 
1356  region.forParticleSubRegionsIndex( [&]( localIndex const esr, ParticleSubRegionBase & subRegion )
1357  {
1358  string const & materialName = subRegion.getReference< string >( materialKeyName );
1359  dataRepository::Group const & constitutiveRelation = subRegion.getConstitutiveModel( materialName );
1360 
1361  dataRepository::Wrapper< VIEWTYPE > * const wrapper = constitutiveRelation.getWrapperPointer< VIEWTYPE >( viewName );
1362  if( wrapper )
1363  {
1364  accessor[er][esr] = wrapper->reference();
1365  }
1366  else
1367  {
1368  GEOS_ERROR_IF( !allowMissingViews, "Material " << materialName << " does not contain " << viewName );
1369  }
1370  } );
1371  }
1372  }
1373  return accessor;
1374 }
1375 
1376 template< typename FIELD_TRAIT >
1379  arrayView1d< string const > const & materialNames,
1380  bool const allowMissingViews ) const
1381 {
1382  return constructMaterialViewAccessor< typename FIELD_TRAIT::type,
1383  traits::ViewTypeConst< typename FIELD_TRAIT::type > >( FIELD_TRAIT::key(),
1384  regionNames,
1385  materialNames,
1386  allowMissingViews );
1387 }
1388 
1389 template< typename MATERIAL_TYPE, typename FIELD_TRAIT >
1391 ParticleManager::constructMaterialFieldAccessor( bool const allowMissingViews ) const
1392 {
1393  GEOS_UNUSED_VAR( allowMissingViews );
1394  return constructMaterialViewAccessor< MATERIAL_TYPE, typename FIELD_TRAIT::type,
1395  traits::ViewTypeConst< typename FIELD_TRAIT::type > >( FIELD_TRAIT::key() );
1396 }
1397 
1398 template< typename T, int NDIM, typename PERM >
1401  arrayView1d< string const > const & regionNames,
1402  string const & materialKeyName,
1403  bool const allowMissingViews ) const
1404 {
1405  return constructMaterialViewAccessor< Array< T, NDIM, PERM >, ArrayView< T const, NDIM, getUSD< PERM > > >( viewName,
1406  regionNames,
1407  materialKeyName,
1408  allowMissingViews );
1409 }
1410 
1411 template< typename MATERIALTYPE, typename VIEWTYPE, typename LHS >
1413 ParticleManager::constructMaterialViewAccessor( string const & viewName ) const
1414 {
1416 
1417  // Resize the accessor to all regions and subregions
1418  for( localIndex er = 0; er < numRegions(); ++er )
1419  {
1420  accessor[er].resize( getRegion( er ).numSubRegions() );
1421  }
1422 
1423  // Loop only over regions named and populate according to given material names
1424  for( localIndex er = 0; er < numRegions(); ++er )
1425  {
1426  ParticleRegionBase const & region = getRegion( er );
1427 
1428  region.forParticleSubRegionsIndex( [&]( localIndex const esr,
1429  ParticleSubRegionBase const & subRegion )
1430  {
1431  dataRepository::Group const & constitutiveGroup = subRegion.getConstitutiveModels();
1432 
1433  string materialName;
1434  constitutiveGroup.forSubGroups< MATERIALTYPE >( [&]( MATERIALTYPE const & constitutiveRelation )
1435  {
1436  materialName = constitutiveRelation.getName();
1437  if( constitutiveRelation.template hasWrapper( viewName ) ) //NOTE (matteo): I have added this check to allow for the view to be
1438  // missing. I am not sure this is the default behaviour we want though.
1439  {
1440  accessor[er][esr] = constitutiveRelation.template getReference< VIEWTYPE >( viewName );
1441  }
1442  } );
1443  } );
1444  }
1445  return accessor;
1446 }
1447 
1448 template< typename MATERIALTYPE, typename T, int NDIM, typename PERM >
1451 {
1452  return constructMaterialViewAccessor< MATERIALTYPE, Array< T, NDIM, PERM >, ArrayView< T const, NDIM, getUSD< PERM > > >( viewName );
1453 }
1454 
1455 template< typename CONSTITUTIVE_TYPE >
1457 ParticleManager::constructFullConstitutiveAccessor( constitutive::ConstitutiveManager const & cm ) const
1458 {
1460  accessor.resize( numRegions() );
1461  for( localIndex kReg=0; kReg<numRegions(); ++kReg )
1462  {
1463  ParticleRegionBase const & particleRegion = getRegion( kReg );
1464  accessor[kReg].resize( particleRegion.numSubRegions() );
1465 
1466  for( localIndex kSubReg=0; kSubReg<particleRegion.numSubRegions(); ++kSubReg )
1467  {
1468  ParticleSubRegionBase const & subRegion = particleRegion.getSubRegion( kSubReg );
1469  dataRepository::Group const & constitutiveGroup = subRegion.getConstitutiveModels();
1470  accessor[kReg][kSubReg].resize( cm.numSubGroups() );
1471 
1472  for( localIndex matIndex=0; matIndex<cm.numSubGroups(); ++matIndex )
1473  {
1474  string const & constitutiveName = cm.getGroup( matIndex ).getName();
1475 
1476  CONSTITUTIVE_TYPE * const
1477  constitutiveRelation = constitutiveGroup.getGroupPointer< CONSTITUTIVE_TYPE >( constitutiveName );
1478  if( constitutiveRelation != nullptr )
1479  {
1480  accessor[kReg][kSubReg][matIndex] = constitutiveRelation;
1481  }
1482  }
1483  }
1484  }
1485  return accessor;
1486 }
1487 
1488 template< typename CONSTITUTIVE_TYPE >
1490 ParticleManager::constructFullConstitutiveAccessor( constitutive::ConstitutiveManager const & cm )
1491 {
1493  accessor.resize( numRegions() );
1494  for( localIndex kReg=0; kReg<numRegions(); ++kReg )
1495  {
1496  ParticleRegionBase & particleRegion = getRegion( kReg );
1497  accessor[kReg].resize( particleRegion.numSubRegions() );
1498 
1499  for( localIndex kSubReg=0; kSubReg<particleRegion.numSubRegions(); ++kSubReg )
1500  {
1501  ParticleSubRegionBase & subRegion = particleRegion.getSubRegion( kSubReg );
1502  dataRepository::Group & constitutiveGroup = subRegion.getConstitutiveModels();
1503  accessor[kReg][kSubReg].resize( cm.numSubGroups() );
1504 
1505  for( localIndex matIndex=0; matIndex<cm.numSubGroups(); ++matIndex )
1506  {
1507  string const & constitutiveName = cm.getGroup( matIndex ).getName();
1508 
1509  CONSTITUTIVE_TYPE * const
1510  constitutiveRelation = constitutiveGroup.getGroupPointer< CONSTITUTIVE_TYPE >( constitutiveName );
1511  if( constitutiveRelation != nullptr )
1512  {
1513  accessor[kReg][kSubReg][matIndex] = constitutiveRelation;
1514  }
1515  }
1516  }
1517  }
1518  return accessor;
1519 }
1520 
1521 }
1522 #endif /* GEOS_MESH_PARTICLEREGIONMANAGER_HPP */
#define GEOS_UNUSED_VAR(...)
Mark an unused variable and silence compiler warnings.
Definition: GeosxMacros.hpp:84
#define GEOS_ERROR_IF_EQ_MSG(lhs, rhs, msg)
Raise a hard error if two values are equal.
Definition: Logger.hpp:211
#define GEOS_ERROR_IF(EXP, msg)
Conditionally raise a hard error and terminate the program.
Definition: Logger.hpp:142
constexpr static INDEX_TYPE invalid_index
the value of an invalid index
Definition: KeyIndexT.hpp:51
INDEX_TYPE size() const
function to return the number of entries stored
INDEX_TYPE getIndex(KEY_TYPE const &key) const
The ObjectManagerBase is the base object of all object managers in the mesh data hierachy.
virtual localIndex packGlobalMapsSize(arrayView1d< localIndex const > const &packList, integer const recursive) const
Computes the pack size of the global maps elements in the @ packList.
virtual localIndex unpack(buffer_unit_type const *&buffer, arrayView1d< localIndex > &packList, integer const recursive, bool onDevice, parallelDeviceEvents &events, MPI_Op op=MPI_REPLACE) override
Unpack a buffer.
virtual localIndex packGlobalMaps(buffer_unit_type *&buffer, arrayView1d< localIndex const > const &packList, integer const recursive) const
Packs the global maps elements in the @ packList.
virtual localIndex unpackGlobalMaps(buffer_unit_type const *&buffer, localIndex_array &packList, integer const recursive)
Unpacks the global maps from buffer.
Abstract base class for ParticleBlockManager.
The ParticleManager class provides an interface to ObjectManagerBase in order to manage ParticleRegio...
void forParticleSubRegionsComplete(LAMBDA &&lambda) const
This const function is used to launch kernel function over the particle subregions of all subregion t...
ConstitutiveRelationAccessor< CONSTITUTIVE_TYPE > constructFullConstitutiveAccessor(constitutive::ConstitutiveManager const &cm) const
Construct a ConstitutiveRelationAccessor.
void resize(integer_array const &numParticles, string_array const &regionNames, string_array const &particleTypes)
Set the number of particles for a set of particle regions.
virtual void setSchemaDeviations(xmlWrapper::xmlNode schemaRoot, xmlWrapper::xmlNode schemaParent, integer documentationType) override
Inform the schema generator of any deviations between the xml and GEOS data structures.
virtual void expandObjectCatalogs() override
Expand any catalogs in the data structure.
void forParticleRegions(LOOKUP_CONTAINER const &targetRegions, LAMBDA &&lambda) const
This const function is used to launch kernel function over the target particle regions with region ty...
void forParticleSubRegions(LAMBDA &&lambda) const
This const function is used to launch kernel function over the particle subregions of all the subregi...
void updateMaps()
Updates the globalToLocal and localToGlobal maps.
MaterialViewAccessor< LHS > constructFullMaterialViewAccessor(string const &viewName, constitutive::ConstitutiveManager const &cm) const
This is a const function to construct a MaterialViewAccessor to access the material data.
void forParticleSubRegions(LOOKUP_CONTAINER const &targetRegions, LAMBDA &&lambda)
This function is used to launch kernel function over the specified target particle subregions.
array1d< array1d< array1d< VIEWTYPE > > > MaterialViewAccessor
The MaterialViewAccessor at the ParticleManager level is a 3D array of VIEWTYPE.
bool hasRegion(string const &name) const
Determines if a ParticleRegion with the input name exists.
void forParticleSubRegions(LAMBDA &&lambda)
This function is used to launch kernel function over the particle subregions of all the subregion typ...
virtual void setMaxGlobalIndex() override final
Set the maximum local and global index.
ParticleViewAccessor< traits::ViewTypeConst< typename FIELD_TRAIT::type > > constructFieldAccessor(string const &neighborName=string()) const
This is a const function to construct a ParticleViewAccessor to access the data registered on the mes...
void forParticleSubRegions(LOOKUP_CONTAINER const &targetRegions, LAMBDA &&lambda) const
This const function is used to launch kernel function over the specified target particle subregions w...
void forParticleRegionsComplete(LAMBDA lambda)
This function is used to launch kernel function over all the particle regions that can be casted to o...
int PackGlobalMaps(buffer_unit_type *&buffer, ParticleViewAccessor< arrayView1d< localIndex > > const &packList) const
Pack a buffer.
int Unpack(buffer_unit_type const *&buffer, ParticleViewAccessor< arrayView1d< localIndex > > &packList)
Unpack a buffer.
void forParticleSubRegionsComplete(LAMBDA &&lambda)
This function is used to launch kernel function over all the particle subregions that can be casted t...
void generateMesh(ParticleBlockManagerABC &particleBlockManager)
Generate the mesh.
array1d< array1d< VIEWTYPE > > ParticleViewAccessor
The ParticleViewAccessor at the ParticleManager level is an array of array of VIEWTYPE.
void forParticleRegions(LAMBDA &&lambda) const
This const function is used to launch kernel function over all the particle regions with region type ...
static string catalogName()
The function is to return the name of the ParticleManager in the object catalog.
subGroupMap const & getRegions() const
Get a collection of particle regions.
void forParticleRegionsComplete(LOOKUP_CONTAINER const &targetRegions, LAMBDA lambda) const
This const function is used to launch kernel function over the specified target particle regions.
localIndex numParticleBlocks() const
Get the number of particle blocks.
void forParticleSubRegions(LAMBDA &&lambda) const
This const function is used to launch kernel function over the particle subregions of the specified s...
void forParticleSubRegionsComplete(LOOKUP_CONTAINER const &targetRegions, LAMBDA &&lambda)
This function is used to launch kernel function over the specified target particle subregions that ca...
void forParticleSubRegions(LAMBDA &&lambda)
This function is used to launch kernel function over the particle subregions of the specified subregi...
void forParticleRegionsComplete(LOOKUP_CONTAINER const &targetRegions, LAMBDA lambda)
This function is used to launch kernel function over the specified target particle regions.
localIndex numRegions() const
Get the number of regions.
ParticleViewAccessor< ArrayView< T const, NDIM, getUSD< PERM > > > constructArrayViewAccessor(string const &name, string const &neighborName=string()) const
This is a function to construct a ParticleViewAccessor to access array data registered on the mesh.
T & getRegion(KEY_TYPE const &key)
Get a particle region.
void forParticleSubRegionsComplete(LAMBDA &&lambda)
This function is used to launch kernel function over the particle subregions of all subregion types.
ParticleViewAccessor< traits::ViewTypeConst< typename FIELD_TRAIT::type > > constructMaterialFieldAccessor(arrayView1d< string const > const &regionNames, arrayView1d< string const > const &materialNames, bool const allowMissingViews=false) const
This is a const function to construct a MaterialViewAccessor to access the material data for specifie...
ParticleViewAccessor< ArrayView< T const, NDIM, getUSD< PERM > > > constructMaterialArrayViewAccessor(string const &viewName, arrayView1d< string const > const &regionNames, string const &materialKeyName, bool const allowMissingViews=false) const
Construct a view accessor for material data, assuming array as storage type.
T const & getRegion(KEY_TYPE const &key) const
Get a particle region.
void forParticleSubRegionsComplete(LAMBDA &&lambda) const
This const function is used to launch kernel function over all the particle subregions that can be ca...
int UnpackGlobalMaps(buffer_unit_type const *&buffer, ParticleViewAccessor< ReferenceWrapper< localIndex_array > > &packList)
Unpack a buffer.
virtual string getCatalogName() const override final
Virtual access to catalogName()
void forParticleSubRegionsComplete(LOOKUP_CONTAINER const &targetRegions, LAMBDA &&lambda) const
This const function is used to launch kernel function over the specified target particle subregions.
ParticleViewAccessor< LHS > constructViewAccessor(string const &name, string const &neighborName=string()) const
This is a const function to construct a ParticleViewAccessor to access the data registered on the mes...
virtual Group * createChild(string const &childKey, string const &childName) override
Create a new ParticleRegion object as a child of this group.
void forParticleRegionsComplete(LAMBDA lambda)
This function is used to launch kernel function over all the types of particle regions.
int PackSize(string_array const &wrapperNames, ParticleViewAccessor< arrayView1d< localIndex > > const &packList) const
Get the buffer size needed to pack a list of wrappers.
void forParticleRegionsComplete(LAMBDA lambda) const
This const function is used to launch kernel function over all the particle regions that can be caste...
void forParticleSubRegions(LOOKUP_CONTAINER const &targetRegions, LAMBDA &&lambda)
This function is used to launch kernel function over the specified target particle subregions with th...
ParticleManager(string const &name, Group *const parent)
Constructor.
subGroupMap & getRegions()
Get a collection of particle regions.
void forParticleRegionsComplete(LAMBDA lambda) const
This const function is used to launch kernel function over all the types of particle regions.
void forParticleSubRegionsComplete(LOOKUP_CONTAINER const &targetRegions, LAMBDA &&lambda) const
This const function is used to launch kernel function over the specified target particle subregions t...
void forParticleSubRegionsComplete(LOOKUP_CONTAINER const &targetRegions, LAMBDA &&lambda)
This function is used to launch kernel function over the specified target particle subregions.
int Unpack(buffer_unit_type const *&buffer, ParticleReferenceAccessor< array1d< localIndex > > &packList)
Unpack a buffer.
typename ParticleViewAccessor< VIEWTYPE >::NestedViewTypeConst ParticleViewConst
The ParticleViewAccessor at the ParticleManager level is the type resulting from ParticleViewAccessor...
void forParticleRegions(LOOKUP_CONTAINER const &targetRegions, LAMBDA &&lambda)
This function is used to launch kernel function over the target particle regions with region type = P...
void forParticleRegionsComplete(LOOKUP_CONTAINER const &targetRegions, LAMBDA lambda) const
This const function is used to launch kernel function over the specified target particle regions with...
ParticleViewAccessor< ReferenceWrapper< VIEWTYPE > > constructReferenceAccessor(string const &viewName, string const &neighborName=string()) const
This is a const function to construct a ParticleViewAccessor to access the data registered on the mes...
void forParticleRegions(LAMBDA &&lambda)
This function is used to launch kernel function over all the particle regions with region type = Part...
int Pack(buffer_unit_type *&buffer, string_array const &wrapperNames, ParticleViewAccessor< arrayView1d< localIndex > > const &packList) const
Pack a list of wrappers to a buffer.
ParticleViewAccessor< LHS > constructMaterialViewAccessor(string const &viewName, arrayView1d< string const > const &regionNames, string const &materialKeyName, bool const allowMissingViews=false) const
This is a const function to construct a MaterialViewAccessor to access the material data for specifie...
array1d< array1d< ReferenceWrapper< VIEWTYPE > > > ParticleReferenceAccessor
The ParticleViewAccessor at the ParticleManager level is a 2D array of ReferenceWrapper around VIEWTY...
typename ParticleViewAccessor< VIEWTYPE >::NestedViewType ParticleView
The ParticleViewAccessor at the ParticleManager level is the type resulting from ParticleViewAccessor...
void forParticleSubRegions(LOOKUP_CONTAINER const &targetRegions, LAMBDA &&lambda) const
This const function is used to launch kernel function over the specified target particle subregions.
void forParticleRegionsComplete(LOOKUP_CONTAINER const &targetRegions, LAMBDA lambda)
This function is used to launch kernel function over the specified target particle regions with regio...
localIndex getNumberOfParticles() const
Get the number of particles in all ParticleSubRegions of type T.
int PackGlobalMapsSize(ParticleViewAccessor< arrayView1d< localIndex > > const &packList) const
Get the size of the buffer to be packed.
virtual ~ParticleManager() override
Destructor.
array1d< array1d< array1d< CONSTITUTIVE_TYPE * > > > ConstitutiveRelationAccessor
The ConstitutiveRelationAccessor at the ParticleManager level is a 3D array of CONSTITUTIVE_TYPE.
The ParticleRegionBase is the base class to manage the data stored at the particle level.
localIndex numSubRegions() const
Get the number of subregions in the region.
SUBREGIONTYPE const & getSubRegion(KEY_TYPE const &key) const
Get a reference to a subregion.
void forParticleSubRegionsIndex(LAMBDA &&lambda) const
Apply LAMBDA to the subregions, loop using subregion indices.
T const & getConstitutiveModel(string const &name) const
Get a pointer to the constitutive model.
dataRepository::Group const & getConstitutiveModels() const
Get the group in which the constitutive models of this subregion are registered.
T * getGroupPointer(KEY const &key)
Return a pointer to a sub-group of the current Group.
Definition: Group.hpp:317
bool hasWrapper(LOOKUP_TYPE const &lookup) const
Check if a wrapper exists.
Definition: Group.hpp:1202
localIndex getIndexInParent() const
Get the group's index within its parent group.
Definition: Group.hpp:1387
GEOS_DECLTYPE_AUTO_RETURN getReference(LOOKUP_TYPE const &lookup) const
Look up a wrapper and get reference to wrapped object.
Definition: Group.hpp:1273
T & getGroup(KEY const &key)
Return a reference to a sub-group of the current Group.
Definition: Group.hpp:336
static bool applyLambdaToContainer(CONTAINERTYPE &container, LAMBDA &&lambda)
Apply a given functor to a container if the container can be cast to one of the specified types.
Definition: Group.hpp:482
localIndex size() const
Get the "size" of the group, which determines the number of elements in resizable wrappers.
Definition: Group.hpp:1315
virtual localIndex packSize(string_array const &wrapperNames, integer const recursive, bool onDevice, parallelDeviceEvents &events) const
Get the size required to pack a list of wrappers.
void forSubGroups(LAMBDA &&lambda)
Apply the given functor to subgroups that can be casted to one of specified types.
Definition: Group.hpp:518
virtual localIndex pack(buffer_unit_type *&buffer, string_array const &wrapperNames, integer const recursive, bool onDevice, parallelDeviceEvents &events) const
Pack a list of wrappers to a buffer.
Wrapper< T > const * getWrapperPointer(LOOKUP_TYPE const &index) const
Retrieve a Wrapper stored in this group.
Definition: Group.hpp:1239
virtual void resize(localIndex const newSize)
Resize the group and all contained wrappers that resize with parent.
T & reference()
Accessor for m_data.
Definition: Wrapper.hpp:581
localIndex indexType
The default index type for entries the hierarchy.
Definition: Group.hpp:58
pugi::xml_node xmlNode
Definition: xmlWrapper.hpp:59
ArrayView< T, 1 > arrayView1d
Alias for 1D array view.
Definition: DataTypes.hpp:180
array1d< string > string_array
A 1-dimensional array of geos::string types.
Definition: DataTypes.hpp:392
array1d< integer > integer_array
A 1-dimensional array of geos::integer types.
Definition: DataTypes.hpp:383
GEOS_LOCALINDEX_TYPE localIndex
Local index type (for indexing objects within an MPI partition).
Definition: DataTypes.hpp:85
std::int32_t integer
Signed integer type.
Definition: DataTypes.hpp:82
signed char buffer_unit_type
Type stored in communication buffers.
Definition: DataTypes.hpp:109
Array< T, 1 > array1d
Alias for 1D array.
Definition: DataTypes.hpp:176
LvArray::ArrayView< T, NDIM, USD, localIndex, LvArray::ChaiBuffer > ArrayView
Multidimensional array view type. See LvArray:ArrayView for details.
Definition: DataTypes.hpp:148
struct to serve as a container for group strings and keys
static constexpr char const * neighborDataString()
Group key associated with particleRegionsGroup.
static constexpr auto particleRegionsGroup()