Skip to content

Commit

Permalink
fixed cuda bug with dual normals
Browse files Browse the repository at this point in the history
  • Loading branch information
Nathaniel Morgan committed Nov 14, 2024
1 parent 2091f15 commit aef786c
Show file tree
Hide file tree
Showing 2 changed files with 22 additions and 40 deletions.
44 changes: 15 additions & 29 deletions single-node-refactor/src/Solvers/SGH_solver_3D/src/force_sgh.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -38,40 +38,27 @@ ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
#include "state.h"
#include "geometry_new.h"

// -------
// A data structure to get the neighboring corners lids inside an elem relative to a corner lid
size_t hex8_corner_lids_in_corner_lid_1D[24] = {
//
const size_t hex8_corner_lids_in_corner_lid[8][3] =
{
// corner 0
1,
2,
4,
{1, 2, 4},
// corner 1
0,
3,
5,
{0, 3, 5},
// corner 2
0,
3,
6,
{0, 3, 6},
// corner 3
2,
1,
7,
{2, 1, 7},
// corner 4
6,
5,
0,
{6, 5, 0},
// corner 5
4,
7,
1,
{4, 7, 1},
// corner 6
4,
7,
2,
{4, 7, 2},
// corner 7
6,
5,
3
{6, 5, 3}
};
// --- corner_lid = 0 ---
// corner_lids_in_corner_lid(0,0) = 1;
Expand Down Expand Up @@ -166,10 +153,10 @@ void SGH3D::get_force(const Material_t& Materials,
const size_t num_nodes_in_elem = 8;



// --- calculate the forces acting on the nodes from the element ---
FOR_ALL(mat_elem_lid, 0, num_mat_elems, {


// extract the artificial viscosity parameters
double q1 = Materials.dissipation_global_vars(mat_id, artificialViscosity::MARSVarNames::q1);
double q1ex = Materials.dissipation_global_vars(mat_id, artificialViscosity::MARSVarNames::q1ex);
Expand Down Expand Up @@ -258,15 +245,14 @@ void SGH3D::get_force(const Material_t& Materials,
// --- Calculate edge normals of a corner ---
double dual_surf_normals_1D[72];
ViewCArrayKokkos <double> dual_surf_normals(&dual_surf_normals_1D[0], 8, 3, num_dims); // [corner_lid, surf_lid, dim]
ViewCArrayKokkos <size_t> corner_lids_in_corner_lid(&hex8_corner_lids_in_corner_lid_1D[0], 8, 3); // [corner_lid, surrounding_nodes]


if (useShockDirection == 1){
// loop over the corners in this element
for (size_t corner_lid = 0; corner_lid < num_nodes_in_elem; corner_lid++) {

// loop the edges in this corner
for (size_t edge_lid=0; edge_lid<num_dims; edge_lid++){
size_t corner_lid_plus = corner_lids_in_corner_lid(corner_lid, edge_lid);
size_t corner_lid_plus = hex8_corner_lids_in_corner_lid[corner_lid][edge_lid];

for (size_t dim=0; dim<num_dims; dim++){
// outward of dual grid edge normal
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -39,15 +39,12 @@ ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
#include "geometry_new.h"

// A data structure to get the neighboring corners lids inside an elem relative to a corner lid
size_t quad4_corner_lids_in_corner_lid_1D[8] = {
1,
3,
0,
2,
1,
3,
2,
0
const size_t quad4_corner_lids_in_corner_lid[4][2] =
{
{1, 3},
{0, 2},
{1, 3},
{2, 0}
};
// --- corner_lid = 0 ---
// corner_lids_in_corner_lid(0,0) = 1;
Expand Down Expand Up @@ -214,15 +211,14 @@ void SGHRZ::get_force_rz(const Material_t& Materials,
// --- Calculate edge normals of a corner ---
double dual_surf_normals_1D[16];
ViewCArrayKokkos <double> dual_surf_normals(&dual_surf_normals_1D[0], 4, 2, num_dims); // [corner_lid, surf_lid, dim]
ViewCArrayKokkos <size_t> corner_lids_in_corner_lid(&quad4_corner_lids_in_corner_lid_1D[0], 4, 2); // [corner_lid, surrounding_nodes]

if (useShockDirection == 1) {
// loop over the corners in this element
for (size_t corner_lid = 0; corner_lid < num_nodes_in_elem; corner_lid++) {

// loop the edges in this corner
for (size_t edge_lid=0; edge_lid<num_dims; edge_lid++){
size_t corner_lid_plus = corner_lids_in_corner_lid(corner_lid, edge_lid);
size_t corner_lid_plus = quad4_corner_lids_in_corner_lid[corner_lid][edge_lid];

for (size_t dim=0; dim<num_dims; dim++){
// outward of dual grid edge normal
Expand Down

0 comments on commit aef786c

Please sign in to comment.