From 1e6f7688c0939e089e60fc80b87bddd3b9d7c0b2 Mon Sep 17 00:00:00 2001 From: Christophe Geuzaine <cgeuzaine@ulg.ac.be> Date: Sat, 16 Oct 2004 22:15:17 +0000 Subject: [PATCH] added an option to specify the maximum delay Gmsh will wait for a solver to respond --- Common/Context.h | 5 +++++ Common/DefaultOptions.h | 3 +++ Common/Options.cpp | 13 ++++++++++++- Common/Options.h | 1 + Fltk/Callbacks.cpp | 3 ++- Fltk/GUI.cpp | 13 +++++++------ Fltk/GmshServer.cpp | 9 ++++++--- Fltk/Makefile | 4 ++-- 8 files changed, 38 insertions(+), 13 deletions(-) diff --git a/Common/Context.h b/Common/Context.h index 047e3b64fa..a02325eb66 100644 --- a/Common/Context.h +++ b/Common/Context.h @@ -199,6 +199,11 @@ public : double anim_delay ; }post; + // solver options + struct{ + int max_delay ; + }solver; + // print options struct{ int format; diff --git a/Common/DefaultOptions.h b/Common/DefaultOptions.h index 5799cd03c8..5773fb07ba 100644 --- a/Common/DefaultOptions.h +++ b/Common/DefaultOptions.h @@ -865,6 +865,9 @@ StringXNumber MeshOptions_Number[] = { } ; StringXNumber SolverOptions_Number[] = { + { F|O, "MaximumDelay" , opt_solver_max_delay , 4.0 , + "Maximum delay allowed for solver response (in seconds)" }, + { F|O, "ClientServer0" , opt_solver_client_server0 , 1. , "Connect solver 0 to the Gmsh server" }, { F|O, "MergeViews0" , opt_solver_merge_views0 , 1. , diff --git a/Common/Options.cpp b/Common/Options.cpp index 28369836cf..a988edd6cf 100644 --- a/Common/Options.cpp +++ b/Common/Options.cpp @@ -1,4 +1,4 @@ -// $Id: Options.cpp,v 1.189 2004-10-15 02:30:50 geuzaine Exp $ +// $Id: Options.cpp,v 1.190 2004-10-16 22:15:16 geuzaine Exp $ // // Copyright (C) 1997-2004 C. Geuzaine, J.-F. Remacle // @@ -4024,6 +4024,17 @@ double opt_mesh_cpu_time(OPT_ARGS_NUM) return s[13] + s[14] + s[15]; } +double opt_solver_max_delay(OPT_ARGS_NUM) +{ + if(action & GMSH_SET) + CTX.solver.max_delay = (val >= 0) ? (int)val : 0; +#if defined(HAVE_FLTK) + if(WID && (action & GMSH_GUI)) + WID->solver_value[0]->value(CTX.solver.max_delay); +#endif + return CTX.solver.max_delay; +} + double opt_solver_client_server(OPT_ARGS_NUM) { #if defined(HAVE_FLTK) diff --git a/Common/Options.h b/Common/Options.h index 6ad335743e..63a711c79d 100644 --- a/Common/Options.h +++ b/Common/Options.h @@ -409,6 +409,7 @@ double opt_mesh_nb_hexahedra(OPT_ARGS_NUM); double opt_mesh_nb_prisms(OPT_ARGS_NUM); double opt_mesh_nb_pyramids(OPT_ARGS_NUM); double opt_mesh_cpu_time(OPT_ARGS_NUM); +double opt_solver_max_delay(OPT_ARGS_NUM); double opt_solver_client_server(OPT_ARGS_NUM); double opt_solver_client_server0(OPT_ARGS_NUM); double opt_solver_client_server1(OPT_ARGS_NUM); diff --git a/Fltk/Callbacks.cpp b/Fltk/Callbacks.cpp index 71482d576c..57d79b2206 100644 --- a/Fltk/Callbacks.cpp +++ b/Fltk/Callbacks.cpp @@ -1,4 +1,4 @@ -// $Id: Callbacks.cpp,v 1.282 2004-10-15 02:30:50 geuzaine Exp $ +// $Id: Callbacks.cpp,v 1.283 2004-10-16 22:15:16 geuzaine Exp $ // // Copyright (C) 1997-2004 C. Geuzaine, J.-F. Remacle // @@ -1046,6 +1046,7 @@ void solver_options_cb(CALLBACK_ARGS) void solver_options_ok_cb(CALLBACK_ARGS) { + opt_solver_max_delay(0, GMSH_SET, WID->solver_value[0]->value()); } // Post options diff --git a/Fltk/GUI.cpp b/Fltk/GUI.cpp index 429f4b6bec..941fbc3f6c 100644 --- a/Fltk/GUI.cpp +++ b/Fltk/GUI.cpp @@ -1,4 +1,4 @@ -// $Id: GUI.cpp,v 1.362 2004-10-16 19:24:18 geuzaine Exp $ +// $Id: GUI.cpp,v 1.363 2004-10-16 22:15:17 geuzaine Exp $ // // Copyright (C) 1997-2004 C. Geuzaine, J.-F. Remacle // @@ -2226,11 +2226,12 @@ void GUI::create_option_window() { { Fl_Group *o = new Fl_Group(L + WB, WB + BH, width - 2 * WB, height - 2 * WB - BH, "General"); - - Fl_Box *text = new Fl_Box(FL_NO_BOX, L + 2 * WB, 3 * WB + 1 * BH, width - 4 * WB, 2 * BH, - "There are no global solver options available yet.\n\n" - "To define your own solver interface, you have to edit the option file."); - text->align(FL_ALIGN_LEFT | FL_ALIGN_TOP | FL_ALIGN_INSIDE | FL_ALIGN_WRAP); + + solver_value[0] = new Fl_Value_Input(L + 2 * WB, 2 * WB + 1 * BH, IW, BH, "Maximum delay for solver response"); + solver_value[0]->minimum(0); + solver_value[0]->maximum(10); + solver_value[0]->step(1); + solver_value[0]->align(FL_ALIGN_RIGHT); o->end(); } diff --git a/Fltk/GmshServer.cpp b/Fltk/GmshServer.cpp index a74cbd1369..66b36c45cd 100644 --- a/Fltk/GmshServer.cpp +++ b/Fltk/GmshServer.cpp @@ -1,4 +1,4 @@ -/* $Id: GmshServer.cpp,v 1.17 2004-05-22 01:24:17 geuzaine Exp $ */ +/* $Id: GmshServer.cpp,v 1.18 2004-10-16 22:15:17 geuzaine Exp $ */ /* * Copyright (C) 1997-2004 C. Geuzaine, J.-F. Remacle * @@ -28,7 +28,9 @@ */ // This is a hacked version using the Gmsh function SystemCall() -// instead system() +// instead system() and using CTX.solver.max_delay in select() +#include "Context.h" +extern Context_T CTX; void SystemCall(char *str); #include <stdio.h> @@ -127,7 +129,8 @@ int Gmsh_StartClient(char *command, char *sockname) /* Watch s to see when it has input. */ /* Wait up to 4 seconds */ - tv.tv_sec = 4; + //tv.tv_sec = 4; + tv.tv_sec = CTX.solver.max_delay; tv.tv_usec = 0; FD_ZERO(&rfds); FD_SET(s, &rfds); diff --git a/Fltk/Makefile b/Fltk/Makefile index 12ab7c0576..4cd75bf4e5 100644 --- a/Fltk/Makefile +++ b/Fltk/Makefile @@ -1,4 +1,4 @@ -# $Id: Makefile,v 1.57 2004-09-25 06:16:13 geuzaine Exp $ +# $Id: Makefile,v 1.58 2004-10-16 22:15:17 geuzaine Exp $ # # Copyright (C) 1997-2004 C. Geuzaine, J.-F. Remacle # @@ -131,7 +131,7 @@ Colorbar_Window.o: Colorbar_Window.cpp ../Common/Gmsh.h \ ../Common/GmshUI.h ../Numeric/Numeric.h GUI.h Opengl_Window.h \ Colorbar_Window.h ../Common/ColorTable.h File_Picker.h \ ../Common/Context.h -GmshServer.o: GmshServer.cpp +GmshServer.o: GmshServer.cpp ../Common/Context.h ../DataStr/List.h Solvers.o: Solvers.cpp ../Common/Gmsh.h ../Common/Message.h \ ../DataStr/Malloc.h ../DataStr/List.h ../DataStr/Tree.h \ ../DataStr/avl.h ../DataStr/Tools.h ../utils/solvers/GmshClient.h \ -- GitLab