-
Notifications
You must be signed in to change notification settings - Fork 24
Add option to convert cooling times in output file to seconds #148
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
base: main
Are you sure you want to change the base?
Changes from all commits
1df072d
81d5d7f
a53e8ea
55c8258
bb93e50
a7228d1
9b4edba
9370056
182e487
266d1f4
5994579
4bc23ae
b142877
bbc962a
ef89289
8fec07e
6eba7c6
3d950f2
20dab87
717b0e5
598b1fb
cce2f7e
582f8b0
32fea30
5da0c69
ba06de0
73212f2
257c8d8
31d3c5e
5f0a04f
d75be17
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
|
|
@@ -51,14 +51,18 @@ OutputFormat::OutputFormat(int type) | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| strcpy(normUnits,"/cm3"); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| normType = 1; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| cooltimeUnits = new char[5]; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| strcpy(cooltimeUnits,"def"); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| cooltimeType = 1; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| gammaSrc = NULL; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| contactDose = NULL; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| next = NULL; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| OutputFormat::OutputFormat(const OutputFormat& o) : | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| resolution(o.resolution), outTypes(o.outTypes), normType(o.normType), actMult(o.actMult) | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| resolution(o.resolution), outTypes(o.outTypes), normType(o.normType), actMult(o.actMult), cooltimeType(o.cooltimeType) | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| actUnits = new char[strlen(o.actUnits)+1]; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
|
@@ -67,13 +71,17 @@ OutputFormat::OutputFormat(const OutputFormat& o) : | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| normUnits = new char[strlen(o.normUnits)+1]; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| strcpy(normUnits,o.normUnits); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| cooltimeUnits = new char[strlen(o.cooltimeUnits)+1]; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| strcpy(cooltimeUnits,o.cooltimeUnits); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| next = NULL; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| OutputFormat::~OutputFormat() | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| delete[] actUnits; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| delete[] normUnits; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| delete[] cooltimeUnits; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| delete gammaSrc; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| delete contactDose; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| delete next; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
|
@@ -141,6 +149,7 @@ OutputFormat* OutputFormat::getOutFmts(istream& input) | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| switch (1<<type) | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| case OUTFMT_UNITS: | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Do we need these braces? |
||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| next->outTypes |= 1<<type; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| delete[] next->actUnits; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| input >> token; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
|
@@ -175,7 +184,34 @@ OutputFormat* OutputFormat::getOutFmts(istream& input) | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| next->normType = OUTNORM_CM3; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| break; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| break; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| delete[] next->cooltimeUnits; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| next->cooltimeUnits = new char[strlen(token)+1]; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe 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?
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe 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...
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Perhaps we figure out a way to make it optional? |
||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| strcpy(next->cooltimeUnits, ""); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| next->cooltimeType = COOLTIME_DEF; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| std::streampos pos = input.tellg(); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 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); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe 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? |
||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| else | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| error(230, "Unknown cooling time unit '%s'", token); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Comment on lines
+195
to
+213
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe 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
|
||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| case OUTFMT_WDR: | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| next->outTypes |= 1<<type; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| input >> token; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
|
@@ -282,7 +318,7 @@ void OutputFormat::write(Volume* volList, Mixture* mixList, Loading* loadList, | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| /* units */ | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| outTypeNum = 0; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| cout << "\t" << Out_Types_Str[outTypeNum] << ": " | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| << ptr->actUnits << " " << ptr->normUnits << endl; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| << ptr->actUnits << " " << ptr->normUnits << " " << ptr->cooltimeUnits << endl; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| /* regular singular responses */ | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| for (++outTypeNum;outTypeNum<lastSingularResponse;outTypeNum++) | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| if (ptr->outTypes & 1<<outTypeNum) | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
|
@@ -291,32 +327,32 @@ void OutputFormat::write(Volume* volList, Mixture* mixList, Loading* loadList, | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| case (OUTFMT_ACT): | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| sprintf(buffer,Out_Types_Str[outTypeNum], | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| ptr->actUnits,ptr->normUnits); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| ptr->actUnits,ptr->normUnits,ptr->cooltimeUnits); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| break; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| case (OUTFMT_SRC) : | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| sprintf(buffer,Out_Types_Str[outTypeNum], | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| /* deliver gamma src filename, */ | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| ptr->normUnits, ptr->gammaSrc->getFileName(),ptr->actUnits,ptr->normUnits); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| ptr->normUnits, ptr->gammaSrc->getFileName(),ptr->actUnits,ptr->normUnits,ptr->cooltimeUnits); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| break; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| case (OUTFMT_CDOSE) : | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| sprintf(buffer,Out_Types_Str[outTypeNum], | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| ptr->contactDose->getFileName()); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| ptr->contactDose->getFileName(),ptr->cooltimeUnits); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| break; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| case (OUTFMT_ADJ) : | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| sprintf(buffer,Out_Types_Str[outTypeNum], | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| ptr->adjointDose->getFileName()); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| ptr->adjointDose->getFileName(),ptr->cooltimeUnits); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| break; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| case (OUTFMT_EXP) : | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| sprintf(buffer, Out_Types_Str[outTypeNum], | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| ptr->exposureDose->getFileName()); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| ptr->exposureDose->getFileName(),ptr->cooltimeUnits); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| break; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| case (OUTFMT_EXP_CYL_VOL) : | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| sprintf(buffer, Out_Types_Str[outTypeNum], | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| ptr->exposureCylVolDose->getFileName()); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| ptr->exposureCylVolDose->getFileName(),ptr->cooltimeUnits); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| break; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| default: | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| sprintf(buffer,Out_Types_Str[outTypeNum], | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| ptr->normUnits); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| ptr->normUnits,ptr->cooltimeUnits); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| cout << "\t" << buffer << endl; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
|
@@ -333,7 +369,7 @@ void OutputFormat::write(Volume* volList, Mixture* mixList, Loading* loadList, | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| cout << endl << endl; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| /* set units for activity */ | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| Result::setNorm(ptr->actMult,ptr->normType); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| Result::setNorm(ptr->actMult,ptr->normType,ptr->cooltimeType); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| /* for each indicated response */ | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| for (outTypeNum=firstResponse;outTypeNum<lastSingularResponse;outTypeNum++) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -31,4 +31,7 @@ | |
| #define CM3_M3 1e-6 | ||
| #define G_KG 1e-3 | ||
|
|
||
| #define COOLTIME_DEF 1 | ||
| #define COOLTIME_S 2 | ||
|
|
||
| #endif | ||
| Original file line number | Diff line number | Diff line change | ||||||
|---|---|---|---|---|---|---|---|---|
|
|
@@ -35,6 +35,7 @@ double Result::actMult = 1; | |||||||
| double Result::metricMult = 1; | ||||||||
| GammaSrc* Result::gammaSrc = NULL; | ||||||||
| char* Result::outReminderStr = NULL; | ||||||||
| int Result::cooltime_units = COOLTIME_DEF; | ||||||||
|
|
||||||||
| /** When called with no arguments, the default constructor sets 'kza' | ||||||||
| and 'next' to 0 and NULL, respectively. Otherwise, they are set, | ||||||||
|
|
@@ -339,7 +340,7 @@ void Result::write(int response, int targetKza, Mixture *mixPtr, | |||||||
| cout << outReminderStr << endl;; | ||||||||
|
|
||||||||
| /* write a standard header for this table */ | ||||||||
| coolList->writeHeader(); | ||||||||
| coolList->writeHeader(Result::getCooltimeMode()); | ||||||||
|
|
||||||||
| if (response == OUTFMT_SRC) | ||||||||
| { | ||||||||
|
|
@@ -592,12 +593,19 @@ void Result::readDump() | |||||||
| } | ||||||||
| } | ||||||||
|
|
||||||||
| void Result::setNorm(double passedActMult, int normType) | ||||||||
| int Result::getCooltimeMode() | ||||||||
| { | ||||||||
| return cooltime_units; | ||||||||
| } | ||||||||
|
|
||||||||
|
|
||||||||
| void Result::setNorm(double passedActMult, int normType, int cooltimeType) | ||||||||
| { | ||||||||
|
|
||||||||
| actMult = passedActMult; | ||||||||
|
|
||||||||
| switch (normType) { | ||||||||
| switch (normType) | ||||||||
| { | ||||||||
|
Comment on lines
+607
to
+608
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
Suggested change
|
||||||||
| case OUTNORM_M3: | ||||||||
| metricMult = 1.0/CM3_M3; | ||||||||
| break; | ||||||||
|
|
@@ -607,6 +615,7 @@ void Result::setNorm(double passedActMult, int normType) | |||||||
| default: | ||||||||
| metricMult = 1; | ||||||||
| } | ||||||||
| cooltime_units = cooltimeType; | ||||||||
|
|
||||||||
| } | ||||||||
|
|
||||||||
|
|
||||||||
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 short function
That does this to ensure consistency across different places we do this (currently only two)