[Getdp] How to add new commands to GetDP ?

DILASSER Guillaume Guillaume.DILASSER at cea.fr
Fri Mar 25 09:33:46 CET 2016


Dear Christophe,

I finally managed to find the solution to my own question with a lot of trial and error. To be a bit more precise with the definition of my problem, I wanted to implement a time loop function using an adaptive time step calculated based on the residue of the equation to be solved. This is different from the existing TimeLoopAdaptive[] function, which uses the local truncation error as control variable and does not work properly with my problem. In case anyone is faced with the same type of problem in the future, here is the solution for the record :



1.       You first need to download and install the two programs flex and bison

2.       In the file ProParser.l, add a new token associated with the name of the function you want to implement (for more information on how to do it, refer to the flex documentation), then run the command flex - -outfile=ProParser.yy.cpp - -prefix=getdp_yy ProParser.l which will regenerate the scanner code (ProParser.yy.cpp).

3.       Then, edit the file ProParser.y to add the syntax of your new operator and the rule with is associated to it (the syntax is built based on tokens defined in the ProParser.l file, refer to the bison documentation for more info). Run then the command bison - -output=ProParser.tab.cpp -d - -name-prefix=getdp_yy ProParser.y to regenerate the parser code (ProParser.tab.cpp / .hpp)

4.       With these, GetDP parser is now able to recognize your new function but you still have to implement it for real. This begins with editing the file ProData.h to add a new structure associated with your function and containing its argument types. In my case, I added a new structure “MyTimeLoop” in the union block of the structure operation. Finally add the source for your new function in GetDP file and don’t forget to add its name in the makefile.

5.       Configure the project with cmake and run make as usual to regenerate the executable.

This is the short version, but I hope these directions would help.



Faithfully Yours,

Guillaume DILASSER
Doctorant SACM / LEAS
CEA - Centre de Saclay - Bât.123 - PC 319c
91191 Gif sur Yvette Cedex - France -

guillaume.dilasser at cea.fr<mailto:guillaume.dilasser at cea.fr>






-----Message d'origine-----
De : Christophe Geuzaine [mailto:cgeuzaine at ulg.ac.be]
Envoyé : jeudi 24 mars 2016 19:09
À : DILASSER Guillaume <Guillaume.DILASSER at cea.fr>
Cc : getdp at geuz.org
Objet : Re: [Getdp] How to add new commands to GetDP ?





Dear Guillaume,



What kind of commands do you want to add? If you only want to add a new function (say, like "XYZ[]"), you don't actually have to modify the parser: you can simply create your new function (see e.g. Legacy/F_Coord.cpp) and add the name in Interface/ProDefines.h.



The same holds for simple resolution operations and other common constructs: see Interface/ProDefines.h.



For more exotic commands, you will indeed have to modify the flex/bison parser. Once you have made a modification, you have to rebuild the C++ version with "make parser".



Hope this helps,



Christophe
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://onelab.info/pipermail/getdp/attachments/20160325/d586a451/attachment.html>


More information about the getdp mailing list