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
void writelogendl();
void writeline(char repeat, int count,
bool endl_after=true, bool endl_before=false);
//! @copydoc Application::Messages::logerror
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);
//! 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
//! species given by the first argument
/*!

View file

@ -68,6 +68,17 @@ void 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)
{
warn_deprecated("error");

View file

@ -762,18 +762,6 @@ void vcs_MultiPhaseEquil::reportCSV(const std::string& reportFile)
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
* equilibrium problem.
@ -1121,15 +1109,11 @@ int vcs_Cantera_to_vprob(Cantera::MultiPhase* mphase,
* Printout the species information: PhaseID's and mole nums
*/
if (vprob->m_printLvl > 1) {
plogf("\n");
print_char('=', 80);
plogf("\n");
print_char('=', 16);
writeline('=', 80, true, true);
writeline('=', 16, false);
plogf(" Cantera_to_vprob: START OF PROBLEM STATEMENT ");
print_char('=', 20);
plogf("\n");
print_char('=', 80);
plogf("\n");
writeline('=', 20);
writeline('=', 80);
plogf(" Phase IDs of species\n");
plogf(" species phaseID phaseName ");
plogf(" Initial_Estimated_kMols\n");
@ -1149,9 +1133,7 @@ int vcs_Cantera_to_vprob(Cantera::MultiPhase* mphase,
/*
* Printout of the Phase structure information
*/
plogf("\n");
print_char('-', 80);
plogf("\n");
writeline('-', 80, true, true);
plogf(" Information about phases\n");
plogf(" PhaseName PhaseNum SingSpec GasPhase EqnState NumSpec");
plogf(" TMolesInert Tmoles(kmol)\n");
@ -1166,15 +1148,12 @@ int vcs_Cantera_to_vprob(Cantera::MultiPhase* mphase,
plogf("%16e\n", VolPhase->totalMoles());
}
plogf("\n");
print_char('=', 80);
plogf("\n");
print_char('=', 16);
writeline('=', 80, true, true);
writeline('=', 16, false);
plogf(" Cantera_to_vprob: END OF PROBLEM STATEMENT ");
print_char('=', 20);
writeline('=', 20);
writeline('=', 80);
plogf("\n");
print_char('=', 80);
plogf("\n\n");
}
return VCS_SUCCESS;
@ -1253,15 +1232,12 @@ int vcs_Cantera_update_vprob(Cantera::MultiPhase* mphase,
* Printout the species information: PhaseID's and mole nums
*/
if (vprob->m_printLvl > 1) {
plogf("\n");
print_char('=', 80);
plogf("\n");
print_char('=', 20);
writeline('=', 80, true, true);
writeline('=', 20, false);
plogf(" Cantera_to_vprob: START OF PROBLEM STATEMENT ");
print_char('=', 20);
writeline('=', 20);
writeline('=', 80);
plogf("\n");
print_char('=', 80);
plogf("\n\n");
plogf(" Phase IDs of species\n");
plogf(" species phaseID phaseName ");
plogf(" Initial_Estimated_kMols\n");
@ -1281,9 +1257,7 @@ int vcs_Cantera_update_vprob(Cantera::MultiPhase* mphase,
/*
* Printout of the Phase structure information
*/
plogf("\n");
print_char('-', 80);
plogf("\n");
writeline('-', 80, true, true);
plogf(" Information about phases\n");
plogf(" PhaseName PhaseNum SingSpec GasPhase EqnState NumSpec");
plogf(" TMolesInert Tmoles(kmol)\n");
@ -1298,15 +1272,12 @@ int vcs_Cantera_update_vprob(Cantera::MultiPhase* mphase,
plogf("%16e\n", VolPhase->totalMoles());
}
plogf("\n");
print_char('=', 80);
plogf("\n");
print_char('=', 20);
writeline('=', 80, true, true);
writeline('=', 20, false);
plogf(" Cantera_to_vprob: END OF PROBLEM STATEMENT ");
print_char('=', 20);
writeline('=', 20);
writeline('=', 80);
plogf("\n");
print_char('=', 80);
plogf("\n\n");
}
return VCS_SUCCESS;

View file

@ -16,9 +16,11 @@
#include "cantera/thermo/ThermoPhase.h"
#include "cantera/thermo/MolalityVPSSTP.h"
#include "cantera/base/global.h"
#include <cstdio>
using namespace Cantera;
using namespace std;
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)
{
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
*/
if (m_printLvl > 0) {
plogf("\n");
print_char('=', 80);
plogf("\n");
print_char('=', 20);
writeline('=', 80, true, true);
writeline('=', 20, false);
plogf(" VCS_PROB: PROBLEM STATEMENT ");
print_char('=', 31);
plogf("\n");
print_char('=', 80);
plogf("\n");
writeline('=', 31);
writeline('=', 80);
plogf("\n");
if (prob_type == 0) {
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
*/
plogf("\n");
print_char('-', 80);
plogf("\n");
writeline('-', 80, true, true);
plogf(" Information about phases\n");
plogf(" PhaseName PhaseNum SingSpec GasPhase "
" EqnState NumSpec");
@ -264,7 +245,7 @@ void VCS_PROB::prob_report(int print_lvl)
fac = 1.0;
}
for (size_t i = 0; i < ne; ++i) {
print_space(26);
writeline(' ', 26, false);
plogf("%-2.2s", ElName[i].c_str());
plogf("%20.12E ", fac * gai[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));
}
}
plogf("\n");
print_char('=', 80);
plogf("\n");
print_char('=', 20);
writeline('=', 80, true, true);
writeline('=', 20, false);
plogf(" VCS_PROB: END OF PROBLEM STATEMENT ");
print_char('=', 24);
writeline('=', 24);
writeline('=', 80);
plogf("\n");
print_char('=', 80);
plogf("\n\n");
}
}

View file

@ -8,24 +8,12 @@
#include "cantera/equil/vcs_solve.h"
#include "cantera/equil/vcs_internal.h"
#include "cantera/equil/vcs_VolPhase.h"
#include "cantera/base/global.h"
using namespace Cantera;
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)
{
bool printActualMoles = true, inertYes = false;
@ -77,11 +65,11 @@ int VCS_SOLVE::vcs_report(int iconv)
/* ******************************************************** */
plogf("\n\n\n\n");
print_line("-", 80);
print_line("-", 80);
writeline('-', 80);
writeline('-', 80);
plogf("\t\t VCS_TP REPORT\n");
print_line("-", 80);
print_line("-", 80);
writeline('-', 80);
writeline('-', 80);
if (iconv < 0) {
plogf(" ERROR: CONVERGENCE CRITERION NOT SATISFIED.\n");
} else if (iconv == 1) {
@ -106,13 +94,13 @@ int VCS_SOLVE::vcs_report(int iconv)
* -------- TABLE OF SPECIES IN DECREASING MOLE NUMBERS --------------
*/
plogf("\n\n");
print_line("-", 80);
writeline('-', 80);
plogf(" Species Equilibrium kmoles ");
plogf("Mole Fraction ChemPot/RT SpecUnkType\n");
print_line("-", 80);
writeline('-', 80);
for (size_t i = 0; i < m_numComponents; ++i) {
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,
m_molNumSpecies_new[i] * molScale, m_feSpecies_old[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) {
size_t l = sortindex[i];
plogf(" %-12.12s", m_speciesName[l].c_str());
print_space(13);
writeline(' ', 13, false);
if (m_speciesUnknownType[l] == VCS_SPECIES_TYPE_MOLNUM) {
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");
}
}
print_line("-", 80);
writeline('-', 80);
plogf("\n");
/*
* ---------- TABLE OF SPECIES FORMATION REACTIONS ------------------
*/
plogf("\n");
print_line("-", m_numComponents*10 + 45);
writeline('-', m_numComponents*10 + 45, true, true);
plogf(" |ComponentID|");
for (size_t j = 0; j < m_numComponents; j++) {
plogf(" %3d", j);
@ -191,7 +178,7 @@ int VCS_SOLVE::vcs_report(int iconv)
plogf(" %10.3g", m_molNumSpecies_old[j] * molScale);
}
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++) {
size_t kspec = m_indexRxnToSpecies[irxn];
plogf(" %3d ", kspec);
@ -203,7 +190,7 @@ int VCS_SOLVE::vcs_report(int iconv)
plogf(" |%10.3g |", m_deltaGRxn_new[irxn]);
plogf("\n");
}
print_line("-", m_numComponents*10 + 45);
writeline('-', m_numComponents*10 + 45);
plogf("\n");
/*
@ -216,7 +203,7 @@ int VCS_SOLVE::vcs_report(int iconv)
double gibbsTotal = 0.0;
plogf("\n\n");
plogf("\n");
print_line("-", m_numElemConstraints*10 + 58);
writeline('-', m_numElemConstraints*10 + 58);
plogf(" | ElementID |");
for (size_t j = 0; j < m_numElemConstraints; j++) {
plogf(" %3d", j);
@ -232,7 +219,7 @@ int VCS_SOLVE::vcs_report(int iconv)
plogf(" %10.3g", m_elemAbundancesGoal[j]);
}
plogf(" | Gibbs Total |\n");
print_line("-", m_numElemConstraints*10 + 58);
writeline('-', m_numElemConstraints*10 + 58);
for (size_t iphase = 0; iphase < m_numPhases; iphase++) {
plogf(" %3d ", iphase);
vcs_VolPhase* VPhase = m_VolPhaseList[iphase];
@ -255,14 +242,14 @@ int VCS_SOLVE::vcs_report(int iconv)
gibbsTotal += gibbsPhase;
plogf(" | %18.11E |\n", gibbsPhase);
}
print_line("-", m_numElemConstraints*10 + 58);
writeline('-', m_numElemConstraints*10 + 58);
plogf(" TOTAL |%10.3e |", totalMoles);
for (size_t j = 0; j < m_numElemConstraints; j++) {
plogf(" %10.3g", gaTPhase[j]);
}
plogf(" | %18.11E |\n", gibbsTotal);
print_line("-", m_numElemConstraints*10 + 58);
writeline('-', m_numElemConstraints*10 + 58);
plogf("\n");
/*
@ -285,7 +272,7 @@ int VCS_SOLVE::vcs_report(int iconv)
plogf("\nElemental Abundances (kmol): ");
plogf(" Actual Target Type ElActive\n");
for (size_t i = 0; i < m_numElemConstraints; ++i) {
print_space(26);
writeline(' ', 26, false);
plogf("%-2.2s", (m_elementName[i]).c_str());
plogf("%20.12E %20.12E", m_elemAbundances[i]*molScale, m_elemAbundancesGoal[i]*molScale);
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 ---------------------
*/
plogf("\n");
print_line("-", 93);
writeline('-', 93, true, true);
plogf("Chemical Potentials of the Species: (dimensionless)\n");
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 "
" ln(AC) ln(X_i) | F z_i phi | ChemPot | (-lnMnaught)");
plogf("| (MolNum ChemPot)|");
plogf("\n");
print_line("-", 147);
writeline('-', 147, true, true);
for (size_t i = 0; i < nspecies; ++i) {
size_t l = sortindex[i];
size_t pid = m_phaseID[l];
@ -352,7 +337,7 @@ int VCS_SOLVE::vcs_report(int iconv)
plogf(" ");
}
plogf(" %20.9E\n", g);
print_line("-", 147);
writeline('-', 147);
/*
* ------------- TABLE OF SOLUTION COUNTERS --------------------------
@ -370,8 +355,8 @@ int VCS_SOLVE::vcs_report(int iconv)
plogf(" vcs_TP: %5d %11s\n",
m_VCount->Its," NA ");
}
print_line("-", 80);
print_line("-", 80);
writeline('-', 80);
writeline('-', 80);
/*
* 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_internal.h"
#include "cantera/equil/vcs_VolPhase.h"
#include "cantera/base/global.h"
#include <cstdio>
using namespace Cantera;
namespace VCSnonideal
{
@ -352,7 +355,7 @@ size_t VCS_SOLVE::vcs_RxnStepSizes(int& forceComponentCalc, size_t& kSpecial)
#ifdef DEBUG_MODE
if (m_debug_print_lvl >= 2) {
plogf(" ");
vcs_print_line("-", 82);
writeline('-', 82);
}
#endif
return iphDel;
@ -372,7 +375,7 @@ size_t VCS_SOLVE::vcs_RxnStepSizes(int& forceComponentCalc, size_t& kSpecial)
#ifdef DEBUG_MODE
if (m_debug_print_lvl >= 2) {
plogf(" ");
vcs_print_line("-", 82);
writeline('-', 82);
}
#endif
return iphDel;

View file

@ -27,8 +27,6 @@ namespace VCSnonideal
{
/************ Prototypes for static functions ******************************/
static void print_space(size_t num);
#ifdef DEBUG_MODE
# ifdef DEBUG_NOT
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(" FROM ESTIMATE Type\n\n");
for (size_t i = 0; i < m_numElemConstraints; ++i) {
print_space(26);
writeline(' ', 26, false);
plogf("%-2.2s", (m_elementName[i]).c_str());
plogf("%20.12E%20.12E %3d\n", m_elemAbundancesGoal[i], m_elemAbundances[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("\n SPECIES FORMULA VECTOR ");
print_space(41);
writeline(' ', 41, false);
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) {
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(" %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]);
if (m_speciesUnknownType[i] == VCS_SPECIES_TYPE_MOLNUM) {
plogf(" Mol_Num");
@ -327,7 +325,7 @@ L_MAINLOOP_ALL_SPECIES:
if (printDetails) {
plogf("\n");
vcs_print_line("=", 110);
writeline('=', 110);
plogf(" Iteration = %3d, Iterations since last evaluation of "
"optimal basis = %3d",
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]);
}
plogf(" ");
vcs_print_line("-", 80);
writeline('-', 80);
plogf(" --- Finished Main Loop");
plogendl();
}
@ -1143,7 +1141,7 @@ L_MAIN_LOOP_END_NO_PRINT:
m_molNumSpecies_new[kspec], m_deltaGRxn_old[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",
l2normdg(VCS_DATA_PTR(m_deltaGRxn_old)),
l2normdg(VCS_DATA_PTR(m_deltaGRxn_new)));
@ -1166,7 +1164,7 @@ L_MAIN_LOOP_END_NO_PRINT:
if (printDetails) {
plogf(" ");
vcs_print_line("-", 103);
writeline('-', 103);
plogf(" --- Summary of the Update ");
if (iti == 0) {
plogf(" (all species):");
@ -1202,7 +1200,7 @@ L_MAIN_LOOP_END_NO_PRINT:
m_deltaGRxn_old[l1], m_deltaGRxn_new[l1]);
}
plogf(" ---");
print_space(56);
writeline(' ', 56, false);
plogf("Norms of Delta G():%14.6E%14.6E",
l2normdg(VCS_DATA_PTR(m_deltaGRxn_old)),
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(" --- ");
vcs_print_line("-", 50);
writeline('-', 50);
for (size_t iph = 0; iph < m_numPhases; iph++) {
vcs_VolPhase* Vphase = m_VolPhaseList[iph];
plogf(" --- %18s = %15.7E\n", Vphase->PhaseName.c_str(), m_tPhaseMoles_new[iph]);
}
plogf(" ");
vcs_print_line("-", 103);
writeline('-', 103);
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_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 "
" logMF Gamma Elect extra ElectrChem\n");
printf(" ");
vcs_print_line("-", 132);
writeline('-', 132);
for (size_t kspec = 0; kspec < m_numSpeciesTot; ++kspec) {
mfValue = 1.0;
@ -4070,7 +4068,7 @@ void VCS_SOLVE::vcs_printSpeciesChemPot(const int stateCalc) const
printf(" % -12.4e\n", total *RT);
}
printf(" ");
vcs_print_line("-", 132);
writeline('-', 132);
}
#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,
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 "
" ElectrChemStar ElectrChem DeltaGStar DeltaG(Pred) Stability\n");
printf(" ");
vcs_print_line("-", 132);
writeline('-', 132);
for (size_t kspec = 0; kspec < m_numSpeciesTot; kspec++) {
@ -4637,7 +4628,7 @@ void VCS_SOLVE::vcs_printDeltaG(const int stateCalc)
}
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* sss;

View file

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

View file

@ -18,6 +18,7 @@
#include "cantera/base/clockWC.h"
#include "cantera/base/vec_functions.h"
#include "cantera/base/stringUtils.h"
#include "cantera/base/global.h"
#include <limits>
@ -36,19 +37,6 @@ const doublereal DampFactor = 4.0;
//! a failure
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);
#ifdef DEBUG_NUMJAC
@ -451,7 +439,7 @@ doublereal NonlinearSolver::solnErrorNorm(const doublereal* const delta_y, const
const int num_entries = printLargest;
printf("\t\t ");
print_line("-", 90);
writeline('-', 90);
printf("\t\t solnErrorNorm(): ");
if (title) {
printf("%s", title);
@ -467,7 +455,7 @@ doublereal NonlinearSolver::solnErrorNorm(const doublereal* const delta_y, const
printf("\t\t I weightdeltaY/sqtN| deltaY "
"ysolnOld ysolnNew Soln_Weights\n");
printf("\t\t ");
print_line("-", 88);
writeline('-', 88);
for (int jnum = 0; jnum < num_entries; jnum++) {
dmax1 = -1.0;
@ -497,7 +485,7 @@ doublereal NonlinearSolver::solnErrorNorm(const doublereal* const delta_y, const
}
}
printf("\t\t ");
print_line("-", 90);
writeline('-', 90);
}
}
return sum_norm;
@ -539,7 +527,7 @@ doublereal NonlinearSolver::residErrorNorm(const doublereal* const resid, const
}
if (m_print_flag >= 6) {
printf("\t\t ");
print_line("-", 90);
writeline('-', 90);
printf("\t\t residErrorNorm(): ");
if (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 I |Resid/ResWt| UnsclRes ResWt | y_curr\n");
printf("\t\t ");
print_line("-", 88);
writeline('-', 88);
for (int jnum = 0; jnum < num_entries; jnum++) {
dmax1 = -1.0;
for (size_t i = 0; i < neq_; i++) {
@ -578,7 +566,7 @@ doublereal NonlinearSolver::residErrorNorm(const doublereal* const resid, const
}
printf("\t\t ");
print_line("-", 90);
writeline('-', 90);
}
}
return sum_norm;
@ -2738,7 +2726,7 @@ int NonlinearSolver::solve_nonlinear_problem(int SolnType, doublereal* const y_c
if (m_print_flag > 3) {
printf("\t");
print_line("=", 119);
writeline('=', 119);
printf("\tsolve_nonlinear_problem(): iteration %d:\n",
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",
stepNorm_1, m_normResid_0, m_normResid_full);
printf("\t");
print_line("=", 119);
writeline('=', 119);
} else {
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);
@ -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 "
"converged, final estimate of the next solution update norm = %-12.4E\n", stepNorm_2);
printf("\t");
print_line("=", 119);
writeline('=', 119);
} else if (retnDamp >= NSOLN_RETN_CONTINUE) {
printf("\t solve_nonlinear_problem(): Damped Newton iteration successful, "
"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);
std::vector<size_t> imax(num_entries, npos);
printf("\t\t ");
print_line("-", 125);
writeline('-', 125);
for (size_t jnum = 0; jnum < num_entries; jnum++) {
dmax1 = -1.0;
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 ");
print_line("-", 125);
writeline('-', 125);
}
//====================================================================================================================
//! 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)
{
size_t nn = m_nv/5;
@ -172,14 +166,14 @@ void Domain1D::showSolution(const doublereal* x)
char buf[100];
doublereal v;
for (i = 0; i < nn; i++) {
drawline();
writeline('-', 79, false, true);
sprintf(buf, "\n z ");
writelog(buf);
for (n = 0; n < 5; n++) {
sprintf(buf, " %10s ",componentName(i*5 + n).c_str());
writelog(buf);
}
drawline();
writeline('-', 79, false, true);
for (j = 0; j < m_points; j++) {
sprintf(buf, "\n %10.4g ",m_z[j]);
writelog(buf);
@ -192,14 +186,14 @@ void Domain1D::showSolution(const doublereal* x)
writelog("\n");
}
size_t nrem = m_nv - 5*nn;
drawline();
writeline('-', 79, false, true);
sprintf(buf, "\n z ");
writelog(buf);
for (n = 0; n < nrem; n++) {
sprintf(buf, " %10s ", componentName(nn*5 + n).c_str());
writelog(buf);
}
drawline();
writeline('-', 79, false, true);
for (j = 0; j < m_points; j++) {
sprintf(buf, "\n %10.4g ",m_z[j]);
writelog(buf);

View file

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

View file

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

View file

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

View file

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