Skip to content

Commit 9cdbde5

Browse files
committed
CleanUp_v1
1 parent 5b3d76e commit 9cdbde5

File tree

4 files changed

+351
-405
lines changed

4 files changed

+351
-405
lines changed

src/pmpo_MPMesh.cpp

Lines changed: 43 additions & 46 deletions
Original file line numberDiff line numberDiff line change
@@ -386,15 +386,14 @@ void MPMesh::T2LTracking(Vec2dView dx){
386386
}
387387

388388
void MPMesh::reconstructSlices() {
389-
if (reconstructSlice.size() == 0) return;
390-
Kokkos::Timer timer;
391-
calcBasis(true);
392-
resetPreComputeFlag();
393-
for (auto const& [index, reconstruct] : reconstructSlice) {
394-
if (reconstruct) reconstruct();
395-
}
396-
reconstructSlice.clear();
397-
pumipic::RecordTime("PolyMPO_Reconstruct", timer.seconds());
389+
if (reconstructSlice.size() == 0) return;
390+
Kokkos::Timer timer;
391+
calcBasis(true);
392+
for (auto const& [index, reconstruct] : reconstructSlice) {
393+
if (reconstruct) reconstruct();
394+
}
395+
reconstructSlice.clear();
396+
pumipic::RecordTime("PolyMPO_Reconstruct", timer.seconds());
398397
}
399398

400399
bool getAnyIsMigrating(MaterialPoints* p_MPs, bool isMigrating) {
@@ -448,9 +447,7 @@ void MPMesh::push_swap_pos(){
448447
p_MPs->updateMPSlice<MPF_Cur_Pos_Rot_Lat_Lon, MPF_Tgt_Pos_Rot_Lat_Lon>();
449448
}
450449

451-
452-
void MPMesh::push(){
453-
450+
void MPMesh::push(){
454451
Kokkos::Timer timer;
455452

456453
p_mesh->computeRotLatLonIncr();
@@ -483,43 +480,43 @@ void MPMesh::push(){
483480
}
484481

485482
void MPMesh::printVTP_mesh(int printVTPIndex){
486-
auto vtxCoords = p_mesh->getMeshField<polyMPO::MeshF_VtxCoords>();
487-
auto elm2VtxConn = p_mesh->getElm2VtxConn();
483+
auto vtxCoords = p_mesh->getMeshField<polyMPO::MeshF_VtxCoords>();
484+
auto elm2VtxConn = p_mesh->getElm2VtxConn();
488485

489-
auto MPsPosition = p_MPs->getPositions();
486+
auto MPsPosition = p_MPs->getPositions();
490487

491-
char* fileOutput = (char *)malloc(sizeof(char) * 256);
492-
sprintf(fileOutput,"polyMPO_MPMesh_mesh_%d.vtp", printVTPIndex);
493-
FILE * pFile = fopen(fileOutput,"w");
494-
free(fileOutput);
495-
496-
auto h_vtxCoords = Kokkos::create_mirror_view(vtxCoords);
497-
IntVtx2ElmView::HostMirror h_elm2VtxConn = Kokkos::create_mirror_view(elm2VtxConn);
498-
const int nCells = p_mesh->getNumElements();
499-
const int nVertices = p_mesh->getNumVertices();
500-
Kokkos::deep_copy(h_vtxCoords,vtxCoords);
501-
Kokkos::deep_copy(h_elm2VtxConn,elm2VtxConn);
502-
fprintf(pFile, "<VTKFile type=\"PolyData\" version=\"1.0\" byte_order=\"LittleEndian\" header_type=\"UInt64\">\n <PolyData>\n <Piece NumberOfPoints=\"%d\" NumberOfVerts=\"0\" NumberOfLines=\"0\" NumberOfStrips=\"0\" NumberOfPolys=\"%d\">\n <Points>\n <DataArray type=\"Float32\" Name=\"Points\" NumberOfComponents=\"3\" format=\"ascii\">\n",nVertices,nCells);
503-
for(int i=0; i<nVertices; i++){
504-
fprintf(pFile, " %f %f %f\n",h_vtxCoords(i,0),h_vtxCoords(i,1),h_vtxCoords(i,2));
505-
}
506-
fprintf(pFile, " </DataArray>\n </Points>\n <Polys>\n <DataArray type=\"Int64\" Name=\"connectivity\" format=\"ascii\">\n");
507-
for(int i=0; i<nCells; i++){
508-
fprintf(pFile, " ");
509-
for(int j=0; j< h_elm2VtxConn(i,0); j++){
510-
fprintf(pFile, "%d ", h_elm2VtxConn(i,j+1)-1);
511-
}
512-
fprintf(pFile, "\n");
513-
}
514-
fprintf(pFile, " </DataArray>\n <DataArray type=\"Int64\" Name=\"offsets\" format=\"ascii\">\n");
488+
char* fileOutput = (char *)malloc(sizeof(char) * 256);
489+
sprintf(fileOutput,"polyMPO_MPMesh_mesh_%d.vtp", printVTPIndex);
490+
FILE * pFile = fopen(fileOutput,"w");
491+
free(fileOutput);
492+
493+
auto h_vtxCoords = Kokkos::create_mirror_view(vtxCoords);
494+
IntVtx2ElmView::HostMirror h_elm2VtxConn = Kokkos::create_mirror_view(elm2VtxConn);
495+
const int nCells = p_mesh->getNumElements();
496+
const int nVertices = p_mesh->getNumVertices();
497+
Kokkos::deep_copy(h_vtxCoords,vtxCoords);
498+
Kokkos::deep_copy(h_elm2VtxConn,elm2VtxConn);
499+
fprintf(pFile, "<VTKFile type=\"PolyData\" version=\"1.0\" byte_order=\"LittleEndian\" header_type=\"UInt64\">\n <PolyData>\n <Piece NumberOfPoints=\"%d\" NumberOfVerts=\"0\" NumberOfLines=\"0\" NumberOfStrips=\"0\" NumberOfPolys=\"%d\">\n <Points>\n <DataArray type=\"Float32\" Name=\"Points\" NumberOfComponents=\"3\" format=\"ascii\">\n",nVertices,nCells);
500+
for(int i=0; i<nVertices; i++){
501+
fprintf(pFile, " %f %f %f\n",h_vtxCoords(i,0),h_vtxCoords(i,1),h_vtxCoords(i,2));
502+
}
503+
fprintf(pFile, " </DataArray>\n </Points>\n <Polys>\n <DataArray type=\"Int64\" Name=\"connectivity\" format=\"ascii\">\n");
504+
for(int i=0; i<nCells; i++){
505+
fprintf(pFile, " ");
506+
for(int j=0; j< h_elm2VtxConn(i,0); j++){
507+
fprintf(pFile, "%d ", h_elm2VtxConn(i,j+1)-1);
508+
}
509+
fprintf(pFile, "\n");
510+
}
511+
fprintf(pFile, " </DataArray>\n <DataArray type=\"Int64\" Name=\"offsets\" format=\"ascii\">\n");
515512

516-
int count = 0;
517-
for(int i=0;i<nCells; i++){
518-
count += h_elm2VtxConn(i,0);
519-
fprintf(pFile, " %d\n",count);
520-
}
521-
fprintf(pFile, " </DataArray>\n </Polys>\n </Piece>\n </PolyData>\n</VTKFile>\n");
522-
fclose(pFile);
513+
int count = 0;
514+
for(int i=0;i<nCells; i++){
515+
count += h_elm2VtxConn(i,0);
516+
fprintf(pFile, " %d\n",count);
517+
}
518+
fprintf(pFile, " </DataArray>\n </Polys>\n </Piece>\n </PolyData>\n</VTKFile>\n");
519+
fclose(pFile);
523520
}
524521

525522
}

src/pmpo_MPMesh.hpp

Lines changed: 17 additions & 43 deletions
Original file line numberDiff line numberDiff line change
@@ -24,45 +24,33 @@ class MPMesh{
2424

2525
public:
2626

27-
MPMesh() : isPreComputed(false){};
28-
void computeMatricesAndSolve();
29-
void resetPreComputeFlag();
30-
Kokkos::View<double*[vec4d_nEntries]> precomputedVtxCoeffs;
31-
Kokkos::View<double*[vec3d_nEntries][vec4d_nEntries]> precomputedVtxCoeffs_new;
32-
3327
Mesh* p_mesh;
3428
MaterialPoints* p_MPs;
3529

36-
std::map<MeshFieldIndex, std::function<void()>> reconstructSlice = std::map<MeshFieldIndex, std::function<void()>>();
37-
3830
//For MPI Communication
3931
int numOwnersTot, numHalosTot;
4032
std::vector<int> numOwnersOnOtherProcs;
4133
std::vector<int> numHalosOnOtherProcs;
4234
std::vector<int>haloOwnerProcs;
43-
44-
std::vector<std::vector<int>> haloOwnerLocalIDs;
45-
46-
//Halos send to owners globalIDs which are converted to local IDs of owners
47-
//Also keep haloLocalID in owner
35+
std::vector<std::vector<int>> haloOwnerLocalIDs;
4836
std::vector<std::vector<int>> ownerOwnerLocalIDs;
4937
std::vector<std::vector<int>> ownerHaloLocalIDs;
5038

5139
void startCommunication();
5240
void communicateFields(const std::vector<std::vector<double>>& fieldData, const int numEntities, const int numEntries, int mode,
5341
std::vector<std::vector<int>>& recvIDVec, std::vector<std::vector<double>>& recvDataVec);
54-
5542
void communicate_and_take_halo_contributions(const Kokkos::View<double**>& meshField, int nEntities, int numEntries, int mode, int op);
56-
43+
5744
MPMesh(Mesh* inMesh, MaterialPoints* inMPs):
58-
p_mesh(inMesh), p_MPs(inMPs) {
45+
p_mesh(inMesh), p_MPs(inMPs) {
5946
};
6047

6148
~MPMesh() {
6249
delete p_mesh;
6350
delete p_MPs;
6451
}
6552

53+
//MP advection and tracking
6654
void CVTTrackingEdgeCenterBased(Vec2dView dx);
6755
void CVTTrackingElmCenterBased(const int printVTPIndex = -1);
6856
void T2LTracking(Vec2dView dx);
@@ -71,48 +59,34 @@ class MPMesh{
7159
void push_swap();
7260
void push_swap_pos();
7361
void push();
62+
7463
void calcBasis(bool use3DArea);
7564

65+
//Reconstruction
7666
DoubleView assemblyV0();
77-
template <MaterialPointSlice index>
78-
DoubleView wtScaAssembly();
79-
template <MaterialPointSlice index>
80-
Vec2dView wtVec2Assembly();
81-
template <MeshFieldIndex meshFieldIndex>
82-
void assembly(int order, MeshFieldType type, bool basisWeightFlag, bool massWeightFlag);
8367
template <MeshFieldIndex meshFieldIndex>
8468
void assemblyVtx0();
8569
template <MeshFieldIndex meshFieldIndex>
8670
void assemblyElm0();
8771
template <MeshFieldIndex meshFieldIndex>
88-
void assemblyVtx1();
89-
template <MeshFieldIndex meshFieldIndex>
90-
void subAssemblyVtx1(int vtxPerElm, int nCells, int comp, double* array);
91-
92-
void subAssemblyCoeffs(int vtxPerElm, int nCells, double* m11, double* m12, double* m13, double* m14,
93-
double* m22, double* m23, double* m24,
94-
double* m33, double* m34,
95-
double* m44);
96-
void solveMatrixAndRegularize(int nVertices, double* m11, double* m12, double* m13, double* m14,
97-
double* m22, double* m23, double* m24,
98-
double* m33, double* m34,
99-
double* m44);
100-
101-
template <MeshFieldIndex meshFieldIndex>
102-
void reconstruct_full();
72+
void assemblyVtx1();
10373
void reconstruct_coeff_full();
104-
void solveMatrix(const Kokkos::View<double**>& vtxMatrices, double& radius, bool scaling);
10574
void invertMatrix(const Kokkos::View<double**>& vtxMatrices, const double& radius);
106-
75+
Kokkos::View<double*[vec3d_nEntries][vec4d_nEntries]> precomputedVtxCoeffs_new;
76+
77+
//Not used currently
78+
std::map<MeshFieldIndex, std::function<void()>> reconstructSlice = std::map<MeshFieldIndex, std::function<void()>>();
79+
template <MaterialPointSlice index>
80+
DoubleView wtScaAssembly();
81+
template <MaterialPointSlice index>
82+
Vec2dView wtVec2Assembly();
83+
template <MeshFieldIndex meshFieldIndex>
84+
void assembly(int order, MeshFieldType type, bool basisWeightFlag, bool massWeightFlag);
10785
template<MeshFieldIndex meshFieldIndex>
10886
void setReconstructSlice(int order, MeshFieldType type);
10987
void reconstructSlices();
11088

111-
// Full assembly on GPU
112-
void assembleField(int vtxPerElm, int nCells, int nVerticesSolve, int nVertices, double* array_sub, double* array_full);
113-
11489
void printVTP_mesh(int printVTPIndex);
115-
11690
void calculateStrain();
11791
};
11892

0 commit comments

Comments
 (0)