Skip to content

Commit d359c5b

Browse files
committed
Checked gnomonic projection of MPs, vertices
1 parent 89adb70 commit d359c5b

File tree

5 files changed

+48
-16
lines changed

5 files changed

+48
-16
lines changed

src/pmpo_MPMesh_assembly.hpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -687,7 +687,7 @@ void MPMesh::startCommunication(){
687687
//Temporary
688688
double radius = p_mesh->getSphereRadius();
689689
bool isRotated=false;
690-
//p_mesh->setGnomonicProjection(isRotated, radius);
690+
p_mesh->setGnomonicProjection(isRotated, radius);
691691

692692

693693
if (p_MPs->getOpMode() != polyMPO::MP_DEBUG)

src/pmpo_c.h

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -75,7 +75,6 @@ void polympo_setOwningProc_f(MPMesh_ptr p_mpmesh, const int nCells, const int* a
7575
void polympo_setOwningProcVertex_f(MPMesh_ptr p_mpmesh, const int nVertices, const int* array);
7676
void polympo_setElmGlobal_f(MPMesh_ptr p_mpmesh, const int nCells, const int* array);
7777
void polympo_setVtxGlobal_f(MPMesh_ptr p_mpmesh, const int nVertices, const int* array);
78-
void polympo_setGnomonicProjection(MPMesh_ptr p_mpmesh);
7978

8079
//Mesh fields
8180
int polympo_getMeshFVtxType_f();

src/pmpo_mesh.cpp

Lines changed: 10 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -44,6 +44,7 @@ namespace polyMPO{
4444

4545
auto dualTriangleAreaEntry = meshFields2TypeAndString.at(MeshF_DualTriangleArea);
4646
PMT_ALWAYS_ASSERT(dualTriangleAreaEntry.first == MeshFType_VtxBased);
47+
dualTriangleArea_ = MeshFView<MeshF_DualTriangleArea>(dualTriangleAreaEntry.second,numVtxs_);
4748
}
4849

4950
void Mesh::setMeshElmBasedFieldSize(){
@@ -78,17 +79,6 @@ namespace polyMPO{
7879
pumipic::RecordTime("PolyMPO_computeRotLatLonIncr", timer.seconds());
7980
}
8081

81-
KOKKOS_INLINE_FUNCTION
82-
void computeGnomonicProjectionAtPoint( const Vec3d& vtxCoord, const double gnomProjElmCenter[4], double& outX, double& outY) {
83-
const double iDen = 1.0 / ( gnomProjElmCenter[1] * gnomProjElmCenter[3] * vtxCoord[0] +
84-
gnomProjElmCenter[0] * gnomProjElmCenter[3] * vtxCoord[1] +
85-
gnomProjElmCenter[2] * vtxCoord[2]);
86-
outX = iDen * (vtxCoord[1] * gnomProjElmCenter[1] -
87-
vtxCoord[1] * gnomProjElmCenter[0]);
88-
outY = iDen * (vtxCoord[2] * gnomProjElmCenter[3] - vtxCoord[1] * gnomProjElmCenter[2] * gnomProjElmCenter[0] -
89-
vtxCoord[0] * gnomProjElmCenter[1] * gnomProjElmCenter[2]);
90-
}
91-
9282
void Mesh::setGnomonicProjection(bool isRotated, double radius){
9383
std::cout<<__FUNCTION__<<std::endl;
9484
auto gnomProjVtx = getMeshField<MeshF_VtxGnomProj>();
@@ -114,6 +104,10 @@ namespace polyMPO{
114104
gnomProjElmCenter(iElm, 2) = invR*elmCenter[2];
115105
gnomProjElmCenter(iElm, 3) = invR*cosLatR;
116106

107+
if(iElm < 10)
108+
printf("Elm %d, Centres %.15e %.15e %.15e %.15e \n", iElm, gnomProjElmCenter(iElm, 0), gnomProjElmCenter(iElm, 1),
109+
gnomProjElmCenter(iElm, 2), gnomProjElmCenter(iElm, 3) );
110+
117111
int nVtxE = elm2VtxConn(iElm,0);
118112
for(int i=0; i<nVtxE; i++){
119113
int vID = elm2VtxConn(iElm, i+1) - 1;
@@ -123,10 +117,14 @@ namespace polyMPO{
123117
}
124118

125119
double outX, outY;
126-
computeGnomonicProjectionAtPoint(vtxCord, &gnomProjElmCenter(iElm, 0), outX, outY);
120+
auto gnomProjElmCenter_sub = Kokkos::subview(gnomProjElmCenter, iElm, Kokkos::ALL);
121+
computeGnomonicProjectionAtPoint(vtxCord, gnomProjElmCenter_sub, outX, outY);
127122

128123
gnomProjVtx(iElm, i, 0) = outX;
129124
gnomProjVtx(iElm, i, 1) = outY;
125+
126+
if(iElm < 10)
127+
printf("Elm %d, Vtx %d -> outX: %.15e, outY: %.15e \n", iElm, i, outX, outY);
130128
}
131129
});
132130
}

src/pmpo_mesh.hpp

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -250,6 +250,23 @@ void Mesh::fillMeshField(int size, int numEntries, double val){
250250
});
251251
}
252252

253+
KOKKOS_INLINE_FUNCTION
254+
void computeGnomonicProjectionAtPoint(const Vec3d& Coord,
255+
const Kokkos::View<double[4], Kokkos::LayoutStride, Kokkos::MemoryTraits<Kokkos::Unmanaged>>& gnomProjElmCenter_sub,
256+
double& outX, double& outY){
257+
/*
258+
printf("Inline %.15e %.15e %.15e %.15e \n", gnomProjElmCenter_sub(0), gnomProjElmCenter_sub(1), gnomProjElmCenter_sub(2),
259+
gnomProjElmCenter_sub(3));
260+
*/
261+
const double iDen = 1.0 / (gnomProjElmCenter_sub(1) * gnomProjElmCenter_sub(3) * Coord[0] +
262+
gnomProjElmCenter_sub(0) * gnomProjElmCenter_sub(3) * Coord[1] +
263+
gnomProjElmCenter_sub(2) * Coord[2]);
264+
outX = iDen * (Coord[1] * gnomProjElmCenter_sub(1) -
265+
Coord[0] * gnomProjElmCenter_sub(0));
266+
outY = iDen * (Coord[2] * gnomProjElmCenter_sub(3) - Coord[1] * gnomProjElmCenter_sub(2) * gnomProjElmCenter_sub(0) -
267+
Coord[0] * gnomProjElmCenter_sub(1) * gnomProjElmCenter_sub(2));
268+
}
269+
253270
}
254271

255272
#endif

src/pmpo_wachspressBasis.hpp

Lines changed: 20 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -272,7 +272,6 @@ void getBasisByAreaGblFormSpherical2(Vec3d MP, int numVtxs, Vec3d* v,
272272
calcBasis(numVtxs, a, c, basis);
273273
}
274274

275-
276275
/*
277276
KOKKOS_INLINE_FUNCTION
278277
void getBasisByAreaGblForm_1(Vec2d MP, int numVtxs, Vec2d* vtxCoords, double* basis) {
@@ -359,6 +358,13 @@ void sphericalInterpolation(MPMesh& mpMesh){
359358
}
360359

361360

361+
KOKKOS_INLINE_FUNCTION
362+
void compute2DplanarTriangleArea(int numVtx,
363+
const Kokkos::View<double[maxVtxsPerElm][2], Kokkos::LayoutStride, Kokkos::MemoryTraits<Kokkos::Unmanaged>>& gnom_vtx_subview,
364+
double mpProjX, double mpProjY, double* basis){
365+
366+
}
367+
362368
inline void sphericalInterpolationDispVelIncr(MPMesh& mpMesh){
363369
Kokkos::Timer timer;
364370
auto p_mesh = mpMesh.p_mesh;
@@ -386,6 +392,10 @@ inline void sphericalInterpolationDispVelIncr(MPMesh& mpMesh){
386392
auto mpField1 = p_MPs->getData<mpfIndex1>();
387393
auto mpField2 = p_MPs->getData<mpfIndex2>();
388394

395+
// Field required for calculting gnomonic projection of MPs
396+
auto gnomProjVtx = p_mesh->getMeshField<polyMPO::MeshF_VtxGnomProj>();
397+
auto gnomProjElmCenter = p_mesh->getMeshField<polyMPO::MeshF_ElmCenterGnomProj>();
398+
389399
auto interpolation = PS_LAMBDA(const int& elm, const int& mp, const int& mask) {
390400
if(mask) {
391401
Vec3d position3d(MPsPosition(mp, 0), MPsPosition(mp, 1), MPsPosition(mp, 2));
@@ -404,7 +414,15 @@ inline void sphericalInterpolationDispVelIncr(MPMesh& mpMesh){
404414
initArray(basisByArea3d, maxVtxsPerElm, 0.0);
405415

406416
getBasisByAreaGblFormSpherical(position3d, numVtx, v3d, radius, basisByArea3d);
407-
417+
418+
//if using gnomonic Projection for weights
419+
double mpProjX, mpProjY;
420+
auto gnomProjElmCenter_sub = Kokkos::subview(gnomProjElmCenter, elm, Kokkos::ALL);
421+
computeGnomonicProjectionAtPoint(position3d, gnomProjElmCenter_sub, mpProjX, mpProjY);
422+
auto gnom_vtx_subview = Kokkos::subview(gnomProjVtx, elm, Kokkos::ALL, Kokkos::ALL);
423+
double basisbyArea2D[maxVtxsPerElm] = {0.0};
424+
compute2DplanarTriangleArea(numVtx, gnom_vtx_subview, mpProjX, mpProjY, basisbyArea2D);
425+
408426
for(int entry=0; entry<numEntries1; entry++){
409427
double mpValue = 0.0;
410428
for(int i=1; i<= numVtx; i++){

0 commit comments

Comments
 (0)