numpy/scipy to aster datas, and vice versa

Hi,

is it possible to create cham_no type of data from a numpy array ?

Is it possible to do the same for matrices, create one from sparse datas ? (Because of element dependancy, I primarly think no, but why not.)

If not, how to add rows and columns to an existing aster matrix ? Add rows to an existing aster vector ?

The idea is to solve a linear problem with large amount of dofs. It would be better to do it inside aster rather than scipy I think.

I dig a bit in the subject.

I am able to modify an existing cham_no like

PHI = CREA_CHAMP(NOM_CHAM='DEPL',
                 NUME_MODE=1,
                 OPERATION='EXTR',
                 RESULTAT=modes,
                 TYPE_CHAM='NOEU_DEPL_R')

PHI2 = PHI
PHI2.setValues(list_of_vals)

How to create one from nothing ?

In the help of libaster there is the initialisation of FieldOnNodesReal

def __init__(self, *args, **kwargs):
        """Overloaded function.

        1. __init__(self: libaster.FieldOnNodesReal) -> None

        2. __init__(self: libaster.FieldOnNodesReal, arg0: libaster.FieldOnNodesReal) -> None

        3. __init__(self: libaster.FieldOnNodesReal, arg0: Model) -> None

        4. __init__(self: libaster.FieldOnNodesReal, arg0: libaster.BaseDOFNumbering) -> None

        5. __init__(self: libaster.FieldOnNodesReal, arg0: libaster.EquationNumbering) -> None

        6. __init__(self: libaster.FieldOnNodesReal, arg0: tuple) -> None

        7. __init__(self: libaster.FieldOnNodesReal, mesh: libaster.BaseMesh, quantity: str, cmps: list[str]) -> None

        8. __init__(self: libaster.FieldOnNodesReal, mesh: libaster.BaseMesh, quantity: str, values: dict[str, float], groupsOfNodes: list[str] = [], groupsOfCells: list[str] = []) -> None
        """

I don’t know what are the lasts inputs in 7 and 8 (mesh is ok I think, from LIRE_MAILLAGE).

Anyone ?

The 8th options seems the most adapted but I don’t know how to fill it.

I do

import code_aster
A = code_aster.Objects.FieldOnNodesReal(mesh, 'DEPL_R')

but I don’t know how to build the dict asked. The str is the componant, so I would say ‘DX’, ‘DY’ and ‘DZ’, but you cannot have repeated keys in the dict so i don’t know how to do this…

With the 7. :

import numpy as np
import code_aster
A = code_aster.Objects.FieldOnNodesReal(mesh, 'DEPL_R', ['DX', 'DY', 'DZ'])
A.setValues(phi.tolist())