Mondaic

salvus.opt.models.data_structures

salvus.opt.models.data_structures salvus opt models data_structures

Data structures for SalvusOpt models.

Classes

DataBlock

class DataBlock(builtins.object):
    def __init__(
        self,
        block_id: int,
        fields: list[str],
        number_of_points: int,
        data: dict[str, npt.NDArray | types.scalar_],
        auxiliary_data: dict[str, npt.NDArray] = default,
        material: type[PhysicalMaterial] | None = None,
        constant_fields: list[str] = default,
    ) -> None: ...

A data block in a BlockModel.

In contrast to a the MeshBlock object, it does not contain any information on the geometry of the mesh.

Parameters
  • block_id int — The block ID.
  • fields list[str] — The fields contained in this block.
  • number_of_points int — Number of data point per field in this block.
  • data dict[str, npt.NDArray | types.scalar_] — A dictionary mapping field names to their data arrays.
  • auxiliary_data dict[str, npt.NDArray] — A dictionary mapping auxiliary field names to their data arrays. Auxiliary data is for example the valence or the finite element mass matrix.
  • material type[PhysicalMaterial] | None — The material associated with this block.
  • constant_fields list[str] — List of fields that are constant (scalars).
Methods
from_json()
def from_json(d: dict) -> DataBlock: ...

Create a Block instance from a JSON-compatible dictionary.

Parameters
  • d dict — A dictionary containing block information.
Returns DataBlock — Block: The deserialized Block instance.
set_data()
def set_data(self, data: dict[str, npt.NDArray | types.scalar_]) -> None: ...

Set the data for this block.

Parameters
  • data dict[str, npt.NDArray | types.scalar_] — A dictionary mapping field names to their data arrays.
Returns None
to_json()
def to_json(self) -> dict: ...

Serialize basic block information to a JSON-compatible dictionary.

Data is not serialized here as this is handled by the BlockModel class.

Returns dict — dict: A dictionary representation of the block.