www.cemf.ir
error.cpp
Go to the documentation of this file.
1 /*------------------------------- phasicFlow ---------------------------------
2  O C enter of
3  O O E ngineering and
4  O O M ultiscale modeling of
5  OOOOOOO F luid flow
6 ------------------------------------------------------------------------------
7  Copyright (C): www.cemf.ir
8  email: hamid.r.norouzi AT gmail.com
9 ------------------------------------------------------------------------------
10 Licence:
11  This file is part of phasicFlow code. It is a free software for simulating
12  granular and multiphase flows. You can redistribute it and/or modify it under
13  the terms of GNU General Public License v3 or any other later versions.
14 
15  phasicFlow is distributed to help others in their research in the field of
16  granular and multiphase flows, but WITHOUT ANY WARRANTY; without even the
17  implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
18 
19 -----------------------------------------------------------------------------*/
20 
21 #include <iostream>
22 #include <stdlib.h>
23 
24 #include <Kokkos_Core.hpp>
25 
26 #include "error.hpp"
27 #include "processors.hpp"
28 #include "streams.hpp"
29 
30 // static pFlow::Ostream& errorStream = pFlow::errReport;
31 
33 
35 fatalErrorMessage(const char* fileName, int linNumber)
36 {
37  errorStream << "\n>>> Fatal error in phasicFlow\n"
38  << "Error occured in source file " << Red_Text(fileName)
39  << " at line " << Red_Text(linNumber) << '\n';
40  return errorStream;
41 }
42 
44 fatalErrorInMessage(const char* fnName, const char* fileName, int linNumber)
45 {
46  errorStream << "\n>>> Fatal error in phasicFlow\n"
47  << " Error is issued in function " << Red_Text(fnName)
48  << ", located in file " << Red_Text(fileName) << " at line "
49  << Red_Text(linNumber) << '\n';
50  return errorStream;
51 }
52 
55  const char* fnName,
56  const char* fileName,
57  int lineNumber
58 )
59 {
60  errorStream << "\n>>> Fatal error in phasicFlow\n";
61  errorStream << " Function " << Red_Text(fnName)
62  << " has not been implemented yet!\n"
63  << " File " << Yellow_Text(fileName) << " at line "
64  << Yellow_Text(lineNumber) << '\n';
65  return errorStream;
66 }
67 
70  const char* fileName,
71  int fileLineNumber,
72  const char* fnName,
73  const char* fName,
74  int lNumber
75 )
76 {
77  errorStream << "\n>>> Fatal IO file error\n"
78  << " IO error at number " << Red_Text(fileLineNumber)
79  << " of file " << Red_Text(fileName) << '\n';
80  errorStream << " IO operation is peformed from function "
81  << Red_Text(fnName) << " in file " << Red_Text(fName)
82  << " at line " << Red_Text(lNumber) << '\n';
83  return errorStream;
84 }
85 
88  const pFlow::word& fileName,
89  int fileLineNumber,
90  const char* fnName,
91  const char* fName,
92  int lNumber
93 )
94 {
95  return ioErrorMessage(
96  fileName.c_str(), fileLineNumber, fnName, fName, lNumber
97  );
98 }
99 
101 warningMessage(const char* fnName, const char* fileName, int linNumber)
102 {
103  errorStream << "\n>>> Warning in phasicFlow\n"
104  << " Warning is issued in function " << Yellow_Text(fnName)
105  << " in source file " << Yellow_Text(fileName) << " at line "
106  << Yellow_Text(linNumber) << '\n';
107  return errorStream;
108 }
109 
111 reportAndExit(int errorCode)
112 {
113  errorStream << "\n>>> phasicFlow is exiting . . ." << pFlow::endl;
114  fatalExitPhasicFlow(errorCode);
115  return errorStream;
116 }
117 
118 int
119 fatalExitPhasicFlow(int errorCode)
120 {
121  // Kokkos should be finalized first
122  Kokkos::finalize();
123 
124  pFlow::processors::abort(errorCode);
125  return errorCode;
126 }
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