salvus.opt.smoothing
Various parameterizations for diffusion-based smoothing.
Functions
get_smooth_model()
get_smooth_model()def get_smooth_model(
job: salvus.flow.sites.salvus_job_array.SalvusJobArray,
model: Optional[
str, pathlib.Path, salvus.mesh.unstructured_mesh.UnstructuredMesh
] = None,
delete_job: bool = True,
) -> salvus.mesh.unstructured_mesh.UnstructuredMesh:
...Get the smooth model from a previously submitted job array
jobsalvus.flow.sites.salvus_job_array.SalvusJobArray — The job array of the smoothing jobsmodelOptional[str, pathlib.Path, salvus.mesh.unstructured_mesh.UnstructuredMesh] — The raw input model. This is optional and only to avoid additional I/O.delete_jobbool — Flag to determine if job should be deleted
run()
run()def run(
site_name: str,
ranks_per_job: Optional[int] = None,
wall_time_in_seconds_per_job: Optional[int] = None,
model: Union[
str, pathlib.Path, salvus.mesh.unstructured_mesh.UnstructuredMesh
],
smoothing_config: Dict[str, Union[salvus.opt.smoothing._Base, str]],
courant_number: Optional[float] = None,
time_step_in_seconds: Optional[float] = None,
poll_interval_in_seconds: Optional[float] = None,
verbosity: int = 1,
) -> salvus.mesh.unstructured_mesh.UnstructuredMesh:
...Smooth a model and return the smoothed model.
The smoothed model will retain a copy of the original contents of each field that is not smoothed.
It will internally submit one job for every to-be-smoothed parameter, thus ranks and wall time settings are per job.
site_namestr — The site to run on.ranks_per_jobOptional[int] — The number of ranks for each individual simulation. Defaults to the site’s configuration value.wall_time_in_seconds_per_jobOptional[int] — The wall time in seconds per job if the site requires one.modelUnion[str, pathlib.Path, salvus.mesh.unstructured_mesh.UnstructuredMesh] — The raw model, unsmoothed model.smoothing_configDict[str, Union[salvus.opt.smoothing._Base, str]] — Smoothing configuration for each smoothing field. Must be a dictionary with the keys being the to-be-smoothed fields and the values smoothing configurations for each field or, alternatively, (remote) file name of precomputed diffusion models.courant_numberOptional[float] — Courant number for auto-time-step detection.time_step_in_secondsOptional[float] — Time step for diffusion equation.poll_interval_in_secondsOptional[float] — If given, the site will be queried with this interval. Defaults to the site’s default.verbosityint — The verbosity level.
run_async()
run_async()def run_async(
site_name: str,
ranks_per_job: Optional[int] = None,
wall_time_in_seconds_per_job: Optional[int] = None,
model: Union[
str, pathlib.Path, salvus.mesh.unstructured_mesh.UnstructuredMesh
],
smoothing_config: Dict[str, Union[salvus.opt.smoothing._Base, str]],
courant_number: Optional[float] = None,
time_step_in_seconds: Optional[float] = None,
verbosity: int = 1,
) -> salvus.flow.sites.salvus_job_array.SalvusJobArray:
...Smooth a model asynchronously and return the resulting job array.
The smoothed model will retain a copy of the original contents of each field that is not smoothed.
It will internally submit one job for every to-be-smoothed parameter, thus ranks and wall time settings are per job.
site_namestr — The site to run on.ranks_per_jobOptional[int] — The number of ranks for each individual simulation. Defaults to the site’s configuration value.wall_time_in_seconds_per_jobOptional[int] — The wall time in seconds per job if the site requires one.modelUnion[str, pathlib.Path, salvus.mesh.unstructured_mesh.UnstructuredMesh] — The raw model, unsmoothed model.smoothing_configDict[str, Union[salvus.opt.smoothing._Base, str]] — Smoothing configuration for each smoothing field. Must be a dictionary with the keys being the to-be-smoothed fields and the values smoothing configurations for each field or, alternatively, (remote) file name of precomputed diffusion models.courant_numberOptional[float] — Courant number for auto-time-step detection.time_step_in_secondsOptional[float] — Time step for diffusion equation.verbosityint — The verbosity level.
Classes
AnisotropicConstant
AnisotropicConstantclass AnisotropicConstant(
salvus.flow.utils.deep_setters._DeepSetter, salvus.opt.smoothing._Base
):
def __init__(self, smoothing_lengths_in_meters: List[float]):
...The type of the smoothing model
smoothing_lengths_in_metersList[float] — Anisotropic smoothing length in meters. Depending on the reference frame of the input mesh this is eitherX,Y,Zorr,theta,phi. Example:[1.0, 2.0]
apply()
apply()def apply(self, d: Union[Dict, _DeepSetter]) -> None:
...Set the contents with a dictionary.
dUnion[Dict, _DeepSetter] — The dictionary to set.
copy()
copy()def copy(self) -> _DeepSetter:
...Return a deep copy of the object.
get_dictionary()
get_dictionary()def get_dictionary(self) -> Dict:
...Get the contents of this object as a dictionary.
get_diffusion_model()
get_diffusion_model()def get_diffusion_model(
self,
mesh: Union[
str, pathlib.Path, salvus.mesh.unstructured_mesh.UnstructuredMesh
],
) -> salvus.mesh.unstructured_mesh.UnstructuredMesh:
...Compute the diffusion coefficients and return the mesh.
meshUnion[str, pathlib.Path, salvus.mesh.unstructured_mesh.UnstructuredMesh] — Mesh file.
validate()
validate()def validate(self) -> None:
...Validates the current state of the configuration against its schema.
AnisotropicModelDependent
AnisotropicModelDependentclass AnisotropicModelDependent(
salvus.flow.utils.deep_setters._DeepSetter, salvus.opt.smoothing._Base
):
def __init__(
self,
reference_velocity: str,
smoothing_lengths_in_wavelengths: List[float],
reference_model: str,
reference_frequency_in_hertz: float,
):
...The type of the smoothing model
reference_velocitystr — Field name of the reference velocity to compute the wave length in Hz. Example:VPsmoothing_lengths_in_wavelengthsList[float] — Anisotropic smoothing length in wavelengths. Depending on the reference frame of the input mesh this is eitherX,Y,Zorr,theta,phi. Example:[1.0, 2.0]reference_modelstr — Reference model to extract the reference velocity from. Example:mesh.h5reference_frequency_in_hertzfloat — Reference frequency to compute the wave length in Hz. Example:1.0
apply()
apply()def apply(self, d: Union[Dict, _DeepSetter]) -> None:
...Set the contents with a dictionary.
dUnion[Dict, _DeepSetter] — The dictionary to set.
copy()
copy()def copy(self) -> _DeepSetter:
...Return a deep copy of the object.
get_dictionary()
get_dictionary()def get_dictionary(self) -> Dict:
...Get the contents of this object as a dictionary.
get_diffusion_model()
get_diffusion_model()def get_diffusion_model(
self,
mesh: Union[
str, pathlib.Path, salvus.mesh.unstructured_mesh.UnstructuredMesh
],
) -> salvus.mesh.unstructured_mesh.UnstructuredMesh:
...Compute the diffusion coefficients and return the mesh.
meshUnion[str, pathlib.Path, salvus.mesh.unstructured_mesh.UnstructuredMesh] — Mesh file.
validate()
validate()def validate(self) -> None:
...Validates the current state of the configuration against its schema.
AnisotropicSpaceDependent
AnisotropicSpaceDependentclass AnisotropicSpaceDependent(
salvus.flow.utils.deep_setters._DeepSetter, salvus.opt.smoothing._Base
):
def __init__(self, model: str, fields: List[str]):
...The type of the smoothing model
modelstr — Model that contains the smoothing field. Example:mesh.h5fieldsList[str] — Field name containing the isotropic smoothing length in meters. Depending on the reference frame of the input mesh this is eitherX,Y,ZorN,E,Z. Example:['SmoothX', 'SmoothY', 'SmoothZ']
apply()
apply()def apply(self, d: Union[Dict, _DeepSetter]) -> None:
...Set the contents with a dictionary.
dUnion[Dict, _DeepSetter] — The dictionary to set.
copy()
copy()def copy(self) -> _DeepSetter:
...Return a deep copy of the object.
get_dictionary()
get_dictionary()def get_dictionary(self) -> Dict:
...Get the contents of this object as a dictionary.
get_diffusion_model()
get_diffusion_model()def get_diffusion_model(
self,
mesh: Union[
str, pathlib.Path, salvus.mesh.unstructured_mesh.UnstructuredMesh
],
) -> salvus.mesh.unstructured_mesh.UnstructuredMesh:
...Compute the diffusion coefficients and return the mesh.
meshUnion[str, pathlib.Path, salvus.mesh.unstructured_mesh.UnstructuredMesh] — Mesh file.
validate()
validate()def validate(self) -> None:
...Validates the current state of the configuration against its schema.
Custom
Customclass Custom(
salvus.flow.utils.deep_setters._DeepSetter, salvus.opt.smoothing._Base
):
def __init__(self, diffusion_model: str):
...The type of the smoothing model
diffusion_modelstr — Name of the model containing the diffusion coefficients. Example:diffusion.h5
apply()
apply()def apply(self, d: Union[Dict, _DeepSetter]) -> None:
...Set the contents with a dictionary.
dUnion[Dict, _DeepSetter] — The dictionary to set.
copy()
copy()def copy(self) -> _DeepSetter:
...Return a deep copy of the object.
get_dictionary()
get_dictionary()def get_dictionary(self) -> Dict:
...Get the contents of this object as a dictionary.
get_diffusion_model()
get_diffusion_model()def get_diffusion_model(
self,
mesh: Union[
str, pathlib.Path, salvus.mesh.unstructured_mesh.UnstructuredMesh
],
) -> salvus.mesh.unstructured_mesh.UnstructuredMesh:
...Compute the diffusion coefficients and return the mesh.
meshUnion[str, pathlib.Path, salvus.mesh.unstructured_mesh.UnstructuredMesh] — Mesh file.
validate()
validate()def validate(self) -> None:
...Validates the current state of the configuration against its schema.
IsotropicConstant
IsotropicConstantclass IsotropicConstant(
salvus.flow.utils.deep_setters._DeepSetter, salvus.opt.smoothing._Base
):
def __init__(self, smoothing_length_in_meters: float):
...The type of the smoothing model
smoothing_length_in_metersfloat — Isotropic smoothing length in meters. Example:1.0
apply()
apply()def apply(self, d: Union[Dict, _DeepSetter]) -> None:
...Set the contents with a dictionary.
dUnion[Dict, _DeepSetter] — The dictionary to set.
copy()
copy()def copy(self) -> _DeepSetter:
...Return a deep copy of the object.
get_dictionary()
get_dictionary()def get_dictionary(self) -> Dict:
...Get the contents of this object as a dictionary.
get_diffusion_model()
get_diffusion_model()def get_diffusion_model(
self,
mesh: Union[
str, pathlib.Path, salvus.mesh.unstructured_mesh.UnstructuredMesh
],
) -> salvus.mesh.unstructured_mesh.UnstructuredMesh:
...Compute the diffusion coefficients and return the mesh.
meshUnion[str, pathlib.Path, salvus.mesh.unstructured_mesh.UnstructuredMesh] — Mesh file.
validate()
validate()def validate(self) -> None:
...Validates the current state of the configuration against its schema.
IsotropicModelDependent
IsotropicModelDependentclass IsotropicModelDependent(
salvus.flow.utils.deep_setters._DeepSetter, salvus.opt.smoothing._Base
):
def __init__(
self,
reference_velocity: str,
reference_frequency_in_hertz: float,
smoothing_length_in_wavelengths: float,
reference_model: Optional[str] = None,
):
...The type of the smoothing model
reference_velocitystr — Field name of the reference velocity to compute the wave length in Hz. Example:VPreference_frequency_in_hertzfloat — Reference frequency to compute the wave length in Hz. Example:1.0smoothing_length_in_wavelengthsfloat — Isotropic smoothing length in wavelengths. Example:1.0reference_modelOptional[str] — Reference model to extract the reference velocity from. Example:mesh.h5
apply()
apply()def apply(self, d: Union[Dict, _DeepSetter]) -> None:
...Set the contents with a dictionary.
dUnion[Dict, _DeepSetter] — The dictionary to set.
copy()
copy()def copy(self) -> _DeepSetter:
...Return a deep copy of the object.
get_dictionary()
get_dictionary()def get_dictionary(self) -> Dict:
...Get the contents of this object as a dictionary.
get_diffusion_model()
get_diffusion_model()def get_diffusion_model(
self,
mesh: Union[
str, pathlib.Path, salvus.mesh.unstructured_mesh.UnstructuredMesh
],
) -> salvus.mesh.unstructured_mesh.UnstructuredMesh:
...Compute the diffusion coefficients and return the mesh.
meshUnion[str, pathlib.Path, salvus.mesh.unstructured_mesh.UnstructuredMesh] — Mesh file.
validate()
validate()def validate(self) -> None:
...Validates the current state of the configuration against its schema.
IsotropicSpaceDependent
IsotropicSpaceDependentclass IsotropicSpaceDependent(
salvus.flow.utils.deep_setters._DeepSetter, salvus.opt.smoothing._Base
):
def __init__(self, field: str, model: str):
...The type of the smoothing model
fieldstr — Field name containing the isotropic smoothing length in meters. Example:smoothmodelstr — Model that contains the smoothing field. Example:mesh.h5
apply()
apply()def apply(self, d: Union[Dict, _DeepSetter]) -> None:
...Set the contents with a dictionary.
dUnion[Dict, _DeepSetter] — The dictionary to set.
copy()
copy()def copy(self) -> _DeepSetter:
...Return a deep copy of the object.
get_dictionary()
get_dictionary()def get_dictionary(self) -> Dict:
...Get the contents of this object as a dictionary.
get_diffusion_model()
get_diffusion_model()def get_diffusion_model(
self,
mesh: Union[
str, pathlib.Path, salvus.mesh.unstructured_mesh.UnstructuredMesh
],
) -> salvus.mesh.unstructured_mesh.UnstructuredMesh:
...Compute the diffusion coefficients and return the mesh.
meshUnion[str, pathlib.Path, salvus.mesh.unstructured_mesh.UnstructuredMesh] — Mesh file.
validate()
validate()def validate(self) -> None:
...Validates the current state of the configuration against its schema.