diff --git a/CMakeLists.txt b/CMakeLists.txt index 0aa565aff8e0e55e191e373422a61b0030d1a5e4..7f9a2265eb9ac6dfc3d50895f05445557dc8d28d 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -43,6 +43,7 @@ option(ENABLE_MSVC_STATIC_RUNTIME "Use static Visual C++ runtime" OFF) option(ENABLE_NATIVE_FILE_CHOOSER "Enable native file chooser in GUI" ON) option(ENABLE_NETGEN "Enable Netgen mesh generator" ON) option(ENABLE_OCC "Enable Open CASCADE geometrical models" ON) +option(ENABLE_ONELAB "Enable OneLab solver interface" ON) option(ENABLE_OSMESA "Use OSMesa for offscreen rendering" OFF) option(ENABLE_PARSER "Build the GEO file parser" ON) option(ENABLE_PETSC "Enable PETSc linear algebra solvers" ON) @@ -804,6 +805,10 @@ if(ENABLE_OSMESA) endif(OSMESA_LIB) endif(ENABLE_OSMESA) +if(ENABLE_ONELAB) + set_config_option(HAVE_ONELAB "OneLab") +endif(ENABLE_ONELAB) + check_function_exists(vsnprintf HAVE_VSNPRINTF) if(NOT HAVE_VSNPRINTF) set_config_option(HAVE_NO_VSNPRINTF "NoVsnprintf") diff --git a/Common/Gmsh.cpp b/Common/Gmsh.cpp index c5d3892fdb85203a94fd30864976dd1a2dad765c..844fd7a393ec664b10e75e8f3bd90640ddf92e67 100644 --- a/Common/Gmsh.cpp +++ b/Common/Gmsh.cpp @@ -16,9 +16,12 @@ #include "CommandLine.h" #include "OS.h" #include "Context.h" -#include "onelab.h" #include "robustPredicates.h" +#if defined(HAVE_ONELAB) +#include "onelab.h" +#endif + #if defined(HAVE_MESH) #include "Generator.h" #include "Field.h" @@ -251,10 +254,12 @@ int GmshFLTK(int argc, char **argv) } // listen to external solvers +#if defined(HAVE_ONELAB) if(CTX::instance()->solver.listen){ onelab::localNetworkClient *c = new onelab::localNetworkClient("Listen", ""); c->run(""); } +#endif // loop return FlGui::instance()->run(); diff --git a/Common/GmshConfig.h.in b/Common/GmshConfig.h.in index cbf5dcd9bbb911f6718b6714483673917077e1df..9b06235418626ed7a8e6c76d0554d1c443b15c33 100644 --- a/Common/GmshConfig.h.in +++ b/Common/GmshConfig.h.in @@ -41,6 +41,7 @@ #cmakedefine HAVE_NO_STDINT_H #cmakedefine HAVE_NO_VSNPRINTF #cmakedefine HAVE_OCC +#cmakedefine HAVE_ONELAB #cmakedefine HAVE_OPENGL #cmakedefine HAVE_OSMESA #cmakedefine HAVE_PARSER diff --git a/Common/GmshMessage.cpp b/Common/GmshMessage.cpp index f959749a0e8cc626993413bccf34157d5efcbc07..36a11730ff7fe030cda6c4f72a923694964e6a54 100644 --- a/Common/GmshMessage.cpp +++ b/Common/GmshMessage.cpp @@ -10,13 +10,16 @@ #include "GmshConfig.h" #include "GmshMessage.h" #include "GmshSocket.h" -#include "onelab.h" #include "Gmsh.h" #include "GModel.h" #include "Options.h" #include "Context.h" #include "OS.h" +#if defined(HAVE_ONELAB) +#include "onelab.h" +#endif + #if defined(HAVE_MPI) #include <mpi.h> #endif @@ -47,8 +50,10 @@ GmshMessage *Msg::_callback = 0; std::string Msg::_commandLine; std::string Msg::_launchDate; GmshClient *Msg::_client = 0; +#if defined(HAVE_ONELAB) onelab::client *Msg::_onelabClient = 0; onelab::server *onelab::server::_server = 0; +#endif #if defined(HAVE_NO_VSNPRINTF) static int vsnprintf(char *str, size_t size, const char *fmt, va_list ap) @@ -579,6 +584,7 @@ int Msg::GetAnswer(const char *question, int defaultval, const char *zero, void Msg::InitializeOnelab(const std::string &name, const std::string &sockname) { +#if defined(HAVE_ONELAB) if(_onelabClient) delete _onelabClient; if (sockname.empty()) _onelabClient = new onelab::localClient(name); @@ -587,6 +593,7 @@ void Msg::InitializeOnelab(const std::string &name, const std::string &sockname) _onelabClient = c; _client = c->getGmshClient(); } +#endif } void Msg::ExchangeOnelabParameter(const std::string &key, @@ -594,6 +601,7 @@ void Msg::ExchangeOnelabParameter(const std::string &key, std::map<std::string, std::vector<double> > &fopt, std::map<std::string, std::vector<std::string> > &copt) { +#if defined(HAVE_ONELAB) if(!_onelabClient || val.empty()) return; std::string name(key); @@ -638,15 +646,18 @@ void Msg::ExchangeOnelabParameter(const std::string &key, if(copt.count("Loop")) ps[0].setAttribute("Loop", copt["Loop"][0]); if(copt.count("Graph")) ps[0].setAttribute("Graph", copt["Graph"][0]); _onelabClient->set(ps[0]); +#endif } void Msg::FinalizeOnelab() { +#if defined(HAVE_ONELAB) if(_onelabClient){ delete _onelabClient; _onelabClient = 0; _client = 0; } +#endif } void Msg::Barrier() diff --git a/Common/GmshRemote.cpp b/Common/GmshRemote.cpp index d26315466c822ba115a757eb3165a11fb6dba561..e2444f12f690aa22dded96b03963a525c164938f 100644 --- a/Common/GmshRemote.cpp +++ b/Common/GmshRemote.cpp @@ -4,19 +4,20 @@ // bugs and problems to <gmsh@geuz.org>. #include <sstream> +#include "GmshConfig.h" #include "GmshMessage.h" + +#if defined(HAVE_ONELAB) && defined(HAVE_POST) + #include "GmshSocket.h" #include "OpenFile.h" #include "OS.h" #include "VertexArray.h" #include "GmshRemote.h" - -#if defined(HAVE_POST) #include "PView.h" #include "PViewOptions.h" #include "PViewData.h" #include "PViewDataRemote.h" -#endif #if defined(HAVE_MPI) #include <mpi.h> @@ -31,7 +32,6 @@ static void computeAndSendVertexArrays(GmshClient *client, bool compute=true) { -#if defined(HAVE_POST) for(unsigned int i = 0; i < PView::list.size(); i++){ PView *p = PView::list[i]; if(compute) p->fillVertexArrays(); @@ -56,10 +56,9 @@ static void computeAndSendVertexArrays(GmshClient *client, bool compute=true) } } } -#endif } -#if defined(HAVE_POST) && defined(HAVE_MPI) +#if defined(HAVE_MPI) // This version sends VArrays using MPI static void computeAndSendVertexArrays() { @@ -133,7 +132,7 @@ static void addToVertexArrays(int length, const char* bytes, int swap) static void gatherAndSendVertexArrays(GmshClient* client, bool swap) { -#if defined(HAVE_POST) && defined(HAVE_MPI) +#if defined(HAVE_MPI) int rank = Msg::GetCommRank(); int nbDaemon = Msg::GetCommSize(); // tell every node to start computing @@ -290,3 +289,12 @@ int GmshRemote() return 0; } + +#else + +int GmshRemote() +{ + Msg::Error("GmshRemote requires Post and OneLab modules"); +} + +#endif diff --git a/Fltk/FlGui.cpp b/Fltk/FlGui.cpp index 240ff5039f58fd9d96b43c970de2b52ce30f8733..162159ab421268ba0bda0edf056e89e0daa34a66 100644 --- a/Fltk/FlGui.cpp +++ b/Fltk/FlGui.cpp @@ -285,7 +285,7 @@ FlGui::FlGui(int argc, char **argv) : _openedThroughMacFinder(false) geoContext = new geometryContextWindow(CTX::instance()->deltaFontSize); meshContext = new meshContextWindow(CTX::instance()->deltaFontSize); about = new aboutWindow(); -#if (FL_MAJOR_VERSION == 1) && (FL_MINOR_VERSION == 3) +#if defined(HAVE_ONELAB) && (FL_MAJOR_VERSION == 1) && (FL_MINOR_VERSION == 3) onelab = new onelabWindow(CTX::instance()->deltaFontSize); #endif @@ -821,7 +821,7 @@ void FlGui::storeCurrentWindowsInfo() CTX::instance()->manipPosition[1] = manip->win->y(); CTX::instance()->ctxPosition[0] = geoContext->win->x(); CTX::instance()->ctxPosition[1] = meshContext->win->y(); -#if (FL_MAJOR_VERSION == 1) && (FL_MINOR_VERSION == 3) +#if defined(HAVE_ONELAB) && (FL_MAJOR_VERSION == 1) && (FL_MINOR_VERSION == 3) CTX::instance()->solverPosition[0] = onelab->x(); CTX::instance()->solverPosition[1] = onelab->y(); #endif @@ -901,7 +901,7 @@ void window_cb(Fl_Widget *w, void *data) FlGui::instance()->geoContext->win->show(); if(FlGui::instance()->meshContext->win->shown()) FlGui::instance()->meshContext->win->show(); -#if (FL_MAJOR_VERSION == 1) && (FL_MINOR_VERSION == 3) +#if defined(HAVE_ONELAB) && (FL_MAJOR_VERSION == 1) && (FL_MINOR_VERSION == 3) if(FlGui::instance()->onelab->shown()) FlGui::instance()->onelab->show(); #endif diff --git a/Fltk/FlGui.h b/Fltk/FlGui.h index 3388bb5a8b6876754468fd2aed94ef9eec977384..42211708a2025f9374abe0542324b5cd22cca8e0 100644 --- a/Fltk/FlGui.h +++ b/Fltk/FlGui.h @@ -63,9 +63,7 @@ class FlGui{ geometryContextWindow *geoContext; meshContextWindow *meshContext; aboutWindow *about; -#if (FL_MAJOR_VERSION == 1) && (FL_MINOR_VERSION == 3) onelabWindow *onelab; -#endif public: FlGui(int argc, char **argv); ~FlGui(){} diff --git a/Fltk/menuWindow.cpp b/Fltk/menuWindow.cpp index 4b4e8e451aa23d96ad6098f832f44894229202a5..ef667da9a34ba4b4a77d43d39783f3c699ee79f6 100644 --- a/Fltk/menuWindow.cpp +++ b/Fltk/menuWindow.cpp @@ -172,6 +172,7 @@ static void file_clear_cb(Fl_Widget *w, void *data) static void file_remote_cb(Fl_Widget *w, void *data) { +#if defined(HAVE_ONELAB) onelab::localNetworkClient *c; onelab::server::citer it = onelab::server::instance()->findClient("GmshRemote"); if(it == onelab::server::instance()->lastClient()){ @@ -215,6 +216,7 @@ static void file_remote_cb(Fl_Widget *w, void *data) server->SendString(GmshSocket::GMSH_SPEED_TEST, "Speed test"); } } +#endif } static void file_window_cb(Fl_Widget *w, void *data) @@ -2330,12 +2332,14 @@ static Fl_Menu_Item bar_table[] = { {"M&erge...", FL_CTRL+FL_SHIFT+'o', (Fl_Callback *)file_merge_cb, 0}, {"Watch Pattern...", 0, (Fl_Callback *)file_watch_cb, 0}, {"&Clear", 0, (Fl_Callback *)file_clear_cb, 0, FL_MENU_DIVIDER}, +#if defined(HAVE_ONELAB) {"Remote", 0, 0, 0, FL_MENU_DIVIDER | FL_SUBMENU}, {"Start...", 0, (Fl_Callback *)file_remote_cb, (void*)"start"}, {"Merge...", 0, (Fl_Callback *)file_remote_cb, (void*)"merge"}, {"Clear", 0, (Fl_Callback *)file_remote_cb, (void*)"clear"}, {"Stop", 0, (Fl_Callback *)file_remote_cb, (void*)"stop"}, {0}, +#endif {"New Window", 0, (Fl_Callback *)file_window_cb, (void*)"new"}, {"Split Window", 0, 0, 0, FL_MENU_DIVIDER | FL_SUBMENU}, {"Horizontally", 0, (Fl_Callback *)file_window_cb, (void*)"split_h"}, @@ -2357,7 +2361,9 @@ static Fl_Menu_Item bar_table[] = { {"&Visibility", FL_CTRL+FL_SHIFT+'v', (Fl_Callback *)visibility_cb, 0}, {"&Clipping", FL_CTRL+FL_SHIFT+'c', (Fl_Callback *)clip_cb, 0}, {"&Manipulator", FL_CTRL+FL_SHIFT+'m', (Fl_Callback *)manip_cb, 0}, +#if defined(HAVE_ONELAB) {"&OneLab", 0, (Fl_Callback *)solver_cb, (void*)(-1), FL_MENU_DIVIDER}, +#endif {"S&tatistics", FL_CTRL+'i', (Fl_Callback *)statistics_cb, 0}, {"M&essage Console", FL_CTRL+'l', (Fl_Callback *)message_cb, 0}, {0}, @@ -2420,7 +2426,9 @@ static Fl_Menu_Item sysbar_table[] = { {"Visibility", FL_META+FL_SHIFT+'v', (Fl_Callback *)visibility_cb, 0}, {"Clipping", FL_META+FL_SHIFT+'c', (Fl_Callback *)clip_cb, 0}, {"Manipulator", FL_META+FL_SHIFT+'m', (Fl_Callback *)manip_cb, 0}, +#if defined(HAVE_ONELAB) {"OneLab", 0, (Fl_Callback *)solver_cb, (void*)(-1), FL_MENU_DIVIDER}, +#endif {"Statistics", FL_META+'i', (Fl_Callback *)statistics_cb, 0}, {"Message Console", FL_META+'l', (Fl_Callback *)message_cb, 0}, {0}, diff --git a/Fltk/onelabWindow.cpp b/Fltk/onelabWindow.cpp index 27579270b96494b9de407b8519a23fba3122b730..aa51bce233b64b99b8fd2beb46f4bf7f938232b9 100644 --- a/Fltk/onelabWindow.cpp +++ b/Fltk/onelabWindow.cpp @@ -4,15 +4,15 @@ // bugs and problems to <gmsh@geuz.org>. #include <FL/Fl.H> -#include <FL/fl_ask.H> +#include "GmshConfig.h" #include "GmshMessage.h" -#include "onelab.h" -#if (FL_MAJOR_VERSION == 1) && (FL_MINOR_VERSION == 3) +#if defined(HAVE_ONELAB) && (FL_MAJOR_VERSION == 1) && (FL_MINOR_VERSION == 3) #include <FL/Fl_Check_Button.H> #include <FL/Fl_Box.H> #include <FL/Fl_Input_Choice.H> +#include <FL/fl_ask.H> #include "inputRange.h" #include "Context.h" #include "GModel.h" @@ -1019,21 +1019,9 @@ void solver_cb(Fl_Widget *w, void *data) #else -bool onelab::localNetworkClient::run(const std::string &what) -{ - Msg::Error("The solver interface requires FLTK 1.3"); - return false; -} - -bool onelab::localNetworkClient::kill() -{ - Msg::Error("The solver interface requires FLTK 1.3"); - return false; -} - void solver_cb(Fl_Widget *w, void *data) { - Msg::Error("The solver interface requires FLTK 1.3"); + Msg::Error("The solver interface requires OneLab and FLTK 1.3"); } #endif diff --git a/Fltk/onelabWindow.h b/Fltk/onelabWindow.h index 170758a8cb939c78ea253e9b46c4d8e317594b20..9e05992cef07aedb9801f2019db206a0733278f8 100644 --- a/Fltk/onelabWindow.h +++ b/Fltk/onelabWindow.h @@ -6,15 +6,16 @@ #ifndef _ONELAB_WINDOW_H_ #define _ONELAB_WINDOW_H_ -#include "onelab.h" +#include "GmshConfig.h" #include <FL/Fl.H> -#if (FL_MAJOR_VERSION == 1) && (FL_MINOR_VERSION == 3) +#if defined(HAVE_ONELAB) && (FL_MAJOR_VERSION == 1) && (FL_MINOR_VERSION == 3) #include <vector> #include <FL/Fl_Window.H> #include <FL/Fl_Tree.H> #include <FL/Fl_Button.H> #include <FL/Fl_Input.H> +#include "onelab.h" class onelabWindow{ private: diff --git a/Fltk/optionWindow.cpp b/Fltk/optionWindow.cpp index c83bebc65541784ff7a8a5cfe7825474bf10f6d5..a935f391a838bc9bffd5108542bb91eacb6b0ba6 100644 --- a/Fltk/optionWindow.cpp +++ b/Fltk/optionWindow.cpp @@ -31,7 +31,10 @@ typedef unsigned long intptr_t; #include "Context.h" #include "graphicWindow.h" #include "openglWindow.h" + +#if defined(HAVE_ONELAB) #include "onelab.h" +#endif extern StringXColor GeneralOptions_Color[] ; extern StringXColor GeometryOptions_Color[] ; @@ -515,6 +518,7 @@ static void solver_options_ok_cb(Fl_Widget *w, void *data) optionWindow *o = FlGui::instance()->options; o->activate((const char*)data); +#if defined(HAVE_ONELAB) int old_listen = (int)opt_solver_listen(0, GMSH_GET, o->solver.butt[0]->value()); opt_solver_listen(0, GMSH_SET, o->solver.butt[0]->value()); if(!old_listen && o->solver.butt[0]->value()){ @@ -526,6 +530,7 @@ static void solver_options_ok_cb(Fl_Widget *w, void *data) else it->second->run(""); } +#endif opt_solver_socket_name(0, GMSH_SET, o->solver.input[0]->value()); opt_solver_timeout(0, GMSH_SET, o->solver.value[0]->value()); diff --git a/Post/PViewDataRemote.h b/Post/PViewDataRemote.h index 4e9f10c1de63da2ed471f97e635419b129a09e38..8bed2ca37348a6485631162057c8e2035916a2d7 100644 --- a/Post/PViewDataRemote.h +++ b/Post/PViewDataRemote.h @@ -9,10 +9,10 @@ #include <vector> #include <string> #include "GmshMessage.h" -#include "onelab.h" #include "GmshSocket.h" #include "PViewData.h" #include "SBoundingBox3d.h" +#include "onelab.h" // The container for a remote dataset (does not contain any actual // data)