Skip to content
Snippets Groups Projects
Commit 6da14526 authored by Adrien Crovato's avatar Adrien Crovato
Browse files

Add verbosity level

parent 0ec92c71
No related branches found
No related tags found
1 merge request!6amfe v1.0.5
Pipeline #6200 passed
...@@ -111,7 +111,7 @@ double FleuryLS::run() ...@@ -111,7 +111,7 @@ double FleuryLS::run()
double phit = fct.eval(h); double phit = fct.eval(h);
fevalIt = 2; fevalIt = 2;
if (verbose > 2) if (verbose > 3)
{ {
std::cout << "Starting Backeting \n"; std::cout << "Starting Backeting \n";
std::cout << "\t" << std::setprecision(16) << "phi1(" << 0 << ") = " << phi1 << '\n'; std::cout << "\t" << std::setprecision(16) << "phi1(" << 0 << ") = " << phi1 << '\n';
...@@ -128,14 +128,14 @@ double FleuryLS::run() ...@@ -128,14 +128,14 @@ double FleuryLS::run()
{ {
if (h > hU) if (h > hU)
{ {
if (verbose > 2) if (verbose > 3)
{ {
std::cout << "Positive slope detected (in ascending bracketing #1)!\n"; std::cout << "Positive slope detected (in ascending bracketing #1)!\n";
} }
if (revAllowed) if (revAllowed)
{ {
if (verbose > 2) if (verbose > 3)
{ {
std::cout << "Reverse Direction of Line Search (in ascending bracketing #1)!" std::cout << "Reverse Direction of Line Search (in ascending bracketing #1)!"
<< "\n"; << "\n";
...@@ -146,7 +146,7 @@ double FleuryLS::run() ...@@ -146,7 +146,7 @@ double FleuryLS::run()
} }
else else
{ {
if (verbose > 2) if (verbose > 3)
{ {
std::cout << "Error in ascending bracketing #1:\n" std::cout << "Error in ascending bracketing #1:\n"
<< std::setprecision(16) << "a1=" << 0 << " a2=" << h << " a3 =" << 2.0 * h << '\n' << std::setprecision(16) << "a1=" << 0 << " a2=" << h << " a3 =" << 2.0 * h << '\n'
...@@ -164,7 +164,7 @@ double FleuryLS::run() ...@@ -164,7 +164,7 @@ double FleuryLS::run()
phit = fct.eval(2 * h); phit = fct.eval(2 * h);
fevalIt++; fevalIt++;
if (verbose > 2) if (verbose > 3)
{ {
std::cout << "Ascending bracketing iteration # " << nB << ": \n"; std::cout << "Ascending bracketing iteration # " << nB << ": \n";
std::cout << "\t" std::cout << "\t"
...@@ -185,14 +185,14 @@ double FleuryLS::run() ...@@ -185,14 +185,14 @@ double FleuryLS::run()
{ {
if (h < hL) if (h < hL)
{ {
if (verbose > 2) if (verbose > 3)
{ {
std::cout << "Positive slope detected (in descending bracketing #2)!\n"; std::cout << "Positive slope detected (in descending bracketing #2)!\n";
} }
if (revAllowed) if (revAllowed)
{ {
if (verbose > 2) if (verbose > 3)
{ {
std::cout << "Reverse Direction of Line Search (in descending bracketing #2) !" std::cout << "Reverse Direction of Line Search (in descending bracketing #2) !"
<< "\n"; << "\n";
...@@ -203,7 +203,7 @@ double FleuryLS::run() ...@@ -203,7 +203,7 @@ double FleuryLS::run()
} }
else else
{ {
if (verbose > 2) if (verbose > 3)
{ {
std::cout << "Error in descending bracketing #2:\n" std::cout << "Error in descending bracketing #2:\n"
<< std::setprecision(16) << "a1=" << 0 << " a2=" << h << " a3 =" << 2.0 * h << '\n' << std::setprecision(16) << "a1=" << 0 << " a2=" << h << " a3 =" << 2.0 * h << '\n'
...@@ -220,7 +220,7 @@ double FleuryLS::run() ...@@ -220,7 +220,7 @@ double FleuryLS::run()
phi3 = phit; phi3 = phit;
phit = fct.eval(h / 2); phit = fct.eval(h / 2);
fevalIt++; fevalIt++;
if (verbose > 2) if (verbose > 3)
{ {
std::cout << "Descending bracketing iteration # " << nB << ": \n"; std::cout << "Descending bracketing iteration # " << nB << ": \n";
std::cout << "\t" std::cout << "\t"
...@@ -241,7 +241,7 @@ double FleuryLS::run() ...@@ -241,7 +241,7 @@ double FleuryLS::run()
double a3 = 2 * h; double a3 = 2 * h;
double a4 = h * (4 * phi2 - 3 * phi1 - phi3) / (4 * phi2 - 2 * phi1 - 2 * phi3); double a4 = h * (4 * phi2 - 3 * phi1 - phi3) / (4 * phi2 - 2 * phi1 - 2 * phi3);
if (verbose > 2) if (verbose > 3)
{ {
std::cout << "Backeting succeeds in " << nB << " iterations : \n"; std::cout << "Backeting succeeds in " << nB << " iterations : \n";
std::cout << "\t" << std::setprecision(16) << "phi1(" << a1 << ") = " << phi1 << '\n'; std::cout << "\t" << std::setprecision(16) << "phi1(" << a1 << ") = " << phi1 << '\n';
...@@ -276,7 +276,7 @@ double FleuryLS::run() ...@@ -276,7 +276,7 @@ double FleuryLS::run()
throw std::runtime_error(msg.str()); throw std::runtime_error(msg.str());
} }
if (verbose > 2) if (verbose > 3)
{ {
std::cout << "Line search iteration # " << nLS << ": \n"; std::cout << "Line search iteration # " << nLS << ": \n";
std::cout << "\t" << std::setprecision(16) << "phi1(" << a1 << ") = " << phi1 << '\n'; std::cout << "\t" << std::setprecision(16) << "phi1(" << a1 << ") = " << phi1 << '\n';
...@@ -319,7 +319,7 @@ double FleuryLS::run() ...@@ -319,7 +319,7 @@ double FleuryLS::run()
A = (a2 - a3) * phi1 + (a3 - a1) * phi2 + (a1 - a2) * phi3; A = (a2 - a3) * phi1 + (a3 - a1) * phi2 + (a1 - a2) * phi3;
if (verbose > 2) if (verbose > 3)
{ {
std::cout << "\t" << std::setprecision(16) << "|A| = " << fabs(A) << "><" << tol << '\n'; std::cout << "\t" << std::setprecision(16) << "|A| = " << fabs(A) << "><" << tol << '\n';
} }
...@@ -337,7 +337,7 @@ double FleuryLS::run() ...@@ -337,7 +337,7 @@ double FleuryLS::run()
(A); (A);
} }
if (verbose > 2) if (verbose > 3)
{ {
std::cout << "Line search succeeds in " << nLS << " iterations : \n"; std::cout << "Line search succeeds in " << nLS << " iterations : \n";
std::cout << "\t" << std::setprecision(16) << "|A| = " << fabs(A) << '\n'; std::cout << "\t" << std::setprecision(16) << "|A| = " << fabs(A) << '\n';
......
...@@ -32,10 +32,10 @@ using namespace tbox; ...@@ -32,10 +32,10 @@ using namespace tbox;
MshDeform::MshDeform(std::shared_ptr<MshData> _msh, MshDeform::MshDeform(std::shared_ptr<MshData> _msh,
std::shared_ptr<tbox::LinearSolver> _linsol, std::shared_ptr<tbox::LinearSolver> _linsol,
int _nDim, int nthrds) : wSharedObject(), int _nDim, int nthrds, int vrb) : wSharedObject(),
nDim(_nDim), nthreads(nthrds), nDim(_nDim), nthreads(nthrds), verbose(vrb),
field(false), fixed(false), moving(false), field(false), fixed(false), moving(false),
msh(_msh), linsol(_linsol) msh(_msh), linsol(_linsol)
{ {
// Check problem dimension // Check problem dimension
if (nDim != 2 && nDim != 3) if (nDim != 2 && nDim != 3)
...@@ -453,19 +453,24 @@ void MshDeform::deform() ...@@ -453,19 +453,24 @@ void MshDeform::deform()
Eigen::VectorXd f = Eigen::VectorXd::Zero(nDim * mshSize), q = Eigen::VectorXd::Zero(nDim * mshSize); Eigen::VectorXd f = Eigen::VectorXd::Zero(nDim * mshSize), q = Eigen::VectorXd::Zero(nDim * mshSize);
// Build stiffness matrix and RHS // Build stiffness matrix and RHS
std::cout << "- Deforming mesh:\n" if (verbose > 0)
<< "assembling matrices... " << std::flush; std::cout << "- Deforming mesh:\n"
<< "assembling matrices... " << std::flush;
this->build(K); this->build(K);
this->build(f); this->build(f);
std::cout << "done" << std::endl; if (verbose > 0)
std::cout << "done" << std::endl;
// Solve the SoE // Solve the SoE
std ::cout << "solving equations... " << std::flush; if (verbose > 0)
std ::cout << "solving equations... " << std::flush;
Eigen::Map<Eigen::VectorXd> f_(f.data(), f.size()), q_(q.data(), q.size()); Eigen::Map<Eigen::VectorXd> f_(f.data(), f.size()), q_(q.data(), q.size());
linsol->compute(K, f_, q_); linsol->compute(K, f_, q_);
std::cout << "done (#it: " << linsol->getIterations() << ", error: " << std::scientific << linsol->getError() << std::fixed << ")" << std::endl; if (verbose > 0)
std::cout << "done (#it: " << linsol->getIterations() << ", error: " << std::scientific << linsol->getError() << std::fixed << ")" << std::endl;
// Update position // Update position
std ::cout << "updating mesh... " << std::flush; if (verbose > 0)
std ::cout << "updating mesh... " << std::flush;
for (auto n : msh->nodes) for (auto n : msh->nodes)
{ {
for (int m = 0; m < nDim; m++) for (int m = 0; m < nDim; m++)
...@@ -486,8 +491,9 @@ void MshDeform::deform() ...@@ -486,8 +491,9 @@ void MshDeform::deform()
e->update(); e->update();
for (auto e : intBndElems) for (auto e : intBndElems)
e->update(); e->update();
std::cout << "done\n" if (verbose > 0)
<< std::endl; std::cout << "done\n"
<< std::endl;
} }
/** /**
......
...@@ -37,6 +37,7 @@ private: ...@@ -37,6 +37,7 @@ private:
size_t mshSize; ///< number of nodes in the mesh size_t mshSize; ///< number of nodes in the mesh
int nDim; ///< dimension of the problem (2 or 3) int nDim; ///< dimension of the problem (2 or 3)
int nthreads; ///< number of threads int nthreads; ///< number of threads
int verbose; ///< verbosity level
std::vector<int> rows; ///< unknown local index std::vector<int> rows; ///< unknown local index
bool field; ///< flag to check if field has been added bool field; ///< flag to check if field has been added
bool fixed; ///< flag to check if at least one fixed boundary has been added bool fixed; ///< flag to check if at least one fixed boundary has been added
...@@ -64,7 +65,7 @@ public: ...@@ -64,7 +65,7 @@ public:
std::shared_ptr<MshData> msh; ///< mesh std::shared_ptr<MshData> msh; ///< mesh
std::shared_ptr<tbox::LinearSolver> linsol; ///< linear (inner) solver std::shared_ptr<tbox::LinearSolver> linsol; ///< linear (inner) solver
MshDeform(std::shared_ptr<MshData> _msh, std::shared_ptr<tbox::LinearSolver> _linsol, int _nDim, int nthrds = 1); MshDeform(std::shared_ptr<MshData> _msh, std::shared_ptr<tbox::LinearSolver> _linsol, int _nDim, int nthrds = 1, int vrb = 1);
virtual ~MshDeform() { std::cout << "~MshDeform()\n"; } virtual ~MshDeform() { std::cout << "~MshDeform()\n"; }
void setField(std::string const &fldName); void setField(std::string const &fldName);
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment