diff --git a/.gitlab-ci.yml b/.gitlab-ci.yml index ab7a6785bbc76ceacdd9fd9e4ffc5739d542a784..cce2c2bae3b02434dc415b25babb0233db16cd8c 100644 --- a/.gitlab-ci.yml +++ b/.gitlab-ci.yml @@ -26,7 +26,7 @@ format: <<: *global_tag_def stage: build script: - - clang-format --version # we use clang-format-10 exclusively + - clang-format --version # we use clang-format-14 exclusively - ./ext/amfe/scripts/format_code.py - mkdir -p patches - if git diff --patch --exit-code > patches/clang-format.patch; then echo "Clang format changed nothing"; else echo "Clang format found changes to make!"; false; fi diff --git a/heat/src/heat.h b/heat/src/heat.h index ef7f46174dd741ebcef3f38c191f3b1c296276b3..6eb386d622d0ce34c069b3483fede6152f497abe 100644 --- a/heat/src/heat.h +++ b/heat/src/heat.h @@ -54,4 +54,4 @@ class HeatTerm; class DisplayHook; }; // namespace heat -#endif //HEAT_H +#endif // HEAT_H diff --git a/heat/src/wBoundary.cpp b/heat/src/wBoundary.cpp index 2ec222185212a1372e162b568bba4ef6a42f79cf..4de424d1dcd3f1c08d768567b23534124f1b88e9 100644 --- a/heat/src/wBoundary.cpp +++ b/heat/src/wBoundary.cpp @@ -21,12 +21,12 @@ using namespace heat; Boundary::Boundary(std::shared_ptr<MshData> _msh, int no, std::shared_ptr<Fct0> _f) : Group(_msh, no), f(_f) { - //pbl.bnds.push_back(this); + // pbl.bnds.push_back(this); } Boundary::Boundary(std::shared_ptr<MshData> _msh, std::string const &name, std::shared_ptr<Fct0> _f) : Group(_msh, name), f(_f) { - //pbl.bnds.push_back(this); + // pbl.bnds.push_back(this); } void Boundary::write(std::ostream &out) const diff --git a/heat/src/wBoundary.h b/heat/src/wBoundary.h index 3c0b8679c64b0b31886691eb04f67853776a356e..24a113db9a7c7d9ee6c97500cd8908c955ccc22a 100644 --- a/heat/src/wBoundary.h +++ b/heat/src/wBoundary.h @@ -47,4 +47,4 @@ public: } // namespace heat -#endif //WBOUNDARY_H +#endif // WBOUNDARY_H diff --git a/heat/src/wCompiledFct.h b/heat/src/wCompiledFct.h index f8d139263c577d36ad5479a9b8bd27ea92e52395..50a097031ec234744cea5cabe4967aa773fe3f22 100644 --- a/heat/src/wCompiledFct.h +++ b/heat/src/wCompiledFct.h @@ -101,4 +101,4 @@ public: }; // namespace heat -#endif //WCOMPILEDFCT_H +#endif // WCOMPILEDFCT_H diff --git a/heat/src/wDirichlet.cpp b/heat/src/wDirichlet.cpp index 932ee6f14b4112314256087f50c69c65353c21fe..32310110a05ee7aa3c1c57d0e9968bc05350727e 100644 --- a/heat/src/wDirichlet.cpp +++ b/heat/src/wDirichlet.cpp @@ -31,7 +31,7 @@ Dirichlet::Dirichlet(std::shared_ptr<MshData> _msh, int no, double _val) : Group auto it = std::unique(nodes.begin(), nodes.end()); nodes.resize(std::distance(nodes.begin(), it)); - //pbl.dBCs.push_back(this); + // pbl.dBCs.push_back(this); } Dirichlet::Dirichlet(std::shared_ptr<MshData> _msh, std::string const &name, double _val) : Group(_msh, name), val(_val) @@ -43,7 +43,7 @@ Dirichlet::Dirichlet(std::shared_ptr<MshData> _msh, std::string const &name, dou auto it = std::unique(nodes.begin(), nodes.end()); nodes.resize(std::distance(nodes.begin(), it)); - //pbl.dBCs.push_back(this); + // pbl.dBCs.push_back(this); } /** diff --git a/heat/src/wDirichlet.h b/heat/src/wDirichlet.h index 6ebf97ba5cfcc6f7faaf9e909edc2a8d9284b46c..b201700ff85338ec13c1179baba9a62876e00c02 100644 --- a/heat/src/wDirichlet.h +++ b/heat/src/wDirichlet.h @@ -52,4 +52,4 @@ public: } // namespace heat -#endif //WDIRICHLET_H +#endif // WDIRICHLET_H diff --git a/heat/src/wDisplayHook.h b/heat/src/wDisplayHook.h index 58dcbaf4746fbebd88fd29c682769d46a8552dc1..1972fd4191b2a7c5dc84efbf050df94418578e41 100644 --- a/heat/src/wDisplayHook.h +++ b/heat/src/wDisplayHook.h @@ -38,4 +38,4 @@ public: } // namespace heat -#endif //WDISPLAYHOOK_H +#endif // WDISPLAYHOOK_H diff --git a/heat/src/wExtractor.h b/heat/src/wExtractor.h index fb79c3773103b6309e657eb882f215464ed93332..8f88ba1127647d59a569f236c281637bcde465e1 100644 --- a/heat/src/wExtractor.h +++ b/heat/src/wExtractor.h @@ -47,4 +47,4 @@ public: } // namespace heat -#endif //WEXTRACTOR_H +#endif // WEXTRACTOR_H diff --git a/heat/src/wHeatTerm.h b/heat/src/wHeatTerm.h index 12f9bc514a172d93de5e8f4a357b69681b155ec5..53c5e4f79c74136b7ac0712b53aa0a2c674c09bf 100644 --- a/heat/src/wHeatTerm.h +++ b/heat/src/wHeatTerm.h @@ -42,4 +42,4 @@ public: }; } // namespace heat -#endif //WHEATTERM_H +#endif // WHEATTERM_H diff --git a/heat/src/wMedium.cpp b/heat/src/wMedium.cpp index ad307a6d1e94383bbb42ddcddd4abd32b040b17f..6586787c2f95348c8d367b3e6e2c788e39ab6b30 100644 --- a/heat/src/wMedium.cpp +++ b/heat/src/wMedium.cpp @@ -24,7 +24,7 @@ Medium::Medium(std::shared_ptr<MshData> _msh, int no, std::shared_ptr<Fct2> _k, double _rhoc) : Group(_msh, no), k(_k), rhoc(_rhoc) { - //pbl.media.push_back(this); + // pbl.media.push_back(this); } Medium::Medium(std::shared_ptr<MshData> _msh, std::string const &name, @@ -32,7 +32,7 @@ Medium::Medium(std::shared_ptr<MshData> _msh, std::string const &name, k(_k), rhoc(_rhoc) { std::cout << "tag=" << *tag << std::endl; - //pbl.media.push_back(this); + // pbl.media.push_back(this); } void Medium::write(std::ostream &out) const diff --git a/heat/src/wMedium.h b/heat/src/wMedium.h index 5ba9b425501ddced5a1c4116846aca06a8efd24b..874818c9e2414e096676310da29a33ce438ab80b 100644 --- a/heat/src/wMedium.h +++ b/heat/src/wMedium.h @@ -48,4 +48,4 @@ public: } // namespace heat -#endif //WMEDIUM_H +#endif // WMEDIUM_H diff --git a/heat/src/wPeriodic.cpp b/heat/src/wPeriodic.cpp index 56930814a7ceb1c87d494dae31751c71fb134a2c..93c9b5ce8a8ca75da974205827631fca16ce86ab 100644 --- a/heat/src/wPeriodic.cpp +++ b/heat/src/wPeriodic.cpp @@ -45,7 +45,7 @@ NodePair::NodePair(Node *_n, Node *_d, double tol) : n(_n), d(_d) Periodic::Periodic(std::shared_ptr<heat::Problem> _pbl, double _TM, double _dTxM, double _dTyM) : wSharedObject(), pbl(_pbl) { - //pbl->pdic = this; + // pbl->pdic = this; reset(_TM, _dTxM, _dTyM); verbose = false; } @@ -70,7 +70,7 @@ void Periodic::init() if (!LR.empty()) return; - //std::cout << "Periodic::init()\n"; + // std::cout << "Periodic::init()\n"; // build a list of nodes related to all the media if (verbose) diff --git a/heat/src/wPeriodic.h b/heat/src/wPeriodic.h index 0e1d4c9ab9143233ef6ade2f392e53dd895f9871..ebb5c48d3fdf4d202ab1602f0e29d51baf919705 100644 --- a/heat/src/wPeriodic.h +++ b/heat/src/wPeriodic.h @@ -39,7 +39,7 @@ public: NodePair(Node *_n, Node *_d, double tol = 1e-12); friend HEAT_API std::ostream &operator<<(std::ostream &out, NodePair const &obj); }; -#endif //SWIG +#endif // SWIG /** * @brief manages periodic BCs @@ -79,4 +79,4 @@ private: } // namespace heat -#endif //WPERIODIC_H +#endif // WPERIODIC_H diff --git a/heat/src/wProblem.h b/heat/src/wProblem.h index 875aa6da5a8e227118090700914de00a567bcc49..5fbda6420c4ff104b1a8e7727ed01166341ba41a 100644 --- a/heat/src/wProblem.h +++ b/heat/src/wProblem.h @@ -64,4 +64,4 @@ public: } // namespace heat -#endif //WPROBLEM_H +#endif // WPROBLEM_H diff --git a/heat/src/wSolver.cpp b/heat/src/wSolver.cpp index 0148904fd71dfe456c1cd073ea6145b8cb754880..30e65f0e610d52b14f6e32d85d26e997b904fbab 100644 --- a/heat/src/wSolver.cpp +++ b/heat/src/wSolver.cpp @@ -146,8 +146,8 @@ void Solver::start(MshExport *mshWriter) // K matrix assembly Eigen::SparseMatrix<double, Eigen::RowMajor> K(msh->nodes.size(), msh->nodes.size()); buildK(K, rhs_); - //tomatlab("K.txt", K); - //throw std::runtime_error("stop!"); + // tomatlab("K.txt", K); + // throw std::runtime_error("stop!"); tms["Kass"].stop(); tms["BCs"].start(); @@ -162,7 +162,7 @@ void Solver::start(MshExport *mshWriter) dBC->apply(rhs); } tms["BCs"].stop(); - //std::cout << rhs << "\n"; + // std::cout << rhs << "\n"; // residual calculation tms["residual"].start(); @@ -176,7 +176,7 @@ void Solver::start(MshExport *mshWriter) Eigen::VectorXd qint2; buildqint(qint2); // calcul de q_int par integration du flux sur l'elem double normdiff = (qint - qint2).norm(); - //if(verbose>1) + // if(verbose>1) std::cout << "norm diff=" << normdiff << '\n'; } @@ -256,47 +256,50 @@ void Solver::start(MshExport *mshWriter) Eigen::Vector2d qM = Eigen::Vector2d::Zero(); for (auto mat : pbl->media) { - tbb::parallel_for_each(mat->tag->elems.begin(), mat->tag->elems.end(), [&](Element *e) { - if (e->type() != ElType::TRI3) - return; - //std::cout << "processing element #" << e->no << "\n"; + tbb::parallel_for_each( + mat->tag->elems.begin(), mat->tag->elems.end(), + [&](Element *e) + { + if (e->type() != ElType::TRI3) + return; + // std::cout << "processing element #" << e->no << "\n"; - // (flux moyen . volume) sur l'element - Eigen::VectorXd qV = HeatTerm::computeFlux(*e, T1, *mat->k); + // (flux moyen . volume) sur l'element + Eigen::VectorXd qV = HeatTerm::computeFlux(*e, T1, *mat->k); - double V = e->getVol(); + double V = e->getVol(); - if (save) - { - // gradient of T at GP 0 - Eigen::VectorXd grad = e->computeGradient(T1, 0); - int i = e->no - 1; - gradT_x[i] = grad(0); - gradT_y[i] = grad(1); - gradT[i] = Eigen::Vector3d(grad(0), grad(1), 0); - - // mean q over the element - kgradT[i] = Eigen::Vector3d(qV(0) / V, qV(1) / V, 0); - - // mean k over the element - Eigen::MatrixXd kmean = HeatTerm::computeMatrix(*e, T1, *mat->k) / V; - kmoy11[i] = kmean(0, 0); - kmoy22[i] = kmean(1, 1); - kmoy12[i] = kmean(0, 1); - kmoy21[i] = kmean(1, 0); - - // tensor - kmean.conservativeResize(3, 3); - kmean.row(2) = Eigen::RowVector3d::Zero(); - kmean.col(2) = Eigen::Vector3d::Zero(); - kmoy[i] = kmean; - //std::cout << kmean << '\n'; - } + if (save) + { + // gradient of T at GP 0 + Eigen::VectorXd grad = e->computeGradient(T1, 0); + int i = e->no - 1; + gradT_x[i] = grad(0); + gradT_y[i] = grad(1); + gradT[i] = Eigen::Vector3d(grad(0), grad(1), 0); + + // mean q over the element + kgradT[i] = Eigen::Vector3d(qV(0) / V, qV(1) / V, 0); + + // mean k over the element + Eigen::MatrixXd kmean = HeatTerm::computeMatrix(*e, T1, *mat->k) / V; + kmoy11[i] = kmean(0, 0); + kmoy22[i] = kmean(1, 1); + kmoy12[i] = kmean(0, 1); + kmoy21[i] = kmean(1, 0); + + // tensor + kmean.conservativeResize(3, 3); + kmean.row(2) = Eigen::RowVector3d::Zero(); + kmean.col(2) = Eigen::Vector3d::Zero(); + kmoy[i] = kmean; + // std::cout << kmean << '\n'; + } - tbb::spin_mutex::scoped_lock lock(mutex); - Vtot += V; - qM += qV; // qM = qM + qV - }); + tbb::spin_mutex::scoped_lock lock(mutex); + Vtot += V; + qM += qV; // qM = qM + qV + }); } qM /= Vtot; @@ -371,25 +374,28 @@ void Solver::buildK(Eigen::SparseMatrix<double, Eigen::RowMajor> &K2, Eigen::Map { if (verbose > 1) std::cout << "\tprocessing " << *mat << '\n'; - tbb::parallel_for_each(mat->tag->elems.begin(), mat->tag->elems.end(), [&](Element *e) { - if (e->type() != ElType::TRI3) - return; - //std::cout << "processing element #" << e->no << "\n"; + tbb::parallel_for_each( + mat->tag->elems.begin(), mat->tag->elems.end(), + [&](Element *e) + { + if (e->type() != ElType::TRI3) + return; + // std::cout << "processing element #" << e->no << "\n"; - Eigen::MatrixXd Ke = HeatTerm::build(*e, T1, *mat->k, false); + Eigen::MatrixXd Ke = HeatTerm::build(*e, T1, *mat->k, false); - // assembly - tbb::spin_mutex::scoped_lock lock(mutex); - for (size_t ii = 0; ii < e->nodes.size(); ++ii) - { - Node *nodi = e->nodes[ii]; - for (size_t jj = 0; jj < e->nodes.size(); ++jj) + // assembly + tbb::spin_mutex::scoped_lock lock(mutex); + for (size_t ii = 0; ii < e->nodes.size(); ++ii) { - Node *nodj = e->nodes[jj]; - T.push_back(Eigen::Triplet<double>(rows[nodi->row], nodj->row, Ke(ii, jj))); + Node *nodi = e->nodes[ii]; + for (size_t jj = 0; jj < e->nodes.size(); ++jj) + { + Node *nodj = e->nodes[jj]; + T.push_back(Eigen::Triplet<double>(rows[nodi->row], nodj->row, Ke(ii, jj))); + } } - } - }); + }); } } else @@ -406,7 +412,8 @@ void Solver::buildK(Eigen::SparseMatrix<double, Eigen::RowMajor> &K2, Eigen::Map if (verbose > 1) std::cout << "\tprocessing " << *mat << '\n'; std::for_each(mat->tag->elems.begin(), mat->tag->elems.end(), - [&](Element *e) { + [&](Element *e) + { if (e->type() != ElType::TRI3) return; Eigen::MatrixXd Ke = HeatTerm::build(*e, T1, *mat->k, true); // bidon @@ -436,7 +443,7 @@ void Solver::buildK(Eigen::SparseMatrix<double, Eigen::RowMajor> &K2, Eigen::Map Eigen::MatrixXd Ke = HeatTerm::build(*e, T1, *mat->k, false); // assembly - //tbb::spin_mutex::scoped_lock lock(mutex); + // tbb::spin_mutex::scoped_lock lock(mutex); for (size_t ii = 0; ii < e->nodes.size(); ++ii) { Node *nodi = e->nodes[ii]; @@ -520,26 +527,29 @@ void Solver::buildK(Eigen::SparseMatrix<double, Eigen::RowMajor> &K2, Eigen::Map double rhocM_Vtot = 0; for (auto mat : pbl->media) { - //std::cout << "\tprocessing " << *mat << '\n'; - tbb::parallel_for_each(mat->tag->elems.begin(), mat->tag->elems.end(), [&](Element *e) { - if (e->type() != ElType::TRI3) - return; - //std::cout << "processing element #" << e->no << "\n"; + // std::cout << "\tprocessing " << *mat << '\n'; + tbb::parallel_for_each( + mat->tag->elems.begin(), mat->tag->elems.end(), + [&](Element *e) + { + if (e->type() != ElType::TRI3) + return; + // std::cout << "processing element #" << e->no << "\n"; - // ** Ce matrix => K matrix - Eigen::VectorXd Ce = HeatTerm::build(*e, T1, Fct0C(1.0)); + // ** Ce matrix => K matrix + Eigen::VectorXd Ce = HeatTerm::build(*e, T1, Fct0C(1.0)); - // assembly - tbb::spin_mutex::scoped_lock lock(mutex); - for (size_t jj = 0; jj < e->nodes.size(); ++jj) - { - Node *nodj = e->nodes[jj]; - K2.coeffRef(n1->row, nodj->row) += (mat->rhoc) * Ce(jj); + // assembly + tbb::spin_mutex::scoped_lock lock(mutex); + for (size_t jj = 0; jj < e->nodes.size(); ++jj) + { + Node *nodj = e->nodes[jj]; + K2.coeffRef(n1->row, nodj->row) += (mat->rhoc) * Ce(jj); - Vtot += Ce(jj); - rhocM_Vtot += (mat->rhoc) * Ce(jj); - } - }); + Vtot += Ce(jj); + rhocM_Vtot += (mat->rhoc) * Ce(jj); + } + }); } rhs(n1->row) = rhocM_Vtot * TM; if (verbose > 1) @@ -558,7 +568,7 @@ void Solver::buildK(Eigen::SparseMatrix<double, Eigen::RowMajor> &K2, Eigen::Map { for (auto nod : dBC->nodes) { - //std::cout << "processing " << *nod << "\n"; + // std::cout << "processing " << *nod << "\n"; for (Eigen::SparseMatrix<double, Eigen::RowMajor>::InnerIterator it(K2, nod->row); it; ++it) { if (it.row() == it.col()) @@ -592,21 +602,24 @@ void Solver::buildqint(Eigen::VectorXd &qint) { if (verbose > 1) std::cout << "\tprocessing " << *mat << '\n'; - tbb::parallel_for_each(mat->tag->elems.begin(), mat->tag->elems.end(), [&](Element *e) { - if (e->type() != ElType::TRI3) - return; - //std::cout << "processing element #" << e->no << "\n"; + tbb::parallel_for_each( + mat->tag->elems.begin(), mat->tag->elems.end(), + [&](Element *e) + { + if (e->type() != ElType::TRI3) + return; + // std::cout << "processing element #" << e->no << "\n"; - Eigen::VectorXd qe = HeatTerm::build2(*e, T1, *mat->k); + Eigen::VectorXd qe = HeatTerm::build2(*e, T1, *mat->k); - // assembly - tbb::spin_mutex::scoped_lock lock(mutex); - for (size_t ii = 0; ii < e->nodes.size(); ++ii) - { - Node *nodi = e->nodes[ii]; - qint(nodi->row) += qe(ii); - } - }); + // assembly + tbb::spin_mutex::scoped_lock lock(mutex); + for (size_t ii = 0; ii < e->nodes.size(); ++ii) + { + Node *nodi = e->nodes[ii]; + qint(nodi->row) += qe(ii); + } + }); } if (!pbl->dBCs.empty()) @@ -640,24 +653,27 @@ void Solver::builds(Eigen::Map<Eigen::VectorXd> &s) for (auto src : pbl->srcs) { - //std::cout << "\tprocessing " << *src << '\n'; - tbb::parallel_for_each(src->tag->elems.begin(), src->tag->elems.end(), [&](Element *e) { - if (e->type() != ElType::TRI3 && e->type() != ElType::LINE2) - return; - //std::cout << "processing element #" << e->no << "\n"; + // std::cout << "\tprocessing " << *src << '\n'; + tbb::parallel_for_each( + src->tag->elems.begin(), src->tag->elems.end(), + [&](Element *e) + { + if (e->type() != ElType::TRI3 && e->type() != ElType::LINE2) + return; + // std::cout << "processing element #" << e->no << "\n"; - // ** se vector => s vector - Eigen::VectorXd se = HeatTerm::build(*e, T1, *src->f); + // ** se vector => s vector + Eigen::VectorXd se = HeatTerm::build(*e, T1, *src->f); - // assembly - tbb::spin_mutex::scoped_lock lock(mutex); + // assembly + tbb::spin_mutex::scoped_lock lock(mutex); - for (size_t ii = 0; ii < e->nodes.size(); ++ii) - { - Node *nodi = e->nodes[ii]; - s(nodi->row) += se(ii); - } - }); + for (size_t ii = 0; ii < e->nodes.size(); ++ii) + { + Node *nodi = e->nodes[ii]; + s(nodi->row) += se(ii); + } + }); } if (verbose > 1) @@ -679,24 +695,27 @@ void Solver::buildq(Eigen::Map<Eigen::VectorXd> &q) for (auto bnd : pbl->bnds) { - //std::cout << "\tprocessing " << *src << '\n'; - tbb::parallel_for_each(bnd->tag->elems.begin(), bnd->tag->elems.end(), [&](Element *e) { - if (e->type() != ElType::LINE2) - return; - //std::cout << "processing element #" << e->no << "\n"; + // std::cout << "\tprocessing " << *src << '\n'; + tbb::parallel_for_each( + bnd->tag->elems.begin(), bnd->tag->elems.end(), + [&](Element *e) + { + if (e->type() != ElType::LINE2) + return; + // std::cout << "processing element #" << e->no << "\n"; - // ** qe vector => q vector - Eigen::VectorXd qe = HeatTerm::build(*e, T1, *bnd->f); + // ** qe vector => q vector + Eigen::VectorXd qe = HeatTerm::build(*e, T1, *bnd->f); - // assembly - tbb::spin_mutex::scoped_lock lock(mutex); + // assembly + tbb::spin_mutex::scoped_lock lock(mutex); - for (size_t ii = 0; ii < e->nodes.size(); ++ii) - { - Node *nodi = e->nodes[ii]; - q(nodi->row) += qe(ii); - } - }); + for (size_t ii = 0; ii < e->nodes.size(); ++ii) + { + Node *nodi = e->nodes[ii]; + q(nodi->row) += qe(ii); + } + }); } if (verbose > 1) diff --git a/heat/src/wSolver.h b/heat/src/wSolver.h index bd83c28c92b110ec40ef87df4fb16fb0c8a4a7e5..bcd624ddf30dfe771d7061a66783a8edf5d9d908 100644 --- a/heat/src/wSolver.h +++ b/heat/src/wSolver.h @@ -76,4 +76,4 @@ private: } // namespace heat -#endif //WSOLVER_H +#endif // WSOLVER_H diff --git a/heat/src/wSource.cpp b/heat/src/wSource.cpp index 149c18d185dade39387f8e6c8cbf94b4f5f310e0..5429e8cb049c61a3fac7e01c77e2edb6dbe2de20 100644 --- a/heat/src/wSource.cpp +++ b/heat/src/wSource.cpp @@ -21,12 +21,12 @@ using namespace heat; Source::Source(std::shared_ptr<MshData> _msh, int no, std::shared_ptr<Fct0> _f) : Group(_msh, no), f(_f) { - //pbl.srcs.push_back(this); + // pbl.srcs.push_back(this); } Source::Source(std::shared_ptr<MshData> _msh, std::string const &name, std::shared_ptr<Fct0> _f) : Group(_msh, name), f(_f) { - //pbl.srcs.push_back(this); + // pbl.srcs.push_back(this); } void Source::write(std::ostream &out) const diff --git a/heat/src/wSource.h b/heat/src/wSource.h index b83b726390099a0499c9df65d6bbb772e0f2adb1..bbaa0f03eb790a90a0687c3fcc9b7f063823ee95 100644 --- a/heat/src/wSource.h +++ b/heat/src/wSource.h @@ -49,4 +49,4 @@ public: } // namespace heat -#endif //WSOURCE_H +#endif // WSOURCE_H diff --git a/waves/attic/wDof.h b/waves/attic/wDof.h index 11a552d81f373bab672c6dde5a50eabc798d1616..26fcd693ea57f48bad285c1057fc6de4d81ffdc2 100644 --- a/waves/attic/wDof.h +++ b/waves/attic/wDof.h @@ -35,9 +35,9 @@ public: Dofs() : wObject(), dofs(0) {} //~Dofs(); - //void add(Dof &dof); + // void add(Dof &dof); size_t size() const { return dofs.size(); } - //virtual void write(std::ostream &out) const; + // virtual void write(std::ostream &out) const; }; -#endif //WDOF_H +#endif // WDOF_H diff --git a/waves/attic/wField.h b/waves/attic/wField.h index 35ad5745d68285a0350de5e55f788d69f680c68c..a3ecc99056e5186c3ac0656ece21854086a347bd 100644 --- a/waves/attic/wField.h +++ b/waves/attic/wField.h @@ -38,4 +38,4 @@ public: virtual void write(std::ostream &out) const; }; -#endif //WFIELD_H +#endif // WFIELD_H diff --git a/waves/attic/wSolver1.h b/waves/attic/wSolver1.h index 9b1afd8075aab6cbadb9afd6d1b6317f48a4cd9e..ecb648b92bf26574ba08be29dc5df3648e7efca4 100644 --- a/waves/attic/wSolver1.h +++ b/waves/attic/wSolver1.h @@ -14,4 +14,4 @@ public: virtual void write(std::ostream &out) const; }; -#endif //WSOLVER1_H +#endif // WSOLVER1_H diff --git a/waves/src/wBoundary.cpp b/waves/src/wBoundary.cpp index 52238cacbabf51932e072a62e09cc07b302f0c8f..90272c26330126f90eb0a0f264bfcc385061ae18 100644 --- a/waves/src/wBoundary.cpp +++ b/waves/src/wBoundary.cpp @@ -21,12 +21,12 @@ using namespace waves; Boundary::Boundary(std::shared_ptr<MshData> _msh, int no, double _c) : Group(_msh, no), c(_c) { - //pbl.bnds.push_back(this); + // pbl.bnds.push_back(this); } Boundary::Boundary(std::shared_ptr<MshData> _msh, std::string const &name, double _c) : Group(_msh, name), c(_c) { - //pbl.bnds.push_back(this); + // pbl.bnds.push_back(this); } void Boundary::write(std::ostream &out) const diff --git a/waves/src/wBoundary.h b/waves/src/wBoundary.h index 98ef337e6ef5d5a00fe916218dd5d1af6d5447f7..38084d5bfd532e24eef514f6f9a8693f79cd0b67 100644 --- a/waves/src/wBoundary.h +++ b/waves/src/wBoundary.h @@ -43,4 +43,4 @@ public: }; } // namespace waves -#endif //WBOUNDARY_H +#endif // WBOUNDARY_H diff --git a/waves/src/wDisplayHook.h b/waves/src/wDisplayHook.h index 859859da5810092b8e671b8028d63afc621d05c2..4dad02c21b1e9264b4bbc4567077bed83ca009f0 100644 --- a/waves/src/wDisplayHook.h +++ b/waves/src/wDisplayHook.h @@ -38,4 +38,4 @@ public: } // namespace waves -#endif //WDISPLAYHOOK_H +#endif // WDISPLAYHOOK_H diff --git a/waves/src/wForwardEuler.cpp b/waves/src/wForwardEuler.cpp index 9efb91b8cbccba642c3f249b406107f915997ce6..810bff0047e892b3df243d0842245a3b3c074756 100644 --- a/waves/src/wForwardEuler.cpp +++ b/waves/src/wForwardEuler.cpp @@ -54,7 +54,7 @@ void ForwardEuler::start(MshExport *mshWriter) // setup results Results results; results.scalars_at_nodes["u"] = &u1; - //results.scalars_at_nodes["v"] = &v1; + // results.scalars_at_nodes["v"] = &v1; // time integration @@ -68,11 +68,11 @@ void ForwardEuler::start(MshExport *mshWriter) while (t < ttot && !stopit) { - //if(verbose) std::cout << "nt " << nt << " t=" << t << "\n"; + // if(verbose) std::cout << "nt " << nt << " t=" << t << "\n"; if (verbose) std::cout << "nt " << nt << " t=" << t << " stopit=" << stopit << "\n"; - //std::for_each(msh->srcs.begin(), msh->srcs.end(), [&](Source *s) { s->apply(t, u1); }); + // std::for_each(msh->srcs.begin(), msh->srcs.end(), [&](Source *s) { s->apply(t, u1); }); for (auto s : pbl->srcs) s->apply(t, u1); @@ -90,7 +90,7 @@ void ForwardEuler::start(MshExport *mshWriter) if (nt % savefreq == 0) { - //std::cout << "nt " << nt << " t=" << t << "\n"; + // std::cout << "nt " << nt << " t=" << t << "\n"; results.time = t; if (wgmsh == Wgmsh::WG_ONE) { diff --git a/waves/src/wForwardEuler.h b/waves/src/wForwardEuler.h index 1be5443bccd6832c32f9201a832442799f8cd21d..f84978382d659e4052cc53a892a2d99f3011ff12 100644 --- a/waves/src/wForwardEuler.h +++ b/waves/src/wForwardEuler.h @@ -39,4 +39,4 @@ public: } // namespace waves -#endif //WFORWARDEULER_H +#endif // WFORWARDEULER_H diff --git a/waves/src/wMedium.cpp b/waves/src/wMedium.cpp index af87497ce489c47ae79574b3c6d6006fcce5dd3b..09488f7fe419e15f7b4f3eb8b71d1ea7606add71 100644 --- a/waves/src/wMedium.cpp +++ b/waves/src/wMedium.cpp @@ -21,12 +21,12 @@ using namespace waves; Medium::Medium(std::shared_ptr<MshData> _msh, int no, double _c) : Group(_msh, no), c(_c) { - //pbl.media.push_back(this); + // pbl.media.push_back(this); } Medium::Medium(std::shared_ptr<MshData> _msh, std::string const &name, double _c) : Group(_msh, name), c(_c) { - //pbl.media.push_back(this); + // pbl.media.push_back(this); } void Medium::write(std::ostream &out) const diff --git a/waves/src/wMedium.h b/waves/src/wMedium.h index a3e370af6f426c82fb3acb39b3f10abe7b4ecdeb..e22b7c575e2ac83fb590938fbd6cc5c628a9cd01 100644 --- a/waves/src/wMedium.h +++ b/waves/src/wMedium.h @@ -44,4 +44,4 @@ public: }; } // namespace waves -#endif //WMEDIUM_H +#endif // WMEDIUM_H diff --git a/waves/src/wNewmark.cpp b/waves/src/wNewmark.cpp index 919521281d4bb4257ddc7b3ebc0ce0d3b36e5165..48f3c547adb51256cf87fa9fbce11dadd9762274 100644 --- a/waves/src/wNewmark.cpp +++ b/waves/src/wNewmark.cpp @@ -56,7 +56,7 @@ void Newmark::start(MshExport *mshWriter) // setup results Results results; results.scalars_at_nodes["u"] = &u1; - //results.scalars_at_nodes["v"] = &v1; + // results.scalars_at_nodes["v"] = &v1; // time integration @@ -90,10 +90,10 @@ void Newmark::start(MshExport *mshWriter) if (nt % savefreq == 0) { - //std::cout << "nt " << nt << " t=" << t << "\n"; + // std::cout << "nt " << nt << " t=" << t << "\n"; results.time = t; results.nt++; - //mshWriter->save("res", results); + // mshWriter->save("res", results); if (dhook) dhook->display(nt, t, u1); diff --git a/waves/src/wNewmark.h b/waves/src/wNewmark.h index b03d5808614e328a8c70fa1eafe7ca94219fa56d..28f0e02ce36c806c07c6a6f097076b4cdd9d8a9d 100644 --- a/waves/src/wNewmark.h +++ b/waves/src/wNewmark.h @@ -42,4 +42,4 @@ public: } // namespace waves -#endif //WNEWMARK_H +#endif // WNEWMARK_H diff --git a/waves/src/wProblem.h b/waves/src/wProblem.h index adff43b5c3307f70f3490bf017a435177be500fc..248d7ab71760abc2e9c81af8bc7f0cda97ae0ff8 100644 --- a/waves/src/wProblem.h +++ b/waves/src/wProblem.h @@ -55,4 +55,4 @@ public: }; } // namespace waves -#endif //WPROBLEM_H +#endif // WPROBLEM_H diff --git a/waves/src/wRungeKutta.cpp b/waves/src/wRungeKutta.cpp index 75e9baf257d5228d88c0eb59446e00984ddd92c7..4b8689dd3c730d5cceea85c9ef312783a6d7b655 100644 --- a/waves/src/wRungeKutta.cpp +++ b/waves/src/wRungeKutta.cpp @@ -52,7 +52,7 @@ void RungeKutta::start(MshExport *mshWriter) // setup results Results results; results.scalars_at_nodes["u"] = &u1; - //results.scalars_at_nodes["v"] = &v1; + // results.scalars_at_nodes["v"] = &v1; // time integration @@ -75,15 +75,16 @@ void RungeKutta::start(MshExport *mshWriter) std::vector<double> u2(msh->nodes.size()); std::vector<double> v2(msh->nodes.size()); - //Node *snod = msh->ntags["Source Point"]->elems[0]->nodes[0]; + // Node *snod = msh->ntags["Source Point"]->elems[0]->nodes[0]; while (t < ttot) { std::cout << "nt " << nt << " t=" << t << "\n"; - //u1[snod->row] = sin(2*M_PI*20*t); // BC - //if(source) source->apply(t, u1); - std::for_each(pbl->srcs.begin(), pbl->srcs.end(), [&](std::shared_ptr<Source> s) { s->apply(t, u1); }); + // u1[snod->row] = sin(2*M_PI*20*t); // BC + // if(source) source->apply(t, u1); + std::for_each(pbl->srcs.begin(), pbl->srcs.end(), [&](std::shared_ptr<Source> s) + { s->apply(t, u1); }); t += dt; nt++; @@ -97,16 +98,17 @@ void RungeKutta::start(MshExport *mshWriter) predictor(u2, v2, up2, vp2, u1, v1, dt, Md, K, S, 1. / 8., t); predictor(u1, v1, up3, vp3, u2, v2, dt, Md, K, S, 1. / 24., t); - //u1[snod->row] = sin(2*M_PI*20*t); //BC bis - //if(source) source->apply(t, u1); - std::for_each(pbl->srcs.begin(), pbl->srcs.end(), [&](std::shared_ptr<Source> s) { s->apply(t, u1); }); + // u1[snod->row] = sin(2*M_PI*20*t); //BC bis + // if(source) source->apply(t, u1); + std::for_each(pbl->srcs.begin(), pbl->srcs.end(), [&](std::shared_ptr<Source> s) + { s->apply(t, u1); }); if (nt % savefreq == 0) { - //std::cout << "nt " << nt << " t=" << t << "\n"; + // std::cout << "nt " << nt << " t=" << t << "\n"; results.time = t; results.nt++; - //mshWriter->save("res", results); + // mshWriter->save("res", results); if (dhook) dhook->display(nt, t, u1); @@ -132,10 +134,11 @@ void RungeKutta::predictor(std::vector<double> &up2, std::vector<double> &vp2, / // equation #1 up2_ = u0_ + vp1_ * ak * dt; - //up2[snod->row] = sin(2*M_PI*20*t); //BC bis - //if(source) source->apply(t, up2); + // up2[snod->row] = sin(2*M_PI*20*t); //BC bis + // if(source) source->apply(t, up2); - std::for_each(pbl->srcs.begin(), pbl->srcs.end(), [&](std::shared_ptr<Source> s) { s->apply(t, up2); }); + std::for_each(pbl->srcs.begin(), pbl->srcs.end(), [&](std::shared_ptr<Source> s) + { s->apply(t, up2); }); // equation #2 vp2_.array() = v0_.array() - ak * dt * (K * up1_ + S * vp1_).array() / Md_.array(); diff --git a/waves/src/wRungeKutta.h b/waves/src/wRungeKutta.h index e79690fda9a1f821768a7f057f733aa409396ed4..61183b156e7b3778956ec4d71ae6acc46e06aa0c 100644 --- a/waves/src/wRungeKutta.h +++ b/waves/src/wRungeKutta.h @@ -51,4 +51,4 @@ private: } // namespace waves -#endif //WRUNGEKUTTA_H +#endif // WRUNGEKUTTA_H diff --git a/waves/src/wSource.cpp b/waves/src/wSource.cpp index 595eea555dba22dd4882125c679a3af0d646e825..3b9952ffc5fa566360c4c27be402978ba3faa5f9 100644 --- a/waves/src/wSource.cpp +++ b/waves/src/wSource.cpp @@ -28,13 +28,13 @@ Source::Source(std::shared_ptr<MshData> _msh, int no) : Group(_msh, no) for (auto n : e->nodes) nodes.push_back(n); /* - std::for_each(tag->elems.begin(), tag->elems.end(), [&](Element *e) { - std::for_each(e->nodes.begin(), e->nodes.end(), [&](Node *n) { - nodes.push_back(n); + std::for_each(tag->elems.begin(), tag->elems.end(), [&](Element *e) { + std::for_each(e->nodes.begin(), e->nodes.end(), [&](Node *n) { + nodes.push_back(n); }); }); */ - //pbl.srcs.push_back(this); + // pbl.srcs.push_back(this); } Source::Source(std::shared_ptr<MshData> _msh, std::string const &name) : Group(_msh, name) @@ -43,13 +43,13 @@ Source::Source(std::shared_ptr<MshData> _msh, std::string const &name) : Group(_ for (auto n : e->nodes) nodes.push_back(n); - //pbl.srcs.push_back(this); + // pbl.srcs.push_back(this); } void Source::write(std::ostream &out) const { out << "Source on " << *tag; out << "(" << nodes.size() << " nodes)"; - //std::for_each(nodes.begin(), nodes.end(), [&](Node *n) { out << '\t' << *n << '\n'; }); - //for(auto n : nodes) { out << '\t' << *n << '\n'; } + // std::for_each(nodes.begin(), nodes.end(), [&](Node *n) { out << '\t' << *n << '\n'; }); + // for(auto n : nodes) { out << '\t' << *n << '\n'; } } diff --git a/waves/src/wSource.h b/waves/src/wSource.h index 6ed54658d85cab00eb657d68bdd2af444c86416a..2884b4a61f0f7d54e3f6c357fdb6e340938eb173 100644 --- a/waves/src/wSource.h +++ b/waves/src/wSource.h @@ -47,4 +47,4 @@ public: }; } // namespace waves -#endif //WSOURCE_H +#endif // WSOURCE_H diff --git a/waves/src/wTimeIntegration.cpp b/waves/src/wTimeIntegration.cpp index 7f13762b1c2144315354fc7b19ba79857c8ca9a5..83f5aa86c67e056b60583ad9c4e60cfebeacfd87 100644 --- a/waves/src/wTimeIntegration.cpp +++ b/waves/src/wTimeIntegration.cpp @@ -102,27 +102,30 @@ void TimeIntegration::buildS(Eigen::SparseMatrix<double, Eigen::RowMajor> &S2) { std::cout << "\tprocessing " << *bnd << '\n'; std::cout << "normal=" << static_cast<Quad4 *>(bnd->tag->elems[0])->getNormal() << '\n'; - tbb::parallel_for_each(bnd->tag->elems.begin(), bnd->tag->elems.end(), [&](Element *e) { - if (e->type() != ElType::QUAD4) - return; - //std::cout << "processing element #" << e->no << "\n"; + tbb::parallel_for_each( + bnd->tag->elems.begin(), bnd->tag->elems.end(), + [&](Element *e) + { + if (e->type() != ElType::QUAD4) + return; + // std::cout << "processing element #" << e->no << "\n"; - // ** Se matrix => S vector - Eigen::MatrixXd Se = WaveTerm::buildM(*e); + // ** Se matrix => S vector + Eigen::MatrixXd Se = WaveTerm::buildM(*e); - // assembly - tbb::spin_mutex::scoped_lock lock(mutex); + // assembly + tbb::spin_mutex::scoped_lock lock(mutex); - for (size_t ii = 0; ii < e->nodes.size(); ++ii) - { - Node *nodi = e->nodes[ii]; - for (size_t jj = 0; jj < e->nodes.size(); ++jj) + for (size_t ii = 0; ii < e->nodes.size(); ++ii) { - Node *nodj = e->nodes[jj]; - T.push_back(Eigen::Triplet<double>(nodi->row, nodj->row, bnd->c * Se(ii, jj))); + Node *nodi = e->nodes[ii]; + for (size_t jj = 0; jj < e->nodes.size(); ++jj) + { + Node *nodj = e->nodes[jj]; + T.push_back(Eigen::Triplet<double>(nodi->row, nodj->row, bnd->c * Se(ii, jj))); + } } - } - }); + }); } // Build, clean and turn to compressed row format S2.setFromTriplets(T.begin(), T.end()); @@ -158,31 +161,34 @@ void TimeIntegration::buildKM_tbb_lambda(Eigen::SparseMatrix<double, Eigen::RowM for (auto mat : pbl->media) { std::cout << "\tprocessing " << *mat << '\n'; - tbb::parallel_for_each(mat->tag->elems.begin(), mat->tag->elems.end(), [&](Element *e) { - if (e->type() != ElType::HEX8) - return; - //std::cout << "processing element #" << e->no << "\n"; + tbb::parallel_for_each( + mat->tag->elems.begin(), mat->tag->elems.end(), + [&](Element *e) + { + if (e->type() != ElType::HEX8) + return; + // std::cout << "processing element #" << e->no << "\n"; - // ** Me matrix => Md vector - Eigen::MatrixXd Me = WaveTerm::buildM(*e); + // ** Me matrix => Md vector + Eigen::MatrixXd Me = WaveTerm::buildM(*e); - // ** Ke matrix => K matrix - Eigen::MatrixXd Ke = WaveTerm::buildK(*e, u); + // ** Ke matrix => K matrix + Eigen::MatrixXd Ke = WaveTerm::buildK(*e, u); - // assembly - tbb::spin_mutex::scoped_lock lock(mutex); + // assembly + tbb::spin_mutex::scoped_lock lock(mutex); - for (size_t ii = 0; ii < e->nodes.size(); ++ii) - { - Node *nodi = e->nodes[ii]; - for (size_t jj = 0; jj < e->nodes.size(); ++jj) + for (size_t ii = 0; ii < e->nodes.size(); ++ii) { - Node *nodj = e->nodes[jj]; - T.push_back(Eigen::Triplet<double>(nodi->row, nodj->row, (mat->c * mat->c) * Ke(ii, jj))); - Md[nodi->row] += Me(ii, jj); + Node *nodi = e->nodes[ii]; + for (size_t jj = 0; jj < e->nodes.size(); ++jj) + { + Node *nodj = e->nodes[jj]; + T.push_back(Eigen::Triplet<double>(nodi->row, nodj->row, (mat->c * mat->c) * Ke(ii, jj))); + Md[nodi->row] += Me(ii, jj); + } } - } - }); + }); } // Build, clean and turn to compressed row format K2.setFromTriplets(T.begin(), T.end()); @@ -194,7 +200,8 @@ void TimeIntegration::buildKM_tbb_lambda(Eigen::SparseMatrix<double, Eigen::RowM std::cout << "[cpu] " << chrono1 << '\n'; } -/*void TimeIntegration::build(MATTYPE type, Eigen::SparseMatrix<double, Eigen::RowMajor> &A2) +/* +void TimeIntegration::build(MATTYPE type, Eigen::SparseMatrix<double, Eigen::RowMajor> &A2) { tbb::spin_mutex mutex; tbb::global_control control(tbb::global_control::max_allowed_parallelism, nthreads); // TODO mettre ça ailleurs... @@ -207,24 +214,26 @@ void TimeIntegration::buildKM_tbb_lambda(Eigen::SparseMatrix<double, Eigen::RowM for (auto mat : pbl->media) { std::cout << "\tprocessing " << *mat << '\n'; - tbb::parallel_for_each(mat->tag->elems.begin(), mat->tag->elems.end(), - [&](Element *e) { - if (e->type() != ElType::HEX8) - return; - Eigen::MatrixXd Ae = e->build(type); - - // assembly - tbb::spin_mutex::scoped_lock lock(mutex); - for (size_t ii = 0; ii < e->nodes.size(); ++ii) - { - Node *nodi = e->nodes[ii]; - for (size_t jj = 0; jj < e->nodes.size(); ++jj) - { - Node *nodj = e->nodes[jj]; - T.push_back(Eigen::Triplet<double>(nodi->row, nodj->row, Ae(ii, jj))); - } - } - }); + tbb::parallel_for_each( + mat->tag->elems.begin(), mat->tag->elems.end(), + [&](Element *e) + { + if (e->type() != ElType::HEX8) + return; + Eigen::MatrixXd Ae = e->build(type); + + // assembly + tbb::spin_mutex::scoped_lock lock(mutex); + for (size_t ii = 0; ii < e->nodes.size(); ++ii) + { + Node *nodi = e->nodes[ii]; + for (size_t jj = 0; jj < e->nodes.size(); ++jj) + { + Node *nodj = e->nodes[jj]; + T.push_back(Eigen::Triplet<double>(nodi->row, nodj->row, Ae(ii, jj))); + } + } + }); } // Build, clean and turn to compressed row format A2.setFromTriplets(T.begin(), T.end()); @@ -234,7 +243,8 @@ void TimeIntegration::buildKM_tbb_lambda(Eigen::SparseMatrix<double, Eigen::RowM std::cout << "S (" << A2.rows() << "," << A2.cols() << ") nnz=" << A2.nonZeros() << "\n"; chrono1.read(); std::cout << "[cpu] " << chrono1 << '\n'; -}*/ +} +*/ void TimeIntegration::write(std::ostream &out) const { diff --git a/waves/src/wTimeIntegration.h b/waves/src/wTimeIntegration.h index b47326b970ee6c174b39abb039b28179146ca044..9a1c2828b134605cff06a3f780fe1a9ecde6d2f4 100644 --- a/waves/src/wTimeIntegration.h +++ b/waves/src/wTimeIntegration.h @@ -78,7 +78,7 @@ public: void setGUI(DisplayHook &hook) { dhook = &hook; } - //void build(tbox::MATTYPE type, Eigen::SparseMatrix<double, Eigen::RowMajor> &A2); + // void build(tbox::MATTYPE type, Eigen::SparseMatrix<double, Eigen::RowMajor> &A2); void stop() { stopit = true; } @@ -89,4 +89,4 @@ public: } // namespace waves -#endif //WTIMEINTEGRATION_H +#endif // WTIMEINTEGRATION_H diff --git a/waves/src/wWaveTerm.h b/waves/src/wWaveTerm.h index 6ad3a384375d2c3c2142294f751f1f0c1da9ddfd..4fa15e3c1188ea42a03d03148b3ba44e30a531cd 100644 --- a/waves/src/wWaveTerm.h +++ b/waves/src/wWaveTerm.h @@ -38,4 +38,4 @@ public: }; } // namespace waves -#endif //WWAVETERM_H +#endif // WWAVETERM_H diff --git a/waves/src/waves.h b/waves/src/waves.h index 46f05cca61dd4d9114762d381ff181d8c665a971..b9839f27921339dae51b4c6312102178ab6ebe0e 100644 --- a/waves/src/waves.h +++ b/waves/src/waves.h @@ -48,4 +48,4 @@ class RungeKutta; class Newmark; } // namespace waves -#endif //WAVES_H +#endif // WAVES_H