diff --git a/src/EVPFFT/src/evpfft.cpp b/src/EVPFFT/src/evpfft.cpp index 9a782251e..7e3c1ba41 100644 --- a/src/EVPFFT/src/evpfft.cpp +++ b/src/EVPFFT/src/evpfft.cpp @@ -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; @@ -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 diff --git a/src/EVPFFT/src/write_micro_state.cpp b/src/EVPFFT/src/write_micro_state.cpp index d3820f5a0..22f6deaf9 100644 --- a/src/EVPFFT/src/write_micro_state.cpp +++ b/src/EVPFFT/src/write_micro_state.cpp @@ -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(); @@ -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 = "\n"; @@ -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; @@ -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)); // } // } @@ -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 diff --git a/src/LS-EVPFFT/src/evpfft.cpp b/src/LS-EVPFFT/src/evpfft.cpp index 70d3accad..fa98dbb84 100644 --- a/src/LS-EVPFFT/src/evpfft.cpp +++ b/src/LS-EVPFFT/src/evpfft.cpp @@ -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; @@ -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 diff --git a/src/LS-EVPFFT/src/write_micro_state.cpp b/src/LS-EVPFFT/src/write_micro_state.cpp index d4d02a25a..c04b8e6fc 100644 --- a/src/LS-EVPFFT/src/write_micro_state.cpp +++ b/src/LS-EVPFFT/src/write_micro_state.cpp @@ -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, { @@ -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(); @@ -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 = "\n"; @@ -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; @@ -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)); // } // } @@ -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