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

Addressing most of the comments about src/dagmc files #676

Merged
merged 5 commits into from
May 28, 2020

Conversation

bam241
Copy link
Member

@bam241 bam241 commented May 13, 2020

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...)

@bam241
Copy link
Member Author

bam241 commented May 13, 2020

I am thinking that addressing the linter suggestion in this PR might be a bit much...
Let me know I can simplify this if necessary....

@bam241 bam241 force-pushed the dagmc_PR_review branch from 83fd683 to 3453826 Compare May 15, 2020 16:28
Copy link
Member

@gonuke gonuke left a 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.

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) {
Copy link
Member

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?

Copy link
Member

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?

Copy link
Member Author

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....

Copy link
Member Author

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

Copy link
Member Author

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 Show resolved Hide resolved
src/dagmc/DagMC.cpp Outdated Show resolved Hide resolved
if (sizeof(cfile) / sizeof(char) > 4) {
memcpy(file_ext, &cfile[strlen(cfile) - 4], 4);
} else {
std::cerr << "DagMC warning: unhandled file "
Copy link
Member

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.

EntityHandle tmp_offset = std::max(surfs.back(), vols.back());
EntityHandle tmp_offset = 0;

if (surfs.size() != 0 && vols.size() != 0) {
Copy link
Member

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....

Copy link
Member Author

@bam241 bam241 May 18, 2020

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 ?

@@ -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);
Copy link
Member

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) {
Copy link
Member

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???

Copy link
Member Author

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 ?

Copy link
Contributor

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

Copy link
Member Author

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 Show resolved Hide resolved
@@ -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;
Copy link
Member

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?

Copy link
Contributor

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

src/dagmc/tests/dagmc_pointinvol_test.cpp Outdated Show resolved Hide resolved
@gonuke
Copy link
Member

gonuke commented May 17, 2020

Not sure why this is failing?? Might need a little more verbosity to figure it out.

Copy link
Member

@gonuke gonuke left a 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...

}
return result;
}

/* SECTION I: Geometry Initialization and problem setup */
Copy link
Member

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?

Copy link
Member Author

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.

src/dagmc/DagMC.cpp Outdated Show resolved Hide resolved
Copy link
Member

@gonuke gonuke left a 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...

Copy link
Member

@gonuke gonuke left a 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

@@ -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") {
Copy link
Member

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

@@ -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;
Copy link
Member

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

@bam241 bam241 force-pushed the dagmc_PR_review branch from 45fe862 to e29bc6c Compare May 28, 2020 15:58
bam241 and others added 5 commits May 28, 2020 12:09
astyling

astyling dagMC.hpp

this should do it

this should finally be working
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
@bam241 bam241 force-pushed the dagmc_PR_review branch from e29bc6c to 4da86ca Compare May 28, 2020 17:13
@bam241
Copy link
Member Author

bam241 commented May 28, 2020

@gonuke I think this is ready.
I rebased, addressed your 2 remaining comments and cleaned the commit history (squash).

@gonuke
Copy link
Member

gonuke commented May 28, 2020

Thanks @bam241 - finally merging!!!

@gonuke gonuke merged commit bd4eb76 into svalinn:develop May 28, 2020
@bam241 bam241 deleted the dagmc_PR_review branch November 28, 2024 14:39
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants