Skip to content
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

Fix angleEdge at culled mesh boundaries #580

Draft
wants to merge 1 commit into
base: master
Choose a base branch
from
Draft
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
16 changes: 15 additions & 1 deletion mesh_tools/mesh_conversion_tools_netcdf_c/mpas_cell_culler.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1231,6 +1231,7 @@ int mapAndOutputEdgeFields( const string inputFilename, const string outputFilen
double *dvEdgeOld, *dvEdgeNew;
double *dcEdgeOld, *dcEdgeNew;
double *angleEdgeOld, *angleEdgeNew;
bool *flipAngleEdge;

bool hasWeightsOnEdge, hasAngleEdge;

Expand All @@ -1239,6 +1240,7 @@ int mapAndOutputEdgeFields( const string inputFilename, const string outputFilen
cellsOnEdgeNew = new int[nEdgesNew*2];
verticesOnEdgeOld = new int[nEdges*2];
verticesOnEdgeNew = new int[nEdgesNew*2];
flipAngleEdge = new bool[nEdgesNew];

ncutil::get_var(inputFilename, "cellsOnEdge", cellsOnEdgeOld);
ncutil::get_var(inputFilename, "verticesOnEdge", verticesOnEdgeOld);
Expand Down Expand Up @@ -1269,18 +1271,21 @@ int mapAndOutputEdgeFields( const string inputFilename, const string outputFilen

verticesOnEdgeNew[edgeMap.at(iEdge)*2] = vertexMap.at(vertex1) + 1;
verticesOnEdgeNew[edgeMap.at(iEdge)*2+1] = vertexMap.at(vertex2) + 1;
flipAngleEdge[edgeMap.at(iEdge)] = false;
} else if (cellMap.at(cell2) == -1){
cellsOnEdgeNew[edgeMap.at(iEdge)*2] = cellMap.at(cell1) + 1;
cellsOnEdgeNew[edgeMap.at(iEdge)*2+1] = 0;

verticesOnEdgeNew[edgeMap.at(iEdge)*2] = vertexMap.at(vertex1) + 1;
verticesOnEdgeNew[edgeMap.at(iEdge)*2+1] = vertexMap.at(vertex2) + 1;
flipAngleEdge[edgeMap.at(iEdge)] = false;
} else if (cellMap.at(cell1) == -1){
cellsOnEdgeNew[edgeMap.at(iEdge)*2] = cellMap.at(cell2) + 1;
cellsOnEdgeNew[edgeMap.at(iEdge)*2+1] = 0;

verticesOnEdgeNew[edgeMap.at(iEdge)*2] = vertexMap.at(vertex2) + 1;
verticesOnEdgeNew[edgeMap.at(iEdge)*2+1] = vertexMap.at(vertex1) + 1;
flipAngleEdge[edgeMap.at(iEdge)] = true;
}
} else if(cell2 == -1){
if(cellMap.at(cell1) != -1){
Expand All @@ -1292,12 +1297,14 @@ int mapAndOutputEdgeFields( const string inputFilename, const string outputFilen
} else {
cout << "ERROR: Edge mask is 1, but has no cells." << endl;
}
flipAngleEdge[edgeMap.at(iEdge)] = false;
} else if(cell1 == -1){
cellsOnEdgeNew[edgeMap.at(iEdge)*2] = cellMap.at(cell2) + 1;
cellsOnEdgeNew[edgeMap.at(iEdge)*2+1] = 0;

verticesOnEdgeNew[edgeMap.at(iEdge)*2] = vertexMap.at(vertex2) + 1;
verticesOnEdgeNew[edgeMap.at(iEdge)*2+1] = vertexMap.at(vertex1) + 1;
flipAngleEdge[edgeMap.at(iEdge)] = true;
} else {
cout << "ERROR: Edge mask is 1, but has no cells." << endl;
}
Expand Down Expand Up @@ -1441,7 +1448,13 @@ int mapAndOutputEdgeFields( const string inputFilename, const string outputFilen
dvEdgeNew[edgeMap.at(iEdge)] = dvEdgeOld[iEdge];
dcEdgeNew[edgeMap.at(iEdge)] = dcEdgeOld[iEdge];
if(hasAngleEdge) {
angleEdgeNew[edgeMap.at(iEdge)] = angleEdgeOld[iEdge];
if(flipAngleEdge[edgeMap.at(iEdge)]) {
angleEdgeNew[edgeMap.at(iEdge)] =
fmod(angleEdgeOld[iEdge], 2.0*M_PI) - M_PI;
}
else {
angleEdgeNew[edgeMap.at(iEdge)] = angleEdgeOld[iEdge];
}
}
}
}
Expand All @@ -1465,6 +1478,7 @@ int mapAndOutputEdgeFields( const string inputFilename, const string outputFilen
delete[] dcEdgeNew;
delete[] angleEdgeOld;
delete[] angleEdgeNew;
delete[] flipAngleEdge;

return 0;
}/*}}}*/
Expand Down