Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
  • Loading branch information
paullric committed Jun 12, 2020
2 parents e450cad + de48603 commit b7d1e56
Show file tree
Hide file tree
Showing 4 changed files with 45 additions and 21 deletions.
29 changes: 23 additions & 6 deletions src/GridElements.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -75,7 +75,9 @@ void Mesh::Clear() {

///////////////////////////////////////////////////////////////////////////////

void Mesh::ConstructEdgeMap(bool verbose) {
void Mesh::ConstructEdgeMap(
bool fVerbose
) {

// Construct the edge map
edgemap.clear();
Expand All @@ -99,7 +101,7 @@ void Mesh::ConstructEdgeMap(bool verbose) {
}
}

if (verbose) Announce("Mesh size: Edges [%i]", edgemap.size());
if (fVerbose) Announce("Mesh size: Edges [%i]", edgemap.size());
}

///////////////////////////////////////////////////////////////////////////////
Expand Down Expand Up @@ -258,7 +260,9 @@ void Mesh::ExchangeFirstAndSecondMesh() {

///////////////////////////////////////////////////////////////////////////////

void Mesh::RemoveCoincidentNodes() {
void Mesh::RemoveCoincidentNodes(
bool fVerbose
) {

// Put nodes into a map, tagging uniques
std::map<Node, int> mapNodes;
Expand All @@ -285,7 +289,9 @@ void Mesh::RemoveCoincidentNodes() {
return;
}

Announce("%i duplicate nodes detected", nodes.size() - vecUniques.size());
if(fVerbose) {
Announce("%i duplicate nodes detected", nodes.size() - vecUniques.size());
}

// Remove duplicates
NodeVector nodesOld = nodes;
Expand Down Expand Up @@ -1173,12 +1179,23 @@ void Mesh::Read(const std::string & strFile) {
int nElementBlocks = dimElementBlocks->size();

// Total number of elements
int nTotalElementCount = 0;
NcDim * dimElements = ncFile.get_dim("num_elem");
if (dimElements == NULL) {
_EXCEPTION1("Exodus Grid file \"%s\" is missing dimension "
for (unsigned ib = 1; ib <= nElementBlocks; ++ib)
{
std::string numelblk = std::string("num_el_in_blk"+std::to_string(ib));
NcDim * dimElementBlockElems = ncFile.get_dim(numelblk.c_str());
nTotalElementCount += (dimElementBlockElems != NULL ? dimElementBlockElems->size() : 0);
}
if (nTotalElementCount == 0)
_EXCEPTION1("Exodus Grid file \"%s\" is missing dimension "
"\"num_elem\"", strFile.c_str());
}
int nTotalElementCount = dimElements->size();
else
{
nTotalElementCount = dimElements->size();
}

// Output size
Announce("Mesh size: Nodes [%i] Elements [%i]",
Expand Down
8 changes: 6 additions & 2 deletions src/GridElements.h
Original file line number Diff line number Diff line change
Expand Up @@ -722,7 +722,9 @@ class Mesh {
/// <summary>
/// Construct the EdgeMap from the NodeVector and FaceVector.
/// </summary>
void ConstructEdgeMap(bool verbose=true);
void ConstructEdgeMap(
bool fVerbose = true
);

/// <summary>
/// Construct the ReverseNodeArray from the NodeVector and FaceVector.
Expand Down Expand Up @@ -751,7 +753,9 @@ class Mesh {
/// <summary>
/// Remove coincident nodes from the Mesh and adjust indices in faces.
/// </summary>
void RemoveCoincidentNodes();
void RemoveCoincidentNodes(
bool fVerbose = true
);

/// <summary>
/// Write the mesh to a NetCDF file in Exodus format.
Expand Down
24 changes: 13 additions & 11 deletions src/OfflineMap.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -337,23 +337,25 @@ void OfflineMap::InitializeCoordinatesFromMeshFV(
DataArray1D<double> & dCenterLat,
DataArray2D<double> & dVertexLon,
DataArray2D<double> & dVertexLat,
bool fLatLon
bool fLatLon,
int nNodesPerFace
) {
int nFaces = mesh.faces.size();

// Count maximum number of Nodes per Face
int nNodesPerFace = 0;
for (int i = 0; i < nFaces; i++) {
if (mesh.faces[i].edges.size() > nNodesPerFace) {
nNodesPerFace = mesh.faces[i].edges.size();
}
}

// Check if already initialized
if (dCenterLon.GetRows() != 0) {
return;
}

int nFaces = mesh.faces.size();

// Count maximum number of Nodes per Face
if (nNodesPerFace == 0) {
for (int i = 0; i < nFaces; i++) {
if (mesh.faces[i].edges.size() > nNodesPerFace) {
nNodesPerFace = mesh.faces[i].edges.size();
}
}
}

dVertexLon.Allocate(nFaces, nNodesPerFace);
dVertexLat.Allocate(nFaces, nNodesPerFace);

Expand Down
5 changes: 3 additions & 2 deletions src/OfflineMap.h
Original file line number Diff line number Diff line change
Expand Up @@ -94,7 +94,7 @@ class OfflineMap {
const std::vector<int>& p_tgtDimSizes
);

private:
protected:
/// <summary>
/// Initialize the coordinate arrays for a finite-volume mesh.
/// </summary>
Expand All @@ -104,7 +104,8 @@ class OfflineMap {
DataArray1D<double> & dCenterLat,
DataArray2D<double> & dVertexLon,
DataArray2D<double> & dVertexLat,
bool fLatLon
bool fLatLon,
int nNodesPerFace = 0
);

/// <summary>
Expand Down

0 comments on commit b7d1e56

Please sign in to comment.