doxygen updates

This commit is contained in:
Harry Moffat 2009-01-14 23:16:24 +00:00
parent 2bbbe08cff
commit be25fef300
4 changed files with 177 additions and 103 deletions

View file

@ -3,7 +3,6 @@
*/
/*
* $Author$
* $Revision$
* $Date$
*/
@ -22,84 +21,100 @@ using namespace std;
namespace Cantera {
void writePlotFile(string fname, string fmt,
string plotTitle, const vector<string> names, const Array2D& data) {
ofstream f(fname.c_str());
if (!f) {
throw CanteraError("writePlotFile","could not open file "+fname+
" for writing.");
}
if (fmt == "TEC") {
outputTEC(f, plotTitle, names, data);
f.close();
}
else if (fmt == "XL") {
outputExcel(f, plotTitle, names, data);
f.close();
}
else {
throw CanteraError("writePlotFile",
"unsupported plot type:" + fmt);
}
// Write a Plotting file
/*
* @param fname Output file name
* @param fmt Either TEC or XL or CSV
* @param plotTitle Title of the plot
* @param names vector of variable names
* @param data N x M data array.
* data(n,m) is the m^th value of the n^th variable.
*/
void writePlotFile(const std::string &fname, const std::string &fmt,
const std::string &plotTitle,
const std::vector<std::string> &names,
const Array2D& data) {
ofstream f(fname.c_str());
if (!f) {
throw CanteraError("writePlotFile","could not open file "+fname+
" for writing.");
}
if (fmt == "TEC") {
outputTEC(f, plotTitle, names, data);
f.close();
}
else if (fmt == "XL" || fmt == "CSV") {
outputExcel(f, plotTitle, names, data);
f.close();
}
else {
throw CanteraError("writePlotFile",
"unsupported plot type:" + fmt);
}
}
/**
* Write a Tecplot data file.
* @param s output stream
* @param title plot title
* @param names vector of variable names
* @param data N x M data array.
* data(n,m) is the m^th value of the n^th variable.
*/
void outputTEC(ostream &s, string title, const vector<string>& names,
const Array2D& data) {
int i,j;
int npts = static_cast<int>(data.nColumns());
int nv = static_cast<int>(data.nRows());
s << "TITLE = \"" + title + "\"" << endl;
s << "VARIABLES = " << endl;
for (i = 0; i < nv; i++) {
s << "\"" << names[i] << "\"" << endl;
}
s << "ZONE T=\"zone1\"" << endl;
s << " I=" << npts << ",J=1,K=1,F=POINT" << endl;
s << "DT=( ";
for (i = 0; i < nv; i++) s << " SINGLE";
s << " )" << endl;
for (i = 0; i < npts; i++) {
for (j = 0; j < nv; j++) {
s << data(j,i) << " ";
}
s << endl;
}
// Write a Tecplot data file.
/*
* @param s output stream
* @param title plot title
* @param names vector of variable names
* @param data N x M data array.
* data(n,m) is the m^th value of the n^th variable.
*/
void outputTEC(std::ostream &s, const std::string &title,
const std::vector<std::string>& names,
const Array2D& data) {
int i,j;
int npts = static_cast<int>(data.nColumns());
int nv = static_cast<int>(data.nRows());
s << "TITLE = \"" + title + "\"" << endl;
s << "VARIABLES = " << endl;
for (i = 0; i < nv; i++) {
s << "\"" << names[i] << "\"" << endl;
}
s << "ZONE T=\"zone1\"" << endl;
s << " I=" << npts << ",J=1,K=1,F=POINT" << endl;
s << "DT=( ";
for (i = 0; i < nv; i++) s << " SINGLE";
s << " )" << endl;
for (i = 0; i < npts; i++) {
for (j = 0; j < nv; j++) {
s << data(j,i) << " ";
}
s << endl;
}
}
/**
* Write an Excel spreadsheet in 'csv' form.
* @param s output stream
* @param title plot title
* @param names vector of variable names @param data N
* x M data array. data(n,m) is the m^th value of the n^th variable.
*/
void outputExcel(ostream &s, string title, const vector<string>& names,
const Array2D& data) {
int i,j;
int npts = static_cast<int>(data.nColumns());
int nv = static_cast<int>(data.nRows());
s << title + "," << endl;
for (i = 0; i < nv; i++) {
s << names[i] << ",";
}
s << endl;
for (i = 0; i < npts; i++) {
for (j = 0; j < nv; j++) {
s << data(j,i) << ",";
}
s << endl;
}
// Write an Excel spreadsheet in 'csv' form.
/*
* @param s output stream
* @param title plot title
* @param names vector of variable names
* @param data N x M data array.
* data(n,m) is the m^th value of the n^th variable.
*/
void outputExcel(std::ostream &s, const std::string &title,
const std::vector<std::string>& names,
const Array2D& data) {
int i,j;
int npts = static_cast<int>(data.nColumns());
int nv = static_cast<int>(data.nRows());
s << title + "," << endl;
for (i = 0; i < nv; i++) {
s << names[i] << ",";
}
s << endl;
for (i = 0; i < npts; i++) {
for (j = 0; j < nv; j++) {
s << data(j,i) << ",";
}
s << endl;
}
}
}

View file

@ -1,25 +1,68 @@
/**
* @file plots.h
* Contains declarations for utility functions for
* outputing to plotting programs.
*/
/*
* $Revision$
* $Date$
*/
// Copyright 2001 California Institute of Technology
#ifndef CT_PLOTS_H
#define CT_PLOTS_H
#include <vector>
#include <string>
#include <fstream>
//using namespace std;
#include "Array.h"
#include "ctexceptions.h"
#include <vector>
#include <string>
#include <fstream>
namespace Cantera {
void writePlotFile(std::string fname, std::string fmt,
std::string plotTitle, const std::vector<std::string> names, const Array2D& data);
void outputTEC(std::ostream &s, std::string title, const std::vector<std::string>& names,
const Array2D& data);
//! Write a Plotting file
/*!
* @param fname Output file name
* @param fmt Either TEC or XL or CSV
* @param plotTitle Title of the plot
* @param names vector of variable names
* @param data N x M data array.
* data(n,m) is the m^th value of the n^th variable.
*/
void writePlotFile(const std::string &fname, const std::string &fmt,
const std::string &plotTitle, const std::vector<std::string> &names,
const Array2D& data);
void outputExcel(std::ostream &s, std::string title, const std::vector<std::string>& names,
const Array2D& data);
//! Write a Tecplot data file.
/*!
* @param s output stream
* @param title plot title
* @param names vector of variable names
* @param data N x M data array.
* data(n,m) is the m^th value of the n^th variable.
*/
void outputTEC(std::ostream &s, const std::string &title,
const std::vector<std::string>& names,
const Array2D& data);
//! Write an Excel spreadsheet in 'csv' form.
/*!
* @param s output stream
* @param title plot title
* @param names vector of variable names
* @param data N x M data array.
* data(n,m) is the m^th value of the n^th variable.
*/
void outputExcel(std::ostream &s, const std::string &title,
const std::vector<std::string>& names,
const Array2D& data);
}
#endif

View file

@ -271,10 +271,14 @@ namespace Cantera {
return count;
}
/**
* Get the file name without the path or extension
// Get the file name without the path or extension
/*
* @param fullPath Input file name consisting
* of the full file name
*
* @return Returns the basename
*/
std::string getFileName(const std::string& path) {
std::string getBaseName(const std::string& path) {
std::string file;
size_t idot = path.find_last_of('.');
size_t islash = path.find_last_of('/');
@ -305,24 +309,18 @@ namespace Cantera {
return atofCheck(stripws(val).c_str());
}
/**
* Generate a logfile name based on an input file name
// Generate a logfile name based on an input file name
/*
* It tries to find the basename. Then, it appends a .log
* to it.
*
* @param infile Input file name
*
* @return Returns a logfile name
*/
std::string logfileName(const std::string& infile) {
std::string logfile;
size_t idot = infile.find_last_of('.');
size_t islash = infile.find_last_of('/');
if (idot > 0 && idot < infile.size()) {
if (islash > 0 && islash < idot) {
logfile = infile.substr(islash+1, idot-islash-1) + ".log";
}
else {
logfile = infile.substr(0,idot) + ".log";
}
}
else {
logfile = infile + ".log";
}
std::string logfile = getBaseName(infile);
logfile += ".log";
return logfile;
}

View file

@ -128,9 +128,27 @@ namespace Cantera {
int fillArrayFromString(const std::string& str, doublereal* const a,
const char delim = ' ');
//! Generate a logfile name based on an input file name
/*!
* It tries to find the basename. Then, it appends a .log
* to it.
*
* @param infile Input file name
*
* @return Returns a logfile name
*/
std::string logfileName(const std::string& infile);
std::string logfileName(const std::string& infile);
std::string getFileName(const std::string& path);
//! Get the file name without the path or extension
/*!
* @param fullPath Input file name consisting
* of the full file name
*
* @return Returns the basename
*/
std::string getBaseName(const std::string& fullPath);
//! Translate a string into one integer value
/*!