Skip to content
Snippets Groups Projects
Commit ab86ce83 authored by Sebastien Blaise's avatar Sebastien Blaise
Browse files

Mesh Optimizer: modified ncurses gui to allow resizing

parent ee690f3c
Branches
Tags
No related merge requests found
...@@ -80,8 +80,6 @@ MeshOpt::MeshOpt(const std::map<MElement*,GEntity*> &element2entity, ...@@ -80,8 +80,6 @@ MeshOpt::MeshOpt(const std::map<MElement*,GEntity*> &element2entity,
} }
_objFunc = &_allObjFunc[0]; _objFunc = &_allObjFunc[0];
if (par.nCurses){ if (par.nCurses){
int nbRow, nbCol;
mvgetScreenSize(nbRow, nbCol);
int minCol = 0; int minCol = 0;
for (int i=0; i < _objFunc->names().size(); i++){ for (int i=0; i < _objFunc->names().size(); i++){
if (i > 0) if (i > 0)
...@@ -91,7 +89,9 @@ MeshOpt::MeshOpt(const std::map<MElement*,GEntity*> &element2entity, ...@@ -91,7 +89,9 @@ MeshOpt::MeshOpt(const std::map<MElement*,GEntity*> &element2entity,
} }
minCol = std::max(minCol, 96); minCol = std::max(minCol, 96);
int minRow = std::max(34, 34+(int)_objFunc->names().size()-5); int minRow = std::max(34, 34+(int)_objFunc->names().size()-5);
if (nbRow < minRow || nbCol < minCol){ int nbRow, nbCol;
mvgetScreenSize(nbRow, nbCol);
while (nbRow < minRow || nbCol < minCol){
for (int i=0; i<nbRow; i++){ for (int i=0; i<nbRow; i++){
mvfillRow(i,' '); mvfillRow(i,' ');
} }
...@@ -99,11 +99,19 @@ MeshOpt::MeshOpt(const std::map<MElement*,GEntity*> &element2entity, ...@@ -99,11 +99,19 @@ MeshOpt::MeshOpt(const std::map<MElement*,GEntity*> &element2entity,
mvprintCenter(firstRow,"Given the number of contributions to the objective function, ncurses"); mvprintCenter(firstRow,"Given the number of contributions to the objective function, ncurses");
mvprintCenter(firstRow+1,"enhanced interface requires a terminal window of minimal size"); mvprintCenter(firstRow+1,"enhanced interface requires a terminal window of minimal size");
mvprintCenter(firstRow+2,"%4ix%4i characters. Yours is %4ix%4i, try resizing the window", minRow, minCol, nbRow, nbCol); mvprintCenter(firstRow+2,"%4ix%4i characters. Yours is %4ix%4i, try resizing the window", minRow, minCol, nbRow, nbCol);
mvprintCenter(firstRow+3,"or disabling the ncurses interface."); mvprintCenter(firstRow+3,"then press SPACE.");
mvpause(); mvpause();
mvterminate(); for (int i=0; i<nbRow; i++){
Msg::SetCallback(NULL); mvfillRow(i,' ');
Msg::Exit(EXIT_FAILURE); }
mvbold(true);
mvprintCenter(0, "OPTIMIZING MESH");
mvfillRow(1,'-');
mvfillRow(10,'-');
mvfillRow(20,'-');
mvfillRow(27,'-');
mvbold(false);
mvgetScreenSize(nbRow, nbCol);
} }
} }
} }
...@@ -157,7 +165,7 @@ void MeshOpt::printProgress(const alglib::real_1d_array &x, double Obj) ...@@ -157,7 +165,7 @@ void MeshOpt::printProgress(const alglib::real_1d_array &x, double Obj)
sprintf(_iterHistory.back(), _objFunc->minMaxStr().c_str()); sprintf(_iterHistory.back(), _objFunc->minMaxStr().c_str());
mvprintList(22, 5, _iterHistory, 1); mvprintList(22, 5, _iterHistory, 1);
} }
if ((_verbose > 2) && (_iter % _intervDisplay == 0)) if ((_verbose > 2) && (_iter % _intervDisplay == 0 || _nCurses))
Msg::Info(("--> Iteration %3d --- OBJ %12.5E (relative decrease = %12.5E)" + Msg::Info(("--> Iteration %3d --- OBJ %12.5E (relative decrease = %12.5E)" +
_objFunc->minMaxStr()).c_str(), _iter, Obj, Obj/_initObj); _objFunc->minMaxStr()).c_str(), _iter, Obj, Obj/_initObj);
} }
...@@ -309,7 +317,10 @@ int MeshOpt::optimize(const MeshOptParameters &par) ...@@ -309,7 +317,10 @@ int MeshOpt::optimize(const MeshOptParameters &par)
} }
mvprintList(19, -8, _optHistory, 2); mvprintList(19, -8, _optHistory, 2);
} }
if (_verbose > 2) Msg::Info("--- Optimization run %d", iBar); if (_verbose > 2){
Msg::Info("--- Optimization run %d", iBar);
Msg::Info("%s", _objFunc->minMaxStr().c_str());
}
_objFunc->updateParameters(); _objFunc->updateParameters();
runOptim(x, gradObj, par.pass[_iPass].maxOptIter, iBar); runOptim(x, gradObj, par.pass[_iPass].maxOptIter, iBar);
_objFunc->updateMinMax(); _objFunc->updateMinMax();
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment