# # RBniCS is distributed in the hope that it will be useful, # but WITHOUT ANY WARRANTY; without even the implied warranty of # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the # GNU Lesser General Public License for more details. # # You should have received a copy of the GNU Lesser General Public License # along with RBniCS. If not, see <http://www.gnu.org/licenses/>. # import hashlib from rbnics.backends import assign, copy, Function, LinearSolver, product, sum, transpose from rbnics.problems.base import LinearProblem, ParametrizedDifferentialProblem from rbnics.utils.cache import Cache StokesOptimalControlProblem_Base = LinearProblem( ParametrizedDifferentialProblem) class StokesOptimalControlProblem(StokesOptimalControlProblem_Base): """ The problem to be solved is min {J(y, u) = 1/2 m(v - v_d, v - v_d) + 1/2 n(u, u)} y = (v, p) in Y = (V, P), u in U s.t. a(v, phi) + b(phi, p) = c(u, phi) + <f, phi> for all phi in V b(v, xi) = <l, xi> for all xi in P This class will solve the following optimality conditions: m(v, psi) + a*(psi, w) + b*(psi, q) = <g, psi> for all psi in V b*(w, pi ) = 0 for all pi in P n(u, tau) - c*(tau, w) = 0 for all tau in U
# Copyright (C) 2015-2020 by the RBniCS authors # # This file is part of RBniCS. # # SPDX-License-Identifier: LGPL-3.0-or-later from rbnics.problems.base import LinearProblem, ParametrizedDifferentialProblem from rbnics.backends import product, sum, transpose EllipticProblem_Base = LinearProblem(ParametrizedDifferentialProblem) # Base class containing the definition of elliptic problems class EllipticProblem(EllipticProblem_Base): # Default initialization of members def __init__(self, V, **kwargs): # Call to parent EllipticProblem_Base.__init__(self, V, **kwargs) # Form names for elliptic problems self.terms = ["a", "f", "s"] self.terms_order = {"a": 2, "f": 1, "s": 1} self.components = ["u"] class ProblemSolver(EllipticProblem_Base.ProblemSolver): def matrix_eval(self): problem = self.problem return sum( product(problem.compute_theta("a"), problem.operator["a"]))
# the Free Software Foundation, either version 3 of the License, or # (at your option) any later version. # # RBniCS is distributed in the hope that it will be useful, # but WITHOUT ANY WARRANTY; without even the implied warranty of # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the # GNU Lesser General Public License for more details. # # You should have received a copy of the GNU Lesser General Public License # along with RBniCS. If not, see <http://www.gnu.org/licenses/>. # from rbnics.problems.base import LinearProblem, ParametrizedDifferentialProblem from rbnics.backends import product, sum GeostrophicProblem_Base = LinearProblem(ParametrizedDifferentialProblem) class GeostrophicProblem(GeostrophicProblem_Base): # Default initialization of members def __init__(self, V, **kwargs): # Call to parent GeostrophicProblem_Base.__init__(self, V, **kwargs) # Form names for geostrophic problems self.terms = ["a", "f"] self.terms_order = {"a": 2, "f": 1} self.components = ["psi", "q"] # Perform a truth solve class ProblemSolver(GeostrophicProblem_Base.ProblemSolver):
# # RBniCS is distributed in the hope that it will be useful, # but WITHOUT ANY WARRANTY; without even the implied warranty of # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the # GNU Lesser General Public License for more details. # # You should have received a copy of the GNU Lesser General Public License # along with RBniCS. If not, see <http://www.gnu.org/licenses/>. # import hashlib from rbnics.problems.base import LinearProblem, ParametrizedDifferentialProblem from rbnics.backends import assign, copy, Function, LinearSolver, product, sum from rbnics.utils.cache import Cache StokesProblem_Base = LinearProblem(ParametrizedDifferentialProblem) # Base class containing the definition of saddle point problems class StokesProblem(StokesProblem_Base): # Default initialization of members def __init__(self, V, **kwargs): # Call to parent StokesProblem_Base.__init__(self, V, **kwargs) # Form names for saddle point problems self.terms = [ "a", "b", "bt", "f", "g", # Auxiliary terms for supremizer enrichment "bt_restricted" ]
# Copyright (C) 2015-2021 by the RBniCS authors # # This file is part of RBniCS. # # SPDX-License-Identifier: LGPL-3.0-or-later from rbnics.problems.base import LinearProblem, ParametrizedDifferentialProblem from rbnics.backends import product, sum, transpose GeostrophicOptimalControlProblem_Base = LinearProblem(ParametrizedDifferentialProblem) class GeostrophicOptimalControlProblem(GeostrophicOptimalControlProblem_Base): """ The problem to be solved is min {J(y_psi, u) = 1/2 m(y_psi - y_d, y_psi - y_d) + 1/2 n(u, u)} (y_psi, y_q) in YxY, y_d in Y, u in U s.t. a((y_psi, y_q), (z_psi, z_q)) = c(u, z_psi) + <f, z_q> for all (z_psi, z_q) in YxY This class will solve the following optimality conditions: m(y_psi, z_q) + a*((p_psi, p_q), (z_psi, z_q)) = <g, z_q> for all (z_psi, z_q) in YxY n(u, v) - c*(v, ppsi) = 0 for all v in U a((y_psi, y_q), (q_psi, q_q))- c(u, q_psi) = <f, q_q> for all (q_psi, q_q) in YxY and compute the cost functional J(y_psi, u) = 1/2 m(y_psi, y_psi) + 1/2 n(u, u) - <g, y_psi> + 1/2 h where a*(., .) is the adjoint of a