Skip to content

Commit

Permalink
Changes requested in PR
Browse files Browse the repository at this point in the history
  • Loading branch information
dhyan1272 committed Sep 10, 2024
1 parent 1fe77ea commit 7aeb386
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 34 deletions.
25 changes: 3 additions & 22 deletions src/pmpo_MPMesh.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -116,8 +116,7 @@ void MPMesh::CVTTrackingElmCenterBased(const int printVTPIndex){
int numElms = p_mesh->getNumElements();
auto numMPs = p_MPs->getCount();

//const auto vtxCoords = p_mesh->getMeshField<polyMPO::MeshF_VtxCoords>();
const auto elCenters = p_mesh->getMeshField<polyMPO::MeshF_ElmCenterXYZ>();
const auto elmCenter = p_mesh->getMeshField<polyMPO::MeshF_ElmCenterXYZ>();

auto elm2VtxConn = p_mesh->getElm2VtxConn();
auto elm2ElmConn = p_mesh->getElm2ElmConn();
Expand All @@ -130,21 +129,6 @@ void MPMesh::CVTTrackingElmCenterBased(const int printVTPIndex){
printVTP_mesh(printVTPIndex);
}

/*
Vec3dView elmCenter("elementCenter",numElms);
Kokkos::parallel_for("calcElementCenter", numElms, KOKKOS_LAMBDA(const int elm){
int numVtx = elm2VtxConn(elm,0);
double sum_x = 0.0, sum_y = 0.0, sum_z = 0.0;
for(int i=1; i<= numVtx; i++){
sum_x += vtxCoords(elm2VtxConn(elm,i)-1,0);
sum_y += vtxCoords(elm2VtxConn(elm,i)-1,1);
sum_z += vtxCoords(elm2VtxConn(elm,i)-1,2);
}
elmCenter(elm)[0] = sum_x/numVtx;
elmCenter(elm)[1] = sum_y/numVtx;
elmCenter(elm)[2] = sum_z/numVtx;
});
*/
Vec3dView history("positionHistory",numMPs);
Vec3dView resultLeft("positionResult",numMPs);
Vec3dView resultRight("positionResult",numMPs);
Expand All @@ -159,11 +143,8 @@ void MPMesh::CVTTrackingElmCenterBased(const int printVTPIndex){
while(true){
int numConnElms = elm2ElmConn(iElm,0);

//Old delta
//Vec3d delta = MPnew - elmCenter(iElm);

//New delta
Vec3d center(elCenters(iElm, 0), elCenters(iElm, 1), elCenters(iElm, 2));
Vec3d center(elmCenter(iElm, 0), elmCenter(iElm, 1), elmCenter(iElm, 2));
Vec3d delta = MPnew - center;

double minDistSq = delta[0]*delta[0] + delta[1]*delta[1] + delta[2]*delta[2];
Expand All @@ -173,7 +154,7 @@ void MPMesh::CVTTrackingElmCenterBased(const int printVTPIndex){
int elmID = elm2ElmConn(iElm,i)-1;
//delta = MPnew - elmCenter(elmID);
//New delta
Vec3d center(elCenters(elmID, 0), elCenters(elmID, 1), elCenters(elmID, 2));
Vec3d center(elmCenter(elmID, 0), elmCenter(elmID, 1), elmCenter(elmID, 2));
delta = MPnew - center;

double neighborDistSq = delta[0]*delta[0] + delta[1]*delta[1] + delta[2]*delta[2];
Expand Down
23 changes: 11 additions & 12 deletions src/pmpo_c.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -705,14 +705,14 @@ void polympo_setMeshElmCenter_f(MPMesh_ptr p_mpmesh, const int nElements, const
PMT_ALWAYS_ASSERT(p_mesh->getNumElements()==nElements);

//copy the host array to the device
auto coordsArray = p_mesh->getMeshField<polyMPO::MeshF_ElmCenterXYZ>();
auto h_coordsArray = Kokkos::create_mirror_view(coordsArray);
auto elmCenter = p_mesh->getMeshField<polyMPO::MeshF_ElmCenterXYZ>();
auto h_elmCenter = Kokkos::create_mirror_view(elmCenter);
for(int i=0; i<nElements; i++){
h_coordsArray(i,0) = xArray[i];
h_coordsArray(i,1) = yArray[i];
h_coordsArray(i,2) = zArray[i];
h_elmCenter(i,0) = xArray[i];
h_elmCenter(i,1) = yArray[i];
h_elmCenter(i,2) = zArray[i];
}
Kokkos::deep_copy(coordsArray, h_coordsArray);
Kokkos::deep_copy(elmCenter, h_elmCenter);
}

void polympo_getMeshElmCenter_f(MPMesh_ptr p_mpmesh, const int nElements, double* xArray, double* yArray, double* zArray){
Expand All @@ -724,13 +724,12 @@ void polympo_getMeshElmCenter_f(MPMesh_ptr p_mpmesh, const int nElements, double
PMT_ALWAYS_ASSERT(p_mesh->getNumElements()==nElements);

//copy the device to host
auto coordsArray = p_mesh->getMeshField<polyMPO::MeshF_ElmCenterXYZ>();
auto h_coordsArray = Kokkos::create_mirror_view_and_copy(Kokkos::HostSpace(),
coordsArray);
auto elmCenter = p_mesh->getMeshField<polyMPO::MeshF_ElmCenterXYZ>();
auto h_elmCenter = Kokkos::create_mirror_view_and_copy(Kokkos::HostSpace(), elmCenter);
for(int i=0; i<nElements; i++){
xArray[i] = h_coordsArray(i,0);
yArray[i] = h_coordsArray(i,1);
zArray[i] = h_coordsArray(i,2);
xArray[i] = h_elmCenter(i,0);
yArray[i] = h_elmCenter(i,1);
zArray[i] = h_elmCenter(i,2);
}
}

Expand Down

0 comments on commit 7aeb386

Please sign in to comment.