Skip to content
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

Fix issues related to updated adjoint #62

Closed
wants to merge 16 commits into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 0 additions & 7 deletions .github/workflows/build.yml
Original file line number Diff line number Diff line change
Expand Up @@ -27,13 +27,6 @@ jobs:
uses: actions/setup-python@v2
with:
python-version: 3.8
- name: Install Animate
run: |
. /home/firedrake/firedrake/bin/activate
cd ..
git clone https://github.com/pyroteus/animate.git
cd animate
python -m pip install -e .
- name: Install Goalie
run: |
. /home/firedrake/firedrake/bin/activate
Expand Down
7 changes: 4 additions & 3 deletions demos/burgers-hessian.py
Original file line number Diff line number Diff line change
Expand Up @@ -27,10 +27,11 @@ def get_form(mesh_seq):
def form(index, solutions):
u, u_ = solutions["u"]
P = mesh_seq.time_partition
dt = Constant(P.timesteps[index])

# Specify viscosity coefficient
nu = Constant(0.0001)
# Define constants
R = FunctionSpace(mesh_seq[index], "R", 0)
dt = Function(R).assign(P.timesteps[index])
nu = Function(R).assign(0.0001)

# Setup variational problem
v = TestFunction(u.function_space())
Expand Down
10 changes: 6 additions & 4 deletions demos/burgers.py
Original file line number Diff line number Diff line change
Expand Up @@ -50,17 +50,19 @@ def get_function_spaces(mesh):
#
# Timestepping information associated with a given subinterval
# can be accessed via the :attr:`TimePartition` attribute of
# the :class:`MeshSeq`. ::
# the :class:`MeshSeq`. For technical reasons, we need to create a :class:`Function`
# in the `'R'` space (of real numbers) to hold constants. ::


def get_form(mesh_seq):
def form(index, solutions):
u, u_ = solutions["u"]
P = mesh_seq.time_partition
dt = Constant(P.timesteps[index])

# Specify viscosity coefficient
nu = Constant(0.0001)
# Define constants
R = FunctionSpace(mesh_seq[index], "R", 0)
dt = Function(R).assign(P.timesteps[index])
nu = Function(R).assign(0.0001)

# Setup variational problem
v = TestFunction(u.function_space())
Expand Down
7 changes: 4 additions & 3 deletions demos/burgers1.py
Original file line number Diff line number Diff line change
Expand Up @@ -28,10 +28,11 @@ def get_form(mesh_seq):
def form(index, solutions):
u, u_ = solutions["u"]
P = mesh_seq.time_partition
dt = Constant(P.timesteps[index])

# Specify viscosity coefficient
nu = Constant(0.0001)
# Define constants
R = FunctionSpace(mesh_seq[index], "R", 0)
dt = Function(R).assign(P.timesteps[index])
nu = Function(R).assign(0.0001)

# Setup variational problem
v = TestFunction(u.function_space())
Expand Down
7 changes: 4 additions & 3 deletions demos/burgers2.py
Original file line number Diff line number Diff line change
Expand Up @@ -28,10 +28,11 @@ def get_form(mesh_seq):
def form(index, solutions):
u, u_ = solutions["u"]
P = mesh_seq.time_partition
dt = Constant(P.timesteps[index])

# Specify viscosity coefficient
nu = Constant(0.0001)
# Define constants
R = FunctionSpace(mesh_seq[index], "R", 0)
dt = Function(R).assign(P.timesteps[index])
nu = Function(R).assign(0.0001)

# Setup variational problem
v = TestFunction(u.function_space())
Expand Down
7 changes: 4 additions & 3 deletions demos/burgers_ee.py
Original file line number Diff line number Diff line change
Expand Up @@ -43,10 +43,11 @@ def get_form(mesh_seq):
def form(index, solutions):
u, u_ = solutions["u"]
P = mesh_seq.time_partition
dt = Constant(P.timesteps[index])

# Specify viscosity coefficient
nu = Constant(0.0001)
# Define constants
R = FunctionSpace(mesh_seq[index], "R", 0)
dt = Function(R).assign(P.timesteps[index])
nu = Function(R).assign(0.0001)

# Setup variational problem
v = TestFunction(u.function_space())
Expand Down
10 changes: 6 additions & 4 deletions demos/burgers_oo.py
Original file line number Diff line number Diff line change
Expand Up @@ -33,10 +33,11 @@ def get_form(self):
def form(index, solutions):
u, u_ = solutions["u"]
P = self.time_partition
dt = Constant(P.timesteps[index])

# Specify viscosity coefficient
nu = Constant(0.0001)
# Define constants
R = FunctionSpace(mesh_seq[index], "R", 0)
dt = Function(R).assign(P.timesteps[index])
nu = Function(R).assign(0.0001)

# Setup variational problem
v = TestFunction(u.function_space())
Expand Down Expand Up @@ -84,7 +85,8 @@ def get_initial_condition(self):

@annotate_qoi
def get_qoi(self, solutions, i):
dt = Constant(self.time_partition[i].timestep)
R = FunctionSpace(self[i], "R", 0)
dt = Function(R).assign(self.time_partition[i].timestep)

def end_time_qoi():
u = solutions["u"]
Expand Down
12 changes: 7 additions & 5 deletions demos/burgers_time_integrated.py
Original file line number Diff line number Diff line change
Expand Up @@ -23,10 +23,11 @@ def get_form(mesh_seq):
def form(index, solutions):
u, u_ = solutions["u"]
P = mesh_seq.time_partition
dt = Constant(P.timesteps[index])

# Specify viscosity coefficient
nu = Constant(0.0001)
# Define constants
R = FunctionSpace(mesh_seq[index], "R", 0)
dt = Function(R).assign(P.timesteps[index])
nu = Function(R).assign(0.0001)

# Setup variational problem
v = TestFunction(u.function_space())
Expand Down Expand Up @@ -93,12 +94,13 @@ def solver(index, ic):
# \;\mathrm dy\;\mathrm dt.
#
# Note that in this case we multiply by the timestep.
# It is wrapped in a :class:`Constant` to avoid
# It is wrapped in a :class:`Function` from `'R'` space to avoid
# recompilation if the value is changed. ::


def get_qoi(mesh_seq, solutions, i):
dt = Constant(mesh_seq.time_partition[i].timestep)
R = FunctionSpace(mesh_seq[i], "R", 0)
dt = Function(R).assign(mesh_seq.time_partition[i].timestep)

def time_integrated_qoi(t):
u = solutions["u"]
Expand Down
11 changes: 6 additions & 5 deletions demos/gray_scott.py
Original file line number Diff line number Diff line change
Expand Up @@ -57,11 +57,12 @@ def form(index, sols):
psi_a, psi_b = TestFunctions(mesh_seq.function_spaces["ab"][index])

# Define constants
dt = Constant(mesh_seq.time_partition[index].timestep)
D_a = Constant(8.0e-05)
D_b = Constant(4.0e-05)
gamma = Constant(0.024)
kappa = Constant(0.06)
R = FunctionSpace(mesh_seq[index], "R", 0)
dt = Function(R).assign(mesh_seq.time_partition[index].timestep)
D_a = Function(R).assign(8.0e-05)
D_b = Function(R).assign(4.0e-05)
gamma = Function(R).assign(0.024)
kappa = Function(R).assign(0.06)

# Write the two equations in variational form
F = (
Expand Down
11 changes: 6 additions & 5 deletions demos/gray_scott_split.py
Original file line number Diff line number Diff line change
Expand Up @@ -57,11 +57,12 @@ def form(index, sols):
psi_b = TestFunction(mesh_seq.function_spaces["b"][index])

# Define constants
dt = Constant(mesh_seq.time_partition[index].timestep)
D_a = Constant(8.0e-05)
D_b = Constant(4.0e-05)
gamma = Constant(0.024)
kappa = Constant(0.06)
R = FunctionSpace(mesh_seq[index], "R", 0)
dt = Function(R).assign(mesh_seq.time_partition[index].timestep)
D_a = Function(R).assign(8.0e-05)
D_b = Function(R).assign(4.0e-05)
gamma = Function(R).assign(0.024)
kappa = Function(R).assign(0.06)

# Write the two equations in variational form
F_a = (
Expand Down
9 changes: 7 additions & 2 deletions demos/point_discharge2d-goal_oriented.py
Original file line number Diff line number Diff line change
Expand Up @@ -36,11 +36,16 @@ def get_form(mesh_seq):
def form(index, sols):
c, c_ = sols["c"]
function_space = mesh_seq.function_spaces["c"][index]
D = Constant(0.1)
u = Constant(as_vector([1, 0]))
h = CellSize(mesh_seq[index])
S = source(mesh_seq[index])

# Define constants
R = FunctionSpace(mesh_seq[index], "R", 0)
D = Function(R).assign(0.1)
u_x = Function(R).assign(1.0)
u_y = Function(R).assign(0.0)
u = as_vector([u_x, u_y])

# SUPG stabilisation parameter
unorm = sqrt(dot(u, u))
tau = 0.5 * h / unorm
Expand Down
9 changes: 7 additions & 2 deletions demos/point_discharge2d-hessian.py
Original file line number Diff line number Diff line change
Expand Up @@ -40,11 +40,16 @@ def get_form(mesh_seq):
def form(index, sols):
c, c_ = sols["c"]
function_space = mesh_seq.function_spaces["c"][index]
D = Constant(0.1)
u = Constant(as_vector([1, 0]))
h = CellSize(mesh_seq[index])
S = source(mesh_seq[index])

# Define constants
R = FunctionSpace(mesh_seq[index], "R", 0)
D = Function(R).assign(0.1)
u_x = Function(R).assign(1.0)
u_y = Function(R).assign(0.0)
u = as_vector([u_x, u_y])

# SUPG stabilisation parameter
unorm = sqrt(dot(u, u))
tau = 0.5 * h / unorm
Expand Down
9 changes: 7 additions & 2 deletions demos/point_discharge2d.py
Original file line number Diff line number Diff line change
Expand Up @@ -71,11 +71,16 @@ def get_form(mesh_seq):
def form(index, sols):
c, c_ = sols["c"]
function_space = mesh_seq.function_spaces["c"][index]
D = Constant(0.1)
u = Constant(as_vector([1, 0]))
h = CellSize(mesh_seq[index])
S = source(mesh_seq[index])

# Define constants
R = FunctionSpace(mesh_seq[index], "R", 0)
D = Function(R).assign(0.1)
u_x = Function(R).assign(1.0)
u_y = Function(R).assign(0.0)
u = as_vector([u_x, u_y])

# SUPG stabilisation parameter
unorm = sqrt(dot(u, u))
tau = 0.5 * h / unorm
Expand Down
8 changes: 6 additions & 2 deletions demos/solid_body_rotation.py
Original file line number Diff line number Diff line change
Expand Up @@ -151,10 +151,14 @@ def form(index, sols, field="c"):
V = mesh_seq.function_spaces[field][index]
mesh = mesh_seq[index]

# Define velocity field
x, y = SpatialCoordinate(mesh)
u = as_vector([-y, x])
dt = Constant(mesh_seq.time_partition[index].timestep)
theta = Constant(0.5)

# Define constants
R = FunctionSpace(mesh_seq[index], "R", 0)
dt = Function(R).assign(mesh_seq.time_partition[index].timestep)
theta = Function(R).assign(0.5)

psi = TrialFunction(V)
phi = TestFunction(V)
Expand Down
Loading
Loading