Skip to content

Commit

Permalink
PR changes 2
Browse files Browse the repository at this point in the history
  • Loading branch information
dhyan1272 committed Sep 17, 2024
1 parent 262a4aa commit e75fdb4
Show file tree
Hide file tree
Showing 5 changed files with 22 additions and 22 deletions.
12 changes: 6 additions & 6 deletions src/pmpo_c.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -696,37 +696,37 @@ void polympo_getMeshVtxRotLat_f(MPMesh_ptr p_mpmesh, const int nVertices, double
}
}

void polympo_setMeshElmCenter_f(MPMesh_ptr p_mpmesh, const int nElements, const double* xArray, const double* yArray, const double* zArray){
void polympo_setMeshElmCenter_f(MPMesh_ptr p_mpmesh, const int nCells, const double* xArray, const double* yArray, const double* zArray){
//chech validity
checkMPMeshValid(p_mpmesh);
auto p_mesh = ((polyMPO::MPMesh*)p_mpmesh)->p_mesh;

//check the size
PMT_ALWAYS_ASSERT(p_mesh->getNumElements()==nElements);
PMT_ALWAYS_ASSERT(p_mesh->getNumElements()==nCells);

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

void polympo_getMeshElmCenter_f(MPMesh_ptr p_mpmesh, const int nElements, double* xArray, double* yArray, double* zArray){
void polympo_getMeshElmCenter_f(MPMesh_ptr p_mpmesh, const int nCells, double* xArray, double* yArray, double* zArray){
//chech validity
checkMPMeshValid(p_mpmesh);
auto p_mesh = ((polyMPO::MPMesh*)p_mpmesh)->p_mesh;

//check the size
PMT_ALWAYS_ASSERT(p_mesh->getNumElements()==nElements);
PMT_ALWAYS_ASSERT(p_mesh->getNumElements()==nCells);

//copy the device to host
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++){
for(int i=0; i<nCells; i++){
xArray[i] = h_elmCenter(i,0);
yArray[i] = h_elmCenter(i,1);
zArray[i] = h_elmCenter(i,2);
Expand Down
4 changes: 2 additions & 2 deletions src/pmpo_c.h
Original file line number Diff line number Diff line change
Expand Up @@ -74,8 +74,8 @@ void polympo_setMeshVtxOnSurfVeloIncr_f(MPMesh_ptr p_mpmesh, const int nComps, c
void polympo_getMeshVtxOnSurfVeloIncr_f(MPMesh_ptr p_mpmesh, const int nComps, const int nVertices, double* array);//vec2d
void polympo_setMeshVtxOnSurfDispIncr_f(MPMesh_ptr p_mpmesh, const int nComps, const int nVertices, const double* array);//vec2d
void polympo_getMeshVtxOnSurfDispIncr_f(MPMesh_ptr p_mpmesh, const int nComps, const int nVertices, double* array);//vec2d
void polympo_setMeshElmCenter_f(MPMesh_ptr p_mpmesh, const int nElements, const double* xArray, const double* yArray, const double* zArray);
void polympo_getMeshElmCenter_f(MPMesh_ptr p_mpmesh, const int nElements, double* xArray, double* yArray, double* zArray);
void polympo_setMeshElmCenter_f(MPMesh_ptr p_mpmesh, const int nCells, const double* xArray, const double* yArray, const double* zArray);
void polympo_getMeshElmCenter_f(MPMesh_ptr p_mpmesh, const int nCells, double* xArray, double* yArray, double* zArray);

// calculations
void polympo_push_f(MPMesh_ptr p_mpmesh);
Expand Down
8 changes: 4 additions & 4 deletions src/pmpo_fortran.f90
Original file line number Diff line number Diff line change
Expand Up @@ -492,11 +492,11 @@ subroutine polympo_getMeshVtxRotLat(mpMesh, nVertices, latitude) &
!> @param nElements(in) length of array in, use for assertion
!> @param x/y/zArray(in) the 1D arrays of element centers coords
!---------------------------------------------------------------------------
subroutine polympo_setMeshElmCenter(mpMesh, nElements, xArray, yArray, zArray) &
subroutine polympo_setMeshElmCenter(mpMesh, nCells, xArray, yArray, zArray) &
bind(C, NAME='polympo_setMeshElmCenter_f')
use :: iso_c_binding
type(c_ptr), value :: mpMesh
integer(c_int), value :: nElements
integer(c_int), value :: nCells
type(c_ptr), intent(in), value :: xArray, yArray, zArray
end subroutine
!---------------------------------------------------------------------------
Expand All @@ -505,11 +505,11 @@ subroutine polympo_setMeshElmCenter(mpMesh, nElements, xArray, yArray, zArray) &
!> @param nElements(in) length of array in, use for assertion
!> @param x/y/zArray(in/out) the 1D arrays of element centers coords
!---------------------------------------------------------------------------
subroutine polympo_getMeshElmCenter(mpMesh, nElements, xArray, yArray, zArray) &
subroutine polympo_getMeshElmCenter(mpMesh, nCells, xArray, yArray, zArray) &
bind(C, NAME='polympo_getMeshElmCenter_f')
use :: iso_c_binding
type(c_ptr), value :: mpMesh
integer(c_int), value :: nElements
integer(c_int), value :: nCells
type(c_ptr), value :: xArray, yArray, zArray
end subroutine
!---------------------------------------------------------------------------
Expand Down
2 changes: 1 addition & 1 deletion src/pmpo_mesh.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,7 @@ namespace polyMPO{
auto elmMassMapEntry = meshFields2TypeAndString.at(MeshF_ElmMass);
PMT_ALWAYS_ASSERT(elmMassMapEntry.first == MeshFType_ElmBased);
elmMass_ = MeshFView<MeshF_ElmMass>(elmMassMapEntry.second,numElms_);
elmCenterXYZ_ = MeshFView<MeshF_ElmCenterXYZ>(meshFields2TypeAndString.at(MeshF_ElmCenterXYZ).second, numElms_);
elmCenterXYZ_ = MeshFView<MeshF_ElmCenterXYZ>(meshFields2TypeAndString.at(MeshF_ElmCenterXYZ).second,numElms_);
}

void Mesh::computeRotLatLonIncr(){
Expand Down
18 changes: 9 additions & 9 deletions src/pmpo_mesh.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -19,13 +19,13 @@ enum MeshFieldIndex{
MeshF_Unsupported,
MeshF_VtxCoords,
MeshF_VtxRotLat,
MeshF_ElmCenterXYZ,
MeshF_Vel,
MeshF_VtxMass,
MeshF_ElmMass,
MeshF_OnSurfVeloIncr,
MeshF_OnSurfDispIncr,
MeshF_RotLatLonIncr,
MeshF_ElmCenterXYZ
MeshF_RotLatLonIncr
};
enum MeshFieldType{
MeshFType_Invalid = -2,
Expand All @@ -37,13 +37,13 @@ enum MeshFieldType{
template <MeshFieldIndex> struct meshFieldToType;
template <> struct meshFieldToType < MeshF_VtxCoords > { using type = Kokkos::View<vec3d_t*>; };
template <> struct meshFieldToType < MeshF_VtxRotLat > { using type = DoubleView; };
template <> struct meshFieldToType < MeshF_ElmCenterXYZ > { using type = Kokkos::View<vec3d_t*>; };
template <> struct meshFieldToType < MeshF_Vel > { using type = Kokkos::View<vec2d_t*>; };
template <> struct meshFieldToType < MeshF_VtxMass > { using type = Kokkos::View<doubleSclr_t*>; };
template <> struct meshFieldToType < MeshF_ElmMass > { using type = Kokkos::View<doubleSclr_t*>; };
template <> struct meshFieldToType < MeshF_OnSurfVeloIncr > { using type = Kokkos::View<vec2d_t*>; };
template <> struct meshFieldToType < MeshF_OnSurfDispIncr > { using type = Kokkos::View<vec2d_t*>; };
template <> struct meshFieldToType < MeshF_RotLatLonIncr > { using type = Kokkos::View<vec2d_t*>; };
template <> struct meshFieldToType < MeshF_ElmCenterXYZ > { using type = Kokkos::View<vec3d_t*>; };

template <MeshFieldIndex index>
using MeshFView = typename meshFieldToType<index>::type;
Expand All @@ -54,13 +54,13 @@ const std::map<MeshFieldIndex, std::pair<MeshFieldType,
{MeshF_Unsupported, {MeshFType_Unsupported,"MeshField_Unsupported"}},
{MeshF_VtxCoords, {MeshFType_VtxBased,"MeshField_VerticesCoords"}},
{MeshF_VtxRotLat, {MeshFType_VtxBased,"MeshField_VerticesLatitude"}},
{MeshF_ElmCenterXYZ, {MeshFType_ElmBased,"MeshField_ElementCenterXYZ"}},
{MeshF_Vel, {MeshFType_VtxBased,"MeshField_Velocity"}},
{MeshF_VtxMass, {MeshFType_VtxBased,"MeshField_VerticesMass"}},
{MeshF_ElmMass, {MeshFType_ElmBased,"MeshField_ElementsMass"}},
{MeshF_OnSurfVeloIncr, {MeshFType_VtxBased,"MeshField_OnSurfaceVelocityIncrement"}},
{MeshF_OnSurfDispIncr, {MeshFType_VtxBased,"MeshField_OnSurfaceDisplacementIncrement"}},
{MeshF_RotLatLonIncr, {MeshFType_VtxBased,"MeshField_RotationalLatitudeLongitudeIncreasement"}},
{MeshF_ElmCenterXYZ, {MeshFType_ElmBased,"MeshField_ElementCenterXYZ"}}};
{MeshF_RotLatLonIncr, {MeshFType_VtxBased,"MeshField_RotationalLatitudeLongitudeIncreasement"}}};

enum mesh_type {mesh_unrecognized_lower = -1,
mesh_general_polygonal, //other meshes
Expand Down Expand Up @@ -88,13 +88,13 @@ class Mesh {
//start of meshFields
MeshFView<MeshF_VtxCoords> vtxCoords_;
MeshFView<MeshF_VtxRotLat> vtxRotLat_;
MeshFView<MeshF_ElmCenterXYZ> elmCenterXYZ_;
MeshFView<MeshF_Vel> vtxVel_;
MeshFView<MeshF_VtxMass> vtxMass_;
MeshFView<MeshF_ElmMass> elmMass_;
MeshFView<MeshF_OnSurfVeloIncr> vtxOnSurfVeloIncr_;
MeshFView<MeshF_OnSurfDispIncr> vtxOnSurfDispIncr_;
MeshFView<MeshF_RotLatLonIncr> vtxRotLatLonIncr_;
MeshFView<MeshF_ElmCenterXYZ>elmCenterXYZ_;
//DoubleMat2DView vtxStress_;

public:
Expand Down Expand Up @@ -173,6 +173,9 @@ auto Mesh::getMeshField(){
else if constexpr (index==MeshF_VtxRotLat){
return vtxRotLat_;
}
else if constexpr (index==MeshF_ElmCenterXYZ){
return elmCenterXYZ_;
}
else if constexpr (index==MeshF_Vel){
return vtxVel_;
}
Expand All @@ -191,9 +194,6 @@ auto Mesh::getMeshField(){
else if constexpr (index==MeshF_RotLatLonIncr){
return vtxRotLatLonIncr_;
}
else if constexpr (index==MeshF_ElmCenterXYZ){
return elmCenterXYZ_;
}
fprintf(stderr,"Mesh Field Index error!\n");
exit(1);
}
Expand Down

0 comments on commit e75fdb4

Please sign in to comment.