Standardize function used for writing a line of repeated characters

This commit is contained in:
Ray Speth 2014-05-27 02:53:06 +00:00
parent 789574ac80
commit 6c0cea5ee4
16 changed files with 129 additions and 266 deletions

View file

@ -171,6 +171,9 @@ void writelogf(const char* fmt,...);
//! Write an end of line character to the screen and flush output //! Write an end of line character to the screen and flush output
void writelogendl(); void writelogendl();
void writeline(char repeat, int count,
bool endl_after=true, bool endl_before=false);
//! @copydoc Application::Messages::logerror //! @copydoc Application::Messages::logerror
void error(const std::string& msg); void error(const std::string& msg);

View file

@ -374,16 +374,6 @@ size_t vcs_optMax(const double* x, const double* xSize, size_t j, size_t n);
*/ */
int vcs_max_int(const int* vector, int length); int vcs_max_int(const int* vector, int length);
//! Prints a line consisting of multiple occurrences of the same string
/*!
* This prints a string num times, and then terminate with a
* end of line character
*
* @param str C string that is null terminated
* @param num number of times the string is to be printed
*/
void vcs_print_line(const char* str, int num);
//! Returns a const char string representing the type of the //! Returns a const char string representing the type of the
//! species given by the first argument //! species given by the first argument
/*! /*!

View file

@ -68,6 +68,17 @@ void writelogendl()
app()->writelogendl(); app()->writelogendl();
} }
void writeline(char repeat, int count, bool endl_after, bool endl_before)
{
if (endl_before) {
writelogendl();
}
writelog(std::string(count, repeat));
if (endl_after) {
writelogendl();
}
}
void error(const std::string& msg) void error(const std::string& msg)
{ {
warn_deprecated("error"); warn_deprecated("error");

View file

@ -762,18 +762,6 @@ void vcs_MultiPhaseEquil::reportCSV(const std::string& reportFile)
fclose(FP); fclose(FP);
} }
//! print char repeatedly to log file
/*!
* @param letter letter to be repeated
* @param num Number of times repeated
*/
static void print_char(const char letter, const int num)
{
for (int i = 0; i < num; i++) {
plogf("%c", letter);
}
}
/* /*
* HKM -> Work on transferring the current value of the voltages into the * HKM -> Work on transferring the current value of the voltages into the
* equilibrium problem. * equilibrium problem.
@ -1121,15 +1109,11 @@ int vcs_Cantera_to_vprob(Cantera::MultiPhase* mphase,
* Printout the species information: PhaseID's and mole nums * Printout the species information: PhaseID's and mole nums
*/ */
if (vprob->m_printLvl > 1) { if (vprob->m_printLvl > 1) {
plogf("\n"); writeline('=', 80, true, true);
print_char('=', 80); writeline('=', 16, false);
plogf("\n");
print_char('=', 16);
plogf(" Cantera_to_vprob: START OF PROBLEM STATEMENT "); plogf(" Cantera_to_vprob: START OF PROBLEM STATEMENT ");
print_char('=', 20); writeline('=', 20);
plogf("\n"); writeline('=', 80);
print_char('=', 80);
plogf("\n");
plogf(" Phase IDs of species\n"); plogf(" Phase IDs of species\n");
plogf(" species phaseID phaseName "); plogf(" species phaseID phaseName ");
plogf(" Initial_Estimated_kMols\n"); plogf(" Initial_Estimated_kMols\n");
@ -1149,9 +1133,7 @@ int vcs_Cantera_to_vprob(Cantera::MultiPhase* mphase,
/* /*
* Printout of the Phase structure information * Printout of the Phase structure information
*/ */
plogf("\n"); writeline('-', 80, true, true);
print_char('-', 80);
plogf("\n");
plogf(" Information about phases\n"); plogf(" Information about phases\n");
plogf(" PhaseName PhaseNum SingSpec GasPhase EqnState NumSpec"); plogf(" PhaseName PhaseNum SingSpec GasPhase EqnState NumSpec");
plogf(" TMolesInert Tmoles(kmol)\n"); plogf(" TMolesInert Tmoles(kmol)\n");
@ -1166,15 +1148,12 @@ int vcs_Cantera_to_vprob(Cantera::MultiPhase* mphase,
plogf("%16e\n", VolPhase->totalMoles()); plogf("%16e\n", VolPhase->totalMoles());
} }
plogf("\n"); writeline('=', 80, true, true);
print_char('=', 80); writeline('=', 16, false);
plogf("\n");
print_char('=', 16);
plogf(" Cantera_to_vprob: END OF PROBLEM STATEMENT "); plogf(" Cantera_to_vprob: END OF PROBLEM STATEMENT ");
print_char('=', 20); writeline('=', 20);
writeline('=', 80);
plogf("\n"); plogf("\n");
print_char('=', 80);
plogf("\n\n");
} }
return VCS_SUCCESS; return VCS_SUCCESS;
@ -1253,15 +1232,12 @@ int vcs_Cantera_update_vprob(Cantera::MultiPhase* mphase,
* Printout the species information: PhaseID's and mole nums * Printout the species information: PhaseID's and mole nums
*/ */
if (vprob->m_printLvl > 1) { if (vprob->m_printLvl > 1) {
plogf("\n"); writeline('=', 80, true, true);
print_char('=', 80); writeline('=', 20, false);
plogf("\n");
print_char('=', 20);
plogf(" Cantera_to_vprob: START OF PROBLEM STATEMENT "); plogf(" Cantera_to_vprob: START OF PROBLEM STATEMENT ");
print_char('=', 20); writeline('=', 20);
writeline('=', 80);
plogf("\n"); plogf("\n");
print_char('=', 80);
plogf("\n\n");
plogf(" Phase IDs of species\n"); plogf(" Phase IDs of species\n");
plogf(" species phaseID phaseName "); plogf(" species phaseID phaseName ");
plogf(" Initial_Estimated_kMols\n"); plogf(" Initial_Estimated_kMols\n");
@ -1281,9 +1257,7 @@ int vcs_Cantera_update_vprob(Cantera::MultiPhase* mphase,
/* /*
* Printout of the Phase structure information * Printout of the Phase structure information
*/ */
plogf("\n"); writeline('-', 80, true, true);
print_char('-', 80);
plogf("\n");
plogf(" Information about phases\n"); plogf(" Information about phases\n");
plogf(" PhaseName PhaseNum SingSpec GasPhase EqnState NumSpec"); plogf(" PhaseName PhaseNum SingSpec GasPhase EqnState NumSpec");
plogf(" TMolesInert Tmoles(kmol)\n"); plogf(" TMolesInert Tmoles(kmol)\n");
@ -1298,15 +1272,12 @@ int vcs_Cantera_update_vprob(Cantera::MultiPhase* mphase,
plogf("%16e\n", VolPhase->totalMoles()); plogf("%16e\n", VolPhase->totalMoles());
} }
plogf("\n"); writeline('=', 80, true, true);
print_char('=', 80); writeline('=', 20, false);
plogf("\n");
print_char('=', 20);
plogf(" Cantera_to_vprob: END OF PROBLEM STATEMENT "); plogf(" Cantera_to_vprob: END OF PROBLEM STATEMENT ");
print_char('=', 20); writeline('=', 20);
writeline('=', 80);
plogf("\n"); plogf("\n");
print_char('=', 80);
plogf("\n\n");
} }
return VCS_SUCCESS; return VCS_SUCCESS;

View file

@ -16,9 +16,11 @@
#include "cantera/thermo/ThermoPhase.h" #include "cantera/thermo/ThermoPhase.h"
#include "cantera/thermo/MolalityVPSSTP.h" #include "cantera/thermo/MolalityVPSSTP.h"
#include "cantera/base/global.h"
#include <cstdio> #include <cstdio>
using namespace Cantera;
using namespace std; using namespace std;
namespace VCSnonideal namespace VCSnonideal
@ -167,20 +169,6 @@ void VCS_PROB::set_gai()
} }
} }
static void print_space(int num)
{
for (int j = 0; j < num; j++) {
(void) plogf(" ");
}
}
static void print_char(const char letter, const int num)
{
for (int i = 0; i < num; i++) {
plogf("%c", letter);
}
}
void VCS_PROB::prob_report(int print_lvl) void VCS_PROB::prob_report(int print_lvl)
{ {
m_printLvl = print_lvl; m_printLvl = print_lvl;
@ -188,16 +176,11 @@ void VCS_PROB::prob_report(int print_lvl)
* Printout the species information: PhaseID's and mole nums * Printout the species information: PhaseID's and mole nums
*/ */
if (m_printLvl > 0) { if (m_printLvl > 0) {
plogf("\n"); writeline('=', 80, true, true);
print_char('=', 80); writeline('=', 20, false);
plogf("\n");
print_char('=', 20);
plogf(" VCS_PROB: PROBLEM STATEMENT "); plogf(" VCS_PROB: PROBLEM STATEMENT ");
print_char('=', 31); writeline('=', 31);
plogf("\n"); writeline('=', 80);
print_char('=', 80);
plogf("\n");
plogf("\n"); plogf("\n");
if (prob_type == 0) { if (prob_type == 0) {
plogf("\tSolve a constant T, P problem:\n"); plogf("\tSolve a constant T, P problem:\n");
@ -235,9 +218,7 @@ void VCS_PROB::prob_report(int print_lvl)
/* /*
* Printout of the Phase structure information * Printout of the Phase structure information
*/ */
plogf("\n"); writeline('-', 80, true, true);
print_char('-', 80);
plogf("\n");
plogf(" Information about phases\n"); plogf(" Information about phases\n");
plogf(" PhaseName PhaseNum SingSpec GasPhase " plogf(" PhaseName PhaseNum SingSpec GasPhase "
" EqnState NumSpec"); " EqnState NumSpec");
@ -264,7 +245,7 @@ void VCS_PROB::prob_report(int print_lvl)
fac = 1.0; fac = 1.0;
} }
for (size_t i = 0; i < ne; ++i) { for (size_t i = 0; i < ne; ++i) {
print_space(26); writeline(' ', 26, false);
plogf("%-2.2s", ElName[i].c_str()); plogf("%-2.2s", ElName[i].c_str());
plogf("%20.12E ", fac * gai[i]); plogf("%20.12E ", fac * gai[i]);
plogf("%3d %3d\n", m_elType[i], ElActive[i]); plogf("%3d %3d\n", m_elType[i], ElActive[i]);
@ -301,15 +282,12 @@ void VCS_PROB::prob_report(int print_lvl)
Vphase->GStar_calc_one(kindex)); Vphase->GStar_calc_one(kindex));
} }
} }
plogf("\n"); writeline('=', 80, true, true);
print_char('=', 80); writeline('=', 20, false);
plogf("\n");
print_char('=', 20);
plogf(" VCS_PROB: END OF PROBLEM STATEMENT "); plogf(" VCS_PROB: END OF PROBLEM STATEMENT ");
print_char('=', 24); writeline('=', 24);
writeline('=', 80);
plogf("\n"); plogf("\n");
print_char('=', 80);
plogf("\n\n");
} }
} }

View file

@ -8,24 +8,12 @@
#include "cantera/equil/vcs_solve.h" #include "cantera/equil/vcs_solve.h"
#include "cantera/equil/vcs_internal.h" #include "cantera/equil/vcs_internal.h"
#include "cantera/equil/vcs_VolPhase.h" #include "cantera/equil/vcs_VolPhase.h"
#include "cantera/base/global.h"
using namespace Cantera;
namespace VCSnonideal namespace VCSnonideal
{ {
static void print_space(int num)
{
for (int j = 0; j < num; j++) {
plogf(" ");
}
}
static void print_line(const std::string& schar, size_t num)
{
for (size_t j = 0; j < num; j++) {
plogf("%s", schar.c_str());
}
plogf("\n");
}
int VCS_SOLVE::vcs_report(int iconv) int VCS_SOLVE::vcs_report(int iconv)
{ {
bool printActualMoles = true, inertYes = false; bool printActualMoles = true, inertYes = false;
@ -77,11 +65,11 @@ int VCS_SOLVE::vcs_report(int iconv)
/* ******************************************************** */ /* ******************************************************** */
plogf("\n\n\n\n"); plogf("\n\n\n\n");
print_line("-", 80); writeline('-', 80);
print_line("-", 80); writeline('-', 80);
plogf("\t\t VCS_TP REPORT\n"); plogf("\t\t VCS_TP REPORT\n");
print_line("-", 80); writeline('-', 80);
print_line("-", 80); writeline('-', 80);
if (iconv < 0) { if (iconv < 0) {
plogf(" ERROR: CONVERGENCE CRITERION NOT SATISFIED.\n"); plogf(" ERROR: CONVERGENCE CRITERION NOT SATISFIED.\n");
} else if (iconv == 1) { } else if (iconv == 1) {
@ -106,13 +94,13 @@ int VCS_SOLVE::vcs_report(int iconv)
* -------- TABLE OF SPECIES IN DECREASING MOLE NUMBERS -------------- * -------- TABLE OF SPECIES IN DECREASING MOLE NUMBERS --------------
*/ */
plogf("\n\n"); plogf("\n\n");
print_line("-", 80); writeline('-', 80);
plogf(" Species Equilibrium kmoles "); plogf(" Species Equilibrium kmoles ");
plogf("Mole Fraction ChemPot/RT SpecUnkType\n"); plogf("Mole Fraction ChemPot/RT SpecUnkType\n");
print_line("-", 80); writeline('-', 80);
for (size_t i = 0; i < m_numComponents; ++i) { for (size_t i = 0; i < m_numComponents; ++i) {
plogf(" %-12.12s", m_speciesName[i].c_str()); plogf(" %-12.12s", m_speciesName[i].c_str());
print_space(13); writeline(' ', 13, false);
plogf("%14.7E %14.7E %12.4E", m_molNumSpecies_old[i] * molScale, plogf("%14.7E %14.7E %12.4E", m_molNumSpecies_old[i] * molScale,
m_molNumSpecies_new[i] * molScale, m_feSpecies_old[i]); m_molNumSpecies_new[i] * molScale, m_feSpecies_old[i]);
plogf(" %3d", m_speciesUnknownType[i]); plogf(" %3d", m_speciesUnknownType[i]);
@ -121,7 +109,7 @@ int VCS_SOLVE::vcs_report(int iconv)
for (size_t i = m_numComponents; i < m_numSpeciesRdc; ++i) { for (size_t i = m_numComponents; i < m_numSpeciesRdc; ++i) {
size_t l = sortindex[i]; size_t l = sortindex[i];
plogf(" %-12.12s", m_speciesName[l].c_str()); plogf(" %-12.12s", m_speciesName[l].c_str());
print_space(13); writeline(' ', 13, false);
if (m_speciesUnknownType[l] == VCS_SPECIES_TYPE_MOLNUM) { if (m_speciesUnknownType[l] == VCS_SPECIES_TYPE_MOLNUM) {
plogf("%14.7E %14.7E %12.4E", m_molNumSpecies_old[l] * molScale, plogf("%14.7E %14.7E %12.4E", m_molNumSpecies_old[l] * molScale,
@ -168,14 +156,13 @@ int VCS_SOLVE::vcs_report(int iconv)
plogf("\n"); plogf("\n");
} }
} }
print_line("-", 80); writeline('-', 80);
plogf("\n"); plogf("\n");
/* /*
* ---------- TABLE OF SPECIES FORMATION REACTIONS ------------------ * ---------- TABLE OF SPECIES FORMATION REACTIONS ------------------
*/ */
plogf("\n"); writeline('-', m_numComponents*10 + 45, true, true);
print_line("-", m_numComponents*10 + 45);
plogf(" |ComponentID|"); plogf(" |ComponentID|");
for (size_t j = 0; j < m_numComponents; j++) { for (size_t j = 0; j < m_numComponents; j++) {
plogf(" %3d", j); plogf(" %3d", j);
@ -191,7 +178,7 @@ int VCS_SOLVE::vcs_report(int iconv)
plogf(" %10.3g", m_molNumSpecies_old[j] * molScale); plogf(" %10.3g", m_molNumSpecies_old[j] * molScale);
} }
plogf(" | DG/RT Rxn |\n"); plogf(" | DG/RT Rxn |\n");
print_line("-", m_numComponents*10 + 45); writeline('-', m_numComponents*10 + 45);
for (size_t irxn = 0; irxn < m_numRxnTot; irxn++) { for (size_t irxn = 0; irxn < m_numRxnTot; irxn++) {
size_t kspec = m_indexRxnToSpecies[irxn]; size_t kspec = m_indexRxnToSpecies[irxn];
plogf(" %3d ", kspec); plogf(" %3d ", kspec);
@ -203,7 +190,7 @@ int VCS_SOLVE::vcs_report(int iconv)
plogf(" |%10.3g |", m_deltaGRxn_new[irxn]); plogf(" |%10.3g |", m_deltaGRxn_new[irxn]);
plogf("\n"); plogf("\n");
} }
print_line("-", m_numComponents*10 + 45); writeline('-', m_numComponents*10 + 45);
plogf("\n"); plogf("\n");
/* /*
@ -216,7 +203,7 @@ int VCS_SOLVE::vcs_report(int iconv)
double gibbsTotal = 0.0; double gibbsTotal = 0.0;
plogf("\n\n"); plogf("\n\n");
plogf("\n"); plogf("\n");
print_line("-", m_numElemConstraints*10 + 58); writeline('-', m_numElemConstraints*10 + 58);
plogf(" | ElementID |"); plogf(" | ElementID |");
for (size_t j = 0; j < m_numElemConstraints; j++) { for (size_t j = 0; j < m_numElemConstraints; j++) {
plogf(" %3d", j); plogf(" %3d", j);
@ -232,7 +219,7 @@ int VCS_SOLVE::vcs_report(int iconv)
plogf(" %10.3g", m_elemAbundancesGoal[j]); plogf(" %10.3g", m_elemAbundancesGoal[j]);
} }
plogf(" | Gibbs Total |\n"); plogf(" | Gibbs Total |\n");
print_line("-", m_numElemConstraints*10 + 58); writeline('-', m_numElemConstraints*10 + 58);
for (size_t iphase = 0; iphase < m_numPhases; iphase++) { for (size_t iphase = 0; iphase < m_numPhases; iphase++) {
plogf(" %3d ", iphase); plogf(" %3d ", iphase);
vcs_VolPhase* VPhase = m_VolPhaseList[iphase]; vcs_VolPhase* VPhase = m_VolPhaseList[iphase];
@ -255,14 +242,14 @@ int VCS_SOLVE::vcs_report(int iconv)
gibbsTotal += gibbsPhase; gibbsTotal += gibbsPhase;
plogf(" | %18.11E |\n", gibbsPhase); plogf(" | %18.11E |\n", gibbsPhase);
} }
print_line("-", m_numElemConstraints*10 + 58); writeline('-', m_numElemConstraints*10 + 58);
plogf(" TOTAL |%10.3e |", totalMoles); plogf(" TOTAL |%10.3e |", totalMoles);
for (size_t j = 0; j < m_numElemConstraints; j++) { for (size_t j = 0; j < m_numElemConstraints; j++) {
plogf(" %10.3g", gaTPhase[j]); plogf(" %10.3g", gaTPhase[j]);
} }
plogf(" | %18.11E |\n", gibbsTotal); plogf(" | %18.11E |\n", gibbsTotal);
print_line("-", m_numElemConstraints*10 + 58); writeline('-', m_numElemConstraints*10 + 58);
plogf("\n"); plogf("\n");
/* /*
@ -285,7 +272,7 @@ int VCS_SOLVE::vcs_report(int iconv)
plogf("\nElemental Abundances (kmol): "); plogf("\nElemental Abundances (kmol): ");
plogf(" Actual Target Type ElActive\n"); plogf(" Actual Target Type ElActive\n");
for (size_t i = 0; i < m_numElemConstraints; ++i) { for (size_t i = 0; i < m_numElemConstraints; ++i) {
print_space(26); writeline(' ', 26, false);
plogf("%-2.2s", (m_elementName[i]).c_str()); plogf("%-2.2s", (m_elementName[i]).c_str());
plogf("%20.12E %20.12E", m_elemAbundances[i]*molScale, m_elemAbundancesGoal[i]*molScale); plogf("%20.12E %20.12E", m_elemAbundances[i]*molScale, m_elemAbundancesGoal[i]*molScale);
plogf(" %3d %3d\n", m_elType[i], m_elementActive[i]); plogf(" %3d %3d\n", m_elType[i], m_elementActive[i]);
@ -295,8 +282,7 @@ int VCS_SOLVE::vcs_report(int iconv)
/* /*
* ------------------ TABLE OF SPECIES CHEM POTS --------------------- * ------------------ TABLE OF SPECIES CHEM POTS ---------------------
*/ */
plogf("\n"); writeline('-', 93, true, true);
print_line("-", 93);
plogf("Chemical Potentials of the Species: (dimensionless)\n"); plogf("Chemical Potentials of the Species: (dimensionless)\n");
double rt = vcs_nondimMult_TP(m_VCS_UnitsFormat, m_temperature); double rt = vcs_nondimMult_TP(m_VCS_UnitsFormat, m_temperature);
@ -306,8 +292,7 @@ int VCS_SOLVE::vcs_report(int iconv)
plogf(" Name TKMoles StandStateChemPot " plogf(" Name TKMoles StandStateChemPot "
" ln(AC) ln(X_i) | F z_i phi | ChemPot | (-lnMnaught)"); " ln(AC) ln(X_i) | F z_i phi | ChemPot | (-lnMnaught)");
plogf("| (MolNum ChemPot)|"); plogf("| (MolNum ChemPot)|");
plogf("\n"); writeline('-', 147, true, true);
print_line("-", 147);
for (size_t i = 0; i < nspecies; ++i) { for (size_t i = 0; i < nspecies; ++i) {
size_t l = sortindex[i]; size_t l = sortindex[i];
size_t pid = m_phaseID[l]; size_t pid = m_phaseID[l];
@ -352,7 +337,7 @@ int VCS_SOLVE::vcs_report(int iconv)
plogf(" "); plogf(" ");
} }
plogf(" %20.9E\n", g); plogf(" %20.9E\n", g);
print_line("-", 147); writeline('-', 147);
/* /*
* ------------- TABLE OF SOLUTION COUNTERS -------------------------- * ------------- TABLE OF SOLUTION COUNTERS --------------------------
@ -370,8 +355,8 @@ int VCS_SOLVE::vcs_report(int iconv)
plogf(" vcs_TP: %5d %11s\n", plogf(" vcs_TP: %5d %11s\n",
m_VCount->Its," NA "); m_VCount->Its," NA ");
} }
print_line("-", 80); writeline('-', 80);
print_line("-", 80); writeline('-', 80);
/* /*
* Set the Units state of the system back to where it was when we * Set the Units state of the system back to where it was when we

View file

@ -11,9 +11,12 @@
#include "cantera/equil/vcs_solve.h" #include "cantera/equil/vcs_solve.h"
#include "cantera/equil/vcs_internal.h" #include "cantera/equil/vcs_internal.h"
#include "cantera/equil/vcs_VolPhase.h" #include "cantera/equil/vcs_VolPhase.h"
#include "cantera/base/global.h"
#include <cstdio> #include <cstdio>
using namespace Cantera;
namespace VCSnonideal namespace VCSnonideal
{ {
@ -352,7 +355,7 @@ size_t VCS_SOLVE::vcs_RxnStepSizes(int& forceComponentCalc, size_t& kSpecial)
#ifdef DEBUG_MODE #ifdef DEBUG_MODE
if (m_debug_print_lvl >= 2) { if (m_debug_print_lvl >= 2) {
plogf(" "); plogf(" ");
vcs_print_line("-", 82); writeline('-', 82);
} }
#endif #endif
return iphDel; return iphDel;
@ -372,7 +375,7 @@ size_t VCS_SOLVE::vcs_RxnStepSizes(int& forceComponentCalc, size_t& kSpecial)
#ifdef DEBUG_MODE #ifdef DEBUG_MODE
if (m_debug_print_lvl >= 2) { if (m_debug_print_lvl >= 2) {
plogf(" "); plogf(" ");
vcs_print_line("-", 82); writeline('-', 82);
} }
#endif #endif
return iphDel; return iphDel;

View file

@ -27,8 +27,6 @@ namespace VCSnonideal
{ {
/************ Prototypes for static functions ******************************/ /************ Prototypes for static functions ******************************/
static void print_space(size_t num);
#ifdef DEBUG_MODE #ifdef DEBUG_MODE
# ifdef DEBUG_NOT # ifdef DEBUG_NOT
static void prneav(void); static void prneav(void);
@ -148,7 +146,7 @@ int VCS_SOLVE::vcs_solve_TP(int print_lvl, int printDetails, int maxit)
plogf("\n ELEMENTAL ABUNDANCES CORRECT"); plogf("\n ELEMENTAL ABUNDANCES CORRECT");
plogf(" FROM ESTIMATE Type\n\n"); plogf(" FROM ESTIMATE Type\n\n");
for (size_t i = 0; i < m_numElemConstraints; ++i) { for (size_t i = 0; i < m_numElemConstraints; ++i) {
print_space(26); writeline(' ', 26, false);
plogf("%-2.2s", (m_elementName[i]).c_str()); plogf("%-2.2s", (m_elementName[i]).c_str());
plogf("%20.12E%20.12E %3d\n", m_elemAbundancesGoal[i], m_elemAbundances[i], plogf("%20.12E%20.12E %3d\n", m_elemAbundancesGoal[i], m_elemAbundances[i],
m_elType[i]); m_elType[i]);
@ -177,9 +175,9 @@ int VCS_SOLVE::vcs_solve_TP(int print_lvl, int printDetails, int maxit)
plogf(" Stan. Chem. Pot. in J/kmol\n"); plogf(" Stan. Chem. Pot. in J/kmol\n");
} }
plogf("\n SPECIES FORMULA VECTOR "); plogf("\n SPECIES FORMULA VECTOR ");
print_space(41); writeline(' ', 41, false);
plogf(" STAN_CHEM_POT EQUILIBRIUM_EST. Species_Type\n\n"); plogf(" STAN_CHEM_POT EQUILIBRIUM_EST. Species_Type\n\n");
print_space(20); writeline(' ', 20, false);
for (size_t i = 0; i < m_numElemConstraints; ++i) { for (size_t i = 0; i < m_numElemConstraints; ++i) {
plogf("%-4.4s ", m_elementName[i].c_str()); plogf("%-4.4s ", m_elementName[i].c_str());
} }
@ -191,7 +189,7 @@ int VCS_SOLVE::vcs_solve_TP(int print_lvl, int printDetails, int maxit)
plogf("% -7.3g ", m_formulaMatrix[j][i]); plogf("% -7.3g ", m_formulaMatrix[j][i]);
} }
plogf(" %3d ", m_phaseID[i]); plogf(" %3d ", m_phaseID[i]);
print_space(std::max(55-int(m_numElemConstraints)*8, 0)); writeline(' ', std::max(55-int(m_numElemConstraints)*8, 0), false);
plogf("%12.5E %12.5E", RT * m_SSfeSpecies[i], m_molNumSpecies_old[i]); plogf("%12.5E %12.5E", RT * m_SSfeSpecies[i], m_molNumSpecies_old[i]);
if (m_speciesUnknownType[i] == VCS_SPECIES_TYPE_MOLNUM) { if (m_speciesUnknownType[i] == VCS_SPECIES_TYPE_MOLNUM) {
plogf(" Mol_Num"); plogf(" Mol_Num");
@ -327,7 +325,7 @@ L_MAINLOOP_ALL_SPECIES:
if (printDetails) { if (printDetails) {
plogf("\n"); plogf("\n");
vcs_print_line("=", 110); writeline('=', 110);
plogf(" Iteration = %3d, Iterations since last evaluation of " plogf(" Iteration = %3d, Iterations since last evaluation of "
"optimal basis = %3d", "optimal basis = %3d",
m_VCount->Its, it1 - 1); m_VCount->Its, it1 - 1);
@ -999,7 +997,7 @@ L_MAIN_LOOP_END_NO_PRINT:
m_molNumSpecies_old[k]+m_deltaMolNumSpecies[k], m_deltaMolNumSpecies[k]); m_molNumSpecies_old[k]+m_deltaMolNumSpecies[k], m_deltaMolNumSpecies[k]);
} }
plogf(" "); plogf(" ");
vcs_print_line("-", 80); writeline('-', 80);
plogf(" --- Finished Main Loop"); plogf(" --- Finished Main Loop");
plogendl(); plogendl();
} }
@ -1143,7 +1141,7 @@ L_MAIN_LOOP_END_NO_PRINT:
m_molNumSpecies_new[kspec], m_deltaGRxn_old[irxn], m_molNumSpecies_new[kspec], m_deltaGRxn_old[irxn],
m_deltaGRxn_tmp[irxn], m_deltaGRxn_new[irxn]); m_deltaGRxn_tmp[irxn], m_deltaGRxn_new[irxn]);
} }
print_space(26); writeline(' ', 26, false);
plogf("Norms of Delta G():%14.6E%14.6E\n", plogf("Norms of Delta G():%14.6E%14.6E\n",
l2normdg(VCS_DATA_PTR(m_deltaGRxn_old)), l2normdg(VCS_DATA_PTR(m_deltaGRxn_old)),
l2normdg(VCS_DATA_PTR(m_deltaGRxn_new))); l2normdg(VCS_DATA_PTR(m_deltaGRxn_new)));
@ -1166,7 +1164,7 @@ L_MAIN_LOOP_END_NO_PRINT:
if (printDetails) { if (printDetails) {
plogf(" "); plogf(" ");
vcs_print_line("-", 103); writeline('-', 103);
plogf(" --- Summary of the Update "); plogf(" --- Summary of the Update ");
if (iti == 0) { if (iti == 0) {
plogf(" (all species):"); plogf(" (all species):");
@ -1202,7 +1200,7 @@ L_MAIN_LOOP_END_NO_PRINT:
m_deltaGRxn_old[l1], m_deltaGRxn_new[l1]); m_deltaGRxn_old[l1], m_deltaGRxn_new[l1]);
} }
plogf(" ---"); plogf(" ---");
print_space(56); writeline(' ', 56, false);
plogf("Norms of Delta G():%14.6E%14.6E", plogf("Norms of Delta G():%14.6E%14.6E",
l2normdg(VCS_DATA_PTR(m_deltaGRxn_old)), l2normdg(VCS_DATA_PTR(m_deltaGRxn_old)),
l2normdg(VCS_DATA_PTR(m_deltaGRxn_new))); l2normdg(VCS_DATA_PTR(m_deltaGRxn_new)));
@ -1210,13 +1208,13 @@ L_MAIN_LOOP_END_NO_PRINT:
plogf(" --- Phase_Name KMoles(after update)\n"); plogf(" --- Phase_Name KMoles(after update)\n");
plogf(" --- "); plogf(" --- ");
vcs_print_line("-", 50); writeline('-', 50);
for (size_t iph = 0; iph < m_numPhases; iph++) { for (size_t iph = 0; iph < m_numPhases; iph++) {
vcs_VolPhase* Vphase = m_VolPhaseList[iph]; vcs_VolPhase* Vphase = m_VolPhaseList[iph];
plogf(" --- %18s = %15.7E\n", Vphase->PhaseName.c_str(), m_tPhaseMoles_new[iph]); plogf(" --- %18s = %15.7E\n", Vphase->PhaseName.c_str(), m_tPhaseMoles_new[iph]);
} }
plogf(" "); plogf(" ");
vcs_print_line("-", 103); writeline('-', 103);
plogf(" --- Total Old Dimensionless Gibbs Free Energy = %20.13E\n", plogf(" --- Total Old Dimensionless Gibbs Free Energy = %20.13E\n",
vcs_Total_Gibbs(VCS_DATA_PTR(m_molNumSpecies_old), VCS_DATA_PTR(m_feSpecies_old), vcs_Total_Gibbs(VCS_DATA_PTR(m_molNumSpecies_old), VCS_DATA_PTR(m_feSpecies_old),
VCS_DATA_PTR(m_tPhaseMoles_old))); VCS_DATA_PTR(m_tPhaseMoles_old)));
@ -4026,7 +4024,7 @@ void VCS_SOLVE::vcs_printSpeciesChemPot(const int stateCalc) const
printf(" --- CHEMICAL POT TABLE (J/kmol) Name PhID MolFR ChemoSS " printf(" --- CHEMICAL POT TABLE (J/kmol) Name PhID MolFR ChemoSS "
" logMF Gamma Elect extra ElectrChem\n"); " logMF Gamma Elect extra ElectrChem\n");
printf(" "); printf(" ");
vcs_print_line("-", 132); writeline('-', 132);
for (size_t kspec = 0; kspec < m_numSpeciesTot; ++kspec) { for (size_t kspec = 0; kspec < m_numSpeciesTot; ++kspec) {
mfValue = 1.0; mfValue = 1.0;
@ -4070,7 +4068,7 @@ void VCS_SOLVE::vcs_printSpeciesChemPot(const int stateCalc) const
printf(" % -12.4e\n", total *RT); printf(" % -12.4e\n", total *RT);
} }
printf(" "); printf(" ");
vcs_print_line("-", 132); writeline('-', 132);
} }
#ifdef DEBUG_MODE #ifdef DEBUG_MODE
@ -4297,13 +4295,6 @@ void VCS_SOLVE::vcs_switch2D(double* const* const Jac,
} }
} }
static void print_space(size_t num)
{
for (size_t j = 0; j < num; j++) {
plogf(" ");
}
}
void VCS_SOLVE::vcs_deltag(const int l, const bool doDeleted, void VCS_SOLVE::vcs_deltag(const int l, const bool doDeleted,
const int vcsState, const bool alterZeroedPhases) const int vcsState, const bool alterZeroedPhases)
{ {
@ -4563,7 +4554,7 @@ void VCS_SOLVE::vcs_printDeltaG(const int stateCalc)
printf(" --- DeltaG Table (J/kmol) Name PhID MoleNum MolFR " printf(" --- DeltaG Table (J/kmol) Name PhID MoleNum MolFR "
" ElectrChemStar ElectrChem DeltaGStar DeltaG(Pred) Stability\n"); " ElectrChemStar ElectrChem DeltaGStar DeltaG(Pred) Stability\n");
printf(" "); printf(" ");
vcs_print_line("-", 132); writeline('-', 132);
for (size_t kspec = 0; kspec < m_numSpeciesTot; kspec++) { for (size_t kspec = 0; kspec < m_numSpeciesTot; kspec++) {
@ -4637,7 +4628,7 @@ void VCS_SOLVE::vcs_printDeltaG(const int stateCalc)
} }
printf(" "); printf(" ");
vcs_print_line("-", 132); writeline('-', 132);
} }

View file

@ -162,16 +162,6 @@ double vcsUtil_gasConstant(int mu_units)
} }
} }
void vcs_print_line(const char* string, int num)
{
if (string) {
for (int j = 0; j < num; j++) {
plogf("%s", string);
}
}
plogendl();
}
const char* vcs_speciesType_string(int speciesStatus, int length) const char* vcs_speciesType_string(int speciesStatus, int length)
{ {
const char* sss; const char* sss;

View file

@ -307,14 +307,6 @@ double BEulerInt::filterNewStep(double timeCurrent, double* y_current, double* y
return 0.0; return 0.0;
} }
static void print_line(const char* str, int n)
{
for (int i = 0; i < n; i++) {
printf("%s", str);
}
printf("\n");
}
/* /*
* Print out for relevant time step information * Print out for relevant time step information
*/ */
@ -330,8 +322,7 @@ static void print_time_step1(int order, int n_time_step, double time,
} else if (order == 2) { } else if (order == 2) {
string = "Adams-Bashforth/TR"; string = "Adams-Bashforth/TR";
} }
printf("\n"); writeline('=', 80, true, true);
print_line("=", 80);
printf("\nStart of Time Step: %5d Time_n = %9.5g Time_nm1 = %9.5g\n", printf("\nStart of Time Step: %5d Time_n = %9.5g Time_nm1 = %9.5g\n",
n_time_step, time, time - delta_t_n); n_time_step, time, time - delta_t_n);
printf("\tIntegration method = %s\n", string); printf("\tIntegration method = %s\n", string);
@ -366,9 +357,7 @@ static void print_time_step2(int time_step_num, int order,
printf("\t\tTolerated Error\n\n"); printf("\t\tTolerated Error\n\n");
printf("\t- Recommended next delta_t (not counting history) = %g\n", printf("\t- Recommended next delta_t (not counting history) = %g\n",
delta_t_np1); delta_t_np1);
printf("\n"); writeline('=', 80, true, true);
print_line("=", 80);
printf("\n");
} }
/* /*
@ -378,8 +367,7 @@ static void print_time_fail(bool convFailure, int time_step_num,
double time, double delta_t_n, double time, double delta_t_n,
double delta_t_np1, double time_error_factor) double delta_t_np1, double time_error_factor)
{ {
printf("\n"); writeline('=', 80, true, true);
print_line("=", 80);
if (convFailure) { if (convFailure) {
printf("\tTime Step Number %5d experienced a convergence " printf("\tTime Step Number %5d experienced a convergence "
"failure\n", time_step_num); "failure\n", time_step_num);
@ -400,8 +388,7 @@ static void print_time_fail(bool convFailure, int time_step_num,
printf("\t\tCalculated truncation error factor = %g\n", printf("\t\tCalculated truncation error factor = %g\n",
time_error_factor); time_error_factor);
} }
printf("\n"); writeline('=', 80, true, true);
print_line("=", 80);
} }
/* /*
@ -412,8 +399,7 @@ static void print_final(double time, int step_failed,
int total_linear_solves, int numConvFails, int total_linear_solves, int numConvFails,
int numTruncFails, int nfe, int nJacEval) int numTruncFails, int nfe, int nJacEval)
{ {
printf("\n"); writeline('=', 80, true, true);
print_line("=", 80);
printf("TIME INTEGRATION ROUTINE HAS FINISHED: "); printf("TIME INTEGRATION ROUTINE HAS FINISHED: ");
if (step_failed) { if (step_failed) {
printf(" IT WAS A FAILURE\n"); printf(" IT WAS A FAILURE\n");
@ -428,8 +414,7 @@ static void print_final(double time, int step_failed,
printf("\tNumber of TimeTruncErr fails = %d\n", numTruncFails); printf("\tNumber of TimeTruncErr fails = %d\n", numTruncFails);
printf("\tNumber of Function evals = %d\n", nfe); printf("\tNumber of Function evals = %d\n", nfe);
printf("\tNumber of Jacobian evals/solvs= %d\n", nJacEval); printf("\tNumber of Jacobian evals/solvs= %d\n", nJacEval);
printf("\n"); writeline('=', 80, true, true);
print_line("=", 80);
} }
/* /*
@ -439,7 +424,7 @@ static void print_lvl1_Header(int nTimes)
{ {
printf("\n"); printf("\n");
if (nTimes) { if (nTimes) {
print_line("-", 80); writeline('-', 80);
} }
printf("time Time Time Time "); printf("time Time Time Time ");
if (nTimes == 0) { if (nTimes == 0) {
@ -454,8 +439,7 @@ static void print_lvl1_Header(int nTimes)
printf(" No. Rslt size Its Its stps error |"); printf(" No. Rslt size Its Its stps error |");
printf(" comment"); printf(" comment");
printf("\n"); writeline('-', 80, true);
print_line("-", 80);
} }
/* /*
@ -676,7 +660,7 @@ double BEulerInt::time_error_norm()
printf("\t\t I entry actual predicted " printf("\t\t I entry actual predicted "
" weight ydot\n"); " weight ydot\n");
printf("\t\t"); printf("\t\t");
print_line("-", 70); writeline('-', 70);
for (j = 0; j < NUM_ENTRIES; j++) { for (j = 0; j < NUM_ENTRIES; j++) {
imax[j] = -1; imax[j] = -1;
} }
@ -705,7 +689,7 @@ double BEulerInt::time_error_norm()
} }
} }
printf("\t\t"); printf("\t\t");
print_line("-", 70); writeline('-', 70);
} }
#endif #endif
rel_norm = 0.0; rel_norm = 0.0;
@ -1338,7 +1322,7 @@ double BEulerInt::soln_error_norm(const double* const delta_y,
printf("\t\t I ysoln deltaY weightY " printf("\t\t I ysoln deltaY weightY "
"Error_Norm**2\n"); "Error_Norm**2\n");
printf("\t\t "); printf("\t\t ");
print_line("-", 80); writeline('-', 80);
for (int jnum = 0; jnum < num_entries; jnum++) { for (int jnum = 0; jnum < num_entries; jnum++) {
dmax1 = -1.0; dmax1 = -1.0;
for (i = 0; i < m_neq; i++) { for (i = 0; i < m_neq; i++) {
@ -1364,7 +1348,7 @@ double BEulerInt::soln_error_norm(const double* const delta_y,
} }
} }
printf("\t\t "); printf("\t\t ");
print_line("-", 80); writeline('-', 80);
} }
return sum_norm; return sum_norm;
} }
@ -1910,7 +1894,7 @@ void BEulerInt::print_solnDelta_norm_contrib(const double* const solnDelta0,
"%10s weight relSoln0 relSoln1\n", s0, s1); "%10s weight relSoln0 relSoln1\n", s0, s1);
vector_int imax(num_entries, -1); vector_int imax(num_entries, -1);
printf("\t\t "); printf("\t\t ");
print_line("-", 90); writeline('-', 90);
for (jnum = 0; jnum < num_entries; jnum++) { for (jnum = 0; jnum < num_entries; jnum++) {
dmax1 = -1.0; dmax1 = -1.0;
for (i = 0; i < m_neq; i++) { for (i = 0; i < m_neq; i++) {
@ -1944,7 +1928,7 @@ void BEulerInt::print_solnDelta_norm_contrib(const double* const solnDelta0,
} }
} }
printf("\t\t "); printf("\t\t ");
print_line("-", 90); writeline('-', 90);
} }
} // End of namespace Cantera } // End of namespace Cantera

View file

@ -18,6 +18,7 @@
#include "cantera/base/clockWC.h" #include "cantera/base/clockWC.h"
#include "cantera/base/vec_functions.h" #include "cantera/base/vec_functions.h"
#include "cantera/base/stringUtils.h" #include "cantera/base/stringUtils.h"
#include "cantera/base/global.h"
#include <limits> #include <limits>
@ -36,19 +37,6 @@ const doublereal DampFactor = 4.0;
//! a failure //! a failure
const int NDAMP = 7; const int NDAMP = 7;
//! Print a line of a single repeated character string
/*!
* @param str Character string
* @param n Iteration length
*/
static void print_line(const char* str, int n)
{
for (int i = 0; i < n; i++) {
printf("%s", str);
}
printf("\n");
}
bool NonlinearSolver::s_TurnOffTiming(false); bool NonlinearSolver::s_TurnOffTiming(false);
#ifdef DEBUG_NUMJAC #ifdef DEBUG_NUMJAC
@ -451,7 +439,7 @@ doublereal NonlinearSolver::solnErrorNorm(const doublereal* const delta_y, const
const int num_entries = printLargest; const int num_entries = printLargest;
printf("\t\t "); printf("\t\t ");
print_line("-", 90); writeline('-', 90);
printf("\t\t solnErrorNorm(): "); printf("\t\t solnErrorNorm(): ");
if (title) { if (title) {
printf("%s", title); printf("%s", title);
@ -467,7 +455,7 @@ doublereal NonlinearSolver::solnErrorNorm(const doublereal* const delta_y, const
printf("\t\t I weightdeltaY/sqtN| deltaY " printf("\t\t I weightdeltaY/sqtN| deltaY "
"ysolnOld ysolnNew Soln_Weights\n"); "ysolnOld ysolnNew Soln_Weights\n");
printf("\t\t "); printf("\t\t ");
print_line("-", 88); writeline('-', 88);
for (int jnum = 0; jnum < num_entries; jnum++) { for (int jnum = 0; jnum < num_entries; jnum++) {
dmax1 = -1.0; dmax1 = -1.0;
@ -497,7 +485,7 @@ doublereal NonlinearSolver::solnErrorNorm(const doublereal* const delta_y, const
} }
} }
printf("\t\t "); printf("\t\t ");
print_line("-", 90); writeline('-', 90);
} }
} }
return sum_norm; return sum_norm;
@ -539,7 +527,7 @@ doublereal NonlinearSolver::residErrorNorm(const doublereal* const resid, const
} }
if (m_print_flag >= 6) { if (m_print_flag >= 6) {
printf("\t\t "); printf("\t\t ");
print_line("-", 90); writeline('-', 90);
printf("\t\t residErrorNorm(): "); printf("\t\t residErrorNorm(): ");
if (title) { if (title) {
printf(" %s ", title); printf(" %s ", title);
@ -550,7 +538,7 @@ doublereal NonlinearSolver::residErrorNorm(const doublereal* const resid, const
printf("\t\t Printout of Largest Contributors to norm:\n"); printf("\t\t Printout of Largest Contributors to norm:\n");
printf("\t\t I |Resid/ResWt| UnsclRes ResWt | y_curr\n"); printf("\t\t I |Resid/ResWt| UnsclRes ResWt | y_curr\n");
printf("\t\t "); printf("\t\t ");
print_line("-", 88); writeline('-', 88);
for (int jnum = 0; jnum < num_entries; jnum++) { for (int jnum = 0; jnum < num_entries; jnum++) {
dmax1 = -1.0; dmax1 = -1.0;
for (size_t i = 0; i < neq_; i++) { for (size_t i = 0; i < neq_; i++) {
@ -578,7 +566,7 @@ doublereal NonlinearSolver::residErrorNorm(const doublereal* const resid, const
} }
printf("\t\t "); printf("\t\t ");
print_line("-", 90); writeline('-', 90);
} }
} }
return sum_norm; return sum_norm;
@ -2738,7 +2726,7 @@ int NonlinearSolver::solve_nonlinear_problem(int SolnType, doublereal* const y_c
if (m_print_flag > 3) { if (m_print_flag > 3) {
printf("\t"); printf("\t");
print_line("=", 119); writeline('=', 119);
printf("\tsolve_nonlinear_problem(): iteration %d:\n", printf("\tsolve_nonlinear_problem(): iteration %d:\n",
num_newt_its); num_newt_its);
} }
@ -3098,7 +3086,7 @@ int NonlinearSolver::solve_nonlinear_problem(int SolnType, doublereal* const y_c
printf("\t solve_nonlinear_problem(): Problem Converged, stepNorm = %11.3E, reduction of res from %11.3E to %11.3E\n", printf("\t solve_nonlinear_problem(): Problem Converged, stepNorm = %11.3E, reduction of res from %11.3E to %11.3E\n",
stepNorm_1, m_normResid_0, m_normResid_full); stepNorm_1, m_normResid_0, m_normResid_full);
printf("\t"); printf("\t");
print_line("=", 119); writeline('=', 119);
} else { } else {
printf("\t solve_nonlinear_problem(): Successfull step taken with stepNorm = %11.3E, reduction of res from %11.3E to %11.3E\n", printf("\t solve_nonlinear_problem(): Successfull step taken with stepNorm = %11.3E, reduction of res from %11.3E to %11.3E\n",
stepNorm_1, m_normResid_0, m_normResid_full); stepNorm_1, m_normResid_0, m_normResid_full);
@ -3108,7 +3096,7 @@ int NonlinearSolver::solve_nonlinear_problem(int SolnType, doublereal* const y_c
printf("\t solve_nonlinear_problem(): Damped Newton iteration successful, nonlin " printf("\t solve_nonlinear_problem(): Damped Newton iteration successful, nonlin "
"converged, final estimate of the next solution update norm = %-12.4E\n", stepNorm_2); "converged, final estimate of the next solution update norm = %-12.4E\n", stepNorm_2);
printf("\t"); printf("\t");
print_line("=", 119); writeline('=', 119);
} else if (retnDamp >= NSOLN_RETN_CONTINUE) { } else if (retnDamp >= NSOLN_RETN_CONTINUE) {
printf("\t solve_nonlinear_problem(): Damped Newton iteration successful, " printf("\t solve_nonlinear_problem(): Damped Newton iteration successful, "
"estimate of the next solution update norm = %-12.4E\n", stepNorm_2); "estimate of the next solution update norm = %-12.4E\n", stepNorm_2);
@ -3237,7 +3225,7 @@ void NonlinearSolver::print_solnDelta_norm_contrib(const doublereal* const step_
"%10s ysolnNewTrialRaw | solnWeight wtDelSoln wtDelSolnTrial\n", stepNorm_1, stepNorm_2); "%10s ysolnNewTrialRaw | solnWeight wtDelSoln wtDelSolnTrial\n", stepNorm_1, stepNorm_2);
std::vector<size_t> imax(num_entries, npos); std::vector<size_t> imax(num_entries, npos);
printf("\t\t "); printf("\t\t ");
print_line("-", 125); writeline('-', 125);
for (size_t jnum = 0; jnum < num_entries; jnum++) { for (size_t jnum = 0; jnum < num_entries; jnum++) {
dmax1 = -1.0; dmax1 = -1.0;
for (size_t i = 0; i < neq_; i++) { for (size_t i = 0; i < neq_; i++) {
@ -3270,7 +3258,7 @@ void NonlinearSolver::print_solnDelta_norm_contrib(const doublereal* const step_
} }
} }
printf("\t\t "); printf("\t\t ");
print_line("-", 125); writeline('-', 125);
} }
//==================================================================================================================== //====================================================================================================================
//! This routine subtracts two numbers for one another //! This routine subtracts two numbers for one another

View file

@ -159,12 +159,6 @@ void Domain1D::setupGrid(size_t n, const doublereal* z)
} }
} }
void drawline()
{
writelog("\n-------------------------------------"
"------------------------------------------");
}
void Domain1D::showSolution(const doublereal* x) void Domain1D::showSolution(const doublereal* x)
{ {
size_t nn = m_nv/5; size_t nn = m_nv/5;
@ -172,14 +166,14 @@ void Domain1D::showSolution(const doublereal* x)
char buf[100]; char buf[100];
doublereal v; doublereal v;
for (i = 0; i < nn; i++) { for (i = 0; i < nn; i++) {
drawline(); writeline('-', 79, false, true);
sprintf(buf, "\n z "); sprintf(buf, "\n z ");
writelog(buf); writelog(buf);
for (n = 0; n < 5; n++) { for (n = 0; n < 5; n++) {
sprintf(buf, " %10s ",componentName(i*5 + n).c_str()); sprintf(buf, " %10s ",componentName(i*5 + n).c_str());
writelog(buf); writelog(buf);
} }
drawline(); writeline('-', 79, false, true);
for (j = 0; j < m_points; j++) { for (j = 0; j < m_points; j++) {
sprintf(buf, "\n %10.4g ",m_z[j]); sprintf(buf, "\n %10.4g ",m_z[j]);
writelog(buf); writelog(buf);
@ -192,14 +186,14 @@ void Domain1D::showSolution(const doublereal* x)
writelog("\n"); writelog("\n");
} }
size_t nrem = m_nv - 5*nn; size_t nrem = m_nv - 5*nn;
drawline(); writeline('-', 79, false, true);
sprintf(buf, "\n z "); sprintf(buf, "\n z ");
writelog(buf); writelog(buf);
for (n = 0; n < nrem; n++) { for (n = 0; n < nrem; n++) {
sprintf(buf, " %10s ", componentName(nn*5 + n).c_str()); sprintf(buf, " %10s ", componentName(nn*5 + n).c_str());
writelog(buf); writelog(buf);
} }
drawline(); writeline('-', 79, false, true);
for (j = 0; j < m_points; j++) { for (j = 0; j < m_points; j++) {
sprintf(buf, "\n %10.4g ",m_z[j]); sprintf(buf, "\n %10.4g ",m_z[j]);
writelog(buf); writelog(buf);

View file

@ -148,9 +148,6 @@ doublereal norm_square(const doublereal* x,
// constants // constants
//----------------------------------------------------------- //-----------------------------------------------------------
const string dashedline =
"-----------------------------------------------------------------";
const doublereal DampFactor = sqrt(2.0); const doublereal DampFactor = sqrt(2.0);
const size_t NDAMP = 7; const size_t NDAMP = 7;
@ -274,13 +271,13 @@ int MultiNewton::dampStep(const doublereal* x0, const doublereal* step0,
// write header // write header
if (loglevel > 0 && writetitle) { if (loglevel > 0 && writetitle) {
writelog("\n\nDamped Newton iteration:\n"); writelog("\n\nDamped Newton iteration:\n");
writelog(dashedline); writeline('-', 65, false);
sprintf(m_buf,"\n%s %9s %9s %9s %9s %9s %5s %5s\n", sprintf(m_buf,"\n%s %9s %9s %9s %9s %9s %5s %5s\n",
"m","F_damp","F_bound","log10(ss)", "m","F_damp","F_bound","log10(ss)",
"log10(s0)","log10(s1)","N_jac","Age"); "log10(s0)","log10(s1)","N_jac","Age");
writelog(m_buf); writelog(m_buf);
writelog(dashedline+"\n"); writeline('-', 65);
} }
// compute the weighted norm of the undamped step size step0 // compute the weighted norm of the undamped step size step0

View file

@ -12,13 +12,6 @@ using namespace std;
namespace Cantera namespace Cantera
{ {
static void sim1D_drawline()
{
string s(78,'.');
s += '\n';
writelog(s.c_str());
}
Sim1D::Sim1D() : Sim1D::Sim1D() :
OneDim() OneDim()
{ {
@ -236,8 +229,7 @@ void Sim1D::solve(int loglevel, bool refine_grid)
bool ok = false; bool ok = false;
if (loglevel > 0) { if (loglevel > 0) {
writelog("\n"); writeline('.', 78, true, true);
sim1D_drawline();
} }
while (!ok) { while (!ok) {
writelog("Attempt Newton solution of steady-state problem...", loglevel); writelog("Attempt Newton solution of steady-state problem...", loglevel);
@ -304,8 +296,7 @@ void Sim1D::solve(int loglevel, bool refine_grid)
} }
} }
if (loglevel > 0) { if (loglevel > 0) {
sim1D_drawline(); writeline('.', 78, true, true);
writelog("\n");
} }
if (loglevel > 2) { if (loglevel > 2) {
showSolution(); showSolution();

View file

@ -18,12 +18,6 @@ using namespace std;
namespace Cantera namespace Cantera
{ {
static void st_drawline()
{
writelog("\n-------------------------------------"
"------------------------------------------");
}
StFlow::StFlow(IdealGasPhase* ph, size_t nsp, size_t points) : StFlow::StFlow(IdealGasPhase* ph, size_t nsp, size_t points) :
Domain1D(nsp+4, points), Domain1D(nsp+4, points),
m_inlet_u(0.0), m_inlet_u(0.0),
@ -464,14 +458,14 @@ void StFlow::showSolution(const doublereal* x)
sprintf(buf, " Pressure: %10.4g Pa \n", m_press); sprintf(buf, " Pressure: %10.4g Pa \n", m_press);
writelog(buf); writelog(buf);
for (i = 0; i < nn; i++) { for (i = 0; i < nn; i++) {
st_drawline(); writeline('-', 79, false, true);
sprintf(buf, "\n z "); sprintf(buf, "\n z ");
writelog(buf); writelog(buf);
for (n = 0; n < 5; n++) { for (n = 0; n < 5; n++) {
sprintf(buf, " %10s ",componentName(i*5 + n).c_str()); sprintf(buf, " %10s ",componentName(i*5 + n).c_str());
writelog(buf); writelog(buf);
} }
st_drawline(); writeline('-', 79, false, true);
for (j = 0; j < m_points; j++) { for (j = 0; j < m_points; j++) {
sprintf(buf, "\n %10.4g ",m_z[j]); sprintf(buf, "\n %10.4g ",m_z[j]);
writelog(buf); writelog(buf);
@ -483,14 +477,14 @@ void StFlow::showSolution(const doublereal* x)
writelog("\n"); writelog("\n");
} }
size_t nrem = m_nv - 5*nn; size_t nrem = m_nv - 5*nn;
st_drawline(); writeline('-', 79, false, true);
sprintf(buf, "\n z "); sprintf(buf, "\n z ");
writelog(buf); writelog(buf);
for (n = 0; n < nrem; n++) { for (n = 0; n < nrem; n++) {
sprintf(buf, " %10s ", componentName(nn*5 + n).c_str()); sprintf(buf, " %10s ", componentName(nn*5 + n).c_str());
writelog(buf); writelog(buf);
} }
st_drawline(); writeline('-', 79, false, true);
for (j = 0; j < m_points; j++) { for (j = 0; j < m_points; j++) {
sprintf(buf, "\n %10.4g ",m_z[j]); sprintf(buf, "\n %10.4g ",m_z[j]);
writelog(buf); writelog(buf);

View file

@ -10,13 +10,6 @@ using namespace std;
namespace Cantera namespace Cantera
{ {
static void r_drawline()
{
string s(78,'#');
s += '\n';
writelog(s.c_str());
}
Refiner::Refiner(Domain1D& domain) : Refiner::Refiner(Domain1D& domain) :
m_ratio(10.0), m_slope(0.8), m_curve(0.8), m_prune(-0.001), m_ratio(10.0), m_slope(0.8), m_curve(0.8), m_prune(-0.001),
m_min_range(0.01), m_domain(&domain), m_npmax(3000), m_min_range(0.01), m_domain(&domain), m_npmax(3000),
@ -220,7 +213,7 @@ double Refiner::value(const double* x, size_t i, size_t j)
void Refiner::show() void Refiner::show()
{ {
if (!m_loc.empty()) { if (!m_loc.empty()) {
r_drawline(); writeline('#', 78);
writelog(string("Refining grid in ") + writelog(string("Refining grid in ") +
m_domain->id()+".\n" m_domain->id()+".\n"
+" New points inserted after grid points "); +" New points inserted after grid points ");
@ -235,7 +228,7 @@ void Refiner::show()
writelog(string(bb->first)+" "); writelog(string(bb->first)+" ");
} }
writelog("\n"); writelog("\n");
r_drawline(); writeline('#', 78);
} else if (m_domain->nPoints() > 1) { } else if (m_domain->nPoints() > 1) {
writelog("no new points needed in "+m_domain->id()+"\n"); writelog("no new points needed in "+m_domain->id()+"\n");
} }