Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

add CSV format for point and polyline output #13

Merged
merged 1 commit into from
Mar 1, 2016
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
79 changes: 52 additions & 27 deletions FEM/Output.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1517,14 +1517,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 @@ -1619,17 +1626,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 @@ -1678,8 +1689,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 @@ -1706,6 +1719,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 @@ -1808,10 +1823,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 @@ -1852,14 +1874,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 @@ -1894,16 +1918,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 @@ -3673,7 +3698,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 @@ -3689,7 +3714,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