26 #ifdef FLOW123D_HAVE_PETSC 29 #include <petsc/private/petscimpl.h> 33 #include <boost/exception/detail/error_info_impl.hpp> 37 #include "petscerror.h" 49 if (signal == SIGINT) {
52 if (signal == SIGFPE ||
58 THROW( ExcSignal() << EI_Signal(signal) << EI_SignalName(strsignal(signal)) );
60 return PetscSignalHandlerDefault(signal,(
void*)0);
72 signal_handler_off_(false)
95 stringstream log_name;
97 if ( log_filename ==
"//" ) {
118 #ifdef FLOW123D_HAVE_PETSC 119 PetscErrorCode ApplicationBase::petscvfprintf(FILE *fd,
const char format[], va_list Argp) {
123 if (fd != stdout && fd != stderr) {
124 ierr = PetscVFPrintfDefault(fd,
format,Argp); CHKERRQ(ierr);
126 const int buf_size = 65000;
129 ierr = PetscVSNPrintf(buff,buf_size,
format,&length,Argp);CHKERRQ(ierr);
134 PetscFunctionReturn(0);
140 #ifdef FLOW123D_HAVE_PETSC 145 PetscVFPrintf = this->petscvfprintf;
149 PetscInitialize(&argc,&argv,PETSC_NULL,PETSC_NULL);
158 MessageOut() <<
"MPI size: " << mpi_size << std::endl;
165 #ifdef FLOW123D_HAVE_PETSC 168 PetscErrorCode ierr=0;
170 ierr = PetscFinalize(); CHKERRQ(ierr);
void system_init(MPI_Comm comm, const string &log_filename)
void system_signal_handler(int signal)
virtual ~ApplicationBase()
Destructor.
virtual void parse_cmd_line(const int argc, char **argv)
#define MessageOut()
Macro defining 'message' record of log.
static bool petsc_initialized
std::string format(CStringRef format_str, ArgList args)
static FILE * petsc_output_
File handler for redirecting PETSc output.
string petsc_redirect_file_
int setup_mpi(MPI_Comm comm)
Set rank of actual process by MPI communicator.
Global macros to enhance readability and debugging, general constants.
bool signal_handler_off_
Turn off signal handling useful to debug with valgrind.
void init(int argc, char **argv)
void set_log_file(std::string log_file_base)
Initialize instance object in format 'log_file_base.process.log'.
static LoggerOptions & get_instance()
Getter of singleton instance object.
PetscErrorCode petsc_signal_handler(int signal, void *context)
void petsc_initialize(int argc, char **argv)
ApplicationBase(int argc, char **argv)
#define THROW(whole_exception_expr)
Wrapper for throw. Saves the throwing point.