GEOS
TaperKernel.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 GEOS_PHYSICSSOLVERS_WAVEPROPAGATION_TAPERKERNEL_HPP_
20 #define GEOS_PHYSICSSOLVERS_WAVEPROPAGATION_TAPERKERNEL_HPP_
21 
22 #include "WaveSolverUtils.hpp"
23 
24 namespace geos
25 {
26 
27 using wsCoordType = WaveSolverUtils::wsCoordType;
28 
30 {
31 
46  template< typename EXEC_POLICY >
47  static void
50  real32 const sizeT,
51  real32 const dt,
52  real32 const vMin,
53  real32 const r,
54  arrayView1d< real32 > const taperCoeff )
55  {
56 
58  RAJA::ReduceMin< parallelDeviceReduce, real32 > xMinGlobal( LvArray::NumericLimits< real32 >::max );
59  RAJA::ReduceMin< parallelDeviceReduce, real32 > yMinGlobal( LvArray::NumericLimits< real32 >::max );
60  RAJA::ReduceMin< parallelDeviceReduce, real32 > zMinGlobal( LvArray::NumericLimits< real32 >::max );
61  RAJA::ReduceMax< parallelDeviceReduce, real32 > xMaxGlobal( -LvArray::NumericLimits< real32 >::max );
62  RAJA::ReduceMax< parallelDeviceReduce, real32 > yMaxGlobal( -LvArray::NumericLimits< real32 >::max );
63  RAJA::ReduceMax< parallelDeviceReduce, real32 > zMaxGlobal( -LvArray::NumericLimits< real32 >::max );
64  RAJA::ReduceMin< parallelDeviceReduce, real32 > xMinInterior( LvArray::NumericLimits< real32 >::max );
65  RAJA::ReduceMin< parallelDeviceReduce, real32 > yMinInterior( LvArray::NumericLimits< real32 >::max );
66  RAJA::ReduceMin< parallelDeviceReduce, real32 > zMinInterior( LvArray::NumericLimits< real32 >::max );
67  RAJA::ReduceMax< parallelDeviceReduce, real32 > xMaxInterior( -LvArray::NumericLimits< real32 >::max );
68  RAJA::ReduceMax< parallelDeviceReduce, real32 > yMaxInterior( -LvArray::NumericLimits< real32 >::max );
69  RAJA::ReduceMax< parallelDeviceReduce, real32 > zMaxInterior( -LvArray::NumericLimits< real32 >::max );
70 
71  real32 xGlobalMin[3]{};
72  real32 xGlobalMax[3]{};
73 
74  forAll< EXEC_POLICY >( size, [=] GEOS_HOST_DEVICE ( localIndex const a )
75  {
76  xMinGlobal.min( nodeCoords[a][0] );
77  yMinGlobal.min( nodeCoords[a][1] );
78  zMinGlobal.min( nodeCoords[a][2] );
79  xMaxGlobal.max( nodeCoords[a][0] );
80  yMaxGlobal.max( nodeCoords[a][1] );
81  zMaxGlobal.max( nodeCoords[a][2] );
82  } );
83 
84  xGlobalMin[0] = xMinGlobal.get();
85  xGlobalMin[1] = yMinGlobal.get();
86  xGlobalMin[2] = zMinGlobal.get();
87  xGlobalMax[0] = xMaxGlobal.get();
88  xGlobalMax[1] = yMaxGlobal.get();
89  xGlobalMax[2] = zMaxGlobal.get();
90 
91 
92  for( integer i=0; i<3; ++i )
93  {
94  xGlobalMin[i] = MpiWrapper::min( xGlobalMin[i] );
95  xGlobalMax[i] = MpiWrapper::max( xGlobalMax[i] );
96  }
97 
98  forAll< EXEC_POLICY >( size, [=] GEOS_HOST_DEVICE ( localIndex const a )
99  {
100  real32 dist=0;
101 
102  real32 distXmin = LvArray::math::abs( nodeCoords[a][0]-xGlobalMin[0] );
103  real32 distXmax = LvArray::math::abs( nodeCoords[a][0]-xGlobalMax[0] );
104  real32 distYmin = LvArray::math::abs( nodeCoords[a][1]-xGlobalMin[1] );
105  real32 distYmax = LvArray::math::abs( nodeCoords[a][1]-xGlobalMax[1] );
106  real32 distZmax = LvArray::math::abs( nodeCoords[a][2]-xGlobalMax[2] );
107 
108  dist=LvArray::math::min( distXmin, (LvArray::math::min( distXmax, LvArray::math::min( distYmin, (LvArray::math::min( distYmax, distZmax ))))));
109 
110  taperCoeff[a] = dist;
111 
112 
113  } );
114 
115  forAll< EXEC_POLICY >( size, [=] GEOS_HOST_DEVICE ( localIndex const a )
116  {
117 
118  real32 dist = taperCoeff[a];
119 
120  if( dist<sizeT )
121  {
122  taperCoeff[a] = LvArray::math::exp((((3*vMin)/(2*sizeT))*LvArray::math::log( r )*pow((sizeT-dist)/sizeT, 2 ))*dt );
123  }
124  else
125  {
126  taperCoeff[a] = 1.0;
127  }
128 
129  } );
130 
131  }
132 
133 
142  template< typename EXEC_POLICY >
143  static void
145  arrayView1d< real32 const > const taperCoeff,
146  arrayView1d< real32 > const vector )
147  {
148  forAll< EXEC_POLICY >( size, [=] GEOS_HOST_DEVICE ( localIndex const a )
149  {
150  vector[a] *= taperCoeff[a];
151  } );
152 
153  }
154 
155 
156 };
157 
158 } // namespace geos
159 
160 #endif //GEOS_PHYSICSSOLVERS_WAVEPROPAGATION_TAPERKERNEL_HPP_
#define GEOS_HOST_DEVICE
Marks a host-device function.
Definition: GeosxMacros.hpp:49
ArrayView< T, 1 > arrayView1d
Alias for 1D array view.
Definition: DataTypes.hpp:179
float real32
32-bit floating point type.
Definition: DataTypes.hpp:96
GEOS_LOCALINDEX_TYPE localIndex
Local index type (for indexing objects within an MPI partition).
Definition: DataTypes.hpp:84
ArrayView< T, 2, USD > arrayView2d
Alias for 2D array view.
Definition: DataTypes.hpp:195
int integer
Signed integer type.
Definition: DataTypes.hpp:81
static T max(T const &value, MPI_Comm comm=MPI_COMM_GEOS)
Convenience function for a MPI_Allreduce using a MPI_MAX operation.
static T min(T const &value, MPI_Comm comm=MPI_COMM_GEOS)
Convenience function for a MPI_Allreduce using a MPI_MIN operation.
static void computeTaperCoeff(localIndex const size, arrayView2d< wsCoordType const, nodes::REFERENCE_POSITION_USD > const nodeCoords, real32 const sizeT, real32 const dt, real32 const vMin, real32 const r, arrayView1d< real32 > const taperCoeff)
Compute coefficients for the taper layers. In this computation the choice of the taper length (sizeT)...
Definition: TaperKernel.hpp:48
static void multiplyByTaperCoeff(localIndex const size, arrayView1d< real32 const > const taperCoeff, arrayView1d< real32 > const vector)
Multiply an array with the taper coefficients.