This documentation is not for the latest stable Salvus version.
# initialize notebook
%matplotlib inline
%config Completer.use_jedi = False
import matplotlib.pyplot as plt
import numpy as np
plt.rcParams["figure.figsize"] = (10, 8)
vp = 1700 # p-wave velocity in m/s
vs = 1000 # s-wave velocity in m/s
rho = 2700 # density in kg / m^3
max_x = 10000 # domain size in x direction
max_y = 5000 # domain size in y direction
fmax = 1.0 # maximum frequency in Hz
elements_per_wavelength = 2.0 # resolution criterion
hmax = vs / fmax / elements_per_wavelength
nelem_x = int(max_x / hmax)
nelem_y = int(max_y / hmax)
from salvus.mesh import mesh_block
sg = mesh_block.generators.cartesian.rectangle_2d(
nelem_x=nelem_x, nelem_y=nelem_y, max_x=max_x, max_y=max_y
)
sg.plot(show=True)
m = sg.get_unstructured_mesh()
m.attach_field("VP", vp * np.ones([m.nelem, m.nodes_per_element]))
m.attach_field("VS", vs * np.ones([m.nelem, m.nodes_per_element]))
m.attach_field("RHO", rho * np.ones([m.nelem, m.nodes_per_element]))
# this is necessary to tell salvus that this is elastic material everywhere.
# Setting it to 1 would make it fluid.
m.attach_field("fluid", np.zeros(m.nelem))
m.find_side_sets(mode="cartesian")
m
<salvus.mesh.unstructured_mesh.UnstructuredMesh at 0x7feb95a49b90>
vp = 1700 # p-wave velocity in m/s
vs = 1000 # s-wave velocity in m/s
rho = 2700 # density in kg / m^3
max_x = 10000 # domain size in x direction
max_y = 5000 # domain size in y direction
max_z = 3000 # domain size in z direction
fmax = 1.0 # maximum frequency in Hz
elements_per_wavelength = 2.0 # resolution criterion
hmax = vs / fmax / elements_per_wavelength
nelem_x = int(max_x / hmax)
nelem_y = int(max_y / hmax)
nelem_z = int(max_z / hmax)
from salvus.mesh import mesh_block
sg = mesh_block.generators.cartesian.cube_3d(
nelem_x=nelem_x,
nelem_y=nelem_y,
nelem_z=nelem_z,
max_x=max_x,
max_y=max_y,
max_z=max_z,
)
m = sg.get_unstructured_mesh()
m.attach_field("VP", vp * np.ones([m.nelem, m.nodes_per_element]))
m.attach_field("VS", vs * np.ones([m.nelem, m.nodes_per_element]))
m.attach_field("RHO", rho * np.ones([m.nelem, m.nodes_per_element]))
m.attach_field("fluid", np.zeros(m.nelem))
m.find_side_sets(mode="cartesian")
m