Skip to content

Commit

Permalink
Merge pull request #134 from wenqing/screen_output
Browse files Browse the repository at this point in the history
Improvement in the creen output
  • Loading branch information
wenqing authored Feb 5, 2019
2 parents cf64daf + a08adb4 commit e61a9ad
Show file tree
Hide file tree
Showing 36 changed files with 464 additions and 565 deletions.
103 changes: 13 additions & 90 deletions Base/display.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,8 @@
extern FILE* OpenMsgFile(void);
extern void CloseMsgFile(FILE*);

namespace Display
{
/**************************************************************************/
/* ROCKFLOW - Funktion: DisplayMsg
*/
Expand Down Expand Up @@ -60,7 +62,8 @@ void DisplayMsg(const char* s)
**************************************************************************/
void ScreenMessage(const char *format , ... )
{
#ifdef USE_MPI
#if defined(USE_PETSC) || defined(USE_MPI) || defined(USE_MPI_PARPROC) || \
defined(USE_MPI_REGSOIL) || defined(USE_MPI_GEMS)
if (myrank > 0)
return;
#endif
Expand All @@ -70,6 +73,14 @@ void ScreenMessage(const char *format , ... )
va_end( arglist );
}

void ScreenMessageNoMPIRank(const char *format , ... )
{
va_list arglist;
va_start( arglist, format );
vprintf( format, arglist );
va_end( arglist );
}

/**************************************************************************/
/* ROCKFLOW - Funktion: DisplayMsgLn
*/
Expand Down Expand Up @@ -97,32 +108,6 @@ void DisplayMsgLn(const char* s)
CloseMsgFile(f);
}

/**************************************************************************/
/* ROCKFLOW - Funktion: DisplayMsgCR
*/
/* Aufgabe:
Schreibt Zeichenkette mit Zeilenruecklauf auf Standardausgabe,
beginnt immer erst nach 12 Zeichen Einrueckung.
*/
/* Formalparameter: (E: Eingabe; R: Rueckgabe; X: Beides)
E char *s: Zeichenkette
*/
/* Ergebnis:
- void -
*/
/* Programmaenderungen:
08/1994 MSR Erste Version
01/2002 MK Umleitung in MSG-Datei
*/
/**************************************************************************/
void DisplayMsgCR(const char* s)
{
FILE* f;
f = OpenMsgFile();
fprintf(f, "%s\r ", s);
CloseMsgFile(f);
}

/**************************************************************************/
/* ROCKFLOW - Funktion: DisplayDouble
*/
Expand Down Expand Up @@ -183,43 +168,6 @@ void DisplayLong(long x)
CloseMsgFile(f);
}

/**************************************************************************/
/* ROCKFLOW - Funktion: DisplayDoubleVector
*/
/* Aufgabe:
Schreibt Vektor auf Standardausgabe
*/
/* Formalparameter: (E: Eingabe; R: Rueckgabe; X: Beides)
E double *vec: Zeiger auf Vektor
E long grad: Laenge des Vektors
E char *text: Ueberschrift ueber Ausgabe
*/
/* Ergebnis:
- void -
*/
/* Programmaenderungen:
08/1994 Hans Herrmann Erste Version
12/1994 MSR Von mathlib nach display portiert
01/2002 MK Umleitung in MSG-Datei
*/
/**************************************************************************/
void DisplayDoubleVector(double* vec, long grad, char* text)
{
FILE* f;
long i;
DisplayMsgLn("");
DisplayMsgLn(text);
f = OpenMsgFile();
for (i = 0; i < grad; i++)
{
fprintf(f, "| %+e |", vec[i]);
fprintf(f, "%s\n ", "");
fflush(stdout);
}
CloseMsgFile(f);
DisplayMsgLn("");
}

/**************************************************************************/
/* ROCKFLOW - Funktion: DisplayErrorMsg
*/
Expand All @@ -244,29 +192,4 @@ void DisplayErrorMsg(const char* s)
fprintf(f, "\n!!!!!!!! %s\n\n ", s);
CloseMsgFile(f);
}

/**************************************************************************/
/* ROCKFLOW - Funktion: DisplayTimeMsg
*/
/* Aufgabe:
Schreibt Laufzeitmeldung auf Standardausgabe.
*/
/* Formalparameter: (E: Eingabe; R: Rueckgabe; X: Beides)
E char *s: Zeichenkette (Fehlermeldung)
E double d: Zeitwert
*/
/* Ergebnis:
- void -
*/
/* Programmaenderungen:
07/1994 MSR Erste Version
01/2002 MK Umleitung in MSG-Datei
*/
/**************************************************************************/
void DisplayTimeMsg(const char* s, double d)
{
FILE* f;
f = OpenMsgFile();
fprintf(f, "\n %s%20ld s\n\n ", s, ((long)d));
CloseMsgFile(f);
}
} // End of name space.
24 changes: 11 additions & 13 deletions Base/display.h
Original file line number Diff line number Diff line change
Expand Up @@ -26,26 +26,24 @@
#include <cstring>
//#include <ctype.h>

namespace Display
{
/*JT: Send output message*/
extern void ScreenMessage(const char *format , ... );
void ScreenMessage(const char *format , ... );
void ScreenMessageNoMPIRank(const char *format , ... );

/* Gibt Programm-Abspann aus */
extern void DisplayMsg(const char* s);
void DisplayMsg(const char* s);
/* Schreibt Zeichenkette ohne Zeilenvorschub auf Standardausgabe */
extern void DisplayMsgLn(const char* s);
/* Schreibt Zeichenkette mit Zeilenvorschub auf Standardausgabe */
extern void DisplayMsgCR(const char* s);
void DisplayMsgLn(const char* s);
/* Schreibt Zeichenkette mit Zeilenruecklauf auf Standardausgabe */
extern void DisplayDouble(double x, int i, int j);
void DisplayDouble(double x, int i, int j);
/* Schreibt Double-Wert ohne Zeilenvorschub auf Standardausgabe */
extern void DisplayLong(long x);
/* Schreibt Long-Wert ohne Zeilenvorschub auf Standardausgabe */
extern void DisplayDoubleVector(double* vec, long grad, char* text);
void DisplayLong(long x);
/* Schreibt Vektor auf Standardausgabe */
// OK411 extern void DisplayDoubleMatrix ( double *mat, long m, long n, char
// *text );
/* Schreibt Matrix auf Standardausgabe */
extern void DisplayErrorMsg(const char* s);
/* Schreibt Fehlermeldung auf Standardausgabe */
extern void DisplayTimeMsg(const char* s, double d);
/* Schreibt Laufzeitmeldung auf Standardausgabe */
void DisplayErrorMsg(const char* s);
}
#endif
3 changes: 2 additions & 1 deletion FEM/DUMUX.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,8 @@ CReadTextfiles_DuMux::~CReadTextfiles_DuMux(void) {}
using std::cout;
using std::string;
using std::vector;
// using std:"\n";

using namespace Display;

/*-------------------------------------------------------------------------
GeoSys - Function: SplitStrings
Expand Down
1 change: 1 addition & 0 deletions FEM/Eclipse.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,7 @@
#include <sys/stat.h> //for check if files exist

using namespace std;
using namespace Display;

CECLIPSEBlock::CECLIPSEBlock(long Nodelength, long Facelength)
{
Expand Down
2 changes: 1 addition & 1 deletion FEM/Material/Solid/BGRaCreep.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -163,7 +163,7 @@ void BGRaCreep::integrateStress(const double dt, const double T,

if (it == _max_iterations - 1)
{
ScreenMessage(
Display::ScreenMessage(
"The local Newton method did not converge within the given "
"number of iterations. Iteration: %d, residual norm: "
"%g",
Expand Down
6 changes: 5 additions & 1 deletion FEM/fem_ele_std.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,9 @@
//#include <iostream>
//#include <limits> // PCH to better use system max and min
#include "memory.h"

#include "display.h"

// Method
#include "mathlib.h"
// Problems
Expand Down Expand Up @@ -499,7 +502,8 @@ CFiniteElementStd::CFiniteElementStd(CRFProcess* Pcs, const int C_Sys_Flad,
if (!done)
{
done = true;
std::cout << "-> Gass flow is formulated as mass balance." << '\n';
Display::ScreenMessage(
"-> Gass flow is formulated as mass balance.\n");
}
}
#if defined(USE_PETSC) // || defined(other parallel libs)//03~04.3012. WW
Expand Down
9 changes: 5 additions & 4 deletions FEM/files0.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -215,7 +215,7 @@ int ReadData(const char* dateiname,
// Check line ending of input files
if (!checkFormatOfInputFiles(dateiname))
{
ScreenMessage("terminate this program");
Display::ScreenMessage("terminate this program");
exit(0);
}
//----------------------------------------------------------------------
Expand Down Expand Up @@ -340,7 +340,7 @@ void CloseMsgFile(FILE* f)
{
if (f != stdout)
if (fclose(f))
DisplayErrorMsg(
Display::DisplayErrorMsg(
"Fehler: Message-Protokolldatei konnte nicht geschlossen "
"werden !!");
}
Expand Down Expand Up @@ -403,8 +403,9 @@ void CURRead(std::string base_file_name)
cur_file.seekg(0L, std::ios::beg);
//========================================================================
// keyword loop
std::cout << "CURRead"
<< "\n";

Display::ScreenMessage("CURRead\n");

while (!cur_file.eof())
{
cur_file.getline(line, MAX_ZEILE);
Expand Down
2 changes: 2 additions & 0 deletions FEM/mathlib.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -179,6 +179,8 @@

#include "prototyp.h"

using namespace Display;

double pai = 4.0 * atan(1.0);
VoidFuncDXCDX ShapeFunction;
VoidFuncDXCDX ShapeFunctionHQ;
Expand Down
1 change: 1 addition & 0 deletions FEM/matrix_routines.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -102,6 +102,7 @@
extern MeshLib::CFEMesh* FEMGet(const std::string&);

using MeshLib::CNode;
using namespace Display;

#ifdef _OPENMP
#include <omp.h>
Expand Down
43 changes: 22 additions & 21 deletions FEM/par_ddc.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -46,6 +46,9 @@ double time_ele_paral;

// FEM-Makros
#include "makros.h"

#include "display.h"

#ifndef NEW_EQS // WW. 11.2008
#include "matrix_routines.h"
#endif
Expand All @@ -63,6 +66,7 @@ vector<int> node_connected_doms; // This will be removed after sparse class is
using namespace std;
using FiniteElement::CFiniteElementVec;
using process::CRFProcessDeformation;
using namespace Display;

#ifdef NEW_EQS
using Math_Group::Linear_EQS;
Expand Down Expand Up @@ -114,7 +118,7 @@ bool SubKeywordFound(string line)
void DOMRead(string file_base_name)
{
//----------------------------------------------------------------------
cout << "DOMRead: ";
ScreenMessage("DOMRead: ");
//----------------------------------------------------------------------
CPARDomain* m_dom = NULL;
char line[MAX_ZEILE];
Expand All @@ -128,8 +132,7 @@ void DOMRead(string file_base_name)
ifstream ddc_file(ddc_file_name.data(), ios::in);
if (!ddc_file.good())
{
cout << "no DDC file"
<< "\n";
ScreenMessage("no DDC file\n");
return;
}
ddc_file.seekg(0L, ios::beg);
Expand All @@ -150,8 +153,7 @@ void DOMRead(string file_base_name)
} // keyword found
} // eof
//----------------------------------------------------------------------
cout << dom_vector.size() << " domains"
<< "\n";
ScreenMessage("%d domains\n", dom_vector.size());
//----------------------------------------------------------------------
}

Expand Down Expand Up @@ -250,8 +252,8 @@ void DOMCreate()

//----------------------------------------------------------------------
// Create domain nodes
cout << "->Create DOM"
<< "\n";
ScreenMessage("->Create Sub-Domains\n");

/* // Comment by WW
for(i=0;i<no_domains;i++){
m_dom = dom_vector[i];
Expand All @@ -261,23 +263,21 @@ void DOMCreate()

//----------------------------------------------------------------------
// Create domain nodes
cout << " Create domain nodes"
<< "\n";
ScreenMessage(" Create domain nodes\n");
for (i = 0; i < no_domains; i++)
{
m_dom = dom_vector[i];
m_dom->m_msh = m_pcs->m_msh;
cout << " Domain:" << m_dom->ID << "\n";
//ScreenMessageNoMPIRank(" Domain: %d\n", m_dom->ID);
m_dom->CreateNodes();
}
//----------------------------------------------------------------------
// Create domain elements
cout << " Create domain elements"
<< "\n";
ScreenMessage(" Create domain elements\n");
for (i = 0; i < no_domains; i++)
{
m_dom = dom_vector[i];
cout << " Domain:" << m_dom->ID << "\n";
//ScreenMessageNoMPIRank(" Domain: %d\n", m_dom->ID);
m_dom->CreateElements(quadr);
}
// For find nodes connected to node WW
Expand All @@ -295,11 +295,10 @@ void DOMCreate()
//
// Find nodes of all neighbors of each node. // WW
// Local topology. WW
cout << " Find nodes on borders"
<< "\n";
ScreenMessage(" Find nodes on borders\n");
FindNodesOnInterface(m_pcs->m_msh, quadr);
cout << " Find the connected nodes for each node"
<< "\n";

ScreenMessage(" Find the connected nodes for each node\n");
#ifndef USE_MPI // WW
for (i = 0; i < no_domains; i++)
{
Expand All @@ -313,16 +312,18 @@ void DOMCreate()
#endif
//----------------------------------------------------------------------
// Create domain EQS
cout << " Create domain EQS"
<< "\n";
ScreenMessage(" Create domain EQS\n");

#ifdef USE_MPI
i = myrank;
#else
for (i = 0; i < no_domains; i++)
{
#endif
m_dom = dom_vector[i];
cout << " Domain:" << m_dom->ID << "\n";
m_dom = dom_vector[i];

//ScreenMessage(" Domain: %d\n", m_dom->ID);

#ifdef NEW_EQS
m_dom->CreateEQS();
#else
Expand Down
Loading

0 comments on commit e61a9ad

Please sign in to comment.