8. The blocks#

Blocks are in the form of a grouping of keywords. They allow for two things:

  • translate logical rules relating to the value or type of content of simple keywords into the order catalog; whereas the conditions under the rules argument relate only to the presence or absence of keywords. We can therefore group keywords together or assign them specific attributes (value by default…) under certain conditions.

  • group keywords by families for greater clarity in AsterStudy. These keywords will then only be visible to the user when the condition is met.

Examples:

SOLVEUR = FACT (status='d',


METHODE = SIMP (status='f', typ=' TXM ', default=" MULT_FRONT ",

into= (" MULT_FRONT "," LDLT ")),


b_mult_front = BLOC (condition = "equal_to ('METHODE', 'MULT_FRONT')",

fr=tr ("Parameters of the multi-frontal method"),

RENUM = SIMP (status='f', typ=' TXM ', default=" MDA ",

into= ("MD"," MDA "," METIS ")),

),

b_ldlt = BLOC (condition = "equal_to ('METHODE', 'LDLT')",

fr=tr ("Parameters for method LDLT "),

RENUM = SIMP (status='f', typ=' TXM ', default=" RCMK ",

into= (" RCMK "," SANS ")),

TAILLE = SIMP (status='f', typ='R', default= 400.),

),

),

Blocks are named by the developer. Their names should start with « b_. » In the example, if METHODEvaut MULT_FRONT, then the optional simple keyword RENUMapparaîtra with three possible values declared under into. On the other hand, if METHODEvaut LDLT, the same keyword will be present but with two different possible values; in addition, it will then be possible to enter the simple keyword TAILLE. These keywords and their respective attributes will only appear in AsterStudy after the user has assigned a value to the simple METHODE keyword.

b_blockname = BLOC (

condition="exists ('MOTCLE1') and is_type ('MOTCLE2') ==grma",

...

This example shows that the condition can be multiple (articulated by or/and) and can also relate to the presence of the keyword (exists (“MOTCLE1”)) or the type of what it contains (is_type (“MOTCLE2”) == grma).

The condition is a Python expression (provided as a string) that is evaluated at the level immediately above the block itself.

Block conditions should not manipulate keywords directly but use functions that rely on keyword names.

These functions are as follows:

  • exists (“MOTCLE”) is checked if MOTCLE exists, i.e. has been entered by the user.

Example: exists (“TYPE_MATR_TANG”).

  • is_in (“MOTCLE”, VALEURS) is checked if the intersection between the value (s) of MOTCLEet VALEURSest is not empty.

Example: is_in ( » CRIT_COMP « , (“EQ”, “NE”).

  • equal_to (“MOTCLE”, VALEUR) is exactly the same as is_in but more natural when MOTCLEet VALEURne only contains one value.

Example: equal_to (“METHODE”, “MUMPS”).

  • is_type (“MOTCLE”) returns the type of MOTCLE.

Example: is_type (“FONCTION”) in (function, function_c).

  • value (“MOTCLE”, default= ») returns the value of MOTCLEs if it exists, otherwise returns the default value which is an empty string by default.

Example: value ( » RELATION « ) .startswith (”META_”).

  • length (“MOTCLE”) returns the number of values provided for MOTCLE. Returns 0 if you don’t know how to calculate the length of value (“MOTCLE”) or if it doesn’t exist.

Example: length (“FREQ”) > 2.

  • less_than (“MOTCLE”, VALEUR) is checked if the value of MOTCLEest is less than VALEUR. Return False if MOTCLEn doesn’t exist.

Example: less_than (“COEF_MULT”, 0).

  • greater_than (“MOTCLE”, VALEUR) is checked if the value of MOTCLEest is greater than VALEUR. Return False if MOTCLEn doesn’t exist.

Example: greater_than (“COEF_MULT”, 0).

Attention :

The keywords manipulated in the conditionof BLOCdoivent be at the same level as the block itself in the tree defined by the factor keywords and blocks. Several keywords BLOCpeuvent be present in the same catalog, at the main root of the order, under factor keywords or in other blocks. In the example above, the simple keywords RENUMet * TAILLE_BLOC are at the same level, lower than METHODE, b_mult_front, and b_ldlt, which is itself lower than that of the factor keyword SOLVEUR. The conditions tested in both blocks thus relate only to the simple keyword METHODEde, a level immediately higher than the blocks themselves.

Attention should be paid to possible conflicts when the same keyword is present in two different blocks. The conditions for activating the two blocks must then be excluded. This is the case of the example above with the simple keyword RENUM: there can be no conflict since the twoconditions METHODE =” MULT_FRONT “ and METHODE =” LDLT “ “ “ cannot be simultaneously satisfied. In a case where the conditions are met at the same time, an error would occur at runtime.