From 6db2fa7907557f3b4e148421cce1827f40b7dc7b Mon Sep 17 00:00:00 2001 From: Sam Reeve <6740307+streeve@users.noreply.github.com> Date: Thu, 28 Sep 2023 17:03:40 -0400 Subject: [PATCH] fixup: simplify cell spacing --- examples/crack_branching.cpp | 2 +- examples/elastic_wave.cpp | 3 +-- examples/kalthoff_winkler.cpp | 2 +- src/CabanaPD_Particles.hpp | 14 +++----------- 4 files changed, 6 insertions(+), 15 deletions(-) diff --git a/examples/crack_branching.cpp b/examples/crack_branching.cpp index e0c80731..b9da5dbc 100644 --- a/examples/crack_branching.cpp +++ b/examples/crack_branching.cpp @@ -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, diff --git a/examples/elastic_wave.cpp b/examples/elastic_wave.cpp index 58af9524..4994cbf9 100644 --- a/examples/elastic_wave.cpp +++ b/examples/elastic_wave.cpp @@ -102,13 +102,12 @@ int main( int argc, char* argv[] ) auto profile = Kokkos::View( 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 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 ) { diff --git a/examples/kalthoff_winkler.cpp b/examples/kalthoff_winkler.cpp index 9b2e6fda..b4e54162 100644 --- a/examples/kalthoff_winkler.cpp +++ b/examples/kalthoff_winkler.cpp @@ -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( diff --git a/src/CabanaPD_Particles.hpp b/src/CabanaPD_Particles.hpp index 353eba7b..5ed915bc 100644 --- a/src/CabanaPD_Particles.hpp +++ b/src/CabanaPD_Particles.hpp @@ -129,9 +129,7 @@ class Particles std::array ghost_mesh_lo; std::array ghost_mesh_hi; std::shared_ptr>> local_grid; - double dx; - double dy; - double dz; + double dx[dim]; int halo_width; @@ -169,6 +167,8 @@ class Particles // 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 ); @@ -190,12 +190,6 @@ class Particles 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(), zero ); - dy = local_mesh.measure( Cajita::Edge(), zero ); - dz = local_mesh.measure( Cajita::Edge(), zero ); } template @@ -445,8 +439,6 @@ class Particles 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;