Commit ab659021 authored by Tim Keil's avatar Tim Keil
Browse files

[model] also remove dual_operator

parent aecfe12d
......@@ -2,6 +2,8 @@
# Copyright 2013-2020 pyMOR developers and contributors. All rights reserved.
# License: BSD 2-Clause License (
import numpy as np
from pymor.algorithms.timestepping import TimeStepper
from pymor.models.interface import Model
from pymor.operators.constructions import IdentityOperator, VectorOperator, ZeroOperator
......@@ -44,9 +46,6 @@ class StationaryModel(Model):
an `estimate_error(U, mu, m)` method. If `error_estimator` is
not `None`, an `estimate_error(U, mu)` method is added to the
model which will call `error_estimator.estimate_error(U, mu, self)`.
The dual |Operator| L* of L, which is e.g. used for computing the gradient
of the output_functional. See Section 1.6.2 in [HPUU09]_ for more details.
A visualizer for the problem. This can be any object with
a `visualize(U, m, ...)` method. If `visualizer`
......@@ -58,8 +57,7 @@ class StationaryModel(Model):
def __init__(self, operator, rhs, output_functional=None, products=None,
error_estimator=None, dual_operator=None,
visualizer=None, name=None):
error_estimator=None, visualizer=None, name=None):
if isinstance(rhs, VectorArray):
assert rhs in operator.range
......@@ -119,14 +117,13 @@ class StationaryModel(Model):
assert self.output_functional is not None
assert self.output_functional.linear
assert self.dual_operator is not None
dual_problem = self.with_(operator=self.dual_operator, rhs=self.output_functional.H)
dual_problem = self.with_(operator=self.operator.H, rhs=self.output_functional.H)
P = dual_problem.solve(mu)
gradient = []
for (parameter, size) in self.parameters.items():
for index in range(size):
output_partial_dmu = self.output_functional.d_mu(parameter, index).apply(U, mu=mu).to_numpy()[0,0]
lhs_d_mu = self.operator.d_mu(parameter, index).apply2(U, P, mu=mu)
lhs_d_mu = self.operator.d_mu(parameter, index).apply2(P, U, mu=mu)
rhs_d_mu = self.rhs.d_mu(parameter, index).apply_adjoint(P, mu=mu).to_numpy()[0,0]
gradient.append((output_partial_dmu + rhs_d_mu - lhs_d_mu)[0,0])
return np.array(gradient)
......@@ -179,8 +179,6 @@ class StationaryRBReductor(ProjectionBasedReductor):
'products': {k: project(v, RB, RB) for k, v in fom.products.items()},
'output_functional': project(fom.output_functional, None, RB) if fom.output_functional else None
if self.fom.dual_operator:
projected_operators['dual_operator'] = project(fom.dual_operator, RB, RB)
return projected_operators
def project_operators_to_subbasis(self, dims):
......@@ -193,8 +191,6 @@ class StationaryRBReductor(ProjectionBasedReductor):
'output_functional': (project_to_subbasis(rom.output_functional, None, dim)
if rom.output_functional else None)
if self.fom.dual_operator:
projected_operators['dual_operator'] = project_to_subbasis(rom.dual_operator, dim, dim)
return projected_operators
def build_rom(self, projected_operators, error_estimator):
......@@ -52,8 +52,6 @@ def create_fom(args):
fom, _ = discretize_stationary_cg(problem, diameter=1. / int(args['GRID_INTERVALS']),
# define the dual operator
fom = fom.with_(dual_operator=fom.operator)
return fom, mu_bar
def record_results(function, parse, data, mu):
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment