Skip to content
Snippets Groups Projects
Commit af536ce0 authored by Christophe Geuzaine's avatar Christophe Geuzaine
Browse files

- new Get/SetNumber and Get/SetString to directly access ONELAB variables

- new GmshExecutableName to get name of exe
parent 77935cce
No related branches found
No related tags found
No related merge requests found
...@@ -803,6 +803,44 @@ void Msg::SetOnelabString(std::string name, std::string val, bool visible) ...@@ -803,6 +803,44 @@ void Msg::SetOnelabString(std::string name, std::string val, bool visible)
#endif #endif
} }
double Msg::GetOnelabNumber(std::string name)
{
#if defined(HAVE_ONELAB)
if(_onelabClient){
std::vector<onelab::number> numbers;
#if defined(HAVE_ONELAB2)
_onelabClient->get(numbers, name, "Gmsh");
#else
_onelabClient->get(numbers, name);
#endif
if(numbers.empty())
Msg::Error("Unknown ONELAB parameter '%s'", name.c_str());
else
return numbers[0].getValue();
}
return 0.;
#endif
}
std::string Msg::GetOnelabString(std::string name)
{
#if defined(HAVE_ONELAB)
if(_onelabClient){
std::vector<onelab::string> strings;
#if defined(HAVE_ONELAB2)
_onelabClient->get(strings, name, "Gmsh");
#else
_onelabClient->get(strings, name);
#endif
if(strings.empty())
Msg::Error("Unknown ONELAB parameter '%s'", name.c_str());
else
return strings[0].getValue();
}
#endif
return "";
}
#if defined(HAVE_ONELAB) #if defined(HAVE_ONELAB)
class localGmsh : public onelab::localClient { class localGmsh : public onelab::localClient {
public: public:
......
...@@ -132,8 +132,10 @@ class Msg { ...@@ -132,8 +132,10 @@ class Msg {
#endif #endif
static void FinalizeOnelab(); static void FinalizeOnelab();
static bool UseOnelab(); static bool UseOnelab();
static void SetOnelabNumber(std::string name, double val, bool visible); static void SetOnelabNumber(std::string name, double val, bool visible=true);
static void SetOnelabString(std::string name, std::string val, bool visible); static void SetOnelabString(std::string name, std::string val, bool visible=true);
static double GetOnelabNumber(std::string name);
static std::string GetOnelabString(std::string name);
static void SetGmshOnelabAction(std::string action){ _gmshOnelabAction = action; } static void SetGmshOnelabAction(std::string action){ _gmshOnelabAction = action; }
static std::string GetGmshOnelabAction(){ return _gmshOnelabAction; } static std::string GetGmshOnelabAction(){ return _gmshOnelabAction; }
static void ExchangeOnelabParameter(const std::string &key, static void ExchangeOnelabParameter(const std::string &key,
......
...@@ -173,10 +173,12 @@ Function return tFunction; ...@@ -173,10 +173,12 @@ Function return tFunction;
GetEnv return tGetEnv; GetEnv return tGetEnv;
GetString return tGetString; GetString return tGetString;
GetNumber return tGetNumber;
GetValue return tGetValue; GetValue return tGetValue;
GMSH_MAJOR_VERSION return tGMSH_MAJOR_VERSION; GMSH_MAJOR_VERSION return tGMSH_MAJOR_VERSION;
GMSH_MINOR_VERSION return tGMSH_MINOR_VERSION; GMSH_MINOR_VERSION return tGMSH_MINOR_VERSION;
GMSH_PATCH_VERSION return tGMSH_PATCH_VERSION; GMSH_PATCH_VERSION return tGMSH_PATCH_VERSION;
GmshExecutableName return tGmshExecutableName;
Hide return tHide; Hide return tHide;
Hole return tHole; Hole return tHole;
...@@ -242,6 +244,8 @@ Reverse return tReverse; ...@@ -242,6 +244,8 @@ Reverse return tReverse;
ScaleLastLayer return tScaleLast; ScaleLastLayer return tScaleLast;
Smoother return tSmoother; Smoother return tSmoother;
SetOrder return tSetOrder; SetOrder return tSetOrder;
SetNumber return tSetNumber;
SetString return tSetString;
Sqrt return tSqrt; Sqrt return tSqrt;
Sin return tSin; Sin return tSin;
Sinh return tSinh; Sinh return tSinh;
......
This diff is collapsed.
...@@ -112,109 +112,113 @@ extern int gmsh_yydebug; ...@@ -112,109 +112,113 @@ extern int gmsh_yydebug;
tUndefineConstant = 321, tUndefineConstant = 321,
tDefineNumber = 322, tDefineNumber = 322,
tDefineString = 323, tDefineString = 323,
tPoint = 324, tSetNumber = 324,
tCircle = 325, tSetString = 325,
tEllipse = 326, tPoint = 326,
tLine = 327, tCircle = 327,
tSphere = 328, tEllipse = 328,
tPolarSphere = 329, tLine = 329,
tSurface = 330, tSphere = 330,
tSpline = 331, tPolarSphere = 331,
tVolume = 332, tSurface = 332,
tCharacteristic = 333, tSpline = 333,
tLength = 334, tVolume = 334,
tParametric = 335, tCharacteristic = 335,
tElliptic = 336, tLength = 336,
tRefineMesh = 337, tParametric = 337,
tAdaptMesh = 338, tElliptic = 338,
tRelocateMesh = 339, tRefineMesh = 339,
tPlane = 340, tAdaptMesh = 340,
tRuled = 341, tRelocateMesh = 341,
tTransfinite = 342, tPlane = 342,
tComplex = 343, tRuled = 343,
tPhysical = 344, tTransfinite = 344,
tCompound = 345, tComplex = 345,
tPeriodic = 346, tPhysical = 346,
tUsing = 347, tCompound = 347,
tPlugin = 348, tPeriodic = 348,
tDegenerated = 349, tUsing = 349,
tRecursive = 350, tPlugin = 350,
tRotate = 351, tDegenerated = 351,
tTranslate = 352, tRecursive = 352,
tSymmetry = 353, tRotate = 353,
tDilate = 354, tTranslate = 354,
tExtrude = 355, tSymmetry = 355,
tLevelset = 356, tDilate = 356,
tRecombine = 357, tExtrude = 357,
tSmoother = 358, tLevelset = 358,
tSplit = 359, tRecombine = 359,
tDelete = 360, tSmoother = 360,
tCoherence = 361, tSplit = 361,
tIntersect = 362, tDelete = 362,
tMeshAlgorithm = 363, tCoherence = 363,
tReverse = 364, tIntersect = 364,
tLayers = 365, tMeshAlgorithm = 365,
tScaleLast = 366, tReverse = 366,
tHole = 367, tLayers = 367,
tAlias = 368, tScaleLast = 368,
tAliasWithOptions = 369, tHole = 369,
tCopyOptions = 370, tAlias = 370,
tQuadTriAddVerts = 371, tAliasWithOptions = 371,
tQuadTriNoNewVerts = 372, tCopyOptions = 372,
tQuadTriSngl = 373, tQuadTriAddVerts = 373,
tQuadTriDbl = 374, tQuadTriNoNewVerts = 374,
tRecombLaterals = 375, tQuadTriSngl = 375,
tTransfQuadTri = 376, tQuadTriDbl = 376,
tText2D = 377, tRecombLaterals = 377,
tText3D = 378, tTransfQuadTri = 378,
tInterpolationScheme = 379, tText2D = 379,
tTime = 380, tText3D = 380,
tCombine = 381, tInterpolationScheme = 381,
tBSpline = 382, tTime = 382,
tBezier = 383, tCombine = 383,
tNurbs = 384, tBSpline = 384,
tNurbsOrder = 385, tBezier = 385,
tNurbsKnots = 386, tNurbs = 386,
tColor = 387, tNurbsOrder = 387,
tColorTable = 388, tNurbsKnots = 388,
tFor = 389, tColor = 389,
tIn = 390, tColorTable = 390,
tEndFor = 391, tFor = 391,
tIf = 392, tIn = 392,
tEndIf = 393, tEndFor = 393,
tExit = 394, tIf = 394,
tAbort = 395, tEndIf = 395,
tField = 396, tExit = 396,
tReturn = 397, tAbort = 397,
tCall = 398, tField = 398,
tFunction = 399, tReturn = 399,
tShow = 400, tCall = 400,
tHide = 401, tFunction = 401,
tGetValue = 402, tShow = 402,
tGetEnv = 403, tHide = 403,
tGetString = 404, tGetValue = 404,
tHomology = 405, tGetEnv = 405,
tCohomology = 406, tGetString = 406,
tBetti = 407, tGetNumber = 407,
tSetOrder = 408, tHomology = 408,
tExists = 409, tCohomology = 409,
tFileExists = 410, tBetti = 410,
tGMSH_MAJOR_VERSION = 411, tSetOrder = 411,
tGMSH_MINOR_VERSION = 412, tExists = 412,
tGMSH_PATCH_VERSION = 413, tFileExists = 413,
tAFFECTDIVIDE = 414, tGMSH_MAJOR_VERSION = 414,
tAFFECTTIMES = 415, tGMSH_MINOR_VERSION = 415,
tAFFECTMINUS = 416, tGMSH_PATCH_VERSION = 416,
tAFFECTPLUS = 417, tGmshExecutableName = 417,
tOR = 418, tAFFECTDIVIDE = 418,
tAND = 419, tAFFECTTIMES = 419,
tNOTEQUAL = 420, tAFFECTMINUS = 420,
tEQUAL = 421, tAFFECTPLUS = 421,
tGREATEROREQUAL = 422, tOR = 422,
tLESSOREQUAL = 423, tAND = 423,
UNARYPREC = 424, tNOTEQUAL = 424,
tMINUSMINUS = 425, tEQUAL = 425,
tPLUSPLUS = 426 tGREATEROREQUAL = 426,
tLESSOREQUAL = 427,
UNARYPREC = 428,
tMINUSMINUS = 429,
tPLUSPLUS = 430
}; };
#endif #endif
...@@ -235,7 +239,7 @@ typedef union YYSTYPE ...@@ -235,7 +239,7 @@ typedef union YYSTYPE
/* Line 2053 of yacc.c */ /* Line 2053 of yacc.c */
#line 239 "Gmsh.tab.hpp" #line 243 "Gmsh.tab.hpp"
} YYSTYPE; } YYSTYPE;
# define YYSTYPE_IS_TRIVIAL 1 # define YYSTYPE_IS_TRIVIAL 1
# define yystype YYSTYPE /* obsolescent; will be withdrawn */ # define yystype YYSTYPE /* obsolescent; will be withdrawn */
......
...@@ -122,7 +122,7 @@ struct doubleXstring{ ...@@ -122,7 +122,7 @@ struct doubleXstring{
%token tCpu tMemory tTotalMemory %token tCpu tMemory tTotalMemory
%token tCreateTopology tCreateTopologyNoHoles %token tCreateTopology tCreateTopologyNoHoles
%token tDistanceFunction tDefineConstant tUndefineConstant %token tDistanceFunction tDefineConstant tUndefineConstant
%token tDefineNumber tDefineString %token tDefineNumber tDefineString tSetNumber tSetString
%token tPoint tCircle tEllipse tLine tSphere tPolarSphere tSurface tSpline tVolume %token tPoint tCircle tEllipse tLine tSphere tPolarSphere tSurface tSpline tVolume
%token tCharacteristic tLength tParametric tElliptic tRefineMesh tAdaptMesh %token tCharacteristic tLength tParametric tElliptic tRefineMesh tAdaptMesh
%token tRelocateMesh %token tRelocateMesh
...@@ -137,9 +137,10 @@ struct doubleXstring{ ...@@ -137,9 +137,10 @@ struct doubleXstring{
%token tText2D tText3D tInterpolationScheme tTime tCombine %token tText2D tText3D tInterpolationScheme tTime tCombine
%token tBSpline tBezier tNurbs tNurbsOrder tNurbsKnots %token tBSpline tBezier tNurbs tNurbsOrder tNurbsKnots
%token tColor tColorTable tFor tIn tEndFor tIf tEndIf tExit tAbort %token tColor tColorTable tFor tIn tEndFor tIf tEndIf tExit tAbort
%token tField tReturn tCall tFunction tShow tHide tGetValue tGetEnv tGetString %token tField tReturn tCall tFunction tShow tHide tGetValue tGetEnv tGetString tGetNumber
%token tHomology tCohomology tBetti tSetOrder tExists tFileExists %token tHomology tCohomology tBetti tSetOrder tExists tFileExists
%token tGMSH_MAJOR_VERSION tGMSH_MINOR_VERSION tGMSH_PATCH_VERSION %token tGMSH_MAJOR_VERSION tGMSH_MINOR_VERSION tGMSH_PATCH_VERSION
%token tGmshExecutableName
%type <d> FExpr FExpr_Single %type <d> FExpr FExpr_Single
%type <v> VExpr VExpr_Single CircleOptions TransfiniteType %type <v> VExpr VExpr_Single CircleOptions TransfiniteType
...@@ -655,6 +656,17 @@ Affectation : ...@@ -655,6 +656,17 @@ Affectation :
tDefineConstant '[' DefineConstants ']' tEND tDefineConstant '[' DefineConstants ']' tEND
| tUndefineConstant '[' UndefineConstants ']' tEND | tUndefineConstant '[' UndefineConstants ']' tEND
| tSetNumber LP StringExpr ',' FExpr RP tEND
{
Msg::SetOnelabNumber($3, $5);
Free($3);
}
| tSetString LP String__Index ',' StringExpr RP tEND
{
Msg::SetOnelabString($3, $5);
Free($3);
Free($5);
}
| String__Index NumericAffectation ListOfDouble tEND | String__Index NumericAffectation ListOfDouble tEND
{ {
if(!gmsh_yysymbols.count($1) && $2 && List_Nbr($3) == 1){ if(!gmsh_yysymbols.count($1) && $2 && List_Nbr($3) == 1){
...@@ -4470,6 +4482,11 @@ FExpr_Single : ...@@ -4470,6 +4482,11 @@ FExpr_Single :
Msg::ExchangeOnelabParameter("", val, floatOptions, charOptions); Msg::ExchangeOnelabParameter("", val, floatOptions, charOptions);
$$ = val[0]; $$ = val[0];
} }
| tGetNumber LP StringExprVar RP
{
$$ = Msg::GetOnelabNumber($3);
Free($3);
}
| String__Index | String__Index
{ {
if(!gmsh_yysymbols.count($1)){ if(!gmsh_yysymbols.count($1)){
...@@ -5290,6 +5307,12 @@ StringExpr : ...@@ -5290,6 +5307,12 @@ StringExpr :
strcpy($$, ctime(&now)); strcpy($$, ctime(&now));
$$[strlen($$) - 1] = '\0'; $$[strlen($$) - 1] = '\0';
} }
| tGmshExecutableName
{
std::string exe = Msg::GetExecutableName();
$$ = (char *)Malloc(exe.size() + 1);
strcpy($$, exe.c_str());
}
| tOnelabAction | tOnelabAction
{ {
std::string action = Msg::GetGmshOnelabAction(); std::string action = Msg::GetGmshOnelabAction();
...@@ -5312,6 +5335,13 @@ StringExpr : ...@@ -5312,6 +5335,13 @@ StringExpr :
Free($3); Free($3);
Free($5); Free($5);
} }
| tGetString '(' StringExprVar ')'
{
std::string s = Msg::GetOnelabString($3);
$$ = (char *)Malloc((s.size() + 1) * sizeof(char));
strcpy($$, s.c_str());
Free($3);
}
| tStrCat LP RecursiveListOfStringExprVar RP | tStrCat LP RecursiveListOfStringExprVar RP
{ {
int size = 1; int size = 1;
......
This diff is collapsed.
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment