21 class gsStructuralAnalysisOutput
24 gsStructuralAnalysisOutput(
const std::string name)
34 gsStructuralAnalysisOutput(
const std::string name,
const gsMatrix<T> & points)
36 gsStructuralAnalysisOutput(name)
44 file.open(m_fname, std::ofstream::out | std::ofstream::trunc);
48 void _initPointHeader(
const std::string name, std::vector<std::string> pointHeaders)
51 file.open(name,std::ofstream::out | std::ofstream::app);
52 for (
index_t p=0; p!=m_points.cols(); p++)
53 for (
size_t h=0; h!=pointHeaders.size(); h++)
54 file<<
"point"<<p<<
"-"<<pointHeaders[h]<<
",";
58 void _initOtherHeader(
const std::string name, std::vector<std::string> otherHeaders)
61 file.open(name,std::ofstream::out | std::ofstream::app);
62 for (
size_t h=0; h!=otherHeaders.size(); h++)
63 file<<otherHeaders[h]<<
",";
67 void _writePointData(
const std::string name,
const gsMatrix<T> & pointData)
70 file.open(name,std::ofstream::out | std::ofstream::app);
71 for (
index_t p=0; p!=pointData.cols(); p++)
72 for (
index_t c=0; c!=pointData.rows(); c++)
73 file << pointData(c,p) <<
",";
77 void _writeOtherData(
const std::string name,
const gsVector<T> & otherData)
80 file.open(name,std::ofstream::out | std::ofstream::app);
81 for (
index_t c=0; c!=otherData.size(); c++)
82 file << otherData.at(c) <<
",";
86 void writePointCoords(
const std::string name)
89 file.open(name,std::ofstream::out);
90 file << std::setprecision(m_precision);
91 _initPointHeader(file);
93 for (
index_t j=0; j!=m_points.cols(); j++)
94 for (
index_t i=0; i!=m_points.rows(); i++)
95 file<<m_points(i,j)<<
",";
99 void init(std::vector<std::string> pointHeaders, std::vector<std::string> otherHeaders)
101 m_nPointHeaders = pointHeaders.size();
102 m_nOtherHeaders = otherHeaders.size();
104 file.open(m_fname,std::ofstream::out);
105 file << std::setprecision(m_precision);
108 this->_initPointHeader(m_fname, pointHeaders);
109 this->_initOtherHeader(m_fname, otherHeaders);
111 file.open(m_fname,std::ofstream::out | std::ofstream::app);
116 void init(std::vector<std::string> pointHeaders)
118 std::vector<std::string> empty;
119 this->init(pointHeaders,empty);
122 void add(
const gsMatrix<T> & pointSolutions,
const gsVector<T> & otherData)
124 GISMO_ASSERT(pointSolutions.rows()==m_nPointHeaders,
"Number of solutions per point is different from the defined number of headers. "<<pointSolutions.rows()<<
" = pointSolutions.rows()==m_nPointHeaders = "<<m_nPointHeaders);
125 GISMO_ASSERT(otherData.size()==m_nOtherHeaders,
"Number of other data is different from the defined number of headers");
127 file.open(m_fname,std::ofstream::out | std::ofstream::app);
128 file << std::setprecision(m_precision);
131 this->_writePointData(m_fname,pointSolutions);
132 this->_writeOtherData(m_fname,otherData);
134 file.open(m_fname,std::ofstream::out | std::ofstream::app);
140 void add(
const gsMatrix<T> & pointSolutions)
143 this->add(pointSolutions,empty);
146 void setPrecision(
index_t precision) { m_precision = precision; }
149 gsMatrix<T> m_points;
151 std::ofstream m_file;
153 index_t m_nPointHeaders, m_nOtherHeaders;
#define index_t
Definition: gsConfig.h:32
#define GISMO_ASSERT(cond, message)
Definition: gsDebug.h:89