Interface with the user syntax

Detailed description

This sections presents the basis to execute Commands.

All Commands executors are subclasses of ExecuteCommand. Commands are factories (ExecuteCommand.run() classmethod) that create an executor that is called to create a result object.

When a new command is added there are different levels of complexity:

  • Commands that are automatically added just using their catalog. Only the commands that return no result can work with this method. Other commands will raise a NotImplementedError exception at runtime. Macro-commands do not need a specific executor. Their catalog and ops() function are sufficient.

    Note

    All Commands that are not explicitly imported by code_aster.Commands.__init__ are automatically created using this method.

  • Commands where the Fortran operator is directly called. Usually it is just necessary to define the type of result object. Example: defi_compor.

  • Commands where keywords are used to create the output result. Example: defi_group.

  • Commands where several steps must be adapted. Usually, the operator directly calls C++ Objects to do the job.

For all features that are not yet supported, please use utilities from the code_aster.Utilities functions (example: unsupported() or required()) to identify them.

Base classes

code_aster.Supervis.ExecuteCommand.command_execution()[source]

Context manager used to simulate the execution of a legacy Fortran operator.

class code_aster.Supervis.ExecuteCommand.ExecuteCommand[source]

Bases: object

This class implements an executor of commands.

Commands executors are defined by subclassing this class and overloading some of the methods. A user’s Command is a factory of these classes.

The run() factory creates an instance of one of these classes and executes successively these steps:

  • compat_syntax_() to eventually change the user’s keywords to adapt the syntax from an older version before syntax checking. Subclasses must not overload this method. The compatibility changes must be defined in compat_syntax attribute in the catalog. Subclasses may define a change_syntax() method for modifications on non-keywords arguments. This should be limited to very specific cases.

  • check_syntax() to check the user’s keywords conformance to to catalog definition.

  • adapt_syntax() to eventually change the user’s keywords to adapt the syntax after syntax checking. Does nothing by default.

  • create_result() to create the DataStructure object. The default implementation only works if the operator creates no object.

  • exec_() that is the main function of the Command. The default implementation calls the legacy Fortran operator.

  • post_exec() that allows to execute additional code after the main function. Does nothing by default.

If a libaster.AsterError exception (or a derivated) is raised during exec_() the behaviour depends on the execution mode.

  • In a standard study, the results are saved and the execution is interrupted. The current result is available if it is validated by the command and the study can be restarted.

  • In the testcase mode (option --test used, see ExecutionParameter or CODE in DEBUT()/POURSUITE()), the exception is raised and can be catched in the commands file. The current result will be available in the except statement if it is validated by the command.

__init__()[source]

Initialization

classmethod run(**kwargs)[source]

Run the command (class method).

Parameters:

keywords (dict) – User keywords

run_(**kwargs)[source]

Run the command (worker).

Parameters:

keywords (dict) – User keywords

publish_result()[source]

Publish the result in the caller context.

property caller_context

The context from which the command has be called.

Type:

dict

property exception

Exception raised during the execution, None if the execution was successful.

Type:

AsterError

static register_hook(func)[source]

Register a hook for post_exec step.

Parameters:

func (function) – Function with signature: ExecuteCommand, dict of keywords.

classmethod show_syntax()[source]

Tell if the current command syntax should be printed.

Returns:

True if the syntax should be printed.

Return type:

bool

_call_oper(syntax)[source]

Call fortran operator.

Parameters:

syntax (CommandSyntax) – Syntax description with user keywords.

property name

Returns the command name.

add_dependencies(keywords)[source]

Register input DataStructure objects as dependencies.

The default implementation registers all input objects as dependencies.

Parameters:

keywords (dict) – User’s keywords.

remove_dependencies(keywords, key1, key2=None)[source]

Remove dependencies to the input DataStructure objects passed with given keywords.

Parameters:
  • keywords (dict) – User’s keywords.

  • key1 (str/list[str]) – One or more simple keywords, or factor keyword.

  • key2 (str/list[str]) – One or more simple keywords if key1 is a factor keyword.

compat_syntax_(keywords)[source]

Call the compatibility function defined in catalog.

As the keywords have not been checked, no assumptions can be done about the presence or the number of values for example. If the syntax is already valid, call adapt_syntax() instead.

Parameters:

keywords (dict) – Keywords arguments of user’s keywords, changed in place.

change_syntax(keywords)[source]

Hook to change keywords before checking syntax.

You must define compat_syntax in the command catalog to adapt the syntax from an old version or for compatibility. compat_syntax is also used by AsterStudy, change_syntax is only called during execution and limited to very specific cases.

If the syntax is already valid, call adapt_syntax() instead.

Parameters:

keywords (dict) – Keywords arguments of user’s keywords, changed in place.

adapt_syntax(keywords)[source]

Hook to adapt syntax after syntax checking.

As the syntax is valid, changes are easier: existence, number of values verify syntax description.

Parameters:

keywords (dict) – Keywords arguments of user’s keywords, changed in place.

print_syntax(keywords)[source]

Print an echo of the Command.

Parameters:

keywords (dict) – Keywords arguments of user’s keywords.

print_result()[source]

Print an echo of the result of the command.

_print_stats()[source]

Print the memory and timer informations.

check_syntax(keywords)[source]

Check the syntax passed to the command. keywords will contain default keywords after executing this method.

Parameters:

keywords (dict) – Keywords arguments of user’s keywords, changed in place.

create_result(keywords)[source]

Create the result before calling the exec command function if needed. The result is stored in an internal attribute and will be built by exec_.

Parameters:

keywords (dict) – Keywords arguments of user’s keywords.

property result

Attribute that holds the result of the Command.

Type:

misc

exec_(keywords)[source]

Execute the command.

Parameters:

keywords (dict) – User’s keywords.

post_exec_(keywords)[source]

Post-treatments executed after the exec_ function. Commands may override post_exec method to add specific actions.

Parameters:

keywords (dict) – Keywords arguments of user’s keywords.

post_exec(keywords)[source]

Hook that allows to add post-treatments after the exec function.

Note

If the Command executes the op fortran subroutine and if the result DataStructure references any inputs in a Jeveux object, pointers on these inputs must be explicitly references into the result.

Parameters:

keywords (dict) – Keywords arguments of user’s keywords.

cleanup()[source]

Clean-up function.

check_ds()[source]

Check a result created by the command.

Parameters:

result (DataStructure) – Object to be checked.

static check_ds_result(result)[source]

Check a DataStructure object.

Parameters:

result (DataStructure) – Object to be checked.

keep_caller_infos(keywords, level=3)[source]

Register the caller frame infos.

Parameters:
  • keywords (dict) – Dict of keywords.

  • level (Optional[int]) – Number of frames to rewind to find the caller. Defaults to 2 (1: here, 2: run_, 3: run).

classmethod debugPrintAll()[source]

Call debugPrint() after each command.

Use ExecuteCommand.debugPrintAll() in a testcase to make each command to dump its result content.

code_aster.Supervis.ExecuteCommand.check_jeveux()[source]

Check that the memory manager (Jeveux) is up.

class code_aster.Supervis.ExecuteCommand.ExecuteMacro[source]

Bases: ExecuteCommand

This implements an executor of legacy macro-commands.

The OPS function of legacy macro-commands returns a return code and declared results through self.register_result(...).

Now the results must be directly returned by the OPS function.

Long term: result = MACRO_COMMAND(**keywords) where result is a DataStructure object (for one result) or a namedtuple-like object (a code_aster NamedTuple) for several results). result is created by the ops function.

For compatibility: create_result() gets the names of the results. The ops function returns the “main” result and registers others with register_result(). exec_() adds it at first position of the namedtuple under the name “main”.

_sdprods

List of CO objects.

Type:

list[CO]

_result_names

List of expected results names.

Type:

list[str]

_add_results

Dict of additional results.

Type:

dict

__init__()[source]

Initialization

create_result(keywords)[source]

Macro-commands create their results in the exec_ method.

Parameters:

keywords (dict) – Keywords arguments of user’s keywords.

print_result()[source]

Print an echo of the result of the command.

cleanup()[source]

Clean-up function.

Force deletion of removed objects after each macro-command. Some macro-commands may directly call gc.collect() if they create a lot of objects or if there is a risk to recreate an object with the same name (example: NonLinearOperator).

exec_(keywords)[source]

Execute the command and fill the _result attribute.

Parameters:

keywords (dict) – User’s keywords.

register_result(result, target)[source]

Register an additional result.

It must called after that the result has been created.

Parameters:
  • result (DataStructure) – Result object to register.

  • target (CO) – CO object.

check_ds()[source]

Check all results created by the command.

Parameters:

result (DataStructure) – Object to be checked.

add_dependencies(keywords)[source]

Register input DataStructure objects as dependencies.

Macro-commands should not have to add dependencies. This should be done by embedded commands.

Parameters:

keywords (dict) – User’s keywords.

property sdprods

Attribute that holds the auxiliary results.

code_aster.Supervis.ExecuteCommand.UserMacro(name, cata, ops)[source]

Helper function that defines a user macro-command from its catalog description and its operator.

Parameters:
  • name (str) – Name of the macro-command.

  • cata (PartOfSyntax) – Catalog description of the macro-command.

  • ops (str) – OPS function of the macro-command.

Returns:

Executor function.

Return type:

ExecuteCommand.run

class code_aster.Supervis.ExecuteCommand.CO(name='unnamed')[source]

Bases: PyDataStructure

Object that identify an auxiliary result of a Macro-Command.

property value_repr

Returns the representation as a keyword value.

is_typco()[source]

Tell if it is an auxiliary result.

getType()[source]

Return a type for syntax checking.

setType(typ)[source]

Declare the future type.

settype(typ)

Declare the future type.

code_aster.Supervis.ExecuteCommand.publish_in(context, dict_objects)[source]

Publish some objects in a context.

It supports list of results as declared in code_aster legacy: If an object is name xxx_n and that xxx exists and is a list in context and xxx[n] exists this item of the list is replaced by the new value.

Parameters:
  • context (dict) – Destination context, changed in place.

  • dict_objects (dict) – Objects to be added into the context.

code_aster.Supervis.ExecuteCommand.get_user_name(command, filename, lineno, strict=True)[source]

Parse the caller syntax to extract the name used by the user.

Parameters:
  • command (str) – Command name.

  • filename (str) – Filename of the caller

  • lineno (int) – Line number in the file.

  • strict (bool, optional) – Tell if the name must be a valid Python variable name.

Returns:

Variable name used by the user, empty if not found.

Return type:

str

code_aster.Supervis.ExecuteCommand.command_separator()[source]

Return a separator line.

Returns:

A separator line.

Return type:

str

code_aster.Supervis.ExecuteCommand.command_header(counter, filename, lineno)[source]

Return the command header.

Parameters:

counter (int) – Number of the command.

Returns:

String representation.

Return type:

str

code_aster.Supervis.ExecuteCommand.command_result(counter, command_name, result)[source]

Return the command footer.

Parameters:
  • counter (int) – Number of the command.

  • command_name (str) – Command name.

  • result (DataStructure|str|list[str]) – Result object or name(s) of the result(s) of the command.

Returns:

String representation.

Return type:

str

code_aster.Supervis.ExecuteCommand.command_memory(command_name)[source]

Return a representation of the current memory consumption.

Parameters:

command_name (str) – Command name.

Returns:

String representation.

Return type:

str

code_aster.Supervis.ExecuteCommand.command_time(counter, cpu, system, elapsed)[source]

Return a representation of elapsed times in a command.

Parameters:
  • cpu (float) – User time.

  • system (float) – System time.

  • elapsed (float) – Elapsed time.

Returns:

String representation.

Return type:

str

class code_aster.Supervis.ExecuteCommand.loop_on_dsdict(mark: str)[source]

Bases: object

Decorator on ExecuteCommand that overloads ‘run_’ method to loop on each result of a DataStructureDict.

Parameters:

mark (str) – Possible paths to keywords that may hold the DataStructureDict object. Format: “mcf1/mcs1|mcf2/mcs2|mcs3|…”

__init__(mark: str)[source]
class code_aster.Supervis.ExecuteCommand.ExceptHookManager[source]

Bases: object

Object to manager the definition of the excepthook.

classmethod enter(command)[source]

Assign the excepthook when entering in a command.

classmethod exit(command)[source]

Called when exiting a command.

classmethod init()[source]

Assign the basic hook.

classmethod excepthook(type, value, traceb)[source]

Hook called on uncaught exceptions raised during the execution of a command.

Parameters:
  • command (ExecuteCommand) – The current command.

  • type (type) – Exception type.

  • value (BaseException) – Exception instance.

  • traceb (traceback) – Exception traceback.

classmethod wraps(command)[source]

Context manager used to enable a specific hook during a command execution.

Serializer — Serialization of code_aster objects

code_aster objects are saved and reloaded using the pickle protocol.

saveObjects() does the saving of objects which are available in the user context (in which saveObjects() is called). The command FIN() automatically calls this function.

Objects are reloaded by the function loadObjects() called just after the Jeveux database has been reloaded by init() if the --continue argument is passed. The command POURSUITE() does also the same.

class code_aster.Supervis.Serializer.FinalizeOptions(value)[source]

Bases: IntFlag

Options for closure.

  • SaveBase: The database is saved.

  • OnlyProc0: The database is saved only on rank #0.

  • InfoResu: Print detailed informations about Result objects.

  • Repack: Enable repacking process.

  • Set: Indicates that options are set (different from the default, 0).

class code_aster.Supervis.Serializer.Serializer(context=None)[source]

Bases: object

This class manages ‘save & reload’ feature.

Parameters:

context (dict) – The context to be saved or in which the loaded objects have to been set.

_ctxt

Working context.

Type:

dict

_pick_filename

Filename of the pickle file.

Type:

str

_base

Filename of the Jeveux database file.

Type:

str

_sha_filename

Filename containing the SHA of the both previous files.

Type:

str

__init__(context=None)[source]

Initialization :param context: context to save or in which loading objects :type context: dict

classmethod canRestart(silent=False)[source]

Tell if a restart is possible. This means that glob & pickled files are consistent.

Parameters:

silent (bool) – if True returns silently, otherwise it raises an exception in case of error.

Returns:

True if the previous execution can be continued.

Return type:

bool

save()[source]

Save objects of the context.

Returns:

List of the names of the DataStructure objects actually saved.

Return type:

list[str]

sign()[source]

Sign the saved files and store their SHA signatures.

load()[source]

Load objects into the context.

code_aster.Supervis.Serializer.saveObjects(level=1, delete=True, options=0)[source]

Save objects of the caller context.

Parameters:
  • level (int) – Number of frames to go back to find the user context.

  • delete (bool) – If True the saved objects are deleted from the context.

  • options (FinalizeOptions) – Options for finalization.

code_aster.Supervis.Serializer.saveObjectsFromContext(context, delete=True, options=0)[source]

Save objects of the given context.

Parameters:
  • context (dict) – Context to be saved.

  • delete (bool) – If True the saved objects are deleted from the context.

  • options (FinalizeOptions) – Options for finalization.

code_aster.Supervis.Serializer.loadObjects(level=1)[source]

Load objects from a file in the caller context.

Parameters:

level (int) – Number of frames to go back to find the user context.

code_aster.Supervis.Serializer.contains_datastructure(sequence)[source]

Tell if a sequence contains a DataStructure.

Parameters:

sequence (iterable) – List-like object.

Returns:

True if sequence contains a DataStructure, False otherwise.

Return type:

bool

class code_aster.Supervis.Serializer.PicklingHelper[source]

Bases: object

Adapt pickling of DataStructure objects.

The objects are identified with their names and are taken from a cache if an object with the same name already exists.

See Dispatch Tables from the pickle documentation.

code_aster.Supervis.Serializer.subtypes(cls)[source]

Return subclasses of ‘cls’.

class code_aster.Supervis.Serializer.AsterPickler(file, protocol=None, fix_imports=True, buffer_callback=None)[source]

Bases: Pickler

Adapt pickling of DataStructure objects.

In the Python namespace, DataStructures are wrappers on shared_ptr through pybind11 instances. So there are several pointers for the same instance. Standard pickling creates new objects for each pointers and during unpickling this creates new pybind11 instance for each Python wrapper. To avoid that, the creation of DataStructure is delegated to the PicklingHelper object.

See Dispatch Tables from the pickle documentation.

code_aster.Supervis.Serializer._filteringContext(context)[source]

Return a context by filtering the input objects by excluding: - modules, - code_aster objects, - …

Parameters:

context (dict) – Context to be filtered.

Returns:

New cleaned context.

Return type:

dict

code_aster.Supervis.Serializer.read_signature(sha_file)[source]

Read the signatures from the file containing the SHA strings.

Parameters:

sha_file (str) – Filename of the pickled file to read.

Returns:

List of the two signatures as SHA256 strings that identify

the pickled file and the (first) Jeveux database file.

Return type:

list[str]

code_aster.Supervis.Serializer.file_signature(filename, offset=0, bufsize=-1)[source]

Compute a signature of the file.

Parameters:
  • filename (str) – File to sign.

  • offset (int) – Offset before reading content (default to 0).

  • bufsize (int) – Size of the content to read (default to -1, content is read up to EOF).

Returns:

Signature as SHA256 string to identify the file.

Return type:

str

CommandSyntax — Interface between C++/Fortran operators and user syntax

The CommandSyntax provides an interface between operators originally defined in Fortran (opXXXX subroutines) and the user syntax. The C/Fortran interface is defined in aster_module.c.

It is also used in some C++ objects to emulate a user command. The C++ interface is available from C++ CommandSyntax class.

The method define() stores the user keywords. The execution of an operator (by libaster.call_oper() for example) registers the current CommandSyntax instance that can be requested by the operator using the functions:

class code_aster.Supervis.CommandSyntax.CommandSyntax(name='unNamed', cata=None)[source]

Bases: object

This class describes the syntax of command for compatibility with the fortran code that use the legacy supervisor.

classmethod setCurrentCommand(command)[source]

Register current command.

Parameters:

command (CommandSyntax) – CommandSyntax to register.

classmethod getCurrentCommand()[source]

Return the current command.

Returns:

Current registered CommandSyntax.

Return type:

CommandSyntax

__init__(name='unNamed', cata=None)[source]

Create a new command or part of syntax.

Parameters:
  • name (str) – Command name (ex: “DEBUT”) or path to catalog (ex: “code_aster.Cata.Commands.DEBUT”).

  • cata (PartOfSyntax) – Command description.

free()[source]

Reset the current command pointer as soon as possible

__repr__()[source]

Representation of the command

debugPrint()[source]

Representation of the command

setResult(sdName, sdType)[source]

Register the result of the command: name and type.

Parameters:
  • sdName (str) – Name of the result created by the Command.

  • sdType (str) – Type of the result created by the Command.

define(dictSyntax, add_default=True, check_syntax=False)[source]

Register the keywords values.

Parameters:
  • dictSyntax (dict) – User keywords.

  • add_default (bool, optional) – Tell if default keywords have to be added or not.

  • check_syntax (bool, optional) – Check that the keywords validity. Only when it has not already been checked by ExecuteCommand object.

getName()[source]

Return the command name.

Returns:

Command name.

Return type:

str

getResultName()[source]

Return the name of the result of the Command.

Returns:

Name of the result of the Command.

Return type:

str

getResultType()[source]

Return the type of the result of the command.

Returns:

Type name of the result of the Command.

Return type:

str

getResultValue()[source]

Return the value of the result of the Command.

Returns:

Name of the result of the Command.

Return type:

str

_getFactorKeyword(factName)[source]

Return the occurrences of a factor keyword.

Parameters:

factName (str) – Name of the factor keyword.

Returns:

List of occurences of a factor keyword, None if it is not

provided by the user.

Return type:

list

_getFactorKeywordOccurrence(factName, occurrence)[source]

Return the definition of an occurrence of a factor keyword.

Parameters:
  • factName (str) – Name of the factor keyword.

  • occurrence (int) – Index of the occurrence (start from 0).

Returns:

Occurrence of a factor keyword, None if it is not

provided by the user.

Return type:

dict

_getDefinition(factName, occurrence)[source]

Return the definition of a factor keyword or of the top-level if factName is blank.

Parameters:
  • factName (str) – Name of the factor keyword.

  • occurrence (int) – Index of the occurrence (start from 0).

Returns:

User keywords under a factor keyword or the Command.

Return type:

dict

_getCataDefinition(factName)[source]

Return the definition of a factor keyword in the catalog or of the top-level if factName is blank.

Parameters:

factName (str) – Name of the factor keyword.

Returns:

Definition of the factor keyword or the Command.

Return type:

CataDefinition

getFactorKeywordNbOcc(factName)[source]

Return the number of occurrences of a factor keyword in the user’s keywords.

Parameters:

factName (str) – Name of the factor keyword.

Returns:

Number of occurrences of a factor keyword.

Return type:

int

getfac(factName)

Return the number of occurrences of a factor keyword in the user’s keywords.

Parameters:

factName (str) – Name of the factor keyword.

Returns:

Number of occurrences of a factor keyword.

Return type:

int

existsFactorAndSimpleKeyword(factName, occurrence, simpName)[source]

Tell if the couple ( factor keyword, simple keyword ) exists in the user keywords.

Parameters:
  • factName (str) – Name of the factor keyword.

  • occurrence (int) – Index of the occurrence (start from 0).

  • simpName (str) – Name of the simple keyword.

Returns:

1 if the keyword exists, else 0.

Return type:

int

getValue(factName, occurrence, simpName)[source]

Return the values of a (simple) keyword.

Parameters:
  • factName (str) – Name of the factor keyword.

  • occurrence (int) – Index of the occurrence (start from 0).

  • simpName (str) – Name of the simple keyword.

Returns:

List of the values provided by the user.

Return type:

list[misc]

getltx(factName, simpName, occurrence, maxval, lenmax)[source]

Wrapper function to return length of strings.

Parameters:
  • factName (str) – Name of the factor keyword.

  • simpName (str) – Name of the simple keyword.

  • occurrence (int) – Index of the occurrence (start from 0).

  • maxval (int) – Maximum number of values read.

  • lenmax (int) – Maximum of lengths.

Returns:

List of the values provided by the user.

Return type:

list[misc]

getvid(factName, simpName, occurrence, maxval)[source]

Wrapper function to return a list of results.

Parameters:
  • factName (str) – Name of the factor keyword.

  • occurrence (int) – Index of the occurrence (start from 0).

  • simpName (str) – Name of the simple keyword.

  • maxval (int) – Maximum number of values read.

Returns:

Returns two values (size, values). size is the number of the values provided by the user. If size > maxval, -size is returned. values is a list of result names.

Return type:

int, list

getvtx(factName, simpName, occurrence, maxval)[source]

Wrapper function to return a list of strings.

Parameters:
  • factName (str) – Name of the factor keyword.

  • occurrence (int) – Index of the occurrence (start from 0).

  • simpName (str) – Name of the simple keyword.

  • maxval (int) – Maximum number of values read.

Returns:

Returns two values (size, values). size is the number of the values provided by the user. If size > maxval, -size is returned. values is a list of strings.

Return type:

int, list

getvis(factName, simpName, occurrence, maxval)[source]

Wrapper function to return a list of integers.

Parameters:
  • factName (str) – Name of the factor keyword.

  • occurrence (int) – Index of the occurrence (start from 0).

  • simpName (str) – Name of the simple keyword.

  • maxval (int) – Maximum number of values read.

Returns:

Returns two values (size, values). size is the number of the values provided by the user. If size > maxval, -size is returned. values is a list of integers.

Return type:

int, list

getvr8(factName, simpName, occurrence, maxval)[source]

Wrapper function to return a list of float numbers.

Parameters:
  • factName (str) – Name of the factor keyword.

  • occurrence (int) – Index of the occurrence (start from 0).

  • simpName (str) – Name of the simple keyword.

  • maxval (int) – Maximum number of values read.

Returns:

Returns two values (size, values). size is the number of the values provided by the user. If size > maxval, -size is returned. values is a list of floats.

Return type:

int, list

getvc8(factName, simpName, occurrence, maxval)[source]

Wrapper function to return a list of complex numbers.

Parameters:
  • factName (str) – Name of the factor keyword.

  • occurrence (int) – Index of the occurrence (start from 0).

  • simpName (str) – Name of the simple keyword.

  • maxval (int) – Maximum number of values read.

Returns:

Returns two values (size, values). size is the number of the values provided by the user. If size > maxval, -size is returned. values is a list of complex numbers.

Return type:

int, list

getvpy(factName, simpName, occurrence)[source]

Wrapper function to return a list of Python objects.

Parameters:
  • factName (str) – Name of the factor keyword.

  • occurrence (int) – Index of the occurrence (start from 0).

  • simpName (str) – Name of the simple keyword.

Returns:

Tuple containing the objects provided by the user.

Return type:

list

getres()[source]

Return the name and type of the result, and the command name.

Returns:

Name of the Command result (name of the jeveux object). str: Type name of the result. str: Command name.

Return type:

str

setres(value)[source]

Define a value for special commands that returns a builtin type (int or float).

Parameters:

value (int|float) – Value returned.

getexm(factName, simpName)[source]

Tell if the couple ( factor keyword, simple keyword ) exists in the Command catalog. It supposes that all blocs conditions are verified.

Parameters:
  • factName (str) – Name of the factor keyword.

  • simpName (str) – Name of the simple keyword.

Returns:

1 if the keyword exists, else 0.

Return type:

int

getmjm(factName, occurrence, maxval)[source]

Return the list of simple keywords provided by the user under a factor keyword.

Parameters:
  • factName (str) – Name of the factor keyword.

  • occurrence (int) – Index of the occurrence (start from 0).

  • maxval (int) – Maximum number of values returned.

Returns:

Two lists: one for the names of simple keywords, alphabetically sorted, and one for the type names of the keywords.

Return type:

list[str], list[str]

getoper()[source]

Return the operator number.

Returns:

Number of the fortran operator subroutine.

Return type:

int

code_aster.Supervis.CommandSyntax._check_strings(factName, simpName, value)[source]

Check that keyword values are strings.

Parameters:

value (str) – Values extracted from a keyword.

Returns:

String values or names for DataStructure objects.

Return type:

list[str]

Definition of code_aster exceptions

The exceptions classes are created from C++. The module code_aster.Supervis.exceptions_ext defines convenient methods for formatting and adds them to the base class code_aster.AsterError.

The class hierarchy for code_aster exceptions is:

AsterError
 |
 +-- ConvergenceError
 |      Raised in case of convergence problem.
 |
 +-- IntegrationError
 |      Raised during local integration (of the behavior for example).
 |
 +-- SolverError
 |      Raised during solving phases.
 |
 +-- ContactError
 |      Raised during contact algorithms.
 |
 +-- TimeLimitError
        Raised when the time limit is reached.

The arguments of AsterError exceptions are the message identifier (idmess) and, optionally and in this order, list of strings (valk), list of ints (vali) and list of floats (valr).

code_aster.Supervis.exceptions_ext.format(exc, code)[source]

Return the related message formatted according to code.

Parameters:
  • exc (AsterError) – Exception raised.

  • code (str) – Level of the message (one of ‘AIESF’, see Utmess).

Returns;

str: Message of the exception.

code_aster.Supervis.exceptions_ext.format_exception(exc)[source]

Return the text to show an exception.

Parameters:

exc (AsterError) – Exception raised.

Returns;

str: String representation of the exception.

code_aster.Supervis.exceptions_ext.get_idmess(exc)[source]

Return the message identifier of the exception.

Parameters:

exc (AsterError) – Exception raised.

Returns;

str: Message identifier (example: CALCUL_12).

typeaster — Understanding code_aster types

This module gives basic functions to convert types as defined in catalogs to their corresponding C++ objects, or their type names as string.

code_aster.Supervis.typeaster.typeaster(cata_type)[source]

Convert a code_aster type used in the syntax description as a string.

Parameters:

cata_type (misc) – Type of a keyword.

Returns:

Name of the code_aster type.

Return type:

str