diff --git a/src/simplebuild_dgcode/data/pkgs/MCPL/G4MCPLPlugins/pymod__MCPLGen/mod.cc b/src/simplebuild_dgcode/data/pkgs/MCPL/G4MCPLPlugins/pymod__MCPLGen/mod.cc index 671946b..7efc5c6 100644 --- a/src/simplebuild_dgcode/data/pkgs/MCPL/G4MCPLPlugins/pymod__MCPLGen/mod.cc +++ b/src/simplebuild_dgcode/data/pkgs/MCPL/G4MCPLPlugins/pymod__MCPLGen/mod.cc @@ -294,11 +294,9 @@ void MCPLGen::init_weight_scale() return;//not present (e.g. files from older McStas versions): use weights as stored if ( !(nrays > 0.0) || !std::isfinite(nrays) ) { if (nrays == -1.0) - printf("MCPLGen ERROR - The input file has a stat:sum:initial_ray_count value which is not" - " available (for instance due to an interrupted run of the application writing the file," - " or because the file contains only a part of the particles of another file), so the weights" - " can not be normalised. Set normalise_by_initial_ray_count=false to use the weights as" - " stored in the file.\n"); + printf("MCPLGen ERROR - The input file has a stat:sum:initial_ray_count value of -1, which" + " means that the value is not available, so the weights can not be normalised. Set" + " normalise_by_initial_ray_count=false to use the weights as stored in the file.\n"); else printf("MCPLGen ERROR - The input file has an invalid stat:sum:initial_ray_count value (%g)," " so the weights can not be normalised. Set normalise_by_initial_ray_count=false to use" diff --git a/src/simplebuild_dgcode/data/pkgs/Utils/ExprParser/libinc/ASTNode.icc b/src/simplebuild_dgcode/data/pkgs/Utils/ExprParser/libinc/ASTNode.icc index eca8064..f90eaa8 100644 --- a/src/simplebuild_dgcode/data/pkgs/Utils/ExprParser/libinc/ASTNode.icc +++ b/src/simplebuild_dgcode/data/pkgs/Utils/ExprParser/libinc/ASTNode.icc @@ -81,31 +81,6 @@ namespace ExprParser { #endif } - template - inline ExprEntityPtr ExprEntity::optimisedVersion() - { - //todo: Can we move this to .cc and make sure implementations don't get copied to clients? - if (isConstant()) { - if (isConstantValue()) - return 0;//we are already optimal - return makeobj>(evaluate()); - } - optimiseChildren(); - auto p = specialOptimisedVersion(); - if (p) { - for (int i =0; i<100000; ++i) { - _ensure_type(p); - if (i==99999) - EXPRPARSER_THROW(LogicError,"non-converging optimisation loop"); - ExprEntityPtr p_opt = p->optimisedVersion(); - if (!p_opt) - break; - p = p_opt; - } - } - return p; - } - template inline ExprEntityConstantValue::ExprEntityConstantValue(TValue val) : ExprEntity(), diff --git a/src/simplebuild_dgcode/data/pkgs/Utils/ExprParser/libsrc/ASTNode.cc b/src/simplebuild_dgcode/data/pkgs/Utils/ExprParser/libsrc/ASTNode.cc index bec4a5d..f4b8efe 100644 --- a/src/simplebuild_dgcode/data/pkgs/Utils/ExprParser/libsrc/ASTNode.cc +++ b/src/simplebuild_dgcode/data/pkgs/Utils/ExprParser/libsrc/ASTNode.cc @@ -2,6 +2,30 @@ namespace ExprParser { + template + ExprEntityPtr ExprEntity::optimisedVersion() + { + if (isConstant()) { + if (isConstantValue()) + return 0;//we are already optimal + return makeobj>(evaluate()); + } + optimiseChildren(); + auto p = specialOptimisedVersion(); + if (p) { + for (int i =0; i<100000; ++i) { + _ensure_type(p); + if (i==99999) + EXPRPARSER_THROW(LogicError,"non-converging optimisation loop"); + ExprEntityPtr p_opt = p->optimisedVersion(); + if (!p_opt) + break; + p = p_opt; + } + } + return p; + } + template class ExprEntity; template class ExprEntity; template class ExprEntity; diff --git a/src/simplebuild_dgcode/data/pkgs_val/UnitTests/G4MCPLTests/app_mkfile/main.cc b/src/simplebuild_dgcode/data/pkgs_val/UnitTests/G4MCPLTests/app_mkfile/main.cc index f6793af..ea94056 100644 --- a/src/simplebuild_dgcode/data/pkgs_val/UnitTests/G4MCPLTests/app_mkfile/main.cc +++ b/src/simplebuild_dgcode/data/pkgs_val/UnitTests/G4MCPLTests/app_mkfile/main.cc @@ -4,8 +4,8 @@ // sb_g4mcpltests_mkfile FILENAME NPARTICLES WEIGHT INITIAL_RAY_COUNT // //A value of "none" for INITIAL_RAY_COUNT means that the file does not get a -//stat:sum:initial_ray_count, while "notfinal" leaves the value at -1 (as when -//the application writing the file was interrupted). +//stat:sum:initial_ray_count, while "notfinal" leaves the value at -1 (i.e. not +//available). #include "mcpl.h" #include diff --git a/src/simplebuild_dgcode/data/pkgs_val/UnitTests/G4MCPLTests/scripts/testmcplstatsums.log b/src/simplebuild_dgcode/data/pkgs_val/UnitTests/G4MCPLTests/scripts/testmcplstatsums.log index f6e001e..44b22bd 100644 --- a/src/simplebuild_dgcode/data/pkgs_val/UnitTests/G4MCPLTests/scripts/testmcplstatsums.log +++ b/src/simplebuild_dgcode/data/pkgs_val/UnitTests/G4MCPLTests/scripts/testmcplstatsums.log @@ -49,7 +49,7 @@ Output stat:sum:initial_geant4_weights = 10 ==> File with initial_ray_count which is not finalised - MCPLGen ERROR - The input file has a stat:sum:initial_ray_count value which is not available (for instance due to an interrupted run of the application writing the file, or because the file contains only a part of the particles of another file), so the weights can not be normalised. Set normalise_by_initial_ray_count=false to use the weights as stored in the file. + MCPLGen ERROR - The input file has a stat:sum:initial_ray_count value of -1, which means that the value is not available, so the weights can not be normalised. Set normalise_by_initial_ray_count=false to use the weights as stored in the file. (simulation failed as expected) ==> File with initial_ray_count which is not finalised, not normalised @@ -144,5 +144,5 @@ Output stat:sum:initial_ray_count = ==> File where initial_ray_count is unavailable - MCPLGen ERROR - The input file has a stat:sum:initial_ray_count value which is not available (for instance due to an interrupted run of the application writing the file, or because the file contains only a part of the particles of another file), so the weights can not be normalised. Set normalise_by_initial_ray_count=false to use the weights as stored in the file. + MCPLGen ERROR - The input file has a stat:sum:initial_ray_count value of -1, which means that the value is not available, so the weights can not be normalised. Set normalise_by_initial_ray_count=false to use the weights as stored in the file. (simulation failed as expected)