Version:

salvus.opt.models.unstructured_model

salvus.opt.models.unstructured_model salvus opt models unstructured_model
An unstructured mesh model.

Functions

retrieve_valence_and_mass_matrix()

Get the valence and mass matrix from the model that has them.
This method will check both models for presence of the valence and mass matrix as fields, and fall back to computing them if neither model has them.
If the model should deal with a region_of_interest, it should be accounted for in the model fields and on-mesh fields already, and the on-the-fly computation will not return appropriate values.
SIGNATURE
def retrieve_valence_and_mass_matrix(
    model_a: UnstructuredModel, model_b: UnstructuredModel
) -> tuple[npt.NDArray, npt.NDArray]: ...
ARGUMENTS
Required
model_a
Type:UnstructuredModel
Description:
First model.
Required
model_b
Type:UnstructuredModel
Description:
Second model.
RETURNS
Return type: tuple[npt.NDArray, npt.NDArray]
A tuple containing the valence and mass matrix (FemMassMatrix as defined by SalvusCompute) from the model that has them, otherwise computed on the fly.

Classes

UnstructuredModel

Unstructured mesh inversion model.
SIGNATURE
class UnstructuredModel(salvus.opt.models.base_model.BaseModel):
    def __init__(
        self,
        name: str,
        model: str | pathlib.Path | UnstructuredMesh,
        fields: list[str],
    ): ...
ARGUMENTS
Required
name
Type:str
Description:
Name of the model.
Required
model
Type:str | pathlib.Path | UnstructuredMesh
Description:
The unstructured mesh.
Required
fields
Type:list[str]
Description:
Names of the elemental fields to use.

Properties

  • FemMassMatrix(npt.NDArray[np.float64])-The mass matrix as SalvusCompute would write it.
  • mass_matrix(npt.NDArray[np.float64])-The mass matrix as defined on the mesh, without valence scaling.
  • model(UnstructuredMesh)-The actual dataset representing the model.
  • name(str)-Model name.
  • status(ModelStatus)-Model status to keep track of whether the model has been modified.
  • valence(npt.NDArray[np.float64])-The valence as defined on the mesh.
  • vector(npt.NDArray[np.float64])-The unstructured mesh model as a vector.

Class Methods

UnstructuredModel.from_disk()
Load a model from disk. This will use the dictionary and path provided.
SIGNATURE
def from_disk(parent_folder: pathlib.Path, d: dict) -> Self: ...
ARGUMENTS
Required
parent_folder
Type:pathlib.Path
Description:
Path to store the model.
Required
d
Type:dict
Description:
Dictionary containing meta information of the model.
UnstructuredModel.from_json()
Create a model from a dictionary.
SIGNATURE
def from_json(d: dict) -> Self: ...
ARGUMENTS
Required
d
Type:dict
Description:
Dictionary containing meta information of the model.

Methods

UnstructuredModel.compute_inf_norm()
Infinity norm of the model.
SIGNATURE
def compute_inf_norm(self) -> float: ...
UnstructuredModel.compute_norm()
Return the model norm.
SIGNATURE
def compute_norm(self) -> float: ...
UnstructuredModel.copy()
Copy the model.
Will load the model from disk if necessary, and leave it in memory.
SIGNATURE
def copy(self, name: str) -> Self: ...
ARGUMENTS
Required
name
Type:str
Description:
Name of the new model.
UnstructuredModel.dot()
Dot product of the model with another model.
SIGNATURE
def dot(self, other: Self) -> float: ...
ARGUMENTS
Required
other
Type:Self
Description:
The other model.
UnstructuredModel.max()
In-place point-wise maximum.
SIGNATURE
def max(self, other: Self) -> Self: ...
ARGUMENTS
Required
other
Type:Self
Description:
Model to compare with.
UnstructuredModel.min()
In-place point-wise minimum.
SIGNATURE
def min(self, other: Self) -> Self: ...
ARGUMENTS
Required
other
Type:Self
Description:
Model to compare with.
UnstructuredModel.set_vector()
Set the model from a vector.
SIGNATURE
def set_vector(self, vector: npt.NDArray[np.float64]) -> None: ...
ARGUMENTS
Required
vector
Type:npt.NDArray[np.float64]
Description:
The vector to set the model from.
UnstructuredModel.to_disk()
Serialize the model to JSON (and an associated npy file).
SIGNATURE
def to_disk(self, parent_folder: pathlib.Path | str) -> dict: ...
ARGUMENTS
Required
parent_folder
Type:pathlib.Path | str
Description:
Parent folder where the JSON + h5 files should be stored.
UnstructuredModel.to_json()
Serialize the object to a dictionary that can be written to JSON.
SIGNATURE
def to_json(
    self,
    external_file_hash: types = None,
    timer: types = None,
    log_to_logger: bool = False,
    comm: types = None,
) -> builtins.dict: ...
ARGUMENTS
Optional
external_file_hash
Type:types
Default value:None
Description:
Hash of any external files associated with this object. Can be passed here in which case it will be stored in a centralized location in the JSON file.
Optional
timer
Type:types
Default value:None
Description:
Execution timer.
Optional
log_to_logger
Type:bool
Default value:False
Description:
Log timings to the logger.
Optional
comm
Type:types
Default value:None
Description:
MPI communicator, if any.

Used in tutorials

Functionality from this module is used in the following tutorials.
PAGE CONTENTS