GEOSX
FieldSpecificationBase.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 Total, S.A
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_MANAGERS_FIELDSPECIFICATION_FIELDSPECIFICATIONBASE_HPP
20 #define GEOSX_MANAGERS_FIELDSPECIFICATION_FIELDSPECIFICATIONBASE_HPP
21 
22 #include "common/DataTypes.hpp"
23 #include "codingUtilities/traits.hpp"
24 #include "codingUtilities/Utilities.hpp"
25 #include "dataRepository/Group.hpp"
29 #include "rajaInterface/GEOS_RAJA_Interface.hpp"
31 
32 
33 namespace geosx
34 {
35 class Function;
36 
37 
43 {
44 public:
45 
55  string const &,
57 
63 
68  static string CatalogName() { return "FieldSpecification"; }
69 
74  virtual const string getCatalogName() const
75  {
77  }
78 
89  FieldSpecificationBase( string const & name, dataRepository::Group * parent );
90 
94  virtual ~FieldSpecificationBase() override;
95 
106  template< typename FIELD_OP, typename POLICY, typename T, int N, int USD >
107  void ApplyFieldValueKernel( ArrayView< T, N, USD > const & field,
108  SortedArrayView< localIndex const > const & targetSet,
109  real64 const time,
110  Group * dataGroup ) const;
111 
123  template< typename FIELD_OP, typename POLICY=parallelHostPolicy >
125  real64 const time,
126  dataRepository::Group * dataGroup,
127  string const & fieldname ) const;
128 
148  template< typename FIELD_OP, typename LAI >
150  real64 const time,
151  dataRepository::Group const * const dataGroup,
152  string const & fieldName,
153  string const & dofMapName,
154  integer const & dofDim,
155  typename LAI::ParallelMatrix & matrix,
156  typename LAI::ParallelVector & rhs ) const;
157 
158 
182  template< typename FIELD_OP, typename LAI, typename LAMBDA >
183  void
185  real64 const time,
186  dataRepository::Group const * const dataGroup,
187  arrayView1d< globalIndex const > const & dofMap,
188  integer const & dofDim,
189  typename LAI::ParallelMatrix & matrix,
190  typename LAI::ParallelVector & rhs,
191  LAMBDA && lambda ) const;
192 
217  template< typename FIELD_OP, typename LAI, typename LAMBDA >
218  void
220  real64 const time,
221  real64 const dt,
222  dataRepository::Group const * const dataGroup,
223  arrayView1d< globalIndex const > const & dofMap,
224  integer const & dofDim,
225  typename LAI::ParallelMatrix & matrix,
226  typename LAI::ParallelVector & rhs,
227  LAMBDA && lambda ) const;
228 
239  template< typename LAI >
241  arrayView1d< globalIndex const > const & dofMap,
242  typename LAI::ParallelMatrix & matrix ) const;
243 
264  template< typename FIELD_OP, typename POLICY, typename T, int NDIM, int USD >
266  real64 const time,
267  dataRepository::Group const * const dataGroup,
268  arrayView1d< globalIndex const > const & dofMap,
269  globalIndex const dofRankOffset,
271  arrayView1d< real64 > const & rhs,
272  ArrayView< T const, NDIM, USD > const & fieldView ) const;
273 
293  template< typename FIELD_OP, typename POLICY >
295  real64 const time,
296  dataRepository::Group const * const dataGroup,
297  string const & fieldName,
298  string const & dofMapName,
299  globalIndex const dofRankOffset,
301  arrayView1d< real64 > const & rhs ) const;
302 
325  template< typename FIELD_OP, typename POLICY, typename LAMBDA >
326  void
328  real64 const time,
329  dataRepository::Group const * const dataGroup,
330  arrayView1d< globalIndex const > const & dofMap,
331  globalIndex const dofRankOffset,
333  arrayView1d< real64 > const & rhs,
334  LAMBDA && lambda ) const;
335 
359  template< typename FIELD_OP, typename POLICY, typename LAMBDA >
360  void
362  real64 const time,
363  real64 const dt,
364  dataRepository::Group const * const dataGroup,
365  arrayView1d< globalIndex const > const & dofMap,
366  globalIndex const dofRankOffset,
368  arrayView1d< real64 > const & rhs,
369  LAMBDA && lambda ) const;
370 
381  template< typename POLICY >
383  arrayView1d< globalIndex const > const & dofMap,
384  CRSMatrixView< real64, globalIndex const > const & matrix ) const;
385 
390  {
392  constexpr static auto setNamesString = "setNames";
394  constexpr static auto constitutivePathString = "constitutivePath";
396  constexpr static auto objectPathString = "objectPath";
398  constexpr static auto fieldNameString = "fieldName";
400  constexpr static auto dataTypeString = "dataType";
402  constexpr static auto componentString = "component";
404  constexpr static auto directionString = "direction";
406  constexpr static auto bcApplicationTableNameString = "bcApplicationTableName";
408  constexpr static auto scaleString = "scale";
410  constexpr static auto functionNameString = "functionName";
412  constexpr static auto initialConditionString = "initialCondition";
414  constexpr static auto beginTimeString = "beginTime";
416  constexpr static auto endTimeString = "endTime";
418  constexpr static auto fluxBoundaryConditionString = "fluxBoundaryCondition";
419  } viewKeys;
420 
425  {} groupKeys;
426 
427 
432  string const & GetFunctionName() const
433  {
434  return m_functionName;
435  }
436 
441  virtual const string & GetObjectPath() const
442  {
443  return m_objectPath;
444  }
445 
450  virtual const string & GetFieldName() const
451  {
452  return m_fieldName;
453  }
454 
459  virtual int GetComponent() const
460  {
461  return m_component;
462  }
463 
469  virtual const R1Tensor & GetDirection( real64 time )
470  {
471  GEOSX_UNUSED_VAR( time );
472  return m_direction;
473  }
474 
480  {
481  return m_beginTime;
482  }
483 
489  {
490  return m_endTime;
491  }
492 
497  string_array const & GetSetNames() const
498  {
499  return m_setNames;
500  }
501 
506  int initialCondition() const
507  {
508  return m_initialCondition;
509  }
510 
515  real64 GetScale() const
516  {
517  return m_scale;
518  }
519 
524  void SetFieldName( string const & fieldName )
525  {
526  m_fieldName = fieldName;
527  }
528 
533  void SetObjectPath( string const & objectPath )
534  {
535  m_objectPath = objectPath;
536  }
537 
542  void SetScale( real64 const & scale )
543  {
544  m_scale = scale;
545  }
546 
551  void InitialCondition( bool isInitialCondition )
552  {
553  m_initialCondition = isInitialCondition;
554  }
555 
560  void AddSetName( string const & setName )
561  {
562  m_setNames.emplace_back( setName );
563  }
564 
565 
566 protected:
567  void PostProcessInput() override final;
568 
571 
572 private:
573 
574 
576  string_array m_setNames;
577 
579  string m_objectPath;
580 
583  string m_fieldName;
584 
585 
586 // string m_dataType;
587 
589  int m_component;
590 
592  R1Tensor m_direction;
593 
595  int m_initialCondition;
596 
598  string m_functionName;
599 
601  real64 m_scale;
602 
604  real64 m_beginTime;
605 
607  real64 m_endTime;
608 
610  string m_bcApplicationFunctionName;
611 
613  //real64 m_setSizeScalingFactor;
614 
615 };
616 
617 
618 template< typename FIELD_OP, typename POLICY, typename T, int N, int USD >
620  SortedArrayView< localIndex const > const & targetSet,
621  real64 const time,
622  Group * dataGroup ) const
623 {
624  integer const component = GetComponent();
625  FunctionManager & functionManager = FunctionManager::Instance();
626 
627  if( m_functionName.empty() )
628  {
629  real64 const value = m_scale;
630  forAll< POLICY >( targetSet.size(), [=] GEOSX_HOST_DEVICE ( localIndex const i )
631  {
632  localIndex const a = targetSet[ i ];
633  FIELD_OP::SpecifyFieldValue( field, a, component, value );
634  } );
635  }
636  else
637  {
638  FunctionBase const * const function = functionManager.GetGroup< FunctionBase >( m_functionName );
639 
640  GEOSX_ERROR_IF( function == nullptr, "Function '" << m_functionName << "' not found" );
641 
642  if( function->isFunctionOfTime()==2 )
643  {
644  real64 const value = m_scale * function->Evaluate( &time );
645  forAll< POLICY >( targetSet.size(), [=] GEOSX_HOST_DEVICE ( localIndex const i )
646  {
647  localIndex const a = targetSet[ i ];
648  FIELD_OP::SpecifyFieldValue( field, a, component, value );
649  } );
650  }
651  else
652  {
653  real64_array result( static_cast< localIndex >( targetSet.size() ) );
654  function->Evaluate( dataGroup, time, targetSet, result );
655  arrayView1d< real64 const > const & resultView = result.toViewConst();
656  real64 const scale = m_scale;
657  forAll< POLICY >( targetSet.size(), [=] GEOSX_HOST_DEVICE ( localIndex const i )
658  {
659  localIndex const a = targetSet[ i ];
660  FIELD_OP::SpecifyFieldValue( field, a, component, scale * resultView[i] );
661  } );
662  }
663  }
664 }
665 
666 
667 template< typename FIELD_OP, typename POLICY >
669  real64 const time,
670  dataRepository::Group * dataGroup,
671  string const & fieldName ) const
672 {
673  dataRepository::WrapperBase * wrapper = dataGroup->getWrapperBase( fieldName );
674  std::type_index typeIndex = std::type_index( wrapper->get_typeid());
675 
677  true,
678  [&]( auto arrayInstance, auto GEOSX_UNUSED_PARAM( dataTypeInstance ) )
679  {
680  using ArrayType = decltype(arrayInstance);
682 
683  auto const & field = view.reference().toView();
684  ApplyFieldValueKernel< FIELD_OP, POLICY >( field, targetSet, time, dataGroup );
685  } );
686 }
687 
688 template< typename FIELD_OP, typename LAI >
690  real64 const time,
691  dataRepository::Group const * const dataGroup,
692  string const & fieldName,
693  string const & dofMapName,
694  integer const & dofDim,
695  typename LAI::ParallelMatrix & matrix,
696  typename LAI::ParallelVector & rhs ) const
697 {
698  dataRepository::WrapperBase const & wrapperBase = *dataGroup->getWrapperBase( fieldName );
699  std::type_index typeIndex = std::type_index( wrapperBase.get_typeid());
700  arrayView1d< globalIndex const > const & dofMap = dataGroup->getReference< array1d< globalIndex > >( dofMapName );
701  integer const component = GetComponent();
702 
703  rtTypes::ApplyArrayTypeLambda1( rtTypes::typeID( typeIndex ), [&]( auto type )
704  {
705  using FieldType = decltype( type );
707  traits::ViewTypeConst< FieldType > fieldView = wrapper.reference();
708 
709  this->ApplyBoundaryConditionToSystem< FIELD_OP, LAI >( targetSet, time, dataGroup, dofMap, dofDim, matrix, rhs,
710  [&]( localIndex const a )
711  {
712  real64 value = 0.0;
713  FieldSpecificationEqual::ReadFieldValue( fieldView, a, component, value );
714  return value;
715  } );
716  } );
717 }
718 
719 template< typename FIELD_OP, typename LAI, typename LAMBDA >
720 void
723  real64 const time,
724  dataRepository::Group const * const dataGroup,
725  arrayView1d< globalIndex const > const & dofMap,
726  integer const & dofDim,
727  typename LAI::ParallelMatrix & matrix,
728  typename LAI::ParallelVector & rhs,
729  LAMBDA && lambda ) const
730 {
731  GEOSX_UNUSED_VAR( dofDim );
732 
733  integer const component = GetComponent();
734  FunctionManager & functionManager = FunctionManager::Instance();
735 
736  globalIndex_array dof( targetSet.size() );
737  real64_array rhsContribution( targetSet.size() );
738 
739  real64 sizeScalingFactor = 0;
741  {
742  // note: this assumes that the ghost elements have been filtered out
743 
744  // recompute the set size here to make sure that topology changes are accounted for
745  integer const localSetSize = targetSet.size();
746  integer globalSetSize = 0;
747 
748  // synchronize
749  MpiWrapper::allReduce( &localSetSize, &globalSetSize, 1, MPI_SUM, MPI_COMM_GEOSX );
750 
751  // set the scaling factor
752  sizeScalingFactor = globalSetSize >= 1 ? 1.0 / globalSetSize : 1;
753  }
754  else
755  {
756  sizeScalingFactor = 1;
757  }
758 
759  if( m_functionName.empty() )
760  {
761 
762  integer counter=0;
763  for( auto a : targetSet )
764  {
765  dof( counter ) = dofMap[a]+component;
766  FIELD_OP::template SpecifyFieldValue< LAI >( dof( counter ),
767  matrix,
768  rhsContribution( counter ),
769  m_scale * sizeScalingFactor,
770  lambda( a ) );
771  ++counter;
772  }
773  FIELD_OP::template PrescribeRhsValues< LAI >( rhs, counter, dof.data(), rhsContribution.data() );
774  }
775  else
776  {
777  FunctionBase const * const function = functionManager.GetGroup< FunctionBase >( m_functionName );
778 
779  GEOSX_ERROR_IF( function == nullptr, "Function '" << m_functionName << "' not found" );
780 
781  if( function->isFunctionOfTime()==2 )
782  {
783  real64 value = m_scale * function->Evaluate( &time ) * sizeScalingFactor;
784  integer counter=0;
785  for( auto a : targetSet )
786  {
787  dof( counter ) = dofMap[a] + component;
788  FIELD_OP::template SpecifyFieldValue< LAI >( dof( counter ),
789  matrix,
790  rhsContribution( counter ),
791  value,
792  lambda( a ) );
793  ++counter;
794  }
795  FIELD_OP::template PrescribeRhsValues< LAI >( rhs, counter, dof.data(), rhsContribution.data() );
796  }
797  else
798  {
799  real64_array result;
800  result.resize( LvArray::integerConversion< localIndex >( targetSet.size()));
801  function->Evaluate( dataGroup, time, targetSet, result );
802  integer counter=0;
803  for( auto a : targetSet )
804  {
805  dof( counter ) = dofMap[a] + component;
806  FIELD_OP::template SpecifyFieldValue< LAI >( dof( counter ),
807  matrix,
808  rhsContribution( counter ),
809  m_scale * result[counter] * sizeScalingFactor,
810  lambda( a ) );
811  ++counter;
812  }
813  FIELD_OP::template PrescribeRhsValues< LAI >( rhs, counter, dof.data(), rhsContribution.data() );
814  }
815  }
816 }
817 
818 template< typename FIELD_OP, typename LAI, typename LAMBDA >
819 void
822  real64 const time,
823  real64 const dt,
824  dataRepository::Group const * const dataGroup,
825  arrayView1d< globalIndex const > const & dofMap,
826  integer const & dofDim,
827  typename LAI::ParallelMatrix & matrix,
828  typename LAI::ParallelVector & rhs,
829  LAMBDA && lambda ) const
830 {
831  GEOSX_UNUSED_VAR( dofDim );
832 
833  integer const component = GetComponent();
834  FunctionManager & functionManager = FunctionManager::Instance();
835 
836  globalIndex_array dof( targetSet.size() );
837  real64_array rhsContribution( targetSet.size() );
838 
839  real64 sizeScalingFactor = 0.0;
841  {
842  // note: this assumes that the ghost elements have been filtered out
843 
844  // recompute the set size here to make sure that topology changes are accounted for
845  integer const localSetSize = targetSet.size();
846  integer globalSetSize = 0;
847 
848  // synchronize
849  MpiWrapper::allReduce( &localSetSize, &globalSetSize, 1, MPI_SUM, MPI_COMM_GEOSX );
850 
851  // set the scaling factor
852  sizeScalingFactor = globalSetSize >= 1 ? 1.0 / globalSetSize : 1;
853  }
854  else
855  {
856  sizeScalingFactor = 1;
857  }
858 
859 
860  if( m_functionName.empty() )
861  {
862 
863  integer counter=0;
864  for( auto a : targetSet )
865  {
866  dof( counter ) = dofMap[a]+component;
867  FIELD_OP::template SpecifyFieldValue< LAI >( dof( counter ),
868  matrix,
869  rhsContribution( counter ),
870  m_scale * dt * sizeScalingFactor,
871  lambda( a ) );
872  ++counter;
873  }
874  FIELD_OP::template PrescribeRhsValues< LAI >( rhs, counter, dof.data(), rhsContribution.data() );
875  }
876  else
877  {
878  FunctionBase const * const function = functionManager.GetGroup< FunctionBase >( m_functionName );
879 
880  GEOSX_ERROR_IF( function == nullptr, "Function '" << m_functionName << "' not found" );
881 
882  if( function->isFunctionOfTime()==2 )
883  {
884  real64 value = m_scale * dt * function->Evaluate( &time ) * sizeScalingFactor;
885  integer counter=0;
886  for( auto a : targetSet )
887  {
888  dof( counter ) = dofMap[a] + component;
889  FIELD_OP::template SpecifyFieldValue< LAI >( dof( counter ),
890  matrix,
891  rhsContribution( counter ),
892  value,
893  lambda( a ) );
894  ++counter;
895  }
896  FIELD_OP::template PrescribeRhsValues< LAI >( rhs, counter, dof.data(), rhsContribution.data() );
897  }
898  else
899  {
900  real64_array result;
901  result.resize( LvArray::integerConversion< localIndex >( targetSet.size()));
902  function->Evaluate( dataGroup, time, targetSet, result );
903  integer counter=0;
904  for( auto a : targetSet )
905  {
906  dof( counter ) = dofMap[a] + component;
907  FIELD_OP::template SpecifyFieldValue< LAI >( dof( counter ),
908  matrix,
909  rhsContribution( counter ),
910  m_scale * dt * result[counter] * sizeScalingFactor,
911  lambda( a ) );
912  ++counter;
913  }
914  FIELD_OP::template PrescribeRhsValues< LAI >( rhs, counter, dof.data(), rhsContribution.data() );
915  }
916  }
917 }
918 
919 template< typename LAI >
921  arrayView1d< globalIndex const > const & dofMap,
922  typename LAI::ParallelMatrix & matrix ) const
923 
924 {
925  integer const component = GetComponent();
926  for( auto a : targetSet )
927  {
928  globalIndex const dof = dofMap[a]+component;
929  matrix.clearRow( dof );
930  }
931 }
932 
933 template< typename FIELD_OP, typename POLICY, typename T, int NDIM, int USD >
935  real64 const time,
936  dataRepository::Group const * const dataGroup,
937  arrayView1d< globalIndex const > const & dofMap,
938  globalIndex const dofRankOffset,
940  arrayView1d< real64 > const & rhs,
941  ArrayView< T const, NDIM, USD > const & fieldView ) const
942 {
943  integer const component = GetComponent();
944  this->ApplyBoundaryConditionToSystem< FIELD_OP, POLICY >( targetSet, time, dataGroup, dofMap, dofRankOffset, matrix, rhs,
945  [fieldView, component] GEOSX_HOST_DEVICE ( localIndex const a )
946  {
947  real64 value = 0.0;
948  FieldSpecificationEqual::ReadFieldValue( fieldView, a, component, value );
949  return value;
950  } );
951 }
952 
953 template< typename FIELD_OP, typename POLICY >
955  real64 const time,
956  dataRepository::Group const * const dataGroup,
957  string const & fieldName,
958  string const & dofMapName,
959  globalIndex const dofRankOffset,
961  arrayView1d< real64 > const & rhs ) const
962 {
963  dataRepository::WrapperBase const & wrapperBase = *dataGroup->getWrapperBase( fieldName );
964  std::type_index typeIndex = std::type_index( wrapperBase.get_typeid());
965  arrayView1d< globalIndex const > const & dofMap = dataGroup->getReference< array1d< globalIndex > >( dofMapName );
966 
967  rtTypes::ApplyArrayTypeLambda1( rtTypes::typeID( typeIndex ), [&]( auto type )
968  {
969  using FieldType = decltype( type );
971  ApplyBoundaryConditionToSystemKernel< FIELD_OP, POLICY >( targetSet, time, dataGroup, dofMap, dofRankOffset, matrix, rhs, wrapper.reference() );
972  } );
973 }
974 
975 template< typename FIELD_OP, typename POLICY, typename LAMBDA >
976 void
979  real64 const time,
980  dataRepository::Group const * const dataGroup,
981  arrayView1d< globalIndex const > const & dofMap,
982  globalIndex const dofRankOffset,
984  arrayView1d< real64 > const & rhs,
985  LAMBDA && lambda ) const
986 {
987  return ApplyBoundaryConditionToSystem< FIELD_OP, POLICY >( targetSet,
988  time,
989  1.0,
990  dataGroup,
991  dofMap,
992  dofRankOffset,
993  matrix,
994  rhs,
995  std::forward< LAMBDA >( lambda ) );
996 }
997 
998 template< typename FIELD_OP, typename POLICY, typename LAMBDA >
999 void
1002  real64 const time,
1003  real64 const dt,
1004  dataRepository::Group const * const dataGroup,
1005  arrayView1d< globalIndex const > const & dofMap,
1006  globalIndex const dofRankOffset,
1008  arrayView1d< real64 > const & rhs,
1009  LAMBDA && lambda ) const
1010 {
1011  integer const component = GetComponent();
1012  string const & functionName = getReference< string >( viewKeyStruct::functionNameString );
1013  FunctionManager & functionManager = FunctionManager::Instance();
1014 
1015  array1d< globalIndex > dofArray( targetSet.size() );
1016  arrayView1d< globalIndex > const & dof = dofArray.toView();
1017 
1018  array1d< real64 > rhsContributionArray( targetSet.size() );
1019  arrayView1d< real64 > const & rhsContribution = rhsContributionArray.toView();
1020 
1021  real64 sizeScalingFactor = 0.0;
1022  if( m_normalizeBySetSize )
1023  {
1024  // note: this assumes that the ghost elements have been filtered out
1025 
1026  // recompute the set size here to make sure that topology changes are accounted for
1027  integer const localSetSize = targetSet.size();
1028  integer globalSetSize = 0;
1029 
1030  // synchronize
1031  MpiWrapper::allReduce( &localSetSize, &globalSetSize, 1, MPI_SUM, MPI_COMM_GEOSX );
1032 
1033  // set the scaling factor
1034  sizeScalingFactor = globalSetSize >= 1 ? 1.0 / globalSetSize : 1;
1035  }
1036  else
1037  {
1038  sizeScalingFactor = 1;
1039  }
1040 
1041 
1042  if( functionName.empty() || functionManager.getGroupReference< FunctionBase >( functionName ).isFunctionOfTime() == 2 )
1043  {
1044  real64 value = m_scale * dt * sizeScalingFactor;
1045  if( !functionName.empty() )
1046  {
1047  FunctionBase const & function = functionManager.getGroupReference< FunctionBase >( functionName );
1048  value *= function.Evaluate( &time );
1049  }
1050 
1051  forAll< POLICY >( targetSet.size(),
1052  [targetSet, dof, dofMap, dofRankOffset, component, matrix, rhsContribution, value, lambda] GEOSX_HOST_DEVICE ( localIndex const i )
1053  {
1054  localIndex const a = targetSet[ i ];
1055  dof[ i ] = dofMap[ a ] + component;
1056  FIELD_OP::SpecifyFieldValue( dof[ i ],
1057  dofRankOffset,
1058  matrix,
1059  rhsContribution[ i ],
1060  value,
1061  lambda( a ) );
1062  } );
1063  }
1064  else
1065  {
1066  FunctionBase const & function = functionManager.getGroupReference< FunctionBase >( functionName );
1067 
1068  real64_array resultsArray( targetSet.size() );
1069  function.Evaluate( dataGroup, time, targetSet, resultsArray );
1070  arrayView1d< real64 const > const & results = resultsArray.toViewConst();
1071  real64 const value = m_scale * dt * sizeScalingFactor;
1072 
1073  forAll< POLICY >( targetSet.size(),
1074  [targetSet, dof, dofMap, dofRankOffset, component, matrix, rhsContribution, results, value, lambda] GEOSX_HOST_DEVICE (
1075  localIndex const i )
1076  {
1077  localIndex const a = targetSet[ i ];
1078  dof[ i ] = dofMap[ a ] + component;
1079  FIELD_OP::SpecifyFieldValue( dof[ i ],
1080  dofRankOffset,
1081  matrix,
1082  rhsContribution[ i ],
1083  value * results[ i ],
1084  lambda( a ) );
1085  } );
1086  }
1087 
1088  FIELD_OP::template PrescribeRhsValues< POLICY >( rhs, dof, dofRankOffset, rhsContribution );
1089 }
1090 
1091 template< typename POLICY >
1093  arrayView1d< globalIndex const > const & dofMap,
1094  CRSMatrixView< real64, globalIndex const > const & matrix ) const
1095 
1096 {
1097  integer const component = GetComponent();
1098  forAll< POLICY >( targetSet.size(), [targetSet, dofMap, matrix, component] GEOSX_HOST_DEVICE ( localIndex const i )
1099  {
1100  localIndex const a = targetSet[ i ];
1101  globalIndex const dof = dofMap[ a ] + component;
1102 
1103  arraySlice1d< real64 > const entries = matrix.getEntries( dof );
1104  localIndex const numEntries = matrix.numNonZeros( dof );
1105 
1106  for( localIndex j = 0; j < numEntries; ++j )
1107  {
1108  entries[ j ] = 0;
1109  }
1110  } );
1111 }
1112 
1113 }
1114 
1115 #endif
#define GEOSX_HOST_DEVICE
Marks a host-device function.
Definition: GeosxMacros.hpp:48
static constexpr auto objectPathString
The key for objectPath.
void SetObjectPath(string const &objectPath)
void ApplyFieldValue(SortedArrayView< localIndex const > const &targetSet, real64 const time, dataRepository::Group *dataGroup, string const &fieldname) const
static constexpr auto beginTimeString
The key for beginTime.
virtual const string getCatalogName() const
return the catalog name
long long int globalIndex
Global index type (for indexing objects across MPI partitions).
Definition: DataTypes.hpp:128
constexpr void scale(VECTOR &&vector, std::remove_reference_t< decltype(vector[0]) > const scale)
Multiply the entries of vector by scale.
void ApplyBoundaryConditionToSystemKernel(SortedArrayView< localIndex const > const &targetSet, real64 const time, dataRepository::Group const *const dataGroup, arrayView1d< globalIndex const > const &dofMap, globalIndex const dofRankOffset, CRSMatrixView< real64, globalIndex const > const &matrix, arrayView1d< real64 > const &rhs, ArrayView< T const, NDIM, USD > const &fieldView) const
Apply a boundary condition to a system of equations.
virtual const string & GetObjectPath() const
void SetScale(real64 const &scale)
static constexpr auto constitutivePathString
The key for constitutivePath.
This class serves to provide a sliced multidimensional interface to the family of LvArray classes...
Definition: ArraySlice.hpp:89
static TypeIDs typeID(std::type_index typeIndex)
Return a TypeID enum given a std::type_index.
Definition: DataTypes.hpp:596
static constexpr auto componentString
The key for component.
static Wrapper< T > * cast(WrapperBase *const base)
Static function to cast a Wrapper base to a derived Wrapper<T>
Definition: Wrapper.hpp:228
static constexpr auto bcApplicationTableNameString
The key for bcApplicationTableName.
LAInterface::ParallelVector ParallelVector
Alias for ParallelVector.
static auto ApplyArrayTypeLambda1(const TypeIDs type, LAMBDA lambda)
this function provides a switchyard for the intrinsic supported GEOSX array types which calls a gener...
Definition: DataTypes.hpp:780
bool m_normalizeBySetSize
The flag used to decide if the BC value is normalized by the size of the set on which it is applied...
string_array const & GetSetNames() const
static string CatalogName()
Static Factory Catalog Functions.
static constexpr auto directionString
The key for direction.
constexpr ArrayView< T const, NDIM, USD, INDEX_TYPE, BUFFER_TYPE > toViewConst() const &
Definition: ArrayView.hpp:242
constexpr ArrayView< T const, NDIM, USD, INDEX_TYPE, BUFFER_TYPE > toViewConst() const &&=delete
Overload for rvalues that is deleted.
This class serves to provide a "view" of a multidimensional array.
Definition: ArrayView.hpp:67
void ApplyFieldValueKernel(ArrayView< T, N, USD > const &field, SortedArrayView< localIndex const > const &targetSet, real64 const time, Group *dataGroup) const
struct geosx::FieldSpecificationBase::groupKeyStruct groupKeys
groupKeys
static FunctionManager & Instance()
Return the function manager instance.
double real64
64-bit floating point type.
Definition: DataTypes.hpp:136
virtual ~FieldSpecificationBase() override
void ZeroSystemRowsForBoundaryCondition(SortedArrayView< localIndex const > const &targetSet, arrayView1d< globalIndex const > const &dofMap, typename LAI::ParallelMatrix &matrix) const
Zero matrix rows to apply boundary conditions.
static CatalogInterface::CatalogType & GetCatalog()
static function to return static catalog.
FieldSpecificationBase(string const &name, dataRepository::Group *parent)
constructor
constexpr ArrayView toView() const &
Definition: ArrayView.hpp:235
constexpr INDEX_TYPE size() const
virtual const string & GetFieldName() const
static constexpr auto functionNameString
The key for functionName.
GEOSX_DECLTYPE_AUTO_RETURN getReference(LOOKUP_TYPE const &lookup) const
Look up a wrapper and get reference to wrapped object.
Definition: Group.hpp:1211
int MPI_COMM_GEOSX
Global MPI communicator used by GEOSX.
Base class for all wrappers containing common operations.
Definition: WrapperBase.hpp:48
virtual void Evaluate(dataRepository::Group const *const group, real64 const time, SortedArrayView< localIndex const > const &set, real64_array &result) const =0
Method to evaluate a function on a target object.
static constexpr auto dataTypeString
The key for dataType.
static constexpr auto setNamesString
The key for setName.
std::int32_t integer
Signed integer type.
Definition: DataTypes.hpp:122
static constexpr auto endTimeString
The key for endTime.
void InitialCondition(bool isInitialCondition)
This class provides the base class/interface for the catalog value objects.
static GEOSX_HOST_DEVICE std::enable_if< !traits::is_tensorT< T >, void >::type ReadFieldValue(arrayView1d< T const > const &field, localIndex const index, integer const component, real64 &value)
Read a field value.
static constexpr auto initialConditionString
The key for initialCondition.
void PostProcessInput() override final
#define GEOSX_UNUSED_VAR(...)
Mark an unused variable and silence compiler warnings.
Definition: GeosxMacros.hpp:78
virtual std::type_info const & get_typeid() const =0
Get the typeid of T.
virtual const R1Tensor & GetDirection(real64 time)
T & reference()
Accessor for m_data.
Definition: Wrapper.hpp:588
void resize(int const numDims, DIMS_TYPE const *const dims)
Resize the dimensions of the Array to match the given dimensions.
Definition: Array.hpp:277
void AddSetName(string const &setName)
std::ptrdiff_t localIndex
Local index type (for indexing objects within an MPI partition).
Definition: DataTypes.hpp:125
static constexpr auto fieldNameString
The key for fieldName.
static constexpr auto scaleString
The key for scale.
static auto ApplyArrayTypeLambda2(const TypeIDs type, bool const errorIfTypeNotFound, LAMBDA &&lambda)
Provides a switchyard for the intrinsic supported GEOSX array types which calls a generic lambda that...
Definition: DataTypes.hpp:836
LAInterface::ParallelMatrix ParallelMatrix
Alias for ParallelMatrix.
static constexpr auto fluxBoundaryConditionString
The key for fluxBoundaryCondition.
#define GEOSX_ERROR_IF(EXP, msg)
Conditionally raise a hard error and terminate the program.
Definition: Logger.hpp:103
void ApplyBoundaryConditionToSystem(SortedArrayView< localIndex const > const &targetSet, real64 const time, dataRepository::Group const *const dataGroup, string const &fieldName, string const &dofMapName, integer const &dofDim, typename LAI::ParallelMatrix &matrix, typename LAI::ParallelVector &rhs) const
Function to apply a boundary condition to a system of equations.
void SetFieldName(string const &fieldName)
struct geosx::FieldSpecificationBase::viewKeyStruct viewKeys
viewKeys
WrapperBase const * getWrapperBase(indexType const index) const
Retrieve a WrapperBase stored in this group.
Definition: Group.hpp:1058
This class provides a fixed dimensional resizeable array interface in addition to an interface simila...
Definition: Array.hpp:55
T * GetGroup(localIndex index)
Retrieve a sub-group from the current Group using an index.
Definition: Group.hpp:374
std::unordered_map< std::string, std::unique_ptr< CatalogInterface< BASETYPE, ARGS... > > > CatalogType
This is the type that will be used for the catalog. The catalog is actually instantiated in the BASET...
#define GEOSX_UNUSED_PARAM(X)
Mark an unused argument and silence compiler warnings.
Definition: GeosxMacros.hpp:66
T & getGroupReference(string const &key)
Definition: Group.hpp:414