diff --git a/dart/src/wAdjoint.cpp b/dart/src/wAdjoint.cpp index d93f7669b50d9bc729645e0031ec1f3b10f0be7b..1d75d8a161601af7cc87be39faea99c2d5baaa17 100644 --- a/dart/src/wAdjoint.cpp +++ b/dart/src/wAdjoint.cpp @@ -739,16 +739,13 @@ void Adjoint::save(MshExport *mshWriter, std::string const &suffix) << sol->pbl->alpha * 180 / 3.14159 << " deg AoA, " << sol->pbl->beta * 180 / 3.14159 << " deg AoS)" << std::endl; - // setup results + // save results Results results; results.scalars_at_nodes["lambdaClPhi"] = &lamClFlo; results.scalars_at_nodes["lambdaCdPhi"] = &lamCdFlo; results.vectors_at_nodes["gradClMsh"] = &dClMsh; results.vectors_at_nodes["gradCdMsh"] = &dCdMsh; - // save (whole mesh and bodies) mshWriter->save(sol->pbl->msh->name + "_adjoint" + suffix, results); - for (auto bnd : sol->pbl->bodies) - bnd->save(sol->pbl->msh->name + '_' + bnd->groups[0]->tag->name + "_adjoint" + suffix, results); } void Adjoint::write(std::ostream &out) const diff --git a/dart/src/wBody.cpp b/dart/src/wBody.cpp index 511e9bea683bcfd6d3a338b3ae06431d4358a567..d0ed003a72b0343f2615affa6c7a88b86797a4cf 100644 --- a/dart/src/wBody.cpp +++ b/dart/src/wBody.cpp @@ -22,8 +22,6 @@ #include "wElement.h" #include "wNode.h" #include <unordered_set> -#include <iomanip> -#include <fstream> using namespace tbox; using namespace dart; @@ -111,84 +109,7 @@ void Body::create() nLoads.resize(nodes.size(), Eigen::Vector3d::Zero()); } -/** - * @brief Save nodal data for further post-processing - */ -void Body::save(std::string const &name, Results const &res) -{ - // Write to file - std::cout << "writing file: " << name + ".dat" - << "... " << std::flush; - std::ofstream outfile; - outfile.open(name + ".dat"); - // Header - outfile << "$Body data" << std::endl; - // Aerodynamic coefficients - outfile << "$Aerodynamic coefficients" << std::endl; - outfile << "!" << std::fixed - << std::setw(14) << "Cl" - << std::setw(15) << "Cd" - << std::setw(15) << "Cs" - << std::setw(15) << "Cm" - << std::endl; - outfile << std::fixed - << std::setw(15) << Cl - << std::setw(15) << Cd - << std::setw(15) << Cs - << std::setw(15) << Cm - << std::endl; - // Elements (connectvity) - outfile << "$Elements" << std::endl; - outfile << groups[0]->tag->elems.size() << std::endl; - for (auto e : groups[0]->tag->elems) - { - outfile << std::fixed - << std::setw(10) << e->no; - for (auto n : e->nodes) - outfile << std::setw(10) << n->no; - outfile << std::endl; - } - //Nodes (data) - outfile << "$Nodal data" << std::endl; - outfile << nodes.size() << std::endl; - outfile << "!" << std::fixed - << std::setw(9) << "no" - << std::setw(15) << "x" - << std::setw(15) << "y" - << std::setw(15) << "z"; - for (auto &p : res.scalars_at_nodes) - outfile << std::setw(15) << p.first; - for (auto &p : res.vectors_at_nodes) - { - outfile << std::setw(14) << p.first << "x" - << std::setw(14) << p.first << "y" - << std::setw(14) << p.first << "z"; - } - outfile << std::endl; - for (auto n : nodes) - { - outfile << std::fixed - << std::setw(10) << n->no - << std::scientific << std::setprecision(6) - << std::setw(15) << n->pos(0) - << std::setw(15) << n->pos(1) - << std::setw(15) << n->pos(2); - for (auto &p : res.scalars_at_nodes) - outfile << std::setw(15) << (*(p.second))[n->row]; - for (auto &p : res.vectors_at_nodes) - outfile << std::setw(15) << (*(p.second))[n->row](0) - << std::setw(15) << (*(p.second))[n->row](1) - << std::setw(15) << (*(p.second))[n->row](2); - outfile << std::endl; - } - // Footer - outfile << std::endl; - // Close file - outfile.close(); - std::cout << "done" << std::endl; -} - void Body::write(std::ostream &out) const { out << *groups[0]->tag << " is a Body immersed in " << *groups[1]->tag << std::endl; -} \ No newline at end of file +} diff --git a/dart/src/wBody.h b/dart/src/wBody.h index 31b8dc17bb4d66a134cbebb17ed8a54b728ca02c..c95931bd096a144c741982d5e75fcf16468aa928 100644 --- a/dart/src/wBody.h +++ b/dart/src/wBody.h @@ -49,8 +49,6 @@ public: Body(std::shared_ptr<tbox::MshData> _msh, std::vector<std::string> const &names); virtual ~Body() { std::cout << "~Body()\n"; } - void save(std::string const &name, tbox::Results const &res); - #ifndef SWIG virtual void write(std::ostream &out) const override; #endif @@ -61,4 +59,4 @@ private: } // namespace dart -#endif //WBODY_H +#endif // WBODY_H diff --git a/dart/src/wSolver.cpp b/dart/src/wSolver.cpp index 11f4d809c5667ee85a44b3bb84e61859ac84af39..73579c7e3c6c29a75e66ceaf99da0147f4133e11 100644 --- a/dart/src/wSolver.cpp +++ b/dart/src/wSolver.cpp @@ -36,6 +36,7 @@ #include <tbb/spin_mutex.h> #include <iomanip> +#include <fstream> using namespace tbox; using namespace dart; @@ -170,7 +171,7 @@ void Solver::save(MshExport *mshWriter, std::string const &suffix) << pbl->alpha * 180 / 3.14159 << "deg AoA, " << pbl->beta * 180 / 3.14159 << "deg AoS)" << std::endl; - // setup results + // save results Results results; results.scalars_at_nodes["phi"] = φ results.scalars_at_nodes["varPhi"] = &vPhi; @@ -179,10 +180,30 @@ void Solver::save(MshExport *mshWriter, std::string const &suffix) results.scalars_at_nodes["rho"] = ρ results.scalars_at_nodes["Mach"] = &M; results.scalars_at_nodes["Cp"] = &Cp; - // save (whole mesh and bodies) mshWriter->save(pbl->msh->name + suffix, results); - for (auto bnd : pbl->bodies) - bnd->save(pbl->msh->name + '_' + bnd->groups[0]->tag->name + suffix, results); + // save aerodynamic loads + std::cout << "writing file: aeroloads" << suffix << ".dat... " << std::flush; + std::ofstream outfile; + outfile.open("aeroloads" + suffix + ".dat"); + // total + outfile << "# Total - " << pbl->msh->name << std::endl; + outfile << std::fixed << std::setprecision(12) + << "Cl = " << Cl << "\n" + << "Cd = " << Cd << "\n" + << "Cs = " << Cs << "\n" + << "Cm = " << Cm << "\n"; + // breakdown + for (auto b : pbl->bodies) + { + outfile << "# Body - " << b->groups[0]->tag->name << " (" << b->groups[0]->tag->elems.size() << " elements)" << std::endl; + outfile << std::fixed << std::setprecision(12) + << "Cl = " << b->Cl << "\n" + << "Cd = " << b->Cd << "\n" + << "Cs = " << b->Cs << "\n" + << "Cm = " << b->Cm << "\n"; + } + outfile.close(); + std::cout << "done." << std::endl; } /**