Skip to content

Commit

Permalink
Merge branch 'lanl:main' into Parallel-Explicit-Solver
Browse files Browse the repository at this point in the history
  • Loading branch information
Adrian-Diaz authored Jan 14, 2025
2 parents 8004bff + 8c5e62f commit a58696d
Show file tree
Hide file tree
Showing 4 changed files with 58 additions and 45 deletions.
10 changes: 5 additions & 5 deletions src/EVPFFT/src/evpfft.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -146,6 +146,11 @@ void EVPFFT::set_some_voxels_arrays_to_zero()
void EVPFFT::init_after_reading_input_data()
{

init_xk_gb();
init_disgradmacro();
init_ept();
init_evm();

#ifndef ABSOLUTE_NO_OUTPUT
if (iwfields == 1) {
int imicro = 0;
Expand All @@ -154,11 +159,6 @@ void EVPFFT::init_after_reading_input_data()
}
#endif

init_xk_gb();
init_disgradmacro();
init_ept();
init_evm();

// the variables initialized in the funcitons below are reduced into
// and should be done once, hence the need for #if guard since the variables
// needs to be initialized after udot and dt are know from fierro
Expand Down
35 changes: 21 additions & 14 deletions src/EVPFFT/src/write_micro_state.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -474,30 +474,40 @@ void EVPFFT::write_micro_state_pvtu()
edotp.update_host();

// Calculate point positions
MatrixTypeRealDevice xtmp(3);
MatrixTypeRealDevice defgradavg(3,3);
MatrixTypeRealDual defgradavg(3,3);
MatrixTypeRealDual xintp(3,npts1+1,npts2+1,npts3+1);
MatrixTypeIntHost pid(npts1+1,npts2+1,npts3+1);

FOR_ALL(
for (int ii = 1; ii <= 3; ii++) {
for (int jj = 1; jj <= 3; jj++) {
if (imicro==0) {
defgradavg.host(ii,jj) = 0.0;
} else {
defgradavg.host(ii,jj) = disgradmacroactual(ii,jj);
}
if (ii==jj) {defgradavg.host(ii,jj) += 1.0;}
}
}
defgradavg.update_device();

FOR_ALL_CLASS(
kz, 1, npts3+2,
ky, 1, npts2+2,
kx, 1, npts1+2, {

xtmp(1) = double(kx+local_start1)-0.5;
xtmp(2) = double(ky+local_start2)-0.5;
xtmp(3) = double(kz+local_start3)-0.5;
double xtmp[3];
xtmp[0] = (double)kx+(double)local_start1-0.5;
xtmp[1] = (double)ky+(double)local_start2-0.5;
xtmp[2] = (double)kz+(double)local_start3-0.5;

for (int ii = 1; ii <= 3; ii++) {
real_t dum = 0.0;
for (int jj = 1; jj <= 3; jj++) {
defgradavg(ii,jj) = disgradmacroactual(ii,jj);
if (ii==jj) {defgradavg(ii,jj) += 1.0;}
dum += defgradavg(ii,jj)*xtmp(jj);
dum += defgradavg(ii,jj)*xtmp[jj-1];
}
xintp(ii,kx,ky,kz) = dum;
}
}); // end FOR_ALL
}); // end FOR_ALL_CLASS
Kokkos::fence();
xintp.update_host();

Expand Down Expand Up @@ -699,7 +709,6 @@ void EVPFFT::write_micro_state_pvtu()
out.open(filename,std::ofstream::binary);

byte_offset = 0;
double crap = 0.0;

// Write Header
//tmp_str = "<?xml version=\"1.0\"?>\n";
Expand Down Expand Up @@ -938,7 +947,7 @@ void EVPFFT::write_micro_state_pvtu()
for (int kx = 1; kx <= npts1+1; kx++){
ic += 1;
for (int dim = 1; dim <= num_dims; dim++){
coord_tmp = xintp(dim,kx,ky,kz);
coord_tmp = xintp.host(dim,kx,ky,kz);
out.write((char *) &coord_tmp,sizeof(coord_tmp));
}
pid(kx,ky,kz) = ic;
Expand Down Expand Up @@ -1006,7 +1015,6 @@ void EVPFFT::write_micro_state_pvtu()
// for (int node_gid = 0; node_gid < num_points; node_gid++){
// for (int dim = 0; dim < num_dims; dim++){
// //out.write((char *) &node_vel.host(1, node_gid, dim),sizeof(double));
// out.write((char *) &crap,sizeof(double));
// }
// }

Expand Down Expand Up @@ -1169,7 +1177,6 @@ void EVPFFT::write_micro_state_pvtu()
// for (int elem_gid = 0; elem_gid < num_cells; elem_gid++){
// for (int ii = 0; ii < 9; ii++){
// //out.write((char *) &elem_stress.host(1,elem_gid,ii),sizeof(double));
// out.write((char *) &crap,sizeof(double));
// }
// }
// // Density
Expand Down
14 changes: 7 additions & 7 deletions src/LS-EVPFFT/src/evpfft.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -150,6 +150,13 @@ void EVPFFT::set_some_voxels_arrays_to_zero()
void EVPFFT::init_after_reading_input_data()
{

init_xk_gb();
init_disgradmacro_velgradmacro();
init_ept();
init_disgrad();
init_evm();
init_defgrad();

#ifndef ABSOLUTE_NO_OUTPUT
if (iwfields == 1) {
int imicro = 0;
Expand All @@ -158,13 +165,6 @@ void EVPFFT::init_after_reading_input_data()
}
#endif

init_xk_gb();
init_disgradmacro_velgradmacro();
init_ept();
init_disgrad();
init_evm();
init_defgrad();

// the variables initialized in the funcitons below are reduced into
// and should be done once, hence the need for #if guard since the variables
// needs to be initialized after udot and dt are know from fierro
Expand Down
44 changes: 25 additions & 19 deletions src/LS-EVPFFT/src/write_micro_state.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -498,34 +498,42 @@ void EVPFFT::write_micro_state_pvtu()
edotp.update_host();

// Calculate point positions
MatrixTypeRealDevice xtmp(3);
MatrixTypeRealDual defgradavg_dual(3,3);
MatrixTypeRealDual uf(3,npts1_g,npts2_g,npts3_g);
MatrixTypeRealDual ufintp(3,npts1+1,npts2+1,npts3+1);
MatrixTypeRealDual xintp(3,npts1+1,npts2+1,npts3+1);
MatrixTypeIntHost pid(npts1+1,npts2+1,npts3+1);

FOR_ALL(
for (int ii = 1; ii <= 3; ii++) {
for (int jj = 1; jj <= 3; jj++) {
defgradavg_dual.host(ii,jj) = defgradavg(ii,jj);
}
}
defgradavg_dual.update_device();

FOR_ALL_CLASS(
kz, 1, npts3+1,
ky, 1, npts2+1,
kx, 1, npts1+1, {

xtmp(1) = double(kx);
xtmp(2) = double(ky);
xtmp(3) = double(kz);
double xtmp[3];
xtmp[0] = double(kx);
xtmp[1] = double(ky);
xtmp[2] = double(kz);
for (int ii = 1; ii <= 3; ii++) {
real_t dum = 0.0;
for (int jj = 1; jj <= 3; jj++) {
dum += defgradavg(ii,jj)*xtmp(jj);
dum += defgradavg_dual(ii,jj)*xtmp[jj-1];
}
uf(ii,kx+local_start1,ky+local_start2,kz+local_start3) = xnode(ii,kx,ky,kz) - dum;
}
}); // end FOR_ALL
}); // end FOR_ALL_CLASS
Kokkos::fence();
uf.update_host();

MPI_Allreduce(MPI_IN_PLACE, uf.host_pointer(), n, MPI_REAL_T, MPI_SUM, mpi_comm);

FOR_ALL(
FOR_ALL_CLASS(
kz, 1, npts3+2,
ky, 1, npts2+2,
kx, 1, npts1+2, {
Expand Down Expand Up @@ -572,27 +580,28 @@ void EVPFFT::write_micro_state_pvtu()
ufintp(ii,kx,ky,kz) = 0.125*(uf(ii,kxn1,kyn1,kzn1)+uf(ii,kxn2,kyn1,kzn1)+uf(ii,kxn1,kyn2,kzn1)+uf(ii,kxn2,kyn2,kzn1)+
uf(ii,kxn1,kyn1,kzn2)+uf(ii,kxn2,kyn1,kzn2)+uf(ii,kxn1,kyn2,kzn2)+uf(ii,kxn2,kyn2,kzn2) );
}
}); // end FOR_ALL
}); // end FOR_ALL_CLASS
Kokkos::fence();
ufintp.update_host();

FOR_ALL(
FOR_ALL_CLASS(
kz, 1, npts3+2,
ky, 1, npts2+2,
kx, 1, npts1+2, {

xtmp(1) = double(kx+local_start1)-0.5;
xtmp(2) = double(ky+local_start2)-0.5;
xtmp(3) = double(kz+local_start3)-0.5;
double xtmp[3];
xtmp[0] = double(kx+local_start1)-0.5;
xtmp[1] = double(ky+local_start2)-0.5;
xtmp[2] = double(kz+local_start3)-0.5;

for (int ii = 1; ii <= 3; ii++) {
real_t dum = 0.0;
for (int jj = 1; jj <= 3; jj++) {
dum += defgradavg(ii,jj)*xtmp(jj);
dum += defgradavg_dual(ii,jj)*xtmp[jj-1];
}
xintp(ii,kx,ky,kz) = dum + ufintp(ii,kx,ky,kz);
}
}); // end FOR_ALL
}); // end FOR_ALL_CLASS
Kokkos::fence();
xintp.update_host();

Expand Down Expand Up @@ -794,7 +803,6 @@ void EVPFFT::write_micro_state_pvtu()
out.open(filename,std::ofstream::binary);

byte_offset = 0;
double crap = 0.0;

// Write Header
//tmp_str = "<?xml version=\"1.0\"?>\n";
Expand Down Expand Up @@ -1033,7 +1041,7 @@ void EVPFFT::write_micro_state_pvtu()
for (int kx = 1; kx <= npts1+1; kx++){
ic += 1;
for (int dim = 1; dim <= num_dims; dim++){
coord_tmp = xintp(dim,kx,ky,kz);
coord_tmp = xintp.host(dim,kx,ky,kz);
out.write((char *) &coord_tmp,sizeof(coord_tmp));
}
pid(kx,ky,kz) = ic;
Expand Down Expand Up @@ -1101,7 +1109,6 @@ void EVPFFT::write_micro_state_pvtu()
// for (int node_gid = 0; node_gid < num_points; node_gid++){
// for (int dim = 0; dim < num_dims; dim++){
// //out.write((char *) &node_vel.host(1, node_gid, dim),sizeof(double));
// out.write((char *) &crap,sizeof(double));
// }
// }

Expand Down Expand Up @@ -1264,7 +1271,6 @@ void EVPFFT::write_micro_state_pvtu()
// for (int elem_gid = 0; elem_gid < num_cells; elem_gid++){
// for (int ii = 0; ii < 9; ii++){
// //out.write((char *) &elem_stress.host(1,elem_gid,ii),sizeof(double));
// out.write((char *) &crap,sizeof(double));
// }
// }
// // Density
Expand Down

0 comments on commit a58696d

Please sign in to comment.