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... |
gonuke
left a comment
There was a problem hiding this comment.
Some thoughts based on context and background.
| 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.
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.
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.
sounds about right for $rev
I don't know what this 10 is for....
There was a problem hiding this comment.
this comes from src/dagmc/DagMCVersion.hpp.in
There was a problem hiding this comment.
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
| 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.
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.
| 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.
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.
just wondering if only one of them is non zero would the min()/max() still work ?
|
|
||
| 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.
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.
I wonder if it's possible for this to be valid if >1???
There was a problem hiding this comment.
I do not know.
Would anyone would have with some more experience about this ?
There was a problem hiding this comment.
1 is caught earlier on, line 102
There was a problem hiding this comment.
ok I remember now,
162 ensure that density_props .size() <= 1
this ensure we have at lease 1 element before calling density_props[0]
| // 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.
Wow - this is verbose. Why can't C++ make this easier??? Does std::stod do any better?
There was a problem hiding this comment.
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. |
gonuke
left a comment
There was a problem hiding this comment.
Maybe a couple of things lost in the revisions...
| return result; | ||
| } | ||
|
|
||
| /* SECTION I: Geometry Initialization and problem setup */ |
There was a problem hiding this comment.
Did we take out the other comments that for these Section headers?
There was a problem hiding this comment.
I am not sure what I did with this...
Some kind of a weird combination of typos...
I'll restore it.
gonuke
left a comment
There was a problem hiding this comment.
Maybe a couple of things lost in the revisions...
gonuke
left a comment
There was a problem hiding this comment.
Two small requests & rebase for merge today
| // 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.
file_ext is already a std::string - no need to caste it here
|
|
||
| // surf/vol offsets are just first handles | ||
| setOffset = std::min(*surfs.begin(), *vols.begin()); | ||
| EntityHandle tmp_offset = 0; |
astyling astyling dagMC.hpp this should do it this should finally be working
Co-authored-by: Paul Wilson <paul.wilson@wisc.edu>
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 <paul.wilson@wisc.edu>
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...)