Open abhyshr opened 1 year ago
No idea what this does. There is hardly any documentation about its intended usage. Seems to me like this is expendable if not used extensively.
Hi Shri, sorry I am not sure whether I messed up this issue #126 by closing it accidentally. I agree with your comments that "have a general "verbosity" level class that prints selective information depending on the verbosity level set. Verbosity level = 0 will print nothing and verbosity level = max_level will print all information." And we can also remove the usage of this class in the dsf_main.cpp, while I would suggest that we keep this class in GridPACK so in the python wrapper we can still easily call this function, otherwise the current existing code of reinforcement learning training will all not work, thanks.
Duly noted. The NoPrint class will not be removed till we put a better alternative for it. I have disabled it though (set status to false) for the dynamics simulation application.
Btw, are you using Gridpack or plan to use it in the future?
As Renke mentioned, the NoPrint class was created to control the printing to standard out so that applications like HADREC would work properly. The idea was to create a singleton that provided a single point where printing could be turned on or off and also could be accessed anywhere in the code to check to see if printing is suppressed. Otherwise the printing status would need to be passed around to multiple different objects and applications. You should be able to control whether or not you want printing enabled at the application level, you could even provide it as a user option. However, I would not get rid of this class entirely, or at least replace it with something else that might suit your functional needs better.
Thanks, Bruce. How does it suppress the PETSc output? I cannot even view any PETSc vectors/matrices, i.e., if I extract the PETSc vector out of the Gridpack vector and call ‘VecView’ on it then it does not print it to stdout. Something is in the NoPrint class (perhaps some global variable that PETSc also uses) that redirects stdout.
I think there is some PETSc parameter that you can set to suppress all output from PETSc. You may have to set NoPrint to true before calling the math initialization to get that to work properly. I'd need to dig into the code to know for sure.
This is the code (in petsc_math.cpp
) that turns off all printing
bool no_print = gridpack::NoPrint::instance()->status();
if (no_print) {
PETSC_STDOUT = fopen("/dev/null", "w");
PETSC_STDERR = fopen("/dev/null", "w");
}
No idea what this does. There is hardly any documentation about its intended usage. Seems to me like this is expendable if not used extensively.