Skip to content

Commit

Permalink
add CSV format for point and polyline output
Browse files Browse the repository at this point in the history
  • Loading branch information
Norihiro Watanabe committed Feb 25, 2016
1 parent 77ea5bb commit 0a4df20
Show file tree
Hide file tree
Showing 3 changed files with 55 additions and 28 deletions.
79 changes: 52 additions & 27 deletions FEM/Output.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1519,14 +1519,21 @@ double COutput::NODWritePLYDataTEC(int number)
return 0.0;
}

const bool is_TECPLOT = (dat_type_name.compare("TECPLOT") == 0);
const bool is_GNUPLOT = (dat_type_name.compare("GNUPLOT") == 0);
const bool is_CSV = (dat_type_name.compare("CSV") == 0);

// File handling
std::string tec_file_name = file_base_name + "_ply_" + geo_name + "_t"
+ number2str<size_t> (_id); //OK4709
if (getProcessType() != FiniteElement::INVALID_PROCESS)
tec_file_name += "_" + convertProcessTypeToString(getProcessType());
if (msh_type_name.size() > 0)
tec_file_name += "_" + msh_type_name;
tec_file_name += TEC_FILE_EXTENSION;
if (is_TECPLOT || is_GNUPLOT)
tec_file_name += TEC_FILE_EXTENSION;
if (is_CSV)
tec_file_name += CSV_FILE_EXTENSION;
if (!_new_file_opened)
remove(tec_file_name.c_str()); //WW

Expand Down Expand Up @@ -1621,17 +1628,21 @@ double COutput::NODWritePLYDataTEC(int number)
// Write header
if (number == 0 || number == 1) //WW if(number==1)
{
//project_title;
std::string project_title_string = "Profiles along polylines";

if (dat_type_name.compare("GNUPLOT") != 0) // 5.3.07 JOD
tec_file << " TITLE = \"" << project_title_string
<< "\"" << "\n";
else
tec_file << "# ";
if (is_TECPLOT) {
//project_title;
std::string project_title_string = "Profiles along polylines";

if (dat_type_name.compare("GNUPLOT") != 0) // 5.3.07 JOD
tec_file << " TITLE = \"" << project_title_string
<< "\"" << "\n";
else
tec_file << "# ";
tec_file << " VARIABLES = ";
}

tec_file << " VARIABLES = \"DIST\" ";
if (is_CSV)
tec_file << "\"TIME\" ";
tec_file << "\"DIST\" ";
for (size_t k = 0; k < no_variables; k++)
{
tec_file << "\"" << _nod_value_vector[k] << "\" ";
Expand Down Expand Up @@ -1680,8 +1691,10 @@ double COutput::NODWritePLYDataTEC(int number)
}
//......................................................................
// , I=" << NodeListLength << ", J=1, K=1, F=POINT" << "\n";
if (dat_type_name.compare("GNUPLOT") == 0) // 6/2012 JOD
if (is_GNUPLOT) // 6/2012 JOD
tec_file << "# ";
if (is_TECPLOT || is_GNUPLOT)
tec_file << " ZONE T=\"TIME=" << _time << "\"" << "\n";

tec_file << " ZONE T=\"TIME=" << _time << "\"" << "\n";
//----------------------------------------------------------------------
Expand All @@ -1708,6 +1721,8 @@ double COutput::NODWritePLYDataTEC(int number)
//bool b_specified_pcs = (m_pcs != NULL); //NW m_pcs = PCSGet(pcs_type_name);
for (size_t j(0); j < nodes_vector.size(); j++)
{
if (is_CSV)
tec_file << aktuelle_zeit << " ";
// tec_file << m_ply->getSBuffer()[j] << " ";
tec_file << interpolation_points[j] << " ";
//WW
Expand Down Expand Up @@ -1810,10 +1825,17 @@ void COutput::NODWritePNTDataTEC(double time_current,int time_step_number)
break;
}

//......................................................................
const bool is_TECPLOT = (dat_type_name.compare("TECPLOT") == 0);
const bool is_GNUPLOT = (dat_type_name.compare("GNUPLOT") == 0);
const bool is_CSV = (dat_type_name.compare("CSV") == 0);

// File handling
std::string tec_file_name(file_base_name + "_time_");
addInfoToFileName(tec_file_name, true, true, true);

if (is_TECPLOT || is_GNUPLOT)
addInfoToFileName(tec_file_name, true, true, true);
else if (is_CSV)
addInfoToFileName(tec_file_name, true, true, true, CSV_FILE_EXTENSION);
if (!_new_file_opened)
remove(tec_file_name.c_str()); //WW
//......................................................................
Expand Down Expand Up @@ -1854,14 +1876,16 @@ void COutput::NODWritePNTDataTEC(double time_current,int time_step_number)
// Write header
if (time_step_number == 0) //WW Old: if(time_step_number==1)
{
//project_title;
if (dat_type_name.compare("GNUPLOT") != 0) { // 6/2012 JOD
if (is_TECPLOT) {
const std::string project_title_string ("Time curves in points");
tec_file << " TITLE = \"" << project_title_string << "\"" << "\n";
} else
tec_file << "# ";
} else if (is_GNUPLOT) {
tec_file << "# ";
}

tec_file << " VARIABLES = \"TIME \" ";
if (is_TECPLOT || is_GNUPLOT)
tec_file << " VARIABLES = ";
tec_file << "\"TIME\" ";

// if(pcs_type_name.compare("RANDOM_WALK")==0)
if (getProcessType() == FiniteElement::RANDOM_WALK)
Expand Down Expand Up @@ -1896,16 +1920,17 @@ void COutput::NODWritePNTDataTEC(double time_current,int time_step_number)
<< " Effective_Strain";
tec_file << "\n";

if (dat_type_name.compare("GNUPLOT") == 0) // 5.3.07 JOD
if (is_GNUPLOT) // 5.3.07 JOD
tec_file << "# "; // comment

if (geo_name.find("POINT") == std::string::npos)
tec_file << " ZONE T=\"POINT="
//, I=" << anz_zeitschritte << ", J=1, K=1, F=POINT" << "\n";
if (is_TECPLOT) {
if (geo_name.find("POINT") == std::string::npos)
tec_file << " ZONE T=\"POINT="
//, I=" << anz_zeitschritte << ", J=1, K=1, F=POINT" << "\n";
<< getGeoTypeAsString() << geo_name << "\"" << "\n";
else
tec_file << " ZONE T=\"POINT=" << geo_name << "\""
else
tec_file << " ZONE T=\"POINT=" << geo_name << "\""
<< "\n"; //, I=" << anz_zeitschritte << ", J=1, K=1, F=POINT" << "\n";
}
}

// For deformation
Expand Down Expand Up @@ -3675,7 +3700,7 @@ void COutput::setInternalVarialbeNames(CFEMesh *msh)
#endif
}

void COutput::addInfoToFileName (std::string& file_name, bool geo, bool process, bool mesh) const
void COutput::addInfoToFileName (std::string& file_name, bool geo, bool process, bool mesh, const std::string &ext) const
{
// add geo type name
if (geo)
Expand All @@ -3691,7 +3716,7 @@ void COutput::addInfoToFileName (std::string& file_name, bool geo, bool process,
file_name += "_" + msh_type_name;

// finally add file extension
file_name += TEC_FILE_EXTENSION;
file_name += ext;
}


Expand Down
3 changes: 2 additions & 1 deletion FEM/Output.h
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@
#ifndef OUTPUT_H
#define OUTPUT_H

#include "makros.h"
#include "DistributionInfo.h"
#include "GeoInfo.h"
#include "ProcessInfo.h"
Expand Down Expand Up @@ -187,7 +188,7 @@ class COutput : public GeoInfo, public ProcessInfo, public DistributionInfo
* @param mesh switch on/off mesh info in file name (default = on)
*/
void addInfoToFileName(std::string& fname, bool geo = true, bool process =
true, bool mesh = true) const; // 09/2010 TF
true, bool mesh = true, const std::string &ext=TEC_FILE_EXTENSION) const; // 09/2010 TF

std::vector<std::string> _nod_value_vector;
std::vector<std::string> _alias_nod_value_vector;
Expand Down
1 change: 1 addition & 0 deletions FEM/rf_out_new.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -285,6 +285,7 @@ void OUTData(double time_current, int time_step_number, bool force_output)
if (m_out->dat_type_name.compare("TECPLOT") == 0
|| m_out->dat_type_name.compare("MATLAB") == 0 || m_out->dat_type_name.compare("GNUPLOT") == 0
|| m_out->dat_type_name.compare("BINARY") == 0 // 08.2012. WW
|| m_out->dat_type_name.compare("CSV") == 0
)
{
// m_out->matlab_delim = " ";
Expand Down

0 comments on commit 0a4df20

Please sign in to comment.