diff --git a/CHANGELOG.txt b/CHANGELOG.txt index ca31e12d509e8bf5d7cde80c069490e89a7cad68..a1dbc035ffa0119c2641d008e50a2a2ceb15af18 100644 --- a/CHANGELOG.txt +++ b/CHANGELOG.txt @@ -6,7 +6,7 @@ fixes. * New API functions: gmsh/isInitialized, occ/convertToNURBS, occ/getCurveLoops, occ/getSurfaceLoops, mesh/importStl, parser/getNames, parser/setNumber, parser/setString, parser/getNumber, parser/getString, parser/clear, - parser/parse + parser/parse, onelab/getChanged, onelab/setChanged 4.9.3 (January 4, 2022): improved handling of degenerate curves in periodic surfaces and boundary layer extrusion; extended Mesh.SaveGroupsOfElements diff --git a/api/gen.py b/api/gen.py index 565e876c5f1d358f68abe484dc526e5634e1595c..b25e40abd5011fc0bfd3545b8e69785507fca715 100644 --- a/api/gen.py +++ b/api/gen.py @@ -1122,6 +1122,12 @@ onelab.add('getNumber', doc, None, istring('name'), ovectordouble('value')) doc = '''Get the value of the string parameter `name' from the ONELAB database. Return an empty vector if the parameter does not exist.''' onelab.add('getString', doc, None, istring('name'), ovectorstring('value')) +doc = '''Check if any parameters in the ONELAB database used by the client `name' have been changed.''' +onelab.add('getChanged', doc, oint, istring('name')) + +doc = '''Set the changed flag to value `value' for all the parameters in the ONELAB database used by the client `name'.''' +onelab.add('setChanged', doc, None, istring('name'), iint('value')) + doc = '''Clear the ONELAB database, or remove a single parameter if `name' is given.''' onelab.add('clear', doc, None, istring('name', '""')) diff --git a/api/gmsh.h b/api/gmsh.h index 62d72a90895092c3efdb57a42157c3633c1a3bbf..240cd79a6ebc3fe542fad00cc315384b01945046 100644 --- a/api/gmsh.h +++ b/api/gmsh.h @@ -3674,6 +3674,19 @@ namespace gmsh { // Top-level functions GMSH_API void getString(const std::string & name, std::vector<std::string> & value); + // gmsh::onelab::getChanged + // + // Check if any parameters in the ONELAB database used by the client `name' + // have been changed. + GMSH_API int getChanged(const std::string & name); + + // gmsh::onelab::setChanged + // + // Set the changed flag to value `value' for all the parameters in the ONELAB + // database used by the client `name'. + GMSH_API void setChanged(const std::string & name, + const int value); + // gmsh::onelab::clear // // Clear the ONELAB database, or remove a single parameter if `name' is given. diff --git a/api/gmsh.h_cwrap b/api/gmsh.h_cwrap index caf479e2e67181f0031d1bd1d9488a8e44253f1f..10db49396498493b5b217bbe8bc73b59a1c2b369 100644 --- a/api/gmsh.h_cwrap +++ b/api/gmsh.h_cwrap @@ -5525,6 +5525,26 @@ namespace gmsh { // Top-level functions value.resize(api_value_n_); for(size_t i = 0; i < api_value_n_; ++i){ value[i] = std::string(api_value_[i]); gmshFree(api_value_[i]); } gmshFree(api_value_); } + // Check if any parameters in the ONELAB database used by the client `name' + // have been changed. + inline int getChanged(const std::string & name) + { + int ierr = 0; + int result_api_ = gmshOnelabGetChanged(name.c_str(), &ierr); + if(ierr) throwLastError(); + return result_api_; + } + + // Set the changed flag to value `value' for all the parameters in the ONELAB + // database used by the client `name'. + inline void setChanged(const std::string & name, + const int value) + { + int ierr = 0; + gmshOnelabSetChanged(name.c_str(), value, &ierr); + if(ierr) throwLastError(); + } + // Clear the ONELAB database, or remove a single parameter if `name' is given. inline void clear(const std::string & name = "") { diff --git a/api/gmsh.jl b/api/gmsh.jl index 782cda267d3917b5271381a662d3dbc97d29e0ae..b8d4c6d5488dfa28e2f6b705044cd6494fa4d6d9 100644 --- a/api/gmsh.jl +++ b/api/gmsh.jl @@ -7164,6 +7164,40 @@ function getString(name) end const get_string = getString +""" + gmsh.onelab.getChanged(name) + +Check if any parameters in the ONELAB database used by the client `name` have +been changed. + +Return an integer value. +""" +function getChanged(name) + ierr = Ref{Cint}() + api_result_ = ccall((:gmshOnelabGetChanged, gmsh.lib), Cint, + (Ptr{Cchar}, Ptr{Cint}), + name, ierr) + ierr[] != 0 && error(gmsh.logger.getLastError()) + return api_result_ +end +const get_changed = getChanged + +""" + gmsh.onelab.setChanged(name, value) + +Set the changed flag to value `value` for all the parameters in the ONELAB +database used by the client `name`. +""" +function setChanged(name, value) + ierr = Ref{Cint}() + ccall((:gmshOnelabSetChanged, gmsh.lib), Cvoid, + (Ptr{Cchar}, Cint, Ptr{Cint}), + name, value, ierr) + ierr[] != 0 && error(gmsh.logger.getLastError()) + return nothing +end +const set_changed = setChanged + """ gmsh.onelab.clear(name = "") diff --git a/api/gmsh.py b/api/gmsh.py index 5c4a46dec9021669b03260ec98aca302859ecf29..97c0a42e102a9993822434b2fafbd9bab0f3199a 100644 --- a/api/gmsh.py +++ b/api/gmsh.py @@ -8207,6 +8207,42 @@ class onelab: return _ovectorstring(api_value_, api_value_n_.value) get_string = getString + @staticmethod + def getChanged(name): + """ + gmsh.onelab.getChanged(name) + + Check if any parameters in the ONELAB database used by the client `name' + have been changed. + + Return an integer value. + """ + ierr = c_int() + api_result_ = lib.gmshOnelabGetChanged( + c_char_p(name.encode()), + byref(ierr)) + if ierr.value != 0: + raise Exception(logger.getLastError()) + return api_result_ + get_changed = getChanged + + @staticmethod + def setChanged(name, value): + """ + gmsh.onelab.setChanged(name, value) + + Set the changed flag to value `value' for all the parameters in the ONELAB + database used by the client `name'. + """ + ierr = c_int() + lib.gmshOnelabSetChanged( + c_char_p(name.encode()), + c_int(value), + byref(ierr)) + if ierr.value != 0: + raise Exception(logger.getLastError()) + set_changed = setChanged + @staticmethod def clear(name=""): """ diff --git a/api/gmshc.cpp b/api/gmshc.cpp index 0b6d8323abfc7a184f10bfa6ffb479ccc4a42bfe..2d48ce18684452c44230d922e9127fe94aa663ca 100644 --- a/api/gmshc.cpp +++ b/api/gmshc.cpp @@ -4656,6 +4656,30 @@ GMSH_API void gmshOnelabGetString(const char * name, char *** value, size_t * va } } +GMSH_API int gmshOnelabGetChanged(const char * name, int * ierr) +{ + int result_api_ = 0; + if(ierr) *ierr = 0; + try { + result_api_ = gmsh::onelab::getChanged(name); + } + catch(...){ + if(ierr) *ierr = 1; + } + return result_api_; +} + +GMSH_API void gmshOnelabSetChanged(const char * name, const int value, int * ierr) +{ + if(ierr) *ierr = 0; + try { + gmsh::onelab::setChanged(name, value); + } + catch(...){ + if(ierr) *ierr = 1; + } +} + GMSH_API void gmshOnelabClear(const char * name, int * ierr) { if(ierr) *ierr = 0; diff --git a/api/gmshc.h b/api/gmshc.h index b078a7d8bb6146891f3a02e454e74c37c65ef5ee..5356e624f38989278e87869e77e57ce332c092fb 100644 --- a/api/gmshc.h +++ b/api/gmshc.h @@ -3224,6 +3224,17 @@ GMSH_API void gmshOnelabGetString(const char * name, char *** value, size_t * value_n, int * ierr); +/* Check if any parameters in the ONELAB database used by the client `name' + * have been changed. */ +GMSH_API int gmshOnelabGetChanged(const char * name, + int * ierr); + +/* Set the changed flag to value `value' for all the parameters in the ONELAB + * database used by the client `name'. */ +GMSH_API void gmshOnelabSetChanged(const char * name, + const int value, + int * ierr); + /* Clear the ONELAB database, or remove a single parameter if `name' is given. */ GMSH_API void gmshOnelabClear(const char * name, int * ierr); diff --git a/api/gmshf.h b/api/gmshf.h index ba50574d09caa33ec36df88a1067973bd1df0c54..4072001d929dc0b4fd080a035d1ff89802c26343 100644 --- a/api/gmshf.h +++ b/api/gmshf.h @@ -6836,6 +6836,31 @@ c integer(c_int)::ierr end subroutine gmshOnelabGetString +! Check if any parameters in the ONELAB database used by the client `name' +! have been changed. + function gmshOnelabGetChanged( + & name, + & ierr) + & bind(C, name = "gmshOnelabGetChanged") + use, intrinsic :: iso_c_binding + integer(c_int)::gmshOnelabGetChanged + character(len = 1, kind = c_char)::name(*) + integer(c_int)::ierr + end function gmshOnelabGetChanged + +! Set the changed flag to value `value' for all the parameters in the ONELAB +! database used by the client `name'. + subroutine gmshOnelabSetChanged( + & name, + & value, + & ierr) + & bind(C, name = "gmshOnelabSetChanged") + use, intrinsic :: iso_c_binding + character(len = 1, kind = c_char)::name(*) + integer(c_int), value::value + integer(c_int)::ierr + end subroutine gmshOnelabSetChanged + ! Clear the ONELAB database, or remove a single parameter if `name' is given. subroutine gmshOnelabClear( & name, diff --git a/doc/texinfo/api.texi b/doc/texinfo/api.texi index 1fe7958f9d08233e86af9bf977e435b04623e95e..2ec91151cfcfca294c7ef94310774d36619f4bc5 100644 --- a/doc/texinfo/api.texi +++ b/doc/texinfo/api.texi @@ -6314,6 +6314,36 @@ Return an empty vector if the parameter does not exist. C++ (@url{@value{GITLAB-PREFIX}/tutorials/c++/t3.cpp#L126,t3.cpp}, @url{@value{GITLAB-PREFIX}/tutorials/c++/t13.cpp#L125,t13.cpp}, @url{@value{GITLAB-PREFIX}/tutorials/c++/t21.cpp#L190,t21.cpp}), Python (@url{@value{GITLAB-PREFIX}/tutorials/python/t3.py#L117,t3.py}, @url{@value{GITLAB-PREFIX}/tutorials/python/t13.py#L111,t13.py}, @url{@value{GITLAB-PREFIX}/tutorials/python/t21.py#L160,t21.py}, @url{@value{GITLAB-PREFIX}/examples/api/custom_gui.py#L75,custom_gui.py}, @url{@value{GITLAB-PREFIX}/examples/api/prepro.py#L178,prepro.py}, ...) @end table +@item gmsh/onelab/getChanged +Check if any parameters in the ONELAB database used by the client @code{name} +have been changed. + +@table @asis +@item Input: +@code{name} +@item Output: +- +@item Return: +integer value +@item Language-specific definition: +@url{@value{GITLAB-PREFIX}/api/gmsh.h#L3681,C++}, @url{@value{GITLAB-PREFIX}/api/gmshc.h#L3229,C}, @url{@value{GITLAB-PREFIX}/api/gmsh.py#L8211,Python}, @url{@value{GITLAB-PREFIX}/api/gmsh.jl#L7175,Julia} +@end table + +@item gmsh/onelab/setChanged +Set the changed flag to value @code{value} for all the parameters in the ONELAB +database used by the client @code{name}. + +@table @asis +@item Input: +@code{name}, @code{value} +@item Output: +- +@item Return: +- +@item Language-specific definition: +@url{@value{GITLAB-PREFIX}/api/gmsh.h#L3687,C++}, @url{@value{GITLAB-PREFIX}/api/gmshc.h#L3234,C}, @url{@value{GITLAB-PREFIX}/api/gmsh.py#L8230,Python}, @url{@value{GITLAB-PREFIX}/api/gmsh.jl#L7191,Julia} +@end table + @item gmsh/onelab/clear Clear the ONELAB database, or remove a single parameter if @code{name} is given. @@ -6325,7 +6355,7 @@ Clear the ONELAB database, or remove a single parameter if @code{name} is given. @item Return: - @item Language-specific definition: -@url{@value{GITLAB-PREFIX}/api/gmsh.h#L3680,C++}, @url{@value{GITLAB-PREFIX}/api/gmshc.h#L3228,C}, @url{@value{GITLAB-PREFIX}/api/gmsh.py#L8211,Python}, @url{@value{GITLAB-PREFIX}/api/gmsh.jl#L7172,Julia} +@url{@value{GITLAB-PREFIX}/api/gmsh.h#L3693,C++}, @url{@value{GITLAB-PREFIX}/api/gmshc.h#L3239,C}, @url{@value{GITLAB-PREFIX}/api/gmsh.py#L8247,Python}, @url{@value{GITLAB-PREFIX}/api/gmsh.jl#L7206,Julia} @item Examples: Python (@url{@value{GITLAB-PREFIX}/examples/api/onelab_test.py#L44,onelab_test.py}) @end table @@ -6343,7 +6373,7 @@ might be linked to the processed input files. @item Return: - @item Language-specific definition: -@url{@value{GITLAB-PREFIX}/api/gmsh.h#L3687,C++}, @url{@value{GITLAB-PREFIX}/api/gmshc.h#L3234,C}, @url{@value{GITLAB-PREFIX}/api/gmsh.py#L8225,Python}, @url{@value{GITLAB-PREFIX}/api/gmsh.jl#L7188,Julia} +@url{@value{GITLAB-PREFIX}/api/gmsh.h#L3700,C++}, @url{@value{GITLAB-PREFIX}/api/gmshc.h#L3245,C}, @url{@value{GITLAB-PREFIX}/api/gmsh.py#L8261,Python}, @url{@value{GITLAB-PREFIX}/api/gmsh.jl#L7222,Julia} @item Examples: Python (@url{@value{GITLAB-PREFIX}/examples/api/onelab_run.py#L24,onelab_run.py}, @url{@value{GITLAB-PREFIX}/examples/api/onelab_run_auto.py#L26,onelab_run_auto.py}) @end table @@ -6365,7 +6395,7 @@ Write a @code{message}. @code{level} can be "info", "warning" or "error". @item Return: - @item Language-specific definition: -@url{@value{GITLAB-PREFIX}/api/gmsh.h#L3697,C++}, @url{@value{GITLAB-PREFIX}/api/gmshc.h#L3239,C}, @url{@value{GITLAB-PREFIX}/api/gmsh.py#L8248,Python}, @url{@value{GITLAB-PREFIX}/api/gmsh.jl#L7213,Julia} +@url{@value{GITLAB-PREFIX}/api/gmsh.h#L3710,C++}, @url{@value{GITLAB-PREFIX}/api/gmshc.h#L3250,C}, @url{@value{GITLAB-PREFIX}/api/gmsh.py#L8284,Python}, @url{@value{GITLAB-PREFIX}/api/gmsh.jl#L7247,Julia} @item Examples: C++ (@url{@value{GITLAB-PREFIX}/tutorials/c++/t7.cpp#L23,t7.cpp}, @url{@value{GITLAB-PREFIX}/tutorials/c++/t8.cpp#L41,t8.cpp}, @url{@value{GITLAB-PREFIX}/tutorials/c++/t9.cpp#L31,t9.cpp}, @url{@value{GITLAB-PREFIX}/tutorials/c++/t13.cpp#L26,t13.cpp}, @url{@value{GITLAB-PREFIX}/tutorials/c++/t16.cpp#L34,t16.cpp}, ...), Python (@url{@value{GITLAB-PREFIX}/tutorials/python/x5.py#L87,x5.py}, @url{@value{GITLAB-PREFIX}/examples/api/custom_gui.py#L60,custom_gui.py}, @url{@value{GITLAB-PREFIX}/examples/api/terrain_stl.py#L26,terrain_stl.py}) @end table @@ -6381,7 +6411,7 @@ Start logging messages. @item Return: - @item Language-specific definition: -@url{@value{GITLAB-PREFIX}/api/gmsh.h#L3703,C++}, @url{@value{GITLAB-PREFIX}/api/gmshc.h#L3244,C}, @url{@value{GITLAB-PREFIX}/api/gmsh.py#L8263,Python}, @url{@value{GITLAB-PREFIX}/api/gmsh.jl#L7227,Julia} +@url{@value{GITLAB-PREFIX}/api/gmsh.h#L3716,C++}, @url{@value{GITLAB-PREFIX}/api/gmshc.h#L3255,C}, @url{@value{GITLAB-PREFIX}/api/gmsh.py#L8299,Python}, @url{@value{GITLAB-PREFIX}/api/gmsh.jl#L7261,Julia} @item Examples: C++ (@url{@value{GITLAB-PREFIX}/tutorials/c++/t16.cpp#L27,t16.cpp}), Python (@url{@value{GITLAB-PREFIX}/tutorials/python/t16.py#L25,t16.py}) @end table @@ -6397,7 +6427,7 @@ Get logged messages. @item Return: - @item Language-specific definition: -@url{@value{GITLAB-PREFIX}/api/gmsh.h#L3708,C++}, @url{@value{GITLAB-PREFIX}/api/gmshc.h#L3247,C}, @url{@value{GITLAB-PREFIX}/api/gmsh.py#L8276,Python}, @url{@value{GITLAB-PREFIX}/api/gmsh.jl#L7243,Julia} +@url{@value{GITLAB-PREFIX}/api/gmsh.h#L3721,C++}, @url{@value{GITLAB-PREFIX}/api/gmshc.h#L3258,C}, @url{@value{GITLAB-PREFIX}/api/gmsh.py#L8312,Python}, @url{@value{GITLAB-PREFIX}/api/gmsh.jl#L7277,Julia} @item Examples: C++ (@url{@value{GITLAB-PREFIX}/tutorials/c++/t16.cpp#L137,t16.cpp}), Python (@url{@value{GITLAB-PREFIX}/tutorials/python/t16.py#L118,t16.py}) @end table @@ -6413,7 +6443,7 @@ Stop logging messages. @item Return: - @item Language-specific definition: -@url{@value{GITLAB-PREFIX}/api/gmsh.h#L3713,C++}, @url{@value{GITLAB-PREFIX}/api/gmshc.h#L3251,C}, @url{@value{GITLAB-PREFIX}/api/gmsh.py#L8294,Python}, @url{@value{GITLAB-PREFIX}/api/gmsh.jl#L7261,Julia} +@url{@value{GITLAB-PREFIX}/api/gmsh.h#L3726,C++}, @url{@value{GITLAB-PREFIX}/api/gmshc.h#L3262,C}, @url{@value{GITLAB-PREFIX}/api/gmsh.py#L8330,Python}, @url{@value{GITLAB-PREFIX}/api/gmsh.jl#L7295,Julia} @item Examples: C++ (@url{@value{GITLAB-PREFIX}/tutorials/c++/t16.cpp#L139,t16.cpp}), Python (@url{@value{GITLAB-PREFIX}/tutorials/python/t16.py#L120,t16.py}) @end table @@ -6429,7 +6459,7 @@ Return wall clock time. @item Return: floating point value @item Language-specific definition: -@url{@value{GITLAB-PREFIX}/api/gmsh.h#L3718,C++}, @url{@value{GITLAB-PREFIX}/api/gmshc.h#L3254,C}, @url{@value{GITLAB-PREFIX}/api/gmsh.py#L8307,Python}, @url{@value{GITLAB-PREFIX}/api/gmsh.jl#L7277,Julia} +@url{@value{GITLAB-PREFIX}/api/gmsh.h#L3731,C++}, @url{@value{GITLAB-PREFIX}/api/gmshc.h#L3265,C}, @url{@value{GITLAB-PREFIX}/api/gmsh.py#L8343,Python}, @url{@value{GITLAB-PREFIX}/api/gmsh.jl#L7311,Julia} @item Examples: Python (@url{@value{GITLAB-PREFIX}/examples/api/import_perf.py#L8,import_perf.py}) @end table @@ -6445,7 +6475,7 @@ Return CPU time. @item Return: floating point value @item Language-specific definition: -@url{@value{GITLAB-PREFIX}/api/gmsh.h#L3723,C++}, @url{@value{GITLAB-PREFIX}/api/gmshc.h#L3257,C}, @url{@value{GITLAB-PREFIX}/api/gmsh.py#L8325,Python}, @url{@value{GITLAB-PREFIX}/api/gmsh.jl#L7294,Julia} +@url{@value{GITLAB-PREFIX}/api/gmsh.h#L3736,C++}, @url{@value{GITLAB-PREFIX}/api/gmshc.h#L3268,C}, @url{@value{GITLAB-PREFIX}/api/gmsh.py#L8361,Python}, @url{@value{GITLAB-PREFIX}/api/gmsh.jl#L7328,Julia} @end table @item gmsh/logger/getLastError @@ -6459,7 +6489,7 @@ Return last error message, if any. @item Return: - @item Language-specific definition: -@url{@value{GITLAB-PREFIX}/api/gmsh.h#L3728,C++}, @url{@value{GITLAB-PREFIX}/api/gmshc.h#L3260,C}, @url{@value{GITLAB-PREFIX}/api/gmsh.py#L8343,Python}, @url{@value{GITLAB-PREFIX}/api/gmsh.jl#L7311,Julia} +@url{@value{GITLAB-PREFIX}/api/gmsh.h#L3741,C++}, @url{@value{GITLAB-PREFIX}/api/gmshc.h#L3271,C}, @url{@value{GITLAB-PREFIX}/api/gmsh.py#L8379,Python}, @url{@value{GITLAB-PREFIX}/api/gmsh.jl#L7345,Julia} @end table @end ftable diff --git a/src/common/gmsh.cpp b/src/common/gmsh.cpp index a2cefb5ac2c75e2451cfcf60490eb3e533c802fe..ed8cc459f1a64aeacab390bc52b373fca1c067b6 100644 --- a/src/common/gmsh.cpp +++ b/src/common/gmsh.cpp @@ -8241,7 +8241,7 @@ GMSH_API void gmsh::onelab::setNumber(const std::string &name, ::onelab::server::instance()->get(ps, name); if(ps.size()) p = ps[0]; p.setValues(value); - ::onelab::server::instance()->set(p); + ::onelab::server::instance()->set(p, "Gmsh"); #else Msg::Error("ONELAB not available"); #endif @@ -8271,7 +8271,7 @@ GMSH_API void gmsh::onelab::setString(const std::string &name, ::onelab::server::instance()->get(ps, name); if(ps.size()) p = ps[0]; p.setValues(value); - ::onelab::server::instance()->set(p); + ::onelab::server::instance()->set(p, "Gmsh"); #else Msg::Error("ONELAB not available"); #endif @@ -8291,6 +8291,28 @@ GMSH_API void gmsh::onelab::getString(const std::string &name, #endif } +GMSH_API int gmsh::onelab::getChanged(const std::string &name) +{ + if(!_checkInit()) return 0; +#if defined(HAVE_ONELAB) + return ::onelab::server::instance()->getChanged(name); +#else + Msg::Error("ONELAB not available"); + return 0; +#endif +} + +GMSH_API void gmsh::onelab::setChanged(const std::string &name, const int value) +{ + if(!_checkInit()) return; +#if defined(HAVE_ONELAB) + return ::onelab::server::instance()->setChanged(value, name); +#else + Msg::Error("ONELAB not available"); + return 0; +#endif +} + GMSH_API void gmsh::onelab::clear(const std::string &name) { if(!_checkInit()) return;