# PhasicFlow: src/phasicFlow/globals/error.cpp Source File
PhasicFlow is an open-source parallel DEM (discrete element method) package for simulating granular flow. It is developed in C++ and can be exectued on both GPU (like CUDA) and CPU.

error.cpp
Go to the documentation of this file.
/*------------------------------- phasicFlow ---------------------------------
O C enter of
O O E ngineering and
O O M ultiscale modeling of
OOOOOOO F luid flow
------------------------------------------------------------------------------
Copyright (C): www.cemf.ir
email: hamid.r.norouzi AT gmail.com
------------------------------------------------------------------------------
Licence:
This file is part of phasicFlow code. It is a free software for simulating
granular and multiphase flows. You can redistribute it and/or modify it under
the terms of GNU General Public License v3 or any other later versions.
phasicFlow is distributed to help others in their research in the field of
granular and multiphase flows, but WITHOUT ANY WARRANTY; without even the
implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
-----------------------------------------------------------------------------*/
#include <iostream>
#include <stdlib.h>
#include <Kokkos_Core.hpp>
#include "error.hpp"
#include "processors.hpp"
#include "streams.hpp"
// static pFlow::Ostream& errorStream = pFlow::errReport;
static pFlow::Ostream& errorStream = pFlow::pOutput;
pFlow::iOstream&
fatalErrorMessage(const char* fileName, int linNumber)
{
errorStream << "\n>>> Fatal error in phasicFlow\n"
<< "Error occured in source file " << Red_Text(fileName)
<< " at line " << Red_Text(linNumber) << '\n';
return errorStream;
}
pFlow::iOstream&
fatalErrorInMessage(const char* fnName, const char* fileName, int linNumber)
{
errorStream << "\n>>> Fatal error in phasicFlow\n"
<< " Error is issued in function " << Red_Text(fnName)
<< ", located in file " << Red_Text(fileName) << " at line "
<< Red_Text(linNumber) << '\n';
return errorStream;
}
pFlow::iOstream&
notImplementedErrorMessage(
const char* fnName,
const char* fileName,
int lineNumber
)
{
errorStream << "\n>>> Fatal error in phasicFlow\n";
errorStream << " Function " << Red_Text(fnName)
<< " has not been implemented yet!\n"
<< " File " << Yellow_Text(fileName) << " at line "
<< Yellow_Text(lineNumber) << '\n';
return errorStream;
}
pFlow::iOstream&
ioErrorMessage(
const char* fileName,
int fileLineNumber,
const char* fnName,
const char* fName,
int lNumber
)
{
errorStream << "\n>>> Fatal IO file error\n"
<< " IO error at number " << Red_Text(fileLineNumber)
<< " of file " << Red_Text(fileName) << '\n';
errorStream << " IO operation is peformed from function "
<< Red_Text(fnName) << " in file " << Red_Text(fName)
<< " at line " << Red_Text(lNumber) << '\n';
return errorStream;
}
pFlow::iOstream&
ioErrorMessage(
const pFlow::word& fileName,
int fileLineNumber,
const char* fnName,
const char* fName,
int lNumber
)
{
return ioErrorMessage(
fileName.c_str(), fileLineNumber, fnName, fName, lNumber
);
}
pFlow::iOstream&
warningMessage(const char* fnName, const char* fileName, int linNumber)
{
errorStream << "\n>>> Warning in phasicFlow\n"
<< " Warning is issued in function " << Yellow_Text(fnName)
<< " in source file " << Yellow_Text(fileName) << " at line "
<< Yellow_Text(linNumber) << '\n';
return errorStream;
}
pFlow::iOstream&
reportAndExit(int errorCode)
{
errorStream << "\n>>> phasicFlow is exiting . . ." << pFlow::endl;
fatalExitPhasicFlow(errorCode);
return errorStream;
}
int
fatalExitPhasicFlow(int errorCode)
{
// Kokkos should be finalized first
Kokkos::finalize();
pFlow::processors::abort(errorCode);
return errorCode;
}
pFlow::pOutput
processorOstream pOutput
errorStream
static pFlow::Ostream & errorStream
Definition: error.cpp:32
processors.hpp
pFlow::word
std::string word
Definition: builtinTypes.hpp:64
fatalErrorInMessage
pFlow::iOstream & fatalErrorInMessage(const char *fnName, const char *fileName, int linNumber)
Definition: error.cpp:44
pFlow::endl
iOstream & endl(iOstream &os)
Add newline and flush stream.
Definition: iOstream.hpp:341
warningMessage
pFlow::iOstream & warningMessage(const char *fnName, const char *fileName, int linNumber)
Definition: error.cpp:101
reportAndExit
pFlow::iOstream & reportAndExit(int errorCode)
Definition: error.cpp:111
Yellow_Text
#define Yellow_Text(text)
Definition: iOstream.hpp:40
fatalExitPhasicFlow
int fatalExitPhasicFlow(int errorCode)
Take actions to fatal exit phasicFlow.
Definition: error.cpp:119
notImplementedErrorMessage
pFlow::iOstream & notImplementedErrorMessage(const char *fnName, const char *fileName, int lineNumber)
Definition: error.cpp:54
fatalErrorMessage
pFlow::iOstream & fatalErrorMessage(const char *fileName, int linNumber)
Definition: error.cpp:35
ioErrorMessage
pFlow::iOstream & ioErrorMessage(const char *fileName, int fileLineNumber, const char *fnName, const char *fName, int lNumber)
Definition: error.cpp:69
Red_Text
#define Red_Text(text)
Definition: iOstream.hpp:39
streams.hpp
pFlow::Ostream
Standard output stream for BINARY and ASCII formats.
Definition: Ostream.hpp:39
pFlow::iOstream
Interface class for any output stream.
Definition: iOstream.hpp:59
pFlow::processors::abort
static void abort(int error)
Abort MPI run or regular run.
Definition: processors.cpp:147
error.hpp