Skip to content

Commit

Permalink
bem: convert from gmsh convention to sparrow ned
Browse files Browse the repository at this point in the history
  • Loading branch information
hvasbath committed Jun 5, 2024
1 parent f2d632c commit 3760cc0
Show file tree
Hide file tree
Showing 3 changed files with 16 additions and 8 deletions.
4 changes: 2 additions & 2 deletions beat/apps/beat.py
Original file line number Diff line number Diff line change
Expand Up @@ -2399,8 +2399,8 @@ def setup(parser):
elif options.mode == bem_mode_str:

comp.point2sources(point)
response = composite.engine.process(
sources=composite.sources, targets=composite.targets
response = comp.engine.process(
sources=comp.sources, targets=comp.targets
)

geoms = response.get_geometry(problem.event)
Expand Down
11 changes: 7 additions & 4 deletions beat/bem/base.py
Original file line number Diff line number Diff line change
Expand Up @@ -116,20 +116,23 @@ def duplicate_property(array):
sources_slips = self.source_slips()
times = num.zeros(1)
for dsource, source_slips in zip(self.discretized_sources, sources_slips):
n_nodes = ncorners * dsource.n_vertices
n_nodes = ncorners * dsource.n_triangles
latlon = num.ones((n_nodes, 2)) * num.array([event.lat, event.lon])
vertices = num.hstack([latlon, dsource.triangles_xyz.reshape((n_nodes, 3))])
nodes_xyz = dsource.triangles_xyz.reshape((n_nodes, 3))
nodes_xyz[:, 2] *= -1.
nodes_xyz[:, 0:2] = num.fliplr(nodes_xyz[:, 0:2])
vertices = num.hstack([latlon, nodes_xyz])
geom = Geometry(times=times, event=event)

faces1 = num.arange(n_nodes, dtype="int64").reshape(
dsource.n_vertices, ncorners
dsource.n_triangles, ncorners
)
faces2 = num.fliplr(faces1)
faces = num.vstack((faces1, faces2))

geom.setup(vertices, faces)
for slip_comp in ["strike", "dip", "normal"]:
slips = source_slips[slip_comp_to_idx[slip_comp]]
slips = source_slips[:, slip_comp_to_idx[slip_comp]].ravel()
geom.add_property(((slip_comp, "float64", [])), duplicate_property(slips))

geoms.append(geom)
Expand Down
9 changes: 7 additions & 2 deletions beat/plotting/bem.py
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@ def slip_distribution_3d(
min_limits = num.floor(sources_coord_limits.min(2).min(1)) * km
max_limits = num.ceil(sources_coord_limits.max(2).max(1)) * km
for j, comp in enumerate(slip_comps):
cmap = plt.get_cmap("hot") if comp == "normal" else plt.get_cmap("seismic")
cmap = plt.get_cmap("hot_r") if comp == "normal" else plt.get_cmap("seismic")
ax = fig.add_subplot(
1, len(slip_comps), j + 1, projection="3d", computed_zorder=False
)
Expand All @@ -54,7 +54,8 @@ def slip_distribution_3d(
if k == 1:
cbounds = [-0.3, 0.3]
else:
cbounds = [cb_round(a.min()), cb_round(a.max())]
#cbounds = [cb_round(a.min()), cb_round(a.max())]
cbounds = [0.3, 1.1]

assert a.size == dsource.n_triangles

Expand Down Expand Up @@ -86,7 +87,11 @@ def slip_distribution_3d(
cax=cbaxes,
orientation="horizontal",
)

cbs.set_label(f"{comp}-slip [m]", fontsize=fontsize)
if comp == "normal":
cbs.set_label(f"Sill opening [m]", fontsize=fontsize)

cbs.ax.tick_params(labelsize=fontsize)

unit_vectors = getattr(dsource, f"unit_{comp}_vectors")
Expand Down

0 comments on commit 3760cc0

Please sign in to comment.