-
Notifications
You must be signed in to change notification settings - Fork 66
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
Addressing most of the comments about src/dagmc files #676
Conversation
I am thinking that addressing the linter suggestion in this PR might be a bit much... |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Some thoughts based on context and background.
src/dagmc/DagMC.cpp
Outdated
const char* interface_string = DAGMC_INTERFACE_REVISION; | ||
if (strlen(interface_string) >= 5) { | ||
std::string interface_string = DAGMC_INTERFACE_REVISION; | ||
if (interface_string.rfind("$Rev:") != std::string::npos) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Does anyone know if this actually works!?!? This looks like a tag expansion that was part of CVS/SVN, but I don't think we ever get "$Rev:" in the file anymore. Perhaps we need a new solution for this entirely?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
If it is working, maybe we should define $Rev:
as a string variable, and refer to it's length where we otherwise use 5 as a magic number below.
I'm not sure why 10 as a magic number below?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
sounds about right for $rev
I don't know what this 10 is for....
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
this comes from src/dagmc/DagMCVersion.hpp.in
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
and did not get populate in my DagMCVersion.hpp
:
#define DAGMC_INTERFACE_REVISION "$Rev$"
<- I still have this like in bld/src/dagmc/DagMCVersion.hpp
src/dagmc/DagMC.cpp
Outdated
if (sizeof(cfile) / sizeof(char) > 4) { | ||
memcpy(file_ext, &cfile[strlen(cfile) - 4], 4); | ||
} else { | ||
std::cerr << "DagMC warning: unhandled file " |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It might still be better for this error to be generated later, after any error messages that might get generated by load_file
. It also looks like they create a std::string
version of cfile
- maybe we should do that earlier and take advantage of std::string
functions throughout.
src/dagmc/DagMC.cpp
Outdated
EntityHandle tmp_offset = std::max(surfs.back(), vols.back()); | ||
EntityHandle tmp_offset = 0; | ||
|
||
if (surfs.size() != 0 && vols.size() != 0) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Looking back at the Pull-Request comment.... I am not sure if these checks are necessary. All valid DagMC geometries must have at least one surface and at least one volume. I don't know if there is a prior check to make sure this is true. If there is, then no check is needed here. If there is not, then perhaps we should check that both are non-zero length and give a failing error if either one is, and then use the (nearly) original code....
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
just wondering if only one of them is non zero would the min()
/max()
still work ?
src/dagmc/DagMC.hpp
Outdated
@@ -446,7 +454,7 @@ inline int DagMC::index_by_handle(EntityHandle handle) { | |||
} | |||
|
|||
inline unsigned int DagMC::num_entities(int dimension) { | |||
assert(0 <= dimension && 3 >= dimension); | |||
assert(0 <= dimension && groups_handle_idx >= dimension); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Since you've setup these variables, you might want to add:
vertex_handle_idx = 0
(to use here) and
curve_handle_idx = 1
(for completeness)
} else { | ||
grp_name = "mat:" + material_props[0]; | ||
volume_density_data_eh[eh] = ""; | ||
if (density_props.size() == 1) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I wonder if it's possible for this to be valid if >1???
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I do not know.
Would anyone would have with some more experience about this ?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
1 is caught earlier on, line 102
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
ok I remember now,
162 ensure that density_props .size() <= 1
this ensure we have at lease 1 element before calling density_props[0]
src/dagmc/dagmcmetadata.cpp
Outdated
@@ -250,7 +254,15 @@ void dagmcMetaData::parse_importance_data() { | |||
imp_particles.insert(pair.first); | |||
// insert into map too | |||
if (importance_map[eh].count(pair.first) == 0) { | |||
importance_map[eh][pair.first] = atof(pair.second.c_str()); | |||
char* e; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Wow - this is verbose. Why can't C++ make this easier??? Does std::stod
do any better?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It probably can, IIRC we hadnt shifted off the C++03 standard for MOAB compatability, so going back to C99 was the only option
Not sure why this is failing?? Might need a little more verbosity to figure it out. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Maybe a couple of things lost in the revisions...
src/dagmc/DagMC.cpp
Outdated
} | ||
return result; | ||
} | ||
|
||
/* SECTION I: Geometry Initialization and problem setup */ |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Did we take out the other comments that for these Section
headers?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I am not sure what I did with this...
Some kind of a weird combination of typos...
I'll restore it.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Maybe a couple of things lost in the revisions...
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Two small requests & rebase for merge today
src/dagmc/DagMC.cpp
Outdated
@@ -124,7 +144,7 @@ ErrorCode DagMC::load_file(const char* cfile) { | |||
// Some options were unhandled; this is common for loading h5m files. | |||
// Print a warning if an option was unhandled for a file that does not end in '.h5m' | |||
std::string filename(cfile); | |||
if (filename.length() < 4 || filename.substr(filename.length() - 4) != ".h5m") { | |||
if (std::string(file_ext) != ".h5m") { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
file_ext
is already a std::string
- no need to caste it here
src/dagmc/DagMC.cpp
Outdated
@@ -379,10 +398,14 @@ ErrorCode DagMC::build_indices(Range& surfs, Range& vols) { | |||
ErrorCode rval = MB_SUCCESS; | |||
|
|||
// surf/vol offsets are just first handles | |||
setOffset = std::min(*surfs.begin(), *vols.begin()); | |||
EntityHandle tmp_offset = 0; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Combine this with line 408
astyling astyling dagMC.hpp this should do it this should finally be working
Co-authored-by: Paul Wilson <[email protected]>
adding comments on error checking the string atof changing strstod to stod and adding mechanisum to catch conversion exception astyling DagMC.cpp and dagmcmetadata.cpp astyling DagMC.hpp
Co-authored-by: Paul Wilson <[email protected]>
addressing @gonuke last comments
@gonuke I think this is ready. |
Thanks @bam241 - finally merging!!! |
This addresses most of the comments about dagmc sources from #660 .
I was not sure how to fix some of them so I ping @pshriwise @gonuke @makeclean on them to get more information.
I also included changes suggested by my linter (mostly line <80 chars...)