Skip to content

Add option to convert cooling times in output file to seconds#148

Open
anu1217 wants to merge 31 commits intosvalinn:mainfrom
anu1217:output_s
Open

Add option to convert cooling times in output file to seconds#148
anu1217 wants to merge 31 commits intosvalinn:mainfrom
anu1217:output_s

Conversation

@anu1217
Copy link
Contributor

@anu1217 anu1217 commented Nov 6, 2025

This PR introduces changes that allow the user to select the units (default or seconds) in which cooling times are printed in the headers of the output tables, if the units keyword is added in the output section of the input file.

Adding this in as a draft for now as this change has had many moving pieces, with changes to function definitions in multiple files, and I anticipate more work being necessary for everything to work as intended.

fixes #137

@gonuke
Copy link
Member

gonuke commented Dec 29, 2025

There is a merge conflict to be resolved here thanks to #215

@anu1217
Copy link
Contributor Author

anu1217 commented Dec 31, 2025

I've pulled from this branch and tested out these changes, and they appear to be working as expected. Some documentation changes are likely still needed.

@anu1217 anu1217 marked this pull request as ready for review December 31, 2025 13:51
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.

I'm a little surprised that this compiles, given some mismatches in the header and code.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think we need to write the cooling time units for these ones, too, probably

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Should print out the units for the other responses now

@anu1217 anu1217 force-pushed the output_s branch 4 times, most recently from 85748c1 to 81d5d7f Compare January 7, 2026 17:34
anu1217 and others added 4 commits January 7, 2026 11:44
Co-authored-by: Paul Wilson <paul.wilson@wisc.edu>
Co-authored-by: Paul Wilson <paul.wilson@wisc.edu>
Co-authored-by: Paul Wilson <paul.wilson@wisc.edu>
@anu1217
Copy link
Contributor Author

anu1217 commented Jan 7, 2026

Before marking this as ready for review, I changed my approach to this problem and pushed all my changes to a different branch, before merging the new branch into this one. I believe this didn't execute the way I expected and left some extraneous changes, which I think have all been resolved now.

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.

Sorry - this review was 1/2 done a while ago and got lost...

Comment on lines +145 to +153
if (cooltime_units == COOLTIME_S) // print cooling time converted to seconds
{
double t_sec = convertTime(ptr->coolingTime, ptr->units);
sprintf(textBuf, "%9.3e s ", t_sec);
}
else // print cooling time in default units
{
sprintf(textBuf, "%7g %c ", ptr->coolingTime, ptr->units);
}
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Maybe a short function

std::string coolingTimeStr(int coolTimeUnit)

That does this to ensure consistency across different places we do this (currently only two)

src/Result.C Outdated
Comment on lines +608 to +617
metricMult = 1;
}
cooltime_units = cooltimeType;
}
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'm not sure this is right...

Don't we still want to make sure metricMult is set correctly in the default case? An don't we want to update cooltime_units regardless of the value of normType?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think I may have deleted too many lines after getting rid of a switch statement for cooltimeType...

Comment on lines +188 to +189
input >> token;
next->cooltimeUnits = new char[strlen(token)+2];
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

For better or worse, this is not backwards compatible and will make old input files fail. We should discuss how important that is...

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This should be backwards compatible now

anu1217 and others added 3 commits February 24, 2026 14:24
correctly set metric multiplier and cooltime units

remove unused break

address feedback
add std namespace

avoid crossing initialization

move initialization of pos

declare pos in block

remove extra space

reinitialize cooltimeUnits so that there is no extra space

initialize cooltimeUnits with the length of the units token

account for nonexisting cooling time units

check condition with first character of token
Address feedback and test some changes
Copy link
Contributor Author

@anu1217 anu1217 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I've addressed most of the feedback here and have tested these changes in a container.

src/Result.C Outdated
Comment on lines +608 to +617
metricMult = 1;
}
cooltime_units = cooltimeType;
}
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think I may have deleted too many lines after getting rid of a switch statement for cooltimeType...

Comment on lines +188 to +189
input >> token;
next->cooltimeUnits = new char[strlen(token)+2];
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This should be backwards compatible now

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.

Sorry for the delay - I had some pending changes that I forgot to submit.

switch (1<<type)
{
case OUTFMT_UNITS:
{
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Do we need these braces?

break;

delete[] next->cooltimeUnits;
next->cooltimeUnits = new char[strlen(token)+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'm not sure this is the right token to use to determine the length?

}
else if (tolower(token[0]) == 'd')
{
input.seekg(pos);
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

What is this doing? Can't you just do nothing in this case?

break;

delete[] next->cooltimeUnits;
next->cooltimeUnits = new char[strlen(token)+1];
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

For better or worse, this is not backwards compatible and will make old input files fail. We should discuss how important that is...

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Perhaps we figure out a way to make it optional?

Comment on lines +195 to +213
if (input >> token)
{
if (tolower(token[0]) == 's')
{
next->cooltimeType = COOLTIME_S;

delete[] next->cooltimeUnits;
next->cooltimeUnits = new char[strlen(token)+1];
strcpy(next->cooltimeUnits, token);
}
else if (tolower(token[0]) == 'd')
{
input.seekg(pos);
}
else
{
error(230, "Unknown cooling time unit '%s'", token);
}
}
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why might need to implement clang-formatting next, but this style is preferred:

Suggested change
if (input >> token)
{
if (tolower(token[0]) == 's')
{
next->cooltimeType = COOLTIME_S;
delete[] next->cooltimeUnits;
next->cooltimeUnits = new char[strlen(token)+1];
strcpy(next->cooltimeUnits, token);
}
else if (tolower(token[0]) == 'd')
{
input.seekg(pos);
}
else
{
error(230, "Unknown cooling time unit '%s'", token);
}
}
if (input >> token) {
if (tolower(token[0]) == 's') {
next->cooltimeType = COOLTIME_S;
delete[] next->cooltimeUnits;
next->cooltimeUnits = new char[strlen(token)+1];
strcpy(next->cooltimeUnits, token);
} else if (tolower(token[0]) == 'd') {
input.seekg(pos);
} else {
error(230, "Unknown cooling time unit '%s'", token);
}
}

Comment on lines +607 to +608
switch (normType)
{
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
switch (normType)
{
switch (normType) {

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.

add option to print time in seconds in output tables

2 participants