-
Notifications
You must be signed in to change notification settings - Fork 0
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Issue 0041 - Add elastic wave propagation #53
Changes from 1 commit
44345b3
8b6d064
bb6f3b0
9f3edbd
baa852d
db5b048
85b5f31
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,6 +1,6 @@ | ||
import firedrake as fire | ||
from .acoustic_wave import AcousticWave | ||
|
||
from ..utils.typing import override | ||
|
||
class AcousticWaveMMS(AcousticWave): | ||
"""Class for solving the acoustic wave equation in 2D or 3D using | ||
|
@@ -10,14 +10,21 @@ class AcousticWaveMMS(AcousticWave): | |
""" | ||
|
||
def matrix_building(self): | ||
self.mms_source_in_space() | ||
self.q_t = fire.Constant(0) | ||
self.source_expression = self.q_t * self.q_xy | ||
|
||
super().matrix_building() | ||
lhs = self.lhs | ||
bcs = fire.DirichletBC(self.function_space, 0.0, "on_boundary") | ||
A = fire.assemble(lhs, bcs=bcs, mat_type="matfree") | ||
self.mms_source_in_space() | ||
self.solver = fire.LinearSolver( | ||
A, solver_parameters=self.solver_parameters | ||
) | ||
dt = self.dt | ||
t = self.current_time | ||
self.u_nm1.assign(self.analytical_solution(t - 2 * dt)) | ||
self.u_n.assign(self.analytical_solution(t - dt)) | ||
|
||
def mms_source_in_space(self): | ||
V = self.function_space | ||
|
@@ -45,10 +52,6 @@ def mms_source_in_space(self): | |
|
||
# self.q_xy.interpolate(sin(pi*x)*sin(pi*y)) | ||
|
||
def mms_source_in_time(self, t): | ||
# return fire.Constant(2*pi**2*t**2 + 2.0) | ||
return fire.Constant(2 * t) | ||
|
||
def analytical_solution(self, t): | ||
self.analytical = fire.Function(self.function_space) | ||
x = self.mesh_z | ||
|
@@ -66,3 +69,7 @@ def analytical_solution(self, t): | |
# self.analytical.assign(analytical) | ||
|
||
return self.analytical | ||
|
||
@override | ||
def update_source_expression(self, t): | ||
self.q_t.assign(2*t) | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I'm uncertain if this is the best practice. While using MMS for this small problem might not cause any issues, for larger cases in the future, we should prioritize wrapping scalar time-dependent variables inside a There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I didn't get the issue here. The variable "q_t" is defined as a There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Ah, I see now. I mistakenly thought that |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,19 +1,4 @@ | ||
from .time_integration_central_difference import central_difference | ||
from .time_integration_central_difference import central_difference_MMS | ||
|
||
|
||
def time_integrator(Wave_object, source_id=0): | ||
if Wave_object.source_type == "ricker": | ||
return time_integrator_ricker(Wave_object, source_id=source_id) | ||
elif Wave_object.source_type == "MMS": | ||
return time_integrator_mms(Wave_object, source_id=source_id) | ||
|
||
|
||
def time_integrator_ricker(Wave_object, source_id=0): | ||
return central_difference(Wave_object, source_id=source_id) | ||
|
||
def time_integrator_mms(Wave_object, source_id=0): | ||
if Wave_object.time_integrator == "central_difference": | ||
return central_difference_MMS(Wave_object, source_id=source_id) | ||
else: | ||
raise ValueError("The time integrator specified is not implemented yet") |
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I renamed the |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Great!