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