-
Notifications
You must be signed in to change notification settings - Fork 1
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Ta/mpas cell centers #35
base: cws/pumipicDps
Are you sure you want to change the base?
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -255,13 +255,6 @@ void polympo_setMeshNumVtxs(MPMesh_ptr p_mpmesh, int numVtxs){ | |
p_mesh->setMeshVtxBasedFieldSize(); | ||
} | ||
|
||
int polympo_getMeshNumVtxs(MPMesh_ptr p_mpmesh) { | ||
checkMPMeshValid(p_mpmesh); //chech vailidity | ||
auto p_mesh = ((polyMPO::MPMesh*)p_mpmesh)->p_mesh; | ||
int nVtxs = p_mesh->getNumVertices(); | ||
return nVtxs; | ||
} | ||
|
||
void polympo_setMeshNumElms(MPMesh_ptr p_mpmesh, int numElms){ | ||
checkMPMeshValid(p_mpmesh); | ||
auto p_mesh = ((polyMPO::MPMesh*)p_mpmesh)->p_mesh; | ||
|
@@ -272,14 +265,10 @@ void polympo_setMeshNumElms(MPMesh_ptr p_mpmesh, int numElms){ | |
p_mesh->setNumElms(numElms); | ||
p_mesh->setElm2VtxConn(elm2Vtx); | ||
p_mesh->setElm2ElmConn(elm2Elm); | ||
p_mesh->setMeshVtxBasedFieldSize(); | ||
} | ||
|
||
int polympo_getMeshNumElms(MPMesh_ptr p_mpmesh) { | ||
checkMPMeshValid(p_mpmesh); //chech vailidity | ||
auto p_mesh = ((polyMPO::MPMesh*)p_mpmesh)->p_mesh; | ||
int nElms = p_mesh->getNumElements(); | ||
return nElms; | ||
} | ||
|
||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Remove empty lines |
||
|
||
void polympo_setMeshTypeGeneralPoly(MPMesh_ptr p_mpmesh){ | ||
//chech validity | ||
|
@@ -375,6 +364,20 @@ void polympo_setMeshElm2ElmConn(MPMesh_ptr p_mpmesh, int maxEdges, int nCells, i | |
}); | ||
} | ||
|
||
int polympo_getMeshNumVtxs(MPMesh_ptr p_mpmesh) { | ||
checkMPMeshValid(p_mpmesh); //chech vailidity | ||
auto p_mesh = ((polyMPO::MPMesh*)p_mpmesh)->p_mesh; | ||
int nVtxs = p_mesh->getNumVertices(); | ||
return nVtxs; | ||
} | ||
|
||
int polympo_getMeshNumElms(MPMesh_ptr p_mpmesh) { | ||
checkMPMeshValid(p_mpmesh); //chech vailidity | ||
auto p_mesh = ((polyMPO::MPMesh*)p_mpmesh)->p_mesh; | ||
int nElms = p_mesh->getNumElements(); | ||
return nElms; | ||
} | ||
|
||
void polympo_setMeshVtxCoords(MPMesh_ptr p_mpmesh, int nVertices, double* xArray, double* yArray, double* zArray){ | ||
//chech validity | ||
checkMPMeshValid(p_mpmesh); | ||
|
@@ -413,6 +416,38 @@ void polympo_getMeshVtxCoords(MPMesh_ptr p_mpmesh, int nVertices, double* xArray | |
} | ||
} | ||
|
||
/* | ||
void polympo_setMeshCellCenters(MPMesh_ptr p_mpmesh, int nCells, double* xArray, double* yArray, double* zArray){ | ||
|
||
checkMPMeshValid(p_mpmesh); | ||
auto p_mesh = ((polyMPO::MPMesh*)p_mpmesh)->p_mesh; | ||
|
||
auto centersArray = p_mesh->getMeshField<polyMPO::MeshF_CellCenters>(); | ||
auto h_centersArray = Kokkos::create_mirror_view(centersArray); | ||
for (int i =0; i<nCenters;i++){ | ||
xArray[i] = h_centersArray(i,0); | ||
yArray[i] = h_centersArray(i,1); | ||
zArray[i] = h_centersArray(i,2); | ||
} | ||
Kokkos::deep_copy(centersArray, h_centersArray); | ||
} | ||
|
||
void polympo_getMeshCellCenters(MPMesh_ptr p_mpmesh, int nCells, double* xArray, double* yArray, double* zArray){ | ||
|
||
checkMPMeshValid(p_mpmesh); | ||
auto p_mesh = ((polyMPO::MPMesh*)p_mpmesh)->p_mesh; | ||
|
||
auto centersArray = p_mesh->getMeshField<polyMPO::MeshF_CellCenters>(); | ||
auto h_centersArray = Kokkos::create_mirror_view_and_copy(Kokkos::HostSpace(),centersArray); | ||
|
||
for (int i=0;i<nCenters;i++){ | ||
xArray[i] = h_centersArray(i,0); | ||
yArray[i] = h_centersArray(i,1); | ||
zArray[i] = h_centersArray(i,2); | ||
} | ||
} | ||
*/ | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. If we don't need the code, please remove it. |
||
|
||
void polympo_setMeshOnSurfVeloIncr(MPMesh_ptr p_mpmesh, int nComps, int nVertices, double* array) { | ||
//check mpMesh is valid | ||
checkMPMeshValid(p_mpmesh); | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -38,19 +38,22 @@ void polympo_setMeshGeomTypePlanar(MPMesh_ptr p_mpmesh); | |
void polympo_setMeshGeomTypeSpherical(MPMesh_ptr p_mpmesh); | ||
void polympo_setMeshSphereRadius(MPMesh_ptr p_mpmesh, double sphereRadius); | ||
void polympo_setMeshNumVtxs(MPMesh_ptr p_mpmesh, int numVtxs); | ||
int polympo_getMeshNumVtxs(MPMesh_ptr p_mpmesh); | ||
void polympo_setMeshNumElms(MPMesh_ptr p_mpmesh, int numElms); | ||
int polympo_getMeshNumElms(MPMesh_ptr p_mpmesh); | ||
void polympo_setMeshNumEdgesPerElm(MPMesh_ptr p_mpmesh, int nCells, int* array); | ||
void polympo_setMeshElm2VtxConn(MPMesh_ptr p_mpmesh, int maxEdges, int nCells, int* array); | ||
void polympo_setMeshElm2ElmConn(MPMesh_ptr p_mpmesh, int maxEdges, int nCells, int* array); | ||
int polympo_getMeshNumVtxs(MPMesh_ptr p_mpmesh); | ||
int polympo_getMeshNumElms(MPMesh_ptr p_mpmesh); | ||
|
||
//Mesh fields | ||
void polympo_setMeshVtxCoords(MPMesh_ptr p_mpmesh, int nVertices, double* xArray, double* yArray, double* zArray); | ||
void polympo_getMeshVtxCoords(MPMesh_ptr p_mpmesh, int nVertices, double* xArray, double* yArray, double* zArray); | ||
void polympo_setMeshVtxCoords(MPMesh_ptr p_mpmesh, int nCells, double* xArray, double* yArray, double* zArray); | ||
void polympo_getMeshVtxCoords(MPMesh_ptr p_mpmesh, int nCells, double* xArray, double* yArray, double* zArray); | ||
//void polympo_setMeshCellCenters(MPMesh_ptr p_mpmesh, int nCenters, double* xArray, double* yArray, double* zArray); | ||
//void polympo_getMeshCellCenters(MPMesh_ptr p_mpmesh, int nCenters, double* xArray, double* yArray, double* zArray); | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Remove commented-out code. |
||
void polympo_setMeshOnSurfVeloIncr(MPMesh_ptr p_mpmesh, int nComps, int nVertices, double* array);//vec2d | ||
void polympo_getMeshOnSurfVeloIncr(MPMesh_ptr p_mpmesh, int nComps, int nVertices, double* array);//vec2d | ||
void polympo_setMeshOnSurfDispIncr(MPMesh_ptr p_mpmesh, int nComps, int nVertices, double* array);//vec2d | ||
void polympo_getMeshOnSurfDispIncr(MPMesh_ptr p_mpmesh, int nComps, int nVertices, double* array);//vec2d | ||
|
||
} | ||
#endif |
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -223,17 +223,6 @@ subroutine polympo_setMeshNumVtxs(mpMesh,numVtxs) & | |
integer(c_int), value :: numVtxs | ||
end subroutine | ||
!--------------------------------------------------------------------------- | ||
!> @brief get the number of vertices from the mesh holding by polyMPO | ||
!> @param mpMesh(in) mpMesh object | ||
!> @param numVtxs(return)) the number of vertices | ||
!--------------------------------------------------------------------------- | ||
function polympo_getMeshNumVtxs(mpMesh) result(numVtxs) & | ||
bind(C, NAME = 'polympo_getMeshNumVtxs') | ||
use :: iso_c_binding | ||
type(c_ptr), intent(in), value :: mpMesh | ||
integer(c_int) :: numVtxs | ||
end function | ||
!--------------------------------------------------------------------------- | ||
!> @brief set the number of elements of the mesh | ||
!> modifies mesh topology polympo_startMeshFill required | ||
!> @param mpMesh(in/out) mpMesh object | ||
|
@@ -246,17 +235,6 @@ subroutine polympo_setMeshNumElms(mpMesh,numElms) & | |
integer(c_int), value :: numElms | ||
end subroutine | ||
!--------------------------------------------------------------------------- | ||
!> @brief get the number of elements from the mesh holding by polyMPO | ||
!> @param mpMesh(in) mpMesh object | ||
!> @param numVtxs(return)) the number of elements | ||
!--------------------------------------------------------------------------- | ||
function polympo_getMeshNumElms(mpMesh) result(numElms) & | ||
bind(C, NAME = 'polympo_getMeshNumElms') | ||
use :: iso_c_binding | ||
type(c_ptr), intent(in), value :: mpMesh | ||
integer(c_int) :: numElms | ||
end function | ||
!--------------------------------------------------------------------------- | ||
!> @brief set the polympo mesh element to vertices connectivity | ||
!> modifies mesh topology polympo_startMeshFill required | ||
!> @param mpmesh(in/out) MPMesh object | ||
|
@@ -285,6 +263,28 @@ subroutine polympo_setMeshElm2ElmConn(mpMesh, maxEdges, nCells, cellsOnCell) & | |
type(c_ptr), intent(in), value :: cellsOnCell | ||
end subroutine | ||
!--------------------------------------------------------------------------- | ||
!> @brief get the number of vertices from the mesh holding by polyMPO | ||
!> @param mpMesh(in) mpMesh object | ||
!> @param numVtxs(return)) the number of vertices | ||
!--------------------------------------------------------------------------- | ||
function polympo_getMeshNumVtxs(mpMesh) result(numVtxs) & | ||
bind(C, NAME = 'polympo_getMeshNumVtxs') | ||
use :: iso_c_binding | ||
type(c_ptr), intent(in), value :: mpMesh | ||
integer(c_int) :: numVtxs | ||
end function | ||
!--------------------------------------------------------------------------- | ||
!> @brief get the number of elements from the mesh holding by polyMPO | ||
!> @param mpMesh(in) mpMesh object | ||
!> @param numVtxs(return)) the number of elements | ||
!--------------------------------------------------------------------------- | ||
function polympo_getMeshNumElms(mpMesh) result(numElms) & | ||
bind(C, NAME = 'polympo_getMeshNumElms') | ||
use :: iso_c_binding | ||
type(c_ptr), intent(in), value :: mpMesh | ||
integer(c_int) :: numElms | ||
end function | ||
!--------------------------------------------------------------------------- | ||
!> @brief set the polympo mesh number of edges per element | ||
!> modifies mesh topology polympo_startMeshFill required | ||
!> @param mpmesh(in/out) MPMesh object | ||
|
@@ -325,6 +325,32 @@ subroutine polympo_getMeshVtxCoords(mpMesh, nVertices, xArray, yArray, zArray) & | |
type(c_ptr), value :: xArray, yArray, zArray | ||
end subroutine | ||
!--------------------------------------------------------------------------- | ||
!> @brief set the polympo mesh cell centers | ||
!> @param mpmesh(in/out) MPMesh object | ||
!> @param nVertices(in) length of array in | ||
!> @param x/y/zArray(in) the 1D arrays of cell coordinates | ||
!--------------------------------------------------------------------------- | ||
!subroutine polympo_setMeshCellCenters(mpMesh, nCenters, xArray, yArray, zArray) & | ||
! bind(C, NAME='polympo_setMeshCellCenters') | ||
! use :: iso_c_binding | ||
! type(c_ptr), value :: mpMesh | ||
! integer(c_int), value:: nVertices | ||
! type(c_ptr), value :: xArray, yArray, zArray | ||
!end subroutine | ||
!--------------------------------------------------------------------------- | ||
!> @brief get the polympo mesh cell centers | ||
!> @param mpmesh(in/out) MPMesh object | ||
!> @param nVertices(in) length of array in, use for assertion | ||
!> @param x/y/zArray(in/out) the 1D arrays of vertices coordinates | ||
!--------------------------------------------------------------------------- | ||
!subroutine polympo_getMeshCellCenters(mpMesh, nCenters, xArray, yArray, zArray) & | ||
! bind(C, NAME='polympo_getMeshCellCenters') | ||
! use :: iso_c_binding | ||
! type(c_ptr), value :: mpMesh | ||
! integer(c_int), value :: nVertices | ||
! type(c_ptr), value :: xArray, yArray, zArray | ||
!end subroutine | ||
!--------------------------------------------------------------------------- | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Remove commented-out code. |
||
!> @brief set the spherical velocity increment mesh array | ||
!> from a host array | ||
!> @param mpmesh(in/out) MPMesh object | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -22,7 +22,8 @@ enum MeshFieldIndex{ | |
MeshF_VtxCoords, | ||
MeshF_Vel, | ||
MeshF_OnSurfVeloIncr, | ||
MeshF_OnSurfDispIncr | ||
MeshF_OnSurfDispIncr, | ||
MeshF_ElmCenterXYZ | ||
}; | ||
enum MeshFieldType{ | ||
MeshFType_Invalid = -2, | ||
|
@@ -37,7 +38,8 @@ const std::map<MeshFieldIndex, std::pair<MeshFieldType, | |
{MeshF_VtxCoords, {MeshFType_VtxBased,"MeshField_VerticesCoords"}}, | ||
{MeshF_Vel, {MeshFType_VtxBased,"MeshField_Velocity"}}, | ||
{MeshF_OnSurfVeloIncr, {MeshFType_VtxBased,"MeshField_OnSurfaceVelocityIncrement"}}, | ||
{MeshF_OnSurfDispIncr, {MeshFType_VtxBased,"MeshField_OnSurfaceDisplacementIncrement"}}}; | ||
{MeshF_OnSurfDispIncr, {MeshFType_VtxBased,"MeshField_OnSurfaceDisplacementIncrement"}}, | ||
{MeshF_ElmCenterXYZ, {MeshFType_ElmBased,"MeshField_ElementCenterXYZ"}}}; | ||
|
||
enum mesh_type {mesh_unrecognized_lower = -1, | ||
mesh_general_polygonal, //other meshes | ||
|
@@ -64,6 +66,7 @@ class Mesh { | |
|
||
//start of meshFields | ||
DoubleVec3dView vtxCoords_; | ||
DoubleVec3dView elmCenterXYZ_; | ||
DoubleVec2dView vtxVel_; | ||
DoubleVec2dView vtxOnSurfVeloIncr_; | ||
DoubleVec2dView vtxOnSurfDispIncr_; | ||
|
@@ -88,6 +91,7 @@ class Mesh { | |
elm2ElmConn_(elm2ElmConn){ | ||
meshEdit_ = true; | ||
setMeshVtxBasedFieldSize(); | ||
setMeshElmBasedFieldSize(); | ||
meshEdit_ = false; | ||
vtxCoords_ = vtxCoords; | ||
} | ||
|
@@ -105,6 +109,8 @@ class Mesh { | |
IntElm2ElmView getElm2ElmConn() { return elm2ElmConn_; } | ||
template<MeshFieldIndex index> auto getMeshField(); | ||
void setMeshVtxBasedFieldSize(); | ||
|
||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Please remove the empty line. |
||
void setMeshElmBasedFieldSize(); | ||
|
||
void setMeshEdit(bool meshEdit) { meshEdit_ = meshEdit; } | ||
//onec MeshType/GeomType is set to valid types, we can't change them anymore | ||
|
@@ -146,6 +152,9 @@ auto Mesh::getMeshField(){ | |
else if constexpr (index==MeshF_OnSurfDispIncr){ | ||
return vtxOnSurfDispIncr_; | ||
} | ||
else if constexpr (index==MeshF_ElmCenterXYZ){ | ||
return elmCenterXYZ_; | ||
} | ||
fprintf(stderr,"Mesh Field Index error!\n"); | ||
exit(1); | ||
} | ||
|
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Please remove this |
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -125,7 +125,8 @@ subroutine readMPASMesh(filename, maxEdges, vertexDegree, & | |
nCells, nVertices, nEdgesOnCell, & | ||
onSphere, sphereRadius, & | ||
xVertex, yVertex, zVertex, & | ||
verticesOnCell, cellsOnCell) | ||
verticesOnCell, cellsOnCell)!,& | ||
!cellCenters) | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Remove commented-out code. |
||
use :: netcdf | ||
use :: iso_c_binding | ||
implicit none | ||
|
@@ -142,7 +143,7 @@ subroutine readMPASMesh(filename, maxEdges, vertexDegree, & | |
|
||
integer :: ncid, status, nCellsID, nVerticesID, maxEdgesID, vertexDegreeID, & | ||
nEdgesOnCellID, xVertexID, yVertexID, zVertexID, & | ||
verticesOnCellID, cellsOnCellID | ||
verticesOnCellID, cellsOnCellID, cellCentersID | ||
|
||
status = nf90_open(path=trim(filename), mode=nf90_nowrite, ncid=ncid) | ||
if (status /= nf90_noerr) then | ||
|
@@ -211,9 +212,10 @@ subroutine readMPASMesh(filename, maxEdges, vertexDegree, & | |
allocate(yVertex(nVertices)) | ||
allocate(zVertex(nVertices)) | ||
allocate(nEdgesOnCell(nCells)) | ||
!allocate(cellCenters(nCells)) | ||
allocate(verticesOnCell(maxEdges, nCells)) | ||
allocate(cellsOnCell(maxEdges, nCells)) | ||
|
||
status = nf90_get_att(ncid, nf90_global, "on_a_sphere", onSphere) | ||
if (status /= nf90_noerr) then | ||
write(0, *) "readMPASMesh: Error on get attribute 'on_a_sphere'" | ||
|
@@ -315,6 +317,13 @@ subroutine readMPASMesh(filename, maxEdges, vertexDegree, & | |
stop | ||
end if | ||
|
||
!status = nf90_get_var(ncid, cellCentersID, cellCenters) | ||
!if (status /= nf90_noerr) then | ||
! write(0, *) "readMPASMesh: Error on get var of 'cellCenters'" | ||
! write(0, *) trim(nf90_strerror(status)) | ||
! stop | ||
!end if | ||
|
||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Remove commented-out code. |
||
status = nf90_close(ncid) | ||
end subroutine readMPASMesh | ||
subroutine setWithMPASMeshByFortran(mpMesh, fileName, n) bind(C, name="setWithMPASMeshByFortran") | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Please remove personal attribute files, and put this in
.gitignore