From 1eec6a0c63ef5da0f938ff94d9a244a5867c5cbf Mon Sep 17 00:00:00 2001 From: Jan Thiedau Date: Mon, 8 Apr 2019 17:15:28 +0200 Subject: [PATCH 1/8] Output - changed element output style to use tecplot cell centered keyword. --- FEM/Output.cpp | 167 +++++++++++++++++++++++++++++++++++---------- FEM/Output.h | 14 ++-- FEM/rf_out_new.cpp | 6 +- 3 files changed, 143 insertions(+), 44 deletions(-) diff --git a/FEM/Output.cpp b/FEM/Output.cpp index c7808612b..45fa8f833 100644 --- a/FEM/Output.cpp +++ b/FEM/Output.cpp @@ -645,8 +645,9 @@ void COutput::Write(fstream* out_file) 08/2005 WW Changes for MultiMSH 12/2005 OK VAR,MSH,PCS concept 07/2007 NW Multi Mesh Type + 04/2019 JT refactoring **************************************************************************/ -void COutput::NODWriteDOMDataTEC() +void COutput::WriteDOMDataTEC() { int te = 0; string eleType; @@ -659,7 +660,9 @@ void COutput::NODWriteDOMDataTEC() //---------------------------------------------------------------------- // Tests // OK4704 - if ((_nod_value_vector.size() == 0) && (mfp_value_vector.size() == 0)) + if ((_nod_value_vector.size() == 0) && + (_ele_value_vector.size() == 0) && + (mfp_value_vector.size() == 0)) return; //...................................................................... // MSH @@ -780,8 +783,25 @@ void COutput::NODWriteDOMDataTEC() tec_file_name += "_" + mrank_str; std::cout << "Tecplot filename: " << tec_file_name << "\n"; #endif - tec_file_name += TEC_FILE_EXTENSION; - // WW + + // output of nodel values + NODWriteDOMDataTEC(tec_file_name+TEC_FILE_EXTENSION, te, eleType); + if (!_ele_value_vector.empty()) + ELEWriteDOMDataTEC(tec_file_name+"_ele"+TEC_FILE_EXTENSION, te, eleType); + } +} + +/************************************************************************** + FEMLib-Method: + Task: + Programing: + 04/2019 JT refactoring +**************************************************************************/ +void COutput::NODWriteDOMDataTEC(string tec_file_name, + const int te, + string ele_type) +{ +// WW if (!_new_file_opened) remove(tec_file_name.c_str()); fstream tec_file(tec_file_name.data(), ios::app | ios::out); @@ -795,7 +815,7 @@ void COutput::NODWriteDOMDataTEC() tec_file.rdbuf()->pubsetbuf(mybuf1, MY_IO_BUFSIZE * MY_IO_BUFSIZE); #endif // - WriteTECHeader(tec_file, te, eleType); + WriteTECHeader(tec_file, te, ele_type); WriteTECNodeData(tec_file); // 08.2012. WW @@ -810,7 +830,7 @@ void COutput::NODWriteDOMDataTEC() } tec_file.close(); // kg44 close file - //-------------------------------------------------------------------- + /*-------------------------------------------------------------------- // tri elements // ***** 07/2010 TF commented out block since the global variable is // always zero @@ -949,8 +969,8 @@ void COutput::NODWriteDOMDataTEC() // WriteTECNodeData(tec_file); // WriteTECElementData(tec_file,3); // tec_file.close(); // kg44 close file - // } - } + // }*/ + } /* @@ -1427,8 +1447,11 @@ void COutput::WriteTECHeader(fstream& tec_file, int e_type, string e_type_name) Programing: 09/2004 OK Implementation 01/2006 OK VAR,PCS,MSH concept + * 04/2019 JT Cell centered element output **************************************************************************/ -void COutput::ELEWriteDOMDataTEC() +void COutput::ELEWriteDOMDataTEC(string tec_file_name, + const int te, + string ele_type_name) { //---------------------------------------------------------------------- if (_ele_value_vector.empty()) @@ -1436,13 +1459,7 @@ void COutput::ELEWriteDOMDataTEC() //---------------------------------------------------------------------- // File handling //...................................................................... - string tec_file_name = file_base_name + "_domain" + "_ele"; - if (getProcessType() != FiniteElement::INVALID_PROCESS) // PCS - // 09/2010 TF msh_type_name; - tec_file_name += "_" + convertProcessTypeToString(getProcessType()); - if (msh_type_name.size() > 1) // MSH - tec_file_name += "_" + msh_type_name; - tec_file_name += TEC_FILE_EXTENSION; + // WW if (!_new_file_opened) remove(tec_file_name.c_str()); @@ -1461,30 +1478,55 @@ void COutput::ELEWriteDOMDataTEC() #endif //-------------------------------------------------------------------- - WriteELEValuesTECHeader(tec_file); - WriteELEValuesTECData(tec_file); + WriteELEValuesTECHeader(tec_file, te,ele_type_name); + WriteELEValuesTECData(tec_file, te); //-------------------------------------------------------------------- + if (!tecplot_zone_share || ! _new_file_opened) + WriteTECElementData(tec_file,te); tec_file.close(); // kg44 close file } -void COutput::WriteELEValuesTECHeader(fstream& tec_file) +void COutput::WriteELEValuesTECHeader(fstream& tec_file, + int e_type, string ele_type_name) { + // OK411 + size_t no_elements = 0; + const size_t mesh_ele_vector_size(m_msh->ele_vector.size()); + for (size_t i = 0; i < mesh_ele_vector_size; i++) + if (m_msh->ele_vector[i]->GetMark()) + if (m_msh->ele_vector[i]->GetElementType() == e_type) + no_elements++; + //-------------------------------------------------------------------- // Write Header I: variables tec_file << "VARIABLES = \"X\",\"Y\",\"Z\",\"VX\",\"VY\",\"VZ\""; + int n_out_vars(6); for (size_t i = 0; i < _ele_value_vector.size(); i++) // WW if (_ele_value_vector[i].find("VELOCITY") == string::npos) + { tec_file << "," << _ele_value_vector[i]; + ++n_out_vars; + } tec_file << "\n"; // Write Header II: zone tec_file << "ZONE T=\""; - tec_file << _time << "s\", "; - tec_file << "I=" << (long)m_msh->ele_vector.size() << ", "; - tec_file << "F=POINT" - << ", "; - tec_file << "C=BLACK"; + tec_file << _time << "s\" \n"; + tec_file << "Nodes= " << m_msh->GetNodesNumber(false) << ", "; + tec_file << "Elements=" << no_elements << ", "; + tec_file << "ET ="<< ele_type_name <<" \n"; + //-------------------------------------------------------------------- + // Write Header III: solution time ; BG 05/2011 + tec_file << "STRANDID=1, SOLUTIONTIME="; + tec_file << _time; // << "s\""; + tec_file << "\n"; + tec_file << "F = FEBLOCK, VARLOCATION=([4-" << n_out_vars << "] = CELLCENTERED)"; tec_file << "\n"; + if (_new_file_opened && tecplot_zone_share) // 08.2012. WW + { + tec_file << "VARSHARELIST=([1-3]=1), "; + tec_file << "CONNECTIVITYSHAREZONE=1\n"; + } } /************************************************************************** @@ -1495,12 +1537,41 @@ void COutput::WriteELEValuesTECHeader(fstream& tec_file) 11/2005 OK MSH 01/2006 OK **************************************************************************/ -void COutput::WriteELEValuesTECData(fstream& tec_file) +void COutput::WriteELEValuesTECData(fstream& tec_file, int e_type) { CRFProcess* m_pcs_2 = NULL; if (_ele_value_vector.empty()) return; + // output of node coordinates (not necesary to output all, but simpler here) + if (!tecplot_zone_share || !_new_file_opened) + { + // streams for buffering since block output is mandatory + std::stringstream y_vals, z_vals; + tec_file << "#x Coordinates:\n"; + y_vals << "#y Coordinates:\n"; + z_vals << "#z Coordinates:\n"; + for (size_t j = 0; j < m_msh->GetNodesNumber(false); j++) + { + CNode* node = m_msh->nod_vector[j]; // 23.01.2013. WW + const double* x = node->getData(); + tec_file << x[0] << " "; + y_vals << x[1] << " "; + z_vals << x[2] << " "; + if (j>0 && j%10==0) + { + tec_file << "\n"; + y_vals << "\n"; + z_vals << "\n"; + } + } + tec_file << "\n"; + y_vals << "\n"; + z_vals << "\n"; + tec_file << y_vals.rdbuf() << z_vals.rdbuf(); + + } + vector skip; // CB size_t no_ele_values = _ele_value_vector.size(); bool out_element_vel = false; @@ -1528,13 +1599,25 @@ void COutput::WriteELEValuesTECData(fstream& tec_file) vector ele_value_index_vector(no_ele_values); GetELEValuesIndexVector(ele_value_index_vector); + // streams for buffering since block output is mandatory + //count trues in skip for additional streams + int n_additional_streams(0); + for (size_t i= 0; i!= skip.size();++i) + if (skip[i]) + ++n_additional_streams; + + std::vector streams(2+n_additional_streams); + tec_file << "# Var Block No. 0 \n"; + for (size_t idx=0;idx != streams.size(); ++idx ) + streams[idx]<< "# Var Block No. " << idx+1 << " \n"; MeshLib::CElem* m_ele = NULL; FiniteElement::ElementValue* gp_ele = NULL; for (size_t i = 0; i < m_msh->ele_vector.size(); i++) { m_ele = m_msh->ele_vector[i]; - double const* xyz(m_ele->GetGravityCenter()); - tec_file << xyz[0] << " " << xyz[1] << " " << xyz[2] << " "; + if (!m_ele->GetMark() || m_ele->GetElementType()!= e_type) + continue; + if (out_element_vel) // WW { if (PCSGet(FiniteElement::FLUID_MOMENTUM)) // PCH 16.11 2009 @@ -1546,12 +1629,12 @@ void COutput::WriteELEValuesTECData(fstream& tec_file) pch_pcs->GetElementValueIndex("VELOCITY1_X") + 1) << " "; - tec_file << pch_pcs->GetElementValue( + streams[0] << pch_pcs->GetElementValue( i, pch_pcs->GetElementValueIndex("VELOCITY1_Y") + 1) << " "; - tec_file << pch_pcs->GetElementValue( + streams[1] << pch_pcs->GetElementValue( i, pch_pcs->GetElementValueIndex("VELOCITY1_Z") + 1) @@ -1561,8 +1644,8 @@ void COutput::WriteELEValuesTECData(fstream& tec_file) { gp_ele = ele_gp_value[i]; tec_file << gp_ele->Velocity(0, 0) << " "; - tec_file << gp_ele->Velocity(1, 0) << " "; - tec_file << gp_ele->Velocity(2, 0) << " "; + streams[0] << gp_ele->Velocity(1, 0) << " "; + streams[1] << gp_ele->Velocity(2, 0) << " "; } } else if (out_element_transport_flux) // JOD 2014-11-10 @@ -1570,20 +1653,32 @@ void COutput::WriteELEValuesTECData(fstream& tec_file) #ifdef USE_TRANSPORT_FLUX gp_ele = ele_gp_value[i]; tec_file << gp_ele->TransportFlux(0, 0) << " "; - tec_file << gp_ele->TransportFlux(1, 0) << " "; - tec_file << gp_ele->TransportFlux(2, 0) << " "; + streams[0] << gp_ele->TransportFlux(1, 0) << " "; + streams[1] << gp_ele->TransportFlux(2, 0) << " "; #endif } for (size_t j = 0; j < ele_value_index_vector.size(); j++) { if (skip[j]) // CB: allow output of velocity AND other ele values { - tec_file << m_pcs_2->GetElementValue(i, + streams[2+j] << m_pcs_2->GetElementValue(i, ele_value_index_vector[j]) - << " "; + << " "; } } - tec_file << "\n"; + if (i>0 && i%10==0) + { + tec_file << "\n"; + for (size_t idx=0;idx != streams.size(); ++idx ) + streams[idx]<< "\n"; + } + } + tec_file << "\n"; + for (size_t idx=0;idx != streams.size(); ++idx ) + streams[idx]<< "\n"; + for (size_t idx=0;idx != streams.size(); ++idx ) + { + tec_file << streams[idx].rdbuf(); } ele_value_index_vector.clear(); diff --git a/FEM/Output.h b/FEM/Output.h index d1511c7a2..81fad7b98 100644 --- a/FEM/Output.h +++ b/FEM/Output.h @@ -125,15 +125,21 @@ class COutput : public GeoInfo, public ProcessInfo, public DistributionInfo // int GetPointClose(CGLPoint); void WriteTimeCurveData(std::fstream&); void WriteTimeCurveHeader(std::fstream&); - void NODWriteDOMDataTEC(); +protected: + void NODWriteDOMDataTEC(std::string, int, std::string); +public: void WriteTECHeader(std::fstream&, int, std::string); void WriteTECNodeData(std::fstream&); void WriteTECElementData(std::fstream&, int); double NODWritePLYDataTEC(int); void NODWritePNTDataTEC(double, int); - void ELEWriteDOMDataTEC(); - void WriteELEValuesTECHeader(std::fstream&); - void WriteELEValuesTECData(std::fstream&); +public: + void WriteDOMDataTEC(); +protected: + void ELEWriteDOMDataTEC(std::string, int, std::string); +public: + void WriteELEValuesTECHeader(std::fstream&, int, std::string); + void WriteELEValuesTECData(std::fstream&, int); void NODWriteSFCDataTEC(int); void NODWriteSFCAverageDataTEC(double, int); // OK void WriteRFO(); // OK diff --git a/FEM/rf_out_new.cpp b/FEM/rf_out_new.cpp index 97c87baab..b6022a870 100644 --- a/FEM/rf_out_new.cpp +++ b/FEM/rf_out_new.cpp @@ -368,8 +368,7 @@ void OUTData(double time_current, int time_step_number, bool force_output) m_out->PCONWriteDOMDataTEC(); // MX else { - m_out->NODWriteDOMDataTEC(); - m_out->ELEWriteDOMDataTEC(); + m_out->WriteDOMDataTEC(); } #if defined(USE_PETSC) // || defined (other parallel solver lib). 12.2012 WW } @@ -399,8 +398,7 @@ void OUTData(double time_current, int time_step_number, bool force_output) m_out->PCONWriteDOMDataTEC(); else { - m_out->NODWriteDOMDataTEC(); - m_out->ELEWriteDOMDataTEC(); + m_out->WriteDOMDataTEC(); } #if defined(USE_PETSC) // || defined (other parallel solver lib). 01.2014 WW } From e91a47da308dbbc7c4ea8d7252e67212958d68a8 Mon Sep 17 00:00:00 2001 From: Jan Thiedau Date: Wed, 10 Apr 2019 17:19:49 +0200 Subject: [PATCH 2/8] Element output: filename structure changed --- FEM/Output.cpp | 28 +++++++++++++++------------- 1 file changed, 15 insertions(+), 13 deletions(-) diff --git a/FEM/Output.cpp b/FEM/Output.cpp index 45fa8f833..bfd7ff959 100644 --- a/FEM/Output.cpp +++ b/FEM/Output.cpp @@ -651,7 +651,8 @@ void COutput::WriteDOMDataTEC() { int te = 0; string eleType; - string tec_file_name; + string tec_file_name1; + string tec_file_name2; #if defined(USE_MPI) || defined(USE_MPI_PARPROC) || defined(USE_MPI_REGSOIL) char tf_name[10]; std::cout << "Process " << myrank << " in WriteDOMDataTEC" @@ -698,40 +699,41 @@ void COutput::WriteDOMDataTEC() te = mesh_type_list[i]; //---------------------------------------------------------------------- // File name handling - tec_file_name = file_base_name + "_" + "domain"; + tec_file_name1 = file_base_name + "_" + "domain"; + tec_file_name2 = ""; if (msh_type_name.size() > 0) // MultiMSH - tec_file_name += "_" + msh_type_name; + tec_file_name2 += "_" + msh_type_name; if (getProcessType() != FiniteElement::INVALID_PROCESS) // PCS - tec_file_name += "_" + convertProcessTypeToString(getProcessType()); + tec_file_name2 += "_" + convertProcessTypeToString(getProcessType()); //====================================================================== switch (te) // NW { case 1: - tec_file_name += "_line"; + tec_file_name2 += "_line"; eleType = "QUADRILATERAL"; break; case 2: - tec_file_name += "_quad"; + tec_file_name2 += "_quad"; eleType = "QUADRILATERAL"; break; case 3: - tec_file_name += "_hex"; + tec_file_name2 += "_hex"; eleType = "BRICK"; break; case 4: - tec_file_name += "_tri"; + tec_file_name2 += "_tri"; eleType = "QUADRILATERAL"; break; case 5: - tec_file_name += "_tet"; + tec_file_name2 += "_tet"; eleType = "TETRAHEDRON"; break; case 6: - tec_file_name += "_pris"; + tec_file_name2 += "_pris"; eleType = "BRICK"; break; case 7: - tec_file_name += "_pyra"; + tec_file_name2 += "_pyra"; eleType = "BRICK"; break; } @@ -785,9 +787,9 @@ void COutput::WriteDOMDataTEC() #endif // output of nodel values - NODWriteDOMDataTEC(tec_file_name+TEC_FILE_EXTENSION, te, eleType); + NODWriteDOMDataTEC(tec_file_name1+tec_file_name2+TEC_FILE_EXTENSION, te, eleType); if (!_ele_value_vector.empty()) - ELEWriteDOMDataTEC(tec_file_name+"_ele"+TEC_FILE_EXTENSION, te, eleType); + ELEWriteDOMDataTEC(tec_file_name1+"_ele"+tec_file_name2+TEC_FILE_EXTENSION, te, eleType); } } From fa6826a0e3b35591739c96e0fd297540db5d172d Mon Sep 17 00:00:00 2001 From: Jan Thiedau Date: Thu, 11 Apr 2019 12:06:02 +0200 Subject: [PATCH 3/8] Element output: fix issues --- FEM/Output.cpp | 21 +++++++++++++++------ 1 file changed, 15 insertions(+), 6 deletions(-) diff --git a/FEM/Output.cpp b/FEM/Output.cpp index bfd7ff959..5474cfdac 100644 --- a/FEM/Output.cpp +++ b/FEM/Output.cpp @@ -778,16 +778,17 @@ void COutput::WriteDOMDataTEC() */ #if defined(USE_MPI) || defined(USE_MPI_PARPROC) || defined(USE_MPI_REGSOIL) sprintf(tf_name, "%d", myrank); - tec_file_name += "_" + string(tf_name); - std::cout << "Tecplot filename: " << tec_file_name << "\n"; + tec_file_name2 += "_" + string(tf_name); + std::cout << "Tecplot filename: " << tec_file_name1+tec_file_name2 << "\n"; #endif #if defined(USE_PETSC) //|| defined(other parallel libs)//03.3012. WW - tec_file_name += "_" + mrank_str; - std::cout << "Tecplot filename: " << tec_file_name << "\n"; + tec_file_name2 += "_" + mrank_str; + std::cout << "Tecplot filename: " << tec_file_name1+tec_file_name2 << "\n"; #endif // output of nodel values - NODWriteDOMDataTEC(tec_file_name1+tec_file_name2+TEC_FILE_EXTENSION, te, eleType); + if (!_nod_value_vector.empty()) + NODWriteDOMDataTEC(tec_file_name1+tec_file_name2+TEC_FILE_EXTENSION, te, eleType); if (!_ele_value_vector.empty()) ELEWriteDOMDataTEC(tec_file_name1+"_ele"+tec_file_name2+TEC_FILE_EXTENSION, te, eleType); } @@ -1550,6 +1551,10 @@ void COutput::WriteELEValuesTECData(fstream& tec_file, int e_type) { // streams for buffering since block output is mandatory std::stringstream y_vals, z_vals; + y_vals.setf(tec_file.flags()); + y_vals.precision(tec_file.precision()); + z_vals.setf(tec_file.flags()); + z_vals.precision(tec_file.precision()); tec_file << "#x Coordinates:\n"; y_vals << "#y Coordinates:\n"; z_vals << "#z Coordinates:\n"; @@ -1611,7 +1616,11 @@ void COutput::WriteELEValuesTECData(fstream& tec_file, int e_type) std::vector streams(2+n_additional_streams); tec_file << "# Var Block No. 0 \n"; for (size_t idx=0;idx != streams.size(); ++idx ) - streams[idx]<< "# Var Block No. " << idx+1 << " \n"; + { + streams[idx].setf(tec_file.flags()); + streams[idx].precision(tec_file.precision()); + streams[idx]<< "# Var Block No. " << idx+1 << "\n"; + } MeshLib::CElem* m_ele = NULL; FiniteElement::ElementValue* gp_ele = NULL; for (size_t i = 0; i < m_msh->ele_vector.size(); i++) From 55e20a78b81d5df4c4f9e4c76747c30f573c00ec Mon Sep 17 00:00:00 2001 From: Jan Thiedau Date: Thu, 11 Apr 2019 15:01:34 +0200 Subject: [PATCH 4/8] Element output: fix --- FEM/Output.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/FEM/Output.cpp b/FEM/Output.cpp index 5474cfdac..389506f36 100644 --- a/FEM/Output.cpp +++ b/FEM/Output.cpp @@ -787,7 +787,7 @@ void COutput::WriteDOMDataTEC() #endif // output of nodel values - if (!_nod_value_vector.empty()) + if (!_nod_value_vector.empty() || !mfp_value_vector.empty() ) NODWriteDOMDataTEC(tec_file_name1+tec_file_name2+TEC_FILE_EXTENSION, te, eleType); if (!_ele_value_vector.empty()) ELEWriteDOMDataTEC(tec_file_name1+"_ele"+tec_file_name2+TEC_FILE_EXTENSION, te, eleType); From 381f78ad01007d1780be04487c596f92f3903d17 Mon Sep 17 00:00:00 2001 From: Jan Thiedau Date: Tue, 21 May 2019 16:28:20 +0200 Subject: [PATCH 5/8] Output Insert new keyword for cell centered Tecplot element ouput --- FEM/Output.cpp | 226 ++++++++++++++++++++++++++++++++++++++------- FEM/Output.h | 21 +++-- FEM/rf_out_new.cpp | 1 + 3 files changed, 208 insertions(+), 40 deletions(-) diff --git a/FEM/Output.cpp b/FEM/Output.cpp index 389506f36..fdbdb5a3a 100644 --- a/FEM/Output.cpp +++ b/FEM/Output.cpp @@ -92,6 +92,7 @@ COutput::COutput() m_pcs = NULL; vtk = NULL; // NW tecplot_zone_share = false; // 10.2012. WW + _tecplot_cell_centered_element_output = false; // 10.2012. WW VARIABLESHARING = false; // BG #if defined(USE_PETSC) || \ defined(USE_MPI) //|| defined(other parallel libs)//01.3014. WW @@ -115,6 +116,7 @@ COutput::COutput(size_t id) m_pcs = NULL; vtk = NULL; // NW tecplot_zone_share = false; // 10.2012. WW + _tecplot_cell_centered_element_output = false; // 10.2012. WW VARIABLESHARING = false; // BG #if defined(USE_PETSC) || \ defined(USE_MPI) //|| defined(other parallel libs)//01.3014. WW @@ -544,6 +546,12 @@ ios::pos_type COutput::Read(std::ifstream& in_str, tecplot_zone_share = true; continue; } + // Tecplot: for cell centered element output + if (line_string.find("$TECPLOT_ELEMENT_OUTPUT_CELL_CENTERED") != string::npos) + { + _tecplot_cell_centered_element_output = true; + continue; + } } return position; } @@ -634,6 +642,14 @@ void COutput::Write(fstream* out_file) *out_file << " "; *out_file << dat_type_name << "\n"; //-------------------------------------------------------------------- + // For teplot zone share. 10.2012. WW + if (tecplot_zone_share) + *out_file << " $TECPLOT_ZONE_SHARE\n"; + //-------------------------------------------------------------------- + // Tecplot: for cell centered element output + if (_tecplot_cell_centered_element_output) + *out_file << " $TECPLOT_ELEMENT_OUTPUT_CELL_CENTERED\n"; + //-------------------------------------------------------------------- } /************************************************************************** @@ -789,8 +805,19 @@ void COutput::WriteDOMDataTEC() // output of nodel values if (!_nod_value_vector.empty() || !mfp_value_vector.empty() ) NODWriteDOMDataTEC(tec_file_name1+tec_file_name2+TEC_FILE_EXTENSION, te, eleType); - if (!_ele_value_vector.empty()) - ELEWriteDOMDataTEC(tec_file_name1+"_ele"+tec_file_name2+TEC_FILE_EXTENSION, te, eleType); + if (!_ele_value_vector.empty() && _tecplot_cell_centered_element_output) + { + fstream tec_file = open_tec_file(tec_file_name1+"_ele"+tec_file_name2+TEC_FILE_EXTENSION); + if (! tec_file.good()) + continue; + //-------------------------------------------------------------------- + WriteELECellCenteredValuesTECHeader(tec_file, te,eleType); + WriteELECellCenteredValuesTECData(tec_file, te); + //-------------------------------------------------------------------- + if (!tecplot_zone_share || ! _new_file_opened) + WriteTECElementData(tec_file,te); + tec_file.close(); // kg44 close file + } } } @@ -804,20 +831,10 @@ void COutput::NODWriteDOMDataTEC(string tec_file_name, const int te, string ele_type) { -// WW - if (!_new_file_opened) - remove(tec_file_name.c_str()); - fstream tec_file(tec_file_name.data(), ios::app | ios::out); - tec_file.setf(ios::scientific, ios::floatfield); - tec_file.precision(12); - if (!tec_file.good()) + fstream tec_file = open_tec_file(tec_file_name); + if (! tec_file.good()) return; -#ifdef SUPERCOMPUTER - // kg44 buffer the output - char mybuf1[MY_IO_BUFSIZE * MY_IO_BUFSIZE]; - tec_file.rdbuf()->pubsetbuf(mybuf1, MY_IO_BUFSIZE * MY_IO_BUFSIZE); -#endif - // + WriteTECHeader(tec_file, te, ele_type); WriteTECNodeData(tec_file); @@ -1444,25 +1461,51 @@ void COutput::WriteTECHeader(fstream& tec_file, int e_type, string e_type_name) } } +std::fstream COutput::open_tec_file(std::string tec_file_name) const +{ + //---------------------------------------------------------------------- + // File handling + //...................................................................... + + // WW + if (!_new_file_opened) + remove(tec_file_name.c_str()); + //...................................................................... + fstream tec_file(tec_file_name.data(), ios::app | ios::out); + tec_file.setf(ios::scientific, ios::floatfield); + tec_file.precision(12); + tec_file.seekg(0L, ios::beg); +#ifdef SUPERCOMPUTER + // kg44 buffer the output + char mybuffer[MY_IO_BUFSIZE * MY_IO_BUFSIZE]; + tec_file.rdbuf()->pubsetbuf(mybuffer, MY_IO_BUFSIZE * MY_IO_BUFSIZE); +// +#endif + return tec_file; +} + /************************************************************************** FEMLib-Method: Task: Programing: 09/2004 OK Implementation 01/2006 OK VAR,PCS,MSH concept - * 04/2019 JT Cell centered element output **************************************************************************/ -void COutput::ELEWriteDOMDataTEC(string tec_file_name, - const int te, - string ele_type_name) +void COutput::ELEWriteDOMDataTEC() { //---------------------------------------------------------------------- - if (_ele_value_vector.empty()) + if (_ele_value_vector.empty() || _tecplot_cell_centered_element_output) return; //---------------------------------------------------------------------- // File handling //...................................................................... - + string tec_file_name = file_base_name + "_domain" + "_ele"; + if (getProcessType() != FiniteElement::INVALID_PROCESS) // PCS + // 09/2010 TF msh_type_name; + tec_file_name += "_" + convertProcessTypeToString(getProcessType()); + if (msh_type_name.size() > 1) // MSH + tec_file_name += "_" + msh_type_name; + tec_file_name += TEC_FILE_EXTENSION; // WW if (!_new_file_opened) remove(tec_file_name.c_str()); @@ -1481,19 +1524,18 @@ void COutput::ELEWriteDOMDataTEC(string tec_file_name, #endif //-------------------------------------------------------------------- - WriteELEValuesTECHeader(tec_file, te,ele_type_name); - WriteELEValuesTECData(tec_file, te); + WriteELEValuesTECHeader(tec_file); + WriteELEValuesTECData(tec_file); //-------------------------------------------------------------------- - if (!tecplot_zone_share || ! _new_file_opened) - WriteTECElementData(tec_file,te); tec_file.close(); // kg44 close file } -void COutput::WriteELEValuesTECHeader(fstream& tec_file, +void COutput::WriteELECellCenteredValuesTECHeader(fstream& tec_file, int e_type, string ele_type_name) { - // OK411 + // OK411 size_t no_elements = 0; + const size_t mesh_ele_vector_size(m_msh->ele_vector.size()); for (size_t i = 0; i < mesh_ele_vector_size; i++) if (m_msh->ele_vector[i]->GetMark()) @@ -1532,15 +1574,34 @@ void COutput::WriteELEValuesTECHeader(fstream& tec_file, } } + +void COutput::WriteELEValuesTECHeader(fstream& tec_file) +{ + // Write Header I: variables + tec_file << "VARIABLES = \"X\",\"Y\",\"Z\",\"VX\",\"VY\",\"VZ\""; + for (size_t i = 0; i < _ele_value_vector.size(); i++) + // WW + if (_ele_value_vector[i].find("VELOCITY") == string::npos) + tec_file << "," << _ele_value_vector[i]; + tec_file << "\n"; + + // Write Header II: zone + tec_file << "ZONE T=\""; + tec_file << _time << "s\", "; + tec_file << "I=" << (long)m_msh->ele_vector.size() << ", "; + tec_file << "F=POINT" + << ", "; + tec_file << "C=BLACK"; + tec_file << "\n"; +} + /************************************************************************** FEMLib-Method: Task: Programing: - 09/2004 OK Implementation - 11/2005 OK MSH - 01/2006 OK + 09/2019 JT **************************************************************************/ -void COutput::WriteELEValuesTECData(fstream& tec_file, int e_type) +void COutput::WriteELECellCenteredValuesTECData(fstream& tec_file, int e_type) { CRFProcess* m_pcs_2 = NULL; if (_ele_value_vector.empty()) @@ -1696,6 +1757,109 @@ void COutput::WriteELEValuesTECData(fstream& tec_file, int e_type) skip.clear(); } +/************************************************************************** + FEMLib-Method: + Task: + Programing: + 09/2004 OK Implementation + 11/2005 OK MSH + 01/2006 OK +**************************************************************************/ +void COutput::WriteELEValuesTECData(fstream& tec_file) +{ + CRFProcess* m_pcs_2 = NULL; + if (_ele_value_vector.empty()) + return; + + vector skip; // CB + size_t no_ele_values = _ele_value_vector.size(); + bool out_element_vel = false; + bool out_element_transport_flux = false; // JOD 2014-11-10 + for (size_t j = 0; j < no_ele_values; j++) // WW + { + if (_ele_value_vector[j].find("VELOCITY") != string::npos) + { + out_element_vel = true; + // break; // CB: allow output of velocity AND other ele values + skip.push_back(false); + } + else if (_ele_value_vector[j].find("TRANSPORT_FLUX") != + string::npos) // JOD 2014-11-10 + { + out_element_transport_flux = true; + skip.push_back(false); + } + else + { + m_pcs_2 = GetPCS_ELE(_ele_value_vector[j]); + skip.push_back(true); + } + } + vector ele_value_index_vector(no_ele_values); + GetELEValuesIndexVector(ele_value_index_vector); + + MeshLib::CElem* m_ele = NULL; + FiniteElement::ElementValue* gp_ele = NULL; + for (size_t i = 0; i < m_msh->ele_vector.size(); i++) + { + m_ele = m_msh->ele_vector[i]; + double const* xyz(m_ele->GetGravityCenter()); + tec_file << xyz[0] << " " << xyz[1] << " " << xyz[2] << " "; + if (out_element_vel) // WW + { + if (PCSGet(FiniteElement::FLUID_MOMENTUM)) // PCH 16.11 2009 + { + CRFProcess* pch_pcs = PCSGet(FiniteElement::FLUID_MOMENTUM); + + tec_file << pch_pcs->GetElementValue( + i, + pch_pcs->GetElementValueIndex("VELOCITY1_X") + + 1) + << " "; + tec_file << pch_pcs->GetElementValue( + i, + pch_pcs->GetElementValueIndex("VELOCITY1_Y") + + 1) + << " "; + tec_file << pch_pcs->GetElementValue( + i, + pch_pcs->GetElementValueIndex("VELOCITY1_Z") + + 1) + << " "; + } + else + { + gp_ele = ele_gp_value[i]; + tec_file << gp_ele->Velocity(0, 0) << " "; + tec_file << gp_ele->Velocity(1, 0) << " "; + tec_file << gp_ele->Velocity(2, 0) << " "; + } + } + else if (out_element_transport_flux) // JOD 2014-11-10 + { +#ifdef USE_TRANSPORT_FLUX + gp_ele = ele_gp_value[i]; + tec_file << gp_ele->TransportFlux(0, 0) << " "; + tec_file << gp_ele->TransportFlux(1, 0) << " "; + tec_file << gp_ele->TransportFlux(2, 0) << " "; +#endif + } + for (size_t j = 0; j < ele_value_index_vector.size(); j++) + { + if (skip[j]) // CB: allow output of velocity AND other ele values + { + tec_file << m_pcs_2->GetElementValue(i, + ele_value_index_vector[j]) + << " "; + } + } + tec_file << "\n"; + } + + ele_value_index_vector.clear(); + skip.clear(); +} + /************************************************************************** FEMLib-Method: Task: diff --git a/FEM/Output.h b/FEM/Output.h index 81fad7b98..f3e1c9b0e 100644 --- a/FEM/Output.h +++ b/FEM/Output.h @@ -125,21 +125,22 @@ class COutput : public GeoInfo, public ProcessInfo, public DistributionInfo // int GetPointClose(CGLPoint); void WriteTimeCurveData(std::fstream&); void WriteTimeCurveHeader(std::fstream&); -protected: - void NODWriteDOMDataTEC(std::string, int, std::string); public: - void WriteTECHeader(std::fstream&, int, std::string); - void WriteTECNodeData(std::fstream&); - void WriteTECElementData(std::fstream&, int); double NODWritePLYDataTEC(int); void NODWritePNTDataTEC(double, int); -public: void WriteDOMDataTEC(); + void ELEWriteDOMDataTEC(); protected: - void ELEWriteDOMDataTEC(std::string, int, std::string); + void NODWriteDOMDataTEC(std::string, int, std::string); + void WriteTECHeader(std::fstream&, int, std::string); + std::fstream open_tec_file(std::string) const; + void WriteTECNodeData(std::fstream&); + void WriteTECElementData(std::fstream&, int); + void WriteELEValuesTECHeader(std::fstream&); + void WriteELECellCenteredValuesTECHeader(std::fstream&, int, std::string); + void WriteELEValuesTECData(std::fstream&); + void WriteELECellCenteredValuesTECData(std::fstream&, int); public: - void WriteELEValuesTECHeader(std::fstream&, int, std::string); - void WriteELEValuesTECData(std::fstream&, int); void NODWriteSFCDataTEC(int); void NODWriteSFCAverageDataTEC(double, int); // OK void WriteRFO(); // OK @@ -284,6 +285,8 @@ class COutput : public GeoInfo, public ProcessInfo, public DistributionInfo /// Tecplot share zone bool tecplot_zone_share; // 10.2012. WW + bool _tecplot_cell_centered_element_output; + #if defined(USE_PETSC) || \ defined(USE_MPI) //|| defined(other parallel libs)//03.3012. WW int mrank; diff --git a/FEM/rf_out_new.cpp b/FEM/rf_out_new.cpp index b6022a870..9b57ec032 100644 --- a/FEM/rf_out_new.cpp +++ b/FEM/rf_out_new.cpp @@ -369,6 +369,7 @@ void OUTData(double time_current, int time_step_number, bool force_output) else { m_out->WriteDOMDataTEC(); + m_out->ELEWriteDOMDataTEC(); } #if defined(USE_PETSC) // || defined (other parallel solver lib). 12.2012 WW } From 461107ae9c68614575dd1372bf431414975e7e5b Mon Sep 17 00:00:00 2001 From: Jan Thiedau Date: Mon, 3 Jun 2019 14:15:33 +0200 Subject: [PATCH 6/8] Tecplot Element output: No move ctor in gcc48->fix --- FEM/Output.cpp | 40 +++++++++++++++++++++------------------- FEM/Output.h | 2 +- 2 files changed, 22 insertions(+), 20 deletions(-) diff --git a/FEM/Output.cpp b/FEM/Output.cpp index fdbdb5a3a..629a36598 100644 --- a/FEM/Output.cpp +++ b/FEM/Output.cpp @@ -807,8 +807,8 @@ void COutput::WriteDOMDataTEC() NODWriteDOMDataTEC(tec_file_name1+tec_file_name2+TEC_FILE_EXTENSION, te, eleType); if (!_ele_value_vector.empty() && _tecplot_cell_centered_element_output) { - fstream tec_file = open_tec_file(tec_file_name1+"_ele"+tec_file_name2+TEC_FILE_EXTENSION); - if (! tec_file.good()) + fstream tec_file; + if (!open_tec_file(tec_file_name1+"_ele"+tec_file_name2+TEC_FILE_EXTENSION,tec_file)) continue; //-------------------------------------------------------------------- WriteELECellCenteredValuesTECHeader(tec_file, te,eleType); @@ -831,8 +831,8 @@ void COutput::NODWriteDOMDataTEC(string tec_file_name, const int te, string ele_type) { - fstream tec_file = open_tec_file(tec_file_name); - if (! tec_file.good()) + fstream tec_file; + if (! open_tec_file(tec_file_name,tec_file)) return; WriteTECHeader(tec_file, te, ele_type); @@ -1461,7 +1461,7 @@ void COutput::WriteTECHeader(fstream& tec_file, int e_type, string e_type_name) } } -std::fstream COutput::open_tec_file(std::string tec_file_name) const +bool COutput::open_tec_file(std::string tec_file_name,fstream& tec_file) const { //---------------------------------------------------------------------- // File handling @@ -1471,7 +1471,7 @@ std::fstream COutput::open_tec_file(std::string tec_file_name) const if (!_new_file_opened) remove(tec_file_name.c_str()); //...................................................................... - fstream tec_file(tec_file_name.data(), ios::app | ios::out); + tec_file.open(tec_file_name.data(), ios::app | ios::out); tec_file.setf(ios::scientific, ios::floatfield); tec_file.precision(12); tec_file.seekg(0L, ios::beg); @@ -1481,7 +1481,7 @@ std::fstream COutput::open_tec_file(std::string tec_file_name) const tec_file.rdbuf()->pubsetbuf(mybuffer, MY_IO_BUFSIZE * MY_IO_BUFSIZE); // #endif - return tec_file; + return tec_file.good(); } /************************************************************************** @@ -1674,13 +1674,14 @@ void COutput::WriteELECellCenteredValuesTECData(fstream& tec_file, int e_type) if (skip[i]) ++n_additional_streams; - std::vector streams(2+n_additional_streams); + std::vector streams(2+n_additional_streams); tec_file << "# Var Block No. 0 \n"; for (size_t idx=0;idx != streams.size(); ++idx ) { - streams[idx].setf(tec_file.flags()); - streams[idx].precision(tec_file.precision()); - streams[idx]<< "# Var Block No. " << idx+1 << "\n"; + streams[idx]=new std::stringstream(); + streams[idx]->setf(tec_file.flags()); + streams[idx]->precision(tec_file.precision()); + *(streams[idx])<< "# Var Block No. " << idx+1 << "\n"; } MeshLib::CElem* m_ele = NULL; FiniteElement::ElementValue* gp_ele = NULL; @@ -1701,12 +1702,12 @@ void COutput::WriteELECellCenteredValuesTECData(fstream& tec_file, int e_type) pch_pcs->GetElementValueIndex("VELOCITY1_X") + 1) << " "; - streams[0] << pch_pcs->GetElementValue( + *(streams[0]) << pch_pcs->GetElementValue( i, pch_pcs->GetElementValueIndex("VELOCITY1_Y") + 1) << " "; - streams[1] << pch_pcs->GetElementValue( + *(streams[1]) << pch_pcs->GetElementValue( i, pch_pcs->GetElementValueIndex("VELOCITY1_Z") + 1) @@ -1716,8 +1717,8 @@ void COutput::WriteELECellCenteredValuesTECData(fstream& tec_file, int e_type) { gp_ele = ele_gp_value[i]; tec_file << gp_ele->Velocity(0, 0) << " "; - streams[0] << gp_ele->Velocity(1, 0) << " "; - streams[1] << gp_ele->Velocity(2, 0) << " "; + *(streams[0]) << gp_ele->Velocity(1, 0) << " "; + *(streams[1]) << gp_ele->Velocity(2, 0) << " "; } } else if (out_element_transport_flux) // JOD 2014-11-10 @@ -1733,7 +1734,7 @@ void COutput::WriteELECellCenteredValuesTECData(fstream& tec_file, int e_type) { if (skip[j]) // CB: allow output of velocity AND other ele values { - streams[2+j] << m_pcs_2->GetElementValue(i, + *(streams[2+j]) << m_pcs_2->GetElementValue(i, ele_value_index_vector[j]) << " "; } @@ -1742,15 +1743,16 @@ void COutput::WriteELECellCenteredValuesTECData(fstream& tec_file, int e_type) { tec_file << "\n"; for (size_t idx=0;idx != streams.size(); ++idx ) - streams[idx]<< "\n"; + *(streams[idx])<< "\n"; } } tec_file << "\n"; for (size_t idx=0;idx != streams.size(); ++idx ) - streams[idx]<< "\n"; + *(streams[idx])<< "\n"; for (size_t idx=0;idx != streams.size(); ++idx ) { - tec_file << streams[idx].rdbuf(); + tec_file << streams[idx]->rdbuf(); + delete streams[idx]; } ele_value_index_vector.clear(); diff --git a/FEM/Output.h b/FEM/Output.h index f3e1c9b0e..16e95ac8d 100644 --- a/FEM/Output.h +++ b/FEM/Output.h @@ -133,7 +133,7 @@ class COutput : public GeoInfo, public ProcessInfo, public DistributionInfo protected: void NODWriteDOMDataTEC(std::string, int, std::string); void WriteTECHeader(std::fstream&, int, std::string); - std::fstream open_tec_file(std::string) const; + bool open_tec_file(std::string,std::fstream&) const; void WriteTECNodeData(std::fstream&); void WriteTECElementData(std::fstream&, int); void WriteELEValuesTECHeader(std::fstream&); From 0c1203d479750d92d98b792bd1f18008a3d042fa Mon Sep 17 00:00:00 2001 From: Jan Thiedau Date: Thu, 6 Jun 2019 10:29:33 +0200 Subject: [PATCH 7/8] Tecplot element output: Small changes Hints by norihiro-w: pass string as const& --- FEM/Output.cpp | 9 +++++---- FEM/Output.h | 8 ++++---- 2 files changed, 9 insertions(+), 8 deletions(-) diff --git a/FEM/Output.cpp b/FEM/Output.cpp index 629a36598..bbe00611a 100644 --- a/FEM/Output.cpp +++ b/FEM/Output.cpp @@ -829,7 +829,7 @@ void COutput::WriteDOMDataTEC() **************************************************************************/ void COutput::NODWriteDOMDataTEC(string tec_file_name, const int te, - string ele_type) + string const & ele_type) { fstream tec_file; if (! open_tec_file(tec_file_name,tec_file)) @@ -1385,7 +1385,7 @@ void COutput::WriteTECElementData(fstream& tec_file, int e_type) 08/2005 WW Output by MSH 12/2005 OK GetMSH **************************************************************************/ -void COutput::WriteTECHeader(fstream& tec_file, int e_type, string e_type_name) +void COutput::WriteTECHeader(fstream& tec_file, int e_type, string const & e_type_name) { // MSH // m_msh = GetMSH(); @@ -1461,7 +1461,7 @@ void COutput::WriteTECHeader(fstream& tec_file, int e_type, string e_type_name) } } -bool COutput::open_tec_file(std::string tec_file_name,fstream& tec_file) const +bool COutput::open_tec_file(std::string const& tec_file_name,fstream& tec_file) const { //---------------------------------------------------------------------- // File handling @@ -1531,7 +1531,8 @@ void COutput::ELEWriteDOMDataTEC() } void COutput::WriteELECellCenteredValuesTECHeader(fstream& tec_file, - int e_type, string ele_type_name) + int e_type, + string const & ele_type_name) { // OK411 size_t no_elements = 0; diff --git a/FEM/Output.h b/FEM/Output.h index 16e95ac8d..b9c09c30a 100644 --- a/FEM/Output.h +++ b/FEM/Output.h @@ -131,13 +131,13 @@ class COutput : public GeoInfo, public ProcessInfo, public DistributionInfo void WriteDOMDataTEC(); void ELEWriteDOMDataTEC(); protected: - void NODWriteDOMDataTEC(std::string, int, std::string); - void WriteTECHeader(std::fstream&, int, std::string); - bool open_tec_file(std::string,std::fstream&) const; + void NODWriteDOMDataTEC(std::string, int, std::string const &); + void WriteTECHeader(std::fstream&, int, std::string const &); + bool open_tec_file(std::string const&,std::fstream&) const; void WriteTECNodeData(std::fstream&); void WriteTECElementData(std::fstream&, int); void WriteELEValuesTECHeader(std::fstream&); - void WriteELECellCenteredValuesTECHeader(std::fstream&, int, std::string); + void WriteELECellCenteredValuesTECHeader(std::fstream&, int, std::string const &); void WriteELEValuesTECData(std::fstream&); void WriteELECellCenteredValuesTECData(std::fstream&, int); public: From 000630cc63cafdcbe0a09aef12bea413ea0d981f Mon Sep 17 00:00:00 2001 From: Jan Thiedau Date: Tue, 11 Jun 2019 11:41:44 +0200 Subject: [PATCH 8/8] Tecplot element output: remove wrong comment --- FEM/Output.cpp | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/FEM/Output.cpp b/FEM/Output.cpp index bbe00611a..747eaaf53 100644 --- a/FEM/Output.cpp +++ b/FEM/Output.cpp @@ -92,7 +92,7 @@ COutput::COutput() m_pcs = NULL; vtk = NULL; // NW tecplot_zone_share = false; // 10.2012. WW - _tecplot_cell_centered_element_output = false; // 10.2012. WW + _tecplot_cell_centered_element_output = false; VARIABLESHARING = false; // BG #if defined(USE_PETSC) || \ defined(USE_MPI) //|| defined(other parallel libs)//01.3014. WW @@ -116,7 +116,7 @@ COutput::COutput(size_t id) m_pcs = NULL; vtk = NULL; // NW tecplot_zone_share = false; // 10.2012. WW - _tecplot_cell_centered_element_output = false; // 10.2012. WW + _tecplot_cell_centered_element_output = false; VARIABLESHARING = false; // BG #if defined(USE_PETSC) || \ defined(USE_MPI) //|| defined(other parallel libs)//01.3014. WW