Skip to content

Commit

Permalink
Merge pull request #57 from streeve/fixup_dx
Browse files Browse the repository at this point in the history
fixup: use simpler interface to get cell spacing
  • Loading branch information
streeve authored Oct 3, 2023
2 parents 1881860 + 6db2fa7 commit 80a431a
Show file tree
Hide file tree
Showing 4 changed files with 6 additions and 15 deletions.
2 changes: 1 addition & 1 deletion examples/crack_branching.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -98,7 +98,7 @@ int main( int argc, char* argv[] )
auto nofail = particles->sliceNoFail();

// Relying on uniform grid here.
double dy = particles->dy;
double dy = particles->dx[1];
double b0 = 2e6 / dy; // Pa

CabanaPD::RegionBoundary plane1( low_x, high_x, low_y - dy, low_y + dy,
Expand Down
3 changes: 1 addition & 2 deletions examples/elastic_wave.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -102,13 +102,12 @@ int main( int argc, char* argv[] )
auto profile = Kokkos::View<double* [2], memory_space>(
Kokkos::ViewAllocateWithoutInitializing( "displacement_profile" ),
num_cell_x );
double length = ( high_corner[0] - low_corner[0] );
int mpi_rank;
MPI_Comm_rank( MPI_COMM_WORLD, &mpi_rank );
Kokkos::View<int*, memory_space> count( "c", 1 );
double dx = particles->dx[0];
auto measure_profile = KOKKOS_LAMBDA( const int pid )
{
double dx = length / num_cell_x;
if ( x( pid, 1 ) < dx / 2.0 && x( pid, 1 ) > -dx / 2.0 &&
x( pid, 2 ) < dx / 2.0 && x( pid, 2 ) > -dx / 2.0 )
{
Expand Down
2 changes: 1 addition & 1 deletion examples/kalthoff_winkler.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -100,7 +100,7 @@ int main( int argc, char* argv[] )
auto f = particles->sliceForce();
auto rho = particles->sliceDensity();

double dx = particles->dx;
double dx = particles->dx[0];

double x_bc = -0.5 * height;
CabanaPD::RegionBoundary plane(
Expand Down
14 changes: 3 additions & 11 deletions src/CabanaPD_Particles.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -129,9 +129,7 @@ class Particles<DeviceType, PMB, Dimension>
std::array<double, 3> ghost_mesh_lo;
std::array<double, 3> ghost_mesh_hi;
std::shared_ptr<Cajita::LocalGrid<Cajita::UniformMesh<double>>> local_grid;
double dx;
double dy;
double dz;
double dx[dim];

int halo_width;

Expand Down Expand Up @@ -169,6 +167,8 @@ class Particles<DeviceType, PMB, Dimension>
// Create global mesh of MPI partitions.
auto global_mesh = Cajita::createUniformGlobalMesh(
low_corner, high_corner, num_cells );
for ( int d = 0; d < 3; d++ )
dx[d] = global_mesh->cellSize( d );

for ( int d = 0; d < 3; d++ )
global_mesh_ext[d] = global_mesh->extent( d );
Expand All @@ -190,12 +190,6 @@ class Particles<DeviceType, PMB, Dimension>
ghost_mesh_hi[d] = local_mesh.highCorner( Cajita::Ghost(), d );
local_mesh_ext[d] = local_mesh.extent( Cajita::Own(), d );
}

// Uniform mesh spacing.
int zero[3] = { 0, 0, 0 };
dx = local_mesh.measure( Cajita::Edge<Cajita::Dim::I>(), zero );
dy = local_mesh.measure( Cajita::Edge<Cajita::Dim::J>(), zero );
dz = local_mesh.measure( Cajita::Edge<Cajita::Dim::K>(), zero );
}

template <class ExecSpace>
Expand Down Expand Up @@ -445,8 +439,6 @@ class Particles<DeviceType, LPS, Dimension>
using base_type::local_mesh_lo;

using base_type::dx;
using base_type::dy;
using base_type::dz;
using base_type::local_grid;

using base_type::halo_width;
Expand Down

0 comments on commit 80a431a

Please sign in to comment.