Skip to content

Commit

Permalink
Merge pull request #65 from ClimateGlobalChange/vijaysm/num_elem_missing
Browse files Browse the repository at this point in the history
If num_elem attribute is missing, compute it
  • Loading branch information
paullric authored Apr 17, 2020
2 parents 471ca3e + cce73e4 commit d4769b6
Showing 1 changed file with 13 additions and 2 deletions.
15 changes: 13 additions & 2 deletions src/GridElements.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1179,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

0 comments on commit d4769b6

Please sign in to comment.