FreeFem 3.5.x
List of all members
fem::femParser Class Reference

provides the syntaxical analysis More...

#include <femParser.hpp>

Public Types

Enums
enum  GraphicsType { FEM_GRAPHIC = 0 , FEM_NO_GRAPHIC = 1 }
 graphics type More...
 

Public Member Functions

Constructors and destructor
 femParser ()
 default constructor More...
 
 ~femParser ()
 destructor More...
 
Mutators
void setGraphicType (GraphicsType gt)
 set the graphic type More...
 
void setText (const char *__t)
 set the buffer to be parsed More...
 

Methods

void parse ()
 parse the buffer More...
 
void chvar (void)
 
noeudPtr instruction (void)
 
creal eval (noeudPtr)
 evaluate the node More...
 
void bucheron (noeudPtr)
 kill the node More...
 
void libere (void)
 free everything More...
 
void showtree (noeudPtr t)
 show the tree More...
 
void initsyntax ()
 initialise the parser
 
void libereparam (void)
 free the parameters More...
 
void initparam ()
 init the parameters More...
 
femMeshCptr getMesh () const
 get the mesh More...
 
static femParserNew ()
 create a new instance More...
 

Detailed Description

provides the syntaxical analysis

The syntaxic analyser works closely with the lexical analyser.

Author
Christophe Prud'homme prudh.nosp@m.omm@.nosp@m.ann.j.nosp@m.ussi.nosp@m.eu.fr
Version
Id
femParser.hpp 206 2006-07-30 16:52:02Z prudhomm

Member Enumeration Documentation

◆ GraphicsType

graphics type

Enumerator
FEM_GRAPHIC 

show the graphics

FEM_NO_GRAPHIC 

do not show the graphics

102 {
103 FEM_GRAPHIC = 0,
104 FEM_NO_GRAPHIC = 1
105 };
@ FEM_NO_GRAPHIC
do not show the graphics
Definition: femParser.hpp:104
@ FEM_GRAPHIC
show the graphics
Definition: femParser.hpp:103

Constructor & Destructor Documentation

◆ femParser()

fem::femParser::femParser ( )

default constructor

Parameters
__tstring to be parsed by the analyser
124 :
125 __tree(),
126 __function_list(),
127 __mesh(),
128 __graph( new femGraphicDeviceIndependent( &__mesh ) ),
129 pt( 0 ),
130 nbsd( 0 ),
131 nbs( 0 ),
132 nba( 0 ),
133 Iter( 1 ),
134 waitm( 0 ),
135 __text( 0 ),
136 __graphic_type( FEM_GRAPHIC )
137{
138 numnoeuds = 0;
139 waitm = 1;
140 pt = NULL;
141 noeuds = new noeudPtr[MAXTREENODES];
142 sd = new long[2*MAXSD];
143 arete = new long[2 * MAXBDYVERTEX];
144 ngbdy = new int[MAXBDYVERTEX];
145 cr = new float[2*MAXBDYVERTEX+1];
146 hh = new float[MAXBDYVERTEX];
147 memset (hh, 0, MAXBDYVERTEX*sizeof(float));
148 flag.si = 0;
149 flag.syst = 0;
150 flag.param = 0;
151 flag.complexe = 0;
152 flag.precise = 0;
153}

◆ ~femParser()

fem::femParser::~femParser ( )

destructor

156{
157 bucheron(__tree);
158 libere();
159
160 if ( __graphic_type == FEM_GRAPHIC )
161 {
162 closegraphique();
163 }
164 delete __graph;
165}
void bucheron(noeudPtr)
kill the node
Definition: femParser.cpp:3282
void libere(void)
free everything
Definition: femParser.cpp:3388

Member Function Documentation

◆ bucheron()

void fem::femParser::bucheron ( noeudPtr  s)

kill the node

3283{
3284 if (s->path != NULL)
3285 delete [] s->path;
3286 if (s->l1)
3287 bucheron (s->l1);
3288 if (s->l2)
3289 bucheron (s->l2);
3290 if (s->l3)
3291 bucheron (s->l3);
3292 if (s->l4)
3293 bucheron (s->l4);
3294 delete s;
3295 s = NULL;
3296}

◆ chvar()

void fem::femParser::chvar ( void  )
189{
190 int i;
191 char *c;
192 Complex I(0,1);
193
194 for (i = 0; i < numidents; i++)
195 {
196 c = idents[i].name;
197 if (!strcmp (c, "x"))
198 variables.x = idents + i;
199 if (!strcmp (c, "y"))
200 variables.y = idents + i;
201 if (!strcmp (c, "t"))
202 variables.t = idents + i;
203 if (!strcmp (c, "ib"))
204 variables.ng = idents + i;
205 if (!strcmp (c, "region"))
206 variables.region = idents + i;
207 if (!strcmp (c, "iv"))
208 variables.cursom = idents + i;
209 if (!strcmp (c, "nx"))
210 variables.nx = idents + i;
211 if (!strcmp (c, "ny"))
212 variables.ny = idents + i;
213 if (!strcmp (c, "nexist"))
214 variables.ne = idents + i;
215 if (!strcmp (c, "I"))
216 variables.I = idents + i;
217 if (!strcmp (c, "pi"))
218 variables.pi = idents + i;
219 }
220 (variables.I)->value = I;
221 (variables.pi)->value = 4.0F * atan (1.0F);
222}

◆ eval()

creal fem::femParser::eval ( noeudPtr  s)

evaluate the node

2856{
2857 static creal temp = 0.F;
2858 int k;
2859 creal* tableaddr;
2860
2861 if (s == NULL)
2862 return 0.F;
2863 switch (s->symb)
2864 {
2865 case adaptmesh:
2866 adapt (s); /* call adaptation routine */
2867 break;
2868
2869 case polygon:
2870 defbdybypoint (s);
2871 break;
2872
2873 case symb_bdy:
2874 defbdy (s);
2875 break;
2876
2877 case symb_build:
2878 build (s);
2879 break;
2880
2881 case symb_dch:
2882 conddch (s);
2883 break;
2884
2885 case symb_frr:
2886 condfrr (s);
2887 break;
2888
2889 case sauvmsh:
2890 sauvtrig (s);
2891 break;
2892
2893 case chargmsh:
2894 chartrig (s);
2895 break;
2896
2897 case symb_exec:
2898 execute (s->path);
2899 break;
2900
2901 case varsolve: //from prepvarsolve
2902 eval (s->l1);
2903 if (s->l3)
2904 ihowsyst = (int) (realpart (eval (s->l3)));
2905 else
2906 ihowsyst = 1;
2907 saveallname = s->path;
2908 if (s->junk <= 0)
2909 {
2910 if (!((s->name)->table))
2911 { if (flag.precise)
2912 { (s->name)->table = new creal[3*__mesh.getNumberOfCells()];
2913 for( k =0; k<3*__mesh.getNumberOfCells();k++) (s->name)->table[k] = 0;
2914 }
2915 else
2916 { (s->name)->table = new creal[__mesh.getNumberOfPoints()];
2917 for( k =0; k<__mesh.getNumberOfPoints();k++) (s->name)->table[k] = 0;
2918 }
2919 }
2920 systable[-1 - (s->junk) ] = s->name;
2921 }
2922 else
2923 {
2924 N = s->junk;
2925 N2 = N * N;
2926 if ((flag.complexe) && (N > 1))
2927 erreur (" Complex system not implemented");
2928 flag.syst = 1;
2929 initparam ();
2930 }
2931 break;
2932
2933 case colon:
2934 eval (s->l1);
2935 varpde(s);
2936 break;
2937
2938 case symb_system:
2939 eval (s->l1);
2940 if (s->l3)
2941 ihowsyst = (int) (realpart (eval (s->l3)));
2942 else
2943 ihowsyst = 1;
2944 saveallname = s->path;
2945 if (s->junk <= 0)
2946 {
2947 if (!((s->name)->table))
2948 {
2949 if (flag.precise)
2950 {
2951 (s->name)->table = new creal[3*__mesh.getNumberOfCells()];
2952 }
2953 else
2954 {
2955 (s->name)->table = new creal[__mesh.getNumberOfPoints()];
2956 }
2957 }
2958 systable[-1 - (s->junk)] = s->name;
2959 }
2960 else
2961 {
2962 N = s->junk;
2963 N2 = N * N;
2964 flag.syst = 1;
2965 if ((flag.complexe) && (N > 1))
2966 erreur (" Complex system not implemented");
2967 initparam ();
2968 }
2969 break;
2970
2971 case symb_pde:
2972 edp (s);
2973 break;
2974
2975 case symb_solv:
2976 case sauvetout:
2977 solve (s);
2978 break;
2979
2980 case id_bdy:
2981 opcondlim (s);
2982 break;
2983
2984 case symb_lapl:
2985 case d_xx:
2986 case d_xy:
2987 case d_yx:
2988 case d_yy:
2989 case div_x:
2990 case div_y:
2991 case symb_id:
2992 oppde (s);
2993 break;
2994
2995 case bint:
2996 if(s->name) tableaddr = s->name->table; else tableaddr = NULL;
2997 if (s->l2 == NULL)
2998 return __fem->binteg((int)realpart(eval(s->l1)),
2999 0,
3000 0,
3001 s->l4->name->table,
3002 tableaddr,
3003 flag.solv);
3004 else if (s->l3 == NULL)
3005 return __fem->binteg((int)realpart(eval(s->l1)),
3006 (int)realpart(eval(s->l2)),
3007 0,
3008 s->l4->name->table,
3009 tableaddr,
3010 flag.solv);
3011 else
3012 return __fem->binteg((int)realpart(eval(s->l1)),
3013 (int)realpart(eval(s->l2)),
3014 (int)realpart(eval(s->l3)),
3015 s->l4->name->table,
3016 tableaddr,
3017 flag.solv);
3018 break;
3019 case gint:
3020 if(s->name) tableaddr = s->name->table; else tableaddr = NULL;
3021 if (s->l1 == NULL)
3022 return __fem->ginteg(0,
3023 0,
3024 0,
3025 s->l4->name->table,
3026 tableaddr,
3027 flag.solv);
3028 else if (s->l2 == NULL)
3029 return __fem->ginteg((int)realpart(eval(s->l1)),
3030 0,
3031 0,
3032 s->l4->name->table,
3033 tableaddr,
3034 flag.solv);
3035 else if (s->l3 == NULL)
3036 return __fem->ginteg((int)realpart(eval(s->l1)),
3037 (int)realpart(eval(s->l2)),
3038 0,
3039 s->l4->name->table,
3040 tableaddr,
3041 flag.solv);
3042 else
3043 return __fem->ginteg((int)realpart(eval(s->l1)),
3044 (int)realpart(eval(s->l2)),
3045 (int)realpart(eval(s->l3)),
3046 s->l4->name->table,
3047 tableaddr,
3048 flag.solv);
3049 break;
3050 case partial_x:
3051 return __fem->deriv (0, s->l1->name->table,flag.solv, (int) realpart ((variables.cursom)->value));
3052
3053 case partial_y:
3054 return __fem->deriv (1, s->l1->name->table, flag.solv, (int) realpart ((variables.cursom)->value));
3055
3056 case symb_user:
3057 return __fem->gfemuser (eval (s->l2), s->l1->name->table, (int) realpart ((variables.cursom)->value));
3058
3059 case evalfct:
3060 return __fem->fctval (s->name->table, realpart (eval (s->l1)), realpart (eval (s->l2)));
3061
3062 case prodscal:
3063 return __fem->prodscalar (s->l1->name->table, s->l2->name->table);
3064
3065 case symb_convect:
3066 return __fem->convect (s->l1->name->table,
3067 s->l2->name->table, s->l3->name->table,
3068 realpart (eval (s->l4)), (int) realpart ((variables.cursom)->value));
3069
3070 case rhsconvect:
3071 return __fem->rhsConvect (s->l1->name->table,
3072 s->l2->name->table, s->l3->name->table,
3073 realpart (eval (s->l4)), (int) realpart ((variables.cursom)->value));
3074
3075 case fctdef:
3076 maketable (s);
3077 break;
3078
3079 case sauve:
3080 sauvefct (s);
3081 break;
3082
3083 case charge:
3084 chargfct (s);
3085 break;
3086
3087 case trace:
3088 plot (s);
3089 break;
3090
3091 case trace3d:
3092 plot3d (s);
3093 break;
3094
3095 case fdecl:
3096 return (s->name)->table[cursom];
3097
3098 case cste:
3099 return s->value;
3100
3101 case becomes:
3102 (s->name)->value = eval (s->l1);
3103
3104 case newvar:
3105 case oldvar:
3106 return (s->name)->value;
3107
3108 case fctfile:
3109 (variables.ne)->value = s->value;
3110 if (!realpart (s->value))
3111 return eval (s->l1);
3112 break;
3113
3114 case op_plus:
3115 return eval (s->l1) + eval (s->l2);
3116
3117 case op_minus:
3118 if (s->l1 == NULL)
3119 return -eval (s->l2);
3120 else
3121 return eval (s->l1) - eval (s->l2);
3122
3123 case star:
3124 return eval (s->l1) * eval (s->l2);
3125
3126 case slash:
3127 return eval (s->l1) / eval (s->l2);
3128
3129 case modulo:
3130 return int(realpart(eval(s->l1))) % int(realpart(eval (s->l2)));
3131
3132 case lt:
3133 return (float)(realpart (eval (s->l1) - eval (s->l2)) < 0.F);
3134
3135 case le:
3136 return (float)(realpart (eval (s->l1) - eval (s->l2)) <= 0.F);
3137
3138 case gt:
3139 return (float)(realpart (eval (s->l1) - eval (s->l2)) > 0.F);
3140
3141 case ge:
3142 return (float)(realpart (eval (s->l1) - eval (s->l2)) >= 0.F);
3143
3144 case eq:
3145 return (float)(realpart (eval (s->l1) - eval (s->l2)) == 0.F);
3146
3147 case neq:
3148 return (float)(realpart (eval (s->l1) - eval (s->l2)) != 0.F);
3149
3150 case et:
3151 return (float)(realpart (eval (s->l1)) && realpart (eval (s->l2)));
3152
3153 case ou:
3154 return (float)(realpart (eval (s->l1)) || realpart (eval (s->l2)));
3155
3156 case sine:
3157 return (float)sin (eval (s->l1));
3158
3159 case one:
3160 return fabs (realpart (eval (s->l1))) < (float)1.e-6 ? 0.F : 1.F;
3161
3162 case cosine:
3163 return (float)cos (eval (s->l1));
3164
3165 case atane:
3166 return (float)atan (realpart (eval (s->l1)));
3167
3168 case exponential:
3169 return (float)exp (realpart (eval (s->l1)));
3170
3171 case expo:
3172 return pow (eval (s->l1), realpart(eval (s->l2)));
3173 //return (float)pow (realpart (eval (s->l1)), realpart (eval (s->l2)));
3174
3175 case logarithm:
3176 return (float)log (realpart (eval (s->l1)));
3177
3178 case mini:
3179 return Mini (realpart (eval (s->l1)), realpart (eval (s->l2)));
3180
3181 case maxi:
3182 return Maxi (realpart (eval (s->l1)), realpart (eval (s->l2)));
3183
3184 case absolute:
3185 return (float)fabs (realpart (eval (s->l1)));
3186
3187
3188 case root:
3189 return (float)sqrt (realpart (eval (s->l1)));
3190
3191 case acose:
3192 return (float)acos (realpart (eval (s->l1)));
3193
3194 case asine:
3195 return (float)asin (realpart (eval (s->l1)));
3196
3197 case tane:
3198 return (float)tan (realpart (eval (s->l1)));
3199
3200 case coshe:
3201 return (float)cosh (realpart (eval (s->l1)));
3202
3203 case sinhe:
3204 return (float)sinh (realpart (eval (s->l1)));
3205
3206 case tanhe:
3207 return (float)tanh (realpart (eval (s->l1)));
3208
3209 case partreal:
3210 return realpart (eval (s->l1));
3211
3212 case partimag:
3213 return imagpart (eval (s->l1));
3214
3215 case penall:
3216 if((int)realpart (eval (s->l1))==(int) realpart ((variables.ng)->value))
3217 return 1.F/penal;
3218 else return 0.F;
3219
3220 case si:
3221 if (s->l3 == NULL)
3222 return realpart (eval (s->l1)) ? eval (s->l2) : temp;
3223 else
3224 return realpart (eval (s->l1)) ? eval (s->l2) : eval (s->l3);
3225
3226 case loop:
3227 {
3228 int i;
3229 NumOfIterations = (int)realpart (s->value); // for xgfem
3230 for (i = 1; i <= realpart (s->value); i++)
3231 {
3232 Iter = i;
3233 eval (s->l1);
3234 }
3235 }
3236 break;
3237
3238 case lbrace:
3239 eval (s->l1);
3240 return eval (s->l2);
3241
3242 case arret:
3243 closegraphique ();
3244 sprintf (errbuf, " interpretor stopped");
3245 erreur (errbuf);
3246 break;
3247 case changewait:
3248 waitm = !waitm;
3249 break;
3250 case wait_state:
3251 waitm = 1;
3252 break;
3253 case nowait:
3254 waitm = 0;
3255 break;
3256 case symb_complex:
3257 flag.complexe = 1;
3258 if (flag.param)
3259 {
3260 delete __fem;
3261 initparam ();
3262 }
3263 break;
3264 case symb_precise:
3265 flag.precise = 1;
3266 if (flag.param)
3267 {
3268 delete __fem;
3269 initparam ();
3270 }
3271 break;
3272
3273 default:
3274 sprintf (errbuf, "illegal symbol met in function eval: %s", mesg[s->symb]);
3275 erreur (errbuf);
3276 }
3277 return 0.F;
3278}
creal eval(noeudPtr)
evaluate the node
Definition: femParser.cpp:2855
void initparam()
init the parameters
Definition: femParser.cpp:1417

◆ getMesh()

femMeshCptr fem::femParser::getMesh ( ) const
inline

get the mesh

187 {
188 return &__mesh;
189 }

◆ initparam()

void fem::femParser::initparam ( )

init the parameters

1418{
1419 long tnp = flag.precise ? 3 * (long) __mesh.getNumberOfCells() : (long) __mesh.getNumberOfPoints();
1420
1421 if (flag.param == 0)
1422 {
1423 __fem = new FEM( &__mesh, flag.precise );
1424 }
1425 if (flag.complexe)
1426 {
1427 if ((N == 1) && ((flag.param == 0) || (flag.param == 2)))
1428 {
1429 param.p1c = new creal[tnp];
1430 param.c1c = new creal[tnp];
1431 param.g1c = new creal[tnp];
1432 param.f1c = new creal[tnp];
1433 param.b1c = new creal[tnp];
1434 param.nuyx1c = new creal[tnp];
1435 param.nuxx1c = new creal[tnp];
1436 param.nuxy1c = new creal[tnp];
1437 param.nuyy1c = new creal[tnp];
1438 param.a11c = new creal[tnp];
1439 param.a21c = new creal[tnp];
1440 param.sol1c = new creal[tnp];
1441 if (param.fplot)
1442 {delete [] param.fplot;param.fplot = NULL;}
1443 param.fplot = new float[tnp];
1444
1445 for (int i = 0; i < tnp; i++)
1446 {
1447 param.p1c[i] = 0;
1448 param.c1c[i] = 0;
1449 param.g1c[i] = 0;
1450 param.f1c[i] = 0;
1451 param.b1c[i] = 0;
1452 param.nuyx1c[i] = 0;
1453 param.a11c[i] = 0;
1454 param.a21c[i] = 0;
1455 param.nuxx1c[i] = 0;
1456 param.nuxy1c[i] = 0;
1457 param.nuyy1c[i] = 0;
1458 param.sol1c[i] = 0;
1459 }
1460 flag.param += N;
1461 }
1462 }
1463 else if ((N == 1) && ((flag.param == 0) || (flag.param == 2)))
1464 {
1465 param.p1 = new float[tnp];
1466 param.c1 = new float[tnp];
1467 param.g1 = new float[tnp];
1468 param.f1 = new float[tnp];
1469 param.b1 = new float[tnp];
1470 param.nuyx1 = new float[tnp];
1471 param.nuxx1 = new float[tnp];
1472 param.nuxy1 = new float[tnp];
1473 param.nuyy1 = new float[tnp];
1474 param.a11 = new float[tnp];
1475 param.a21 = new float[tnp];
1476 param.sol1 = new float[tnp];
1477 if (param.fplot)
1478 delete [] param.fplot;
1479 param.fplot = new float[tnp];
1480 for (int i = 0; i < tnp; i++)
1481 {
1482 param.p1[i] = 0.F;
1483 param.c1[i] = 0.F;
1484 param.g1[i] = 0.F;
1485 param.f1[i] = 0.F;
1486 param.b1[i] = 0.F;
1487 param.nuyx1[i] = 0.F;
1488 param.a11[i] = 0.F;
1489 param.a21[i] = 0.F;
1490 param.nuxx1[i] = 0.F;
1491 param.nuxy1[i] = 0.F;
1492 param.nuyy1[i] = 0.F;
1493 param.sol1[i] = 0.F;
1494 }
1495 flag.param += N;
1496 }
1497 else if ((N == 2) && (flag.param < 2))
1498 {
1499 param.p2.init (tnp); //= new cvect[tnp];//(cvect*)safecalloc(tnp,sizecvect);
1500 param.c2.init (tnp); //= new cmat[tnp];//(cmat*)safecalloc(tnp,sizecmat);
1501 param.g2.init (tnp); //=new cvect[tnp];//(cvect*)safecalloc(tnp,sizecvect);
1502 param.f2.init (tnp); //=new cvect[tnp];//(cvect*)safecalloc(tnp,sizecvect);
1503 param.b2.init (tnp); //=new cmat[tnp];//(cmat*)safecalloc(tnp,sizecmat);
1504 param.nuyx2.init (tnp); //=new cmat[tnp];//(cmat*)safecalloc(tnp,sizecmat);
1505 param.nuxx2.init (tnp); //=new cmat[tnp];//(cmat*)safecalloc(tnp,sizecmat);
1506 param.nuxy2.init (tnp); //=new cmat[tnp];//(cmat*)safecalloc(tnp,sizecmat);
1507 param.nuyy2.init (tnp); //=new cmat[tnp];//(cmat*)safecalloc(tnp,sizecmat);
1508 param.a12.init (tnp); //=new cmat[tnp];//(cmat*)safecalloc(tnp,sizecmat);
1509 param.a22.init (tnp); //=new cmat[tnp];//(cmat*)safecalloc(tnp,sizecmat);
1510 param.sol2.init (tnp); //=new cvect[tnp];//(cvect*)safecalloc(tnp,sizecvect);
1511 if (param.fplot)
1512 delete [] param.fplot;
1513 param.fplot = new float[tnp];
1514 for (int i = 0; i < tnp; i++)
1515 {
1516 param.p2[i] = 0.F;
1517 param.c2[i] = 0.F;
1518 param.g2[i] = 0.F;
1519 param.f2[i] = 0.F;
1520 param.b2[i] = 0.F;
1521 param.nuyx2[i] = 0.F;
1522 param.a12[i] = 0.F;
1523 param.a22[i] = 0.F;
1524 param.nuxx2[i] = 0.F;
1525 param.nuxy2[i] = 0.F;
1526 param.nuyy2[i] = 0.F;
1527 param.sol2[i] = 0.F;
1528 }
1529 flag.param += N;
1530 }
1531}

◆ instruction()

noeudPtr fem::femParser::instruction ( void  )
1025{
1026 noeudPtr l1 = NULL, l2 = NULL, l3 = NULL, res = NULL;
1027 Symbol thesym;
1028 ident *theid = NULL;
1029 float thecst;
1030 char *thechaine;
1031
1032 switch (cursym)
1033 {
1034 case si:
1035 nextsym ();
1036 flag.si = 1; /* this forbids vectors in logical expression in if then else statements */
1037 l1 = expr ();
1038 flag.si = 0;
1039 match (alors);
1040 l2 = instruction ();
1041 if (cursym == autrement)
1042 {
1043 nextsym ();
1044 l3 = instruction ();
1045 }
1046 else
1047 l3 = NULL;
1048 plante (&res, si, 0.F, 0, NULL, pt, l1, l2, l3, NULL);
1049 break;
1050
1051 case loop:
1052 nextsym ();
1053 match (lpar);
1054 thecst = curcst;
1055 match (cste);
1056 match (rpar);
1057 l1 = instruction ();
1058 plante (&res, loop, thecst, 0, NULL, pt, l1, NULL, NULL, NULL);
1059 break;
1060
1061 case newvar:
1062 case oldvar:
1063 case fdecl:
1064 theid = curident;
1065 nextsym ();
1066 if (cursym == fctdef)
1067 {
1068 if (strcmp(theid->name,"x")&&strcmp(theid->name,"y")) // moving the mesh
1069 theid->symb = fdecl;
1070 if (!flag.fct)
1071 match (becomes);
1072 match (fctdef);
1073 l1 = expr ();
1074 plante (&res, fctdef, 0.F, 0, theid, pt, l1, NULL, NULL, NULL);
1075 }
1076 else
1077 {
1078 if (theid->symb == fdecl)
1079 theid->symb = oldvar;
1080 match (becomes);
1081 l1 = expr ();
1082 plante (&res, becomes, 0.F, 0, theid, pt, l1, NULL, NULL, NULL);
1083 }
1084 break;
1085
1086 case fctfile: /* when part of the program is stored (not documented) */
1087 res = fctfileproc ();
1088 break;
1089
1090 case symb_bdy:
1091 case polygon:
1092 res = symb_bdyproc ();
1093 break;
1094
1095 case symb_build:
1096 if (!flag.build)
1097 {
1098 sprintf (errbuf, "line %d: Illegal use of symbol 'buildmesh'", numligne);
1099 erreur (errbuf);
1100 }
1101 nba = 0;
1102 nbsd = 0;
1103 nbs = 0;
1104 nextsym ();
1105 match (lpar);
1106 l1 = expr ();
1107 if(cursym==comma) {nextsym(); l2 = expr();} else l2=NULL;
1108 plante (&res, symb_build, 0.F, 0, NULL, pt, l1, l2, NULL, NULL);
1109 match (rpar);
1110 flag.build = 0;
1111 flag.bdy = 0;
1112 flag.fct = 1;
1113 flag.onbdy = 1;
1114 flag.solv = 1;
1115 break;
1116
1117 case chargmsh:
1118 case sauvmsh:
1119 case symb_exec:
1120 res = diskmshproc ();
1121 break;
1122
1123 case charge:
1124 if (!flag.fct)
1125 {
1126 sprintf (errbuf, "Illegal use of symbol %s\n", mesg[cursym]);
1127 erreur (errbuf);
1128 }
1129 thesym = cursym;
1130 nextsym ();
1131 match (lpar);
1132 thechaine = curchaine;
1133 nextsym ();
1134 match (comma);
1135 theid = curident;
1136 switch (theid->symb)
1137 {
1138 case newvar:
1139 case oldvar:
1140 theid->symb = fdecl;
1141 nextsym ();
1142 break;
1143
1144 default:
1145 match (fdecl);
1146 }
1147 if (cursym == comma)
1148 {
1149 nextsym();
1150 l1 = expr();
1151 }
1152 match (rpar);
1153 plante (&res, thesym, 0.F, 0, theid, thechaine, l1, NULL, NULL, NULL);
1154 break;
1155
1156 case sauve:
1157 if (!flag.fct)
1158 {
1159 sprintf (errbuf, "line %d: Unexpected symbol %s\n", numligne, mesg[cursym]);
1160 erreur (errbuf);
1161 }
1162 thesym = cursym;
1163 nextsym ();
1164 match (lpar);
1165 thechaine = curchaine;
1166 nextsym ();
1167 match (comma);
1168 if (cursym == oldvar)
1169 {
1170 thecst = 1.F;
1171 std::ofstream file (thechaine);
1172
1173 file << ' ' << std::endl;
1174 file.close ();
1175 } // clean the file
1176 else
1177 thecst = 0.F;
1178 l1 = expr ();
1179 if (cursym == comma)
1180 {
1181 nextsym();
1182 l2 = expr();
1183 }
1184 match (rpar);
1185 plante (&res, thesym, thecst, 0, NULL, thechaine, l1, l2, NULL, NULL);
1186 break;
1187
1188 case trace:
1189 case trace3d:
1190 if (!flag.fct)
1191 {
1192 sprintf (errbuf, "line %d: Unexpected symbol %s\n", numligne, mesg[cursym]);
1193 erreur (errbuf);
1194 }
1195 thesym = cursym;
1196 nextsym ();
1197 match (lpar);
1198 l1 = expr ();
1199 plante (&res, thesym, 0.F, 0, NULL, pt, l1, NULL, NULL, NULL);
1200 match (rpar);
1201 break;
1202
1203 case adaptmesh:
1204 {
1205 int i = 0;
1206 noeudPtr li[4] = {NULL,NULL,NULL,NULL};
1207 nextsym ();
1208 match (lpar);
1209 li[i++] = expr ();
1210 while (cursym == comma)
1211 {
1212 nextsym();
1213 li[i] = expr();
1214 i++;
1215 }
1216 plante (&res, adaptmesh, 0.F, 0, NULL, pt, li[0], li[1], li[2], li[3]);
1217 match (rpar);
1218 }
1219 break;
1220
1221 case symb_dch:
1222 if (flag.syst)
1223 res = symb_dchproc ();
1224 else
1225 {
1226 sprintf (errbuf, "line %d: onbdy must be nested within solve(){...}\n", numligne);
1227 erreur (errbuf);
1228 }
1229 break;
1230
1231
1232 case symb_pde:
1233 res = symb_pdeproc ();
1234 break;
1235
1236 case symb_solv:
1237 case sauvetout:
1238 thesym = cursym;
1239 if (flag.syst)
1240 erreur ("Embedded solvers are not allowed");
1241 flag.syst = 1;
1242 res = preparesolve ();
1243 l2 = instruction ();
1244 plante (&res, thesym, 0.F, N, NULL, NULL, res, l2, NULL, NULL);
1245 flag.syst = 0;
1246 N = 1;
1247 break;
1248
1249 case varsolve:
1250 //case sauvetout:
1251 thesym = cursym;
1252 if (flag.syst)
1253 erreur ("Embedded solvers are not allowed");
1254 flag.syst = 1;
1255 res = prepvarsolve ();
1256 l2 = instruction ();
1257 match(colon);
1258 l3 = expr();
1259 plante (&res, colon, 0.F, N, NULL, NULL, res, l2, l3, NULL);
1260 flag.syst = 0;
1261 N = 1;
1262 break;
1263
1264 case arret:
1265 case changewait:
1266 case wait_state:
1267 case nowait:
1268 case symb_complex:
1269 case symb_precise:
1270 plante (&res, cursym, 0.F, 0, NULL, pt, NULL, NULL, NULL, NULL);
1271 nextsym ();
1272 break;
1273
1274 case lbrace:
1275 do
1276 {
1277 nextsym ();
1278 l1 = instruction ();
1279 if (res == NULL)
1280 res = l1;
1281 else if (l1)
1282 plante (&res, lbrace, 0.F, 0, NULL, pt, res, l1, NULL, NULL);
1283 }
1284 while (cursym == semicolon);
1285 match (rbrace);
1286 break;
1287
1288 case semicolon:
1289 nextsym ();
1290 case rbrace:
1291 case _end:
1292 break;
1293
1294 default:
1295 sprintf (errbuf, "line %d: Cannot use this symbol to begin an expression: %s",
1296 numligne, mesg[cursym]);
1297 erreur (errbuf);
1298 }
1299 return res;
1300}

◆ libere()

void fem::femParser::libere ( void  )

free everything

3389{
3390 int i;
3391
3392 delete []arete;arete = NULL;
3393 delete []hh;hh = NULL;
3394 delete []cr;cr = NULL;
3395 delete []ngbdy;ngbdy = NULL;
3396 delete []noeuds;noeuds = NULL;
3397 delete []sd;sd= NULL;
3398
3399 for (i = 0; i < numidents; i++)
3400 {
3401 delete [] idents[i].name;
3402 idents[i].name= NULL;
3403 if (idents[i].symb == fdecl)
3404 delete [] idents[i].table; idents[i].table = NULL;
3405 }
3406 delete []thestring;
3407 thestring = NULL;
3408 if (flag.param)
3409 libereparam ();
3410}
void libereparam(void)
free the parameters
Definition: femParser.cpp:3300

◆ libereparam()

void fem::femParser::libereparam ( void  )

free the parameters

3301{
3302 param.p2.destroy ();
3303 param.c2.destroy ();
3304 param.g2.destroy ();
3305 param.f2.destroy ();
3306 param.b2.destroy ();
3307 param.nuyx2.destroy ();
3308 param.nuxx2.destroy ();
3309 param.nuxy2.destroy ();
3310 param.nuyy2.destroy ();
3311 param.a12.destroy ();
3312 param.a22.destroy ();
3313 param.sol2.destroy ();
3314
3315 if (param.fplot)
3316 {delete [] param.fplot;param.fplot = NULL;}
3317 if (param.p1)
3318 {delete [] param.p1;param.p1 = NULL;}
3319 if (param.c1)
3320 {delete [] param.c1;param.c1 = NULL;}
3321 if (param.g1)
3322 {delete [] param.g1;param.g1 = NULL;}
3323 if (param.f1)
3324 {delete [] param.f1;param.f1 = NULL;}
3325 if (param.b1)
3326 {delete [] param.b1;param.b1 = NULL;}
3327 if (param.nuyx1)
3328 {delete [] param.nuyx1;param.nuyx1 = NULL;}
3329 if (param.nuxx1)
3330 {delete []param.nuxx1;param.nuxx1 = NULL;}
3331 if (param.nuxy1)
3332 {delete [] param.nuxy1;param.nuxy1 = NULL;}
3333 if (param.nuyy1)
3334 {delete [] param.nuyy1;param.nuyy1 = NULL;}
3335 if (param.a11)
3336 {delete [] param.a11;param.a11 = NULL;}
3337 if (param.a21)
3338 {delete [] param.a21;param.a21 = NULL;}
3339 if (param.sol1)
3340 {delete [] param.sol1;param.sol1 = NULL;}
3341 if (param.p1c)
3342 {delete [] param.p1c;param.p1c = NULL;}
3343 if (param.c1c)
3344 {delete []param.c1c;param.c1c = NULL;}
3345 if (param.g1c)
3346 {delete []param.g1c;param.g1c = NULL;}
3347 if (param.f1c)
3348 {delete []param.f1c;param.f1c = NULL;}
3349 if (param.b1c)
3350 {delete []param.b1c;param.b1c= NULL;}
3351 if (param.nuyx1c)
3352 {delete []param.nuyx1c;param.nuyx1c = NULL;}
3353 if (param.nuxy1c)
3354 {delete []param.nuxx1c;param.nuxx1c = NULL;}
3355 if (param.p1)
3356 {delete []param.nuxy1c;param.nuxy1c= NULL;}
3357 if (param.nuyy1c)
3358 {delete []param.nuyy1c;param.nuyy1c = NULL;}
3359 if (param.a11c)
3360 {delete []param.a11c; param.a11c = NULL;}
3361 if (param.a21c)
3362 {delete []param.a21c;param.a21c = NULL;}
3363 if (param.sol1c)
3364 {delete []param.sol1c;param.sol1c = NULL;}
3365
3366 delete __fem;
3367 flag.param = 0;
3368}

◆ New()

static femParser * fem::femParser::New ( )
inlinestatic

create a new instance

151 {
152 return new femParser;
153 }
femParser()
default constructor
Definition: femParser.cpp:123

◆ parse()

void fem::femParser::parse ( )

parse the buffer

173{
174
175 initlex( __text );
176 __tree = instruction();
177 chvar();
178
179 if ( __graphic_type == FEM_GRAPHIC )
180 {
181 initgraphique();
182 }
183
184 eval(__tree);
185}

◆ setGraphicType()

void fem::femParser::setGraphicType ( GraphicsType  gt)
inline

set the graphic type

129 {
130 __graphic_type = gt;
131 }

◆ setText()

void fem::femParser::setText ( const char *  __t)
inline

set the buffer to be parsed

135 {
136 if ( __text != 0 )
137 {
138 delete[] __text;
139 }
140 __text = new char[strlen( __t )+1];
141 strcpy( __text, __t );
142 }

◆ showtree()

void fem::femParser::showtree ( noeudPtr  t)

show the tree

3445{
3446 showtreeaux (0, f);
3447}

The documentation for this class was generated from the following files:

This is the FreeFEM reference manual
Provided by The KFEM project