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()
retrieve_valence_and_mass_matrix()def retrieve_valence_and_mass_matrix(
model_a: UnstructuredModel, model_b: UnstructuredModel
) -> tuple[npt.NDArray, npt.NDArray]: ...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.
model_aUnstructuredModel — First model.model_bUnstructuredModel — Second model.
Classes
UnstructuredModel
UnstructuredModelclass UnstructuredModel(salvus.opt.models.base_model.BaseModel):
def __init__(
self,
name: str,
model: str | pathlib.Path | UnstructuredMesh,
fields: list[str],
): ...Unstructured mesh inversion model.
namestr — Name of the model.modelstr | pathlib.Path | UnstructuredMesh — The unstructured mesh.fieldslist[str] — Names of the elemental fields to use.
FemMassMatrix npt.NDArray[np.float64]
FemMassMatrix npt.NDArray[np.float64]The mass matrix as SalvusCompute would write it.
mass_matrix npt.NDArray[np.float64]
mass_matrix npt.NDArray[np.float64]The mass matrix as defined on the mesh, without valence scaling.
model UnstructuredMesh
model UnstructuredMeshThe actual dataset representing the model.
name str
name strModel name.
status ModelStatus
status ModelStatusModel status to keep track of whether the model has been modified.
valence npt.NDArray[np.float64]
valence npt.NDArray[np.float64]The valence as defined on the mesh.
vector npt.NDArray[np.float64]
vector npt.NDArray[np.float64]The unstructured mesh model as a vector.
from_disk()
from_disk()def from_disk(parent_folder: pathlib.Path, d: dict) -> Self: ...Load a model from disk. This will use the dictionary and path provided.
parent_folderpathlib.Path — Path to store the model.ddict — Dictionary containing meta information of the model.
from_json()
from_json()def from_json(d: dict) -> Self: ...Create a model from a dictionary.
ddict — Dictionary containing meta information of the model.
compute_inf_norm()
compute_inf_norm()def compute_inf_norm(self) -> float: ...Infinity norm of the model.
compute_norm()
compute_norm()def compute_norm(self) -> float: ...Return the model norm.
copy()
copy()def copy(self, name: str) -> Self: ...Copy the model.
Will load the model from disk if necessary, and leave it in memory.
namestr — Name of the new model.
dot()
dot()def dot(self, other: Self) -> float: ...Dot product of the model with another model.
otherSelf — The other model.
max()
max()def max(self, other: Self) -> Self: ...In-place point-wise maximum.
otherSelf — Model to compare with.
self.min()
min()def min(self, other: Self) -> Self: ...In-place point-wise minimum.
otherSelf — Model to compare with.
self.set_vector()
set_vector()def set_vector(self, vector: npt.NDArray[np.float64]) -> None: ...Set the model from a vector.
vectornpt.NDArray[np.float64] — The vector to set the model from.
to_disk()
to_disk()def to_disk(self, parent_folder: pathlib.Path | str) -> dict: ...Serialize the model to JSON (and an associated npy file).
parent_folderpathlib.Path | str — Parent folder where the JSON + h5 files should be stored.
to_json()
to_json()def to_json(
self,
external_file_hash: types = None,
timer: types = None,
log_to_logger: bool = False,
comm: types = None,
) -> builtins.dict: ...Serialize the object to a dictionary that can be written to JSON.
external_file_hashtypes — 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.timertypes — Execution timer.log_to_loggerbool — Log timings to the logger.commtypes — MPI communicator, if any.