# Copyright (C) 2015-2020 by the RBniCS authors
#
# This file is part of RBniCS.
#
# SPDX-License-Identifier: LGPL-3.0-or-later

from rbnics.backends import ProperOrthogonalDecomposition
from rbnics.utils.decorators import ReductionMethodFor
from rbnics.problems.stokes_optimal_control.stokes_optimal_control_problem import StokesOptimalControlProblem
from rbnics.reduction_methods.base import DifferentialProblemReductionMethod, LinearPODGalerkinReduction
from rbnics.reduction_methods.stokes_optimal_control.stokes_optimal_control_reduction_method import (
    StokesOptimalControlReductionMethod)

StokesOptimalControlPODGalerkinReduction_Base = LinearPODGalerkinReduction(
    StokesOptimalControlReductionMethod(DifferentialProblemReductionMethod))


@ReductionMethodFor(StokesOptimalControlProblem, "PODGalerkin")
class StokesOptimalControlPODGalerkinReduction(StokesOptimalControlPODGalerkinReduction_Base):

    # Initialize data structures required for the offline phase: overridden version because supremizer POD
    # is different from a standard component
    def _init_offline(self):
        # We cannot use the standard initialization provided by PODGalerkinReduction because
        # supremizer POD requires a custom initialization. We thus duplicate here part of its code

        # Call parent of parent (!) to initialize inner product and reduced problem
        output = StokesOptimalControlPODGalerkinReduction_Base._init_offline(self)

        # Declare a new POD for each basis component
        self.POD = dict()
Exemple #2
0
# Copyright (C) 2015-2021 by the RBniCS authors
#
# This file is part of RBniCS.
#
# SPDX-License-Identifier: LGPL-3.0-or-later

from rbnics.utils.decorators import ReductionMethodFor
from rbnics.reduction_methods.base import DifferentialProblemReductionMethod, LinearPODGalerkinReduction
from problems import GeostrophicOptimalControlProblem
from .geostrophic_optimal_control_reduction_method import GeostrophicOptimalControlReductionMethod

GeostrophicOptimalControlPODGalerkinReduction_Base = LinearPODGalerkinReduction(
    GeostrophicOptimalControlReductionMethod(
        DifferentialProblemReductionMethod))


@ReductionMethodFor(GeostrophicOptimalControlProblem, "PODGalerkin")
class GeostrophicOptimalControlPODGalerkinReduction(
        GeostrophicOptimalControlPODGalerkinReduction_Base):

    # Compute basis functions performing POD: overridden to handle aggregated spaces
    def compute_basis_functions(self):
        # Carry out POD
        basis_functions = dict()
        N = dict()
        for component in self.truth_problem.components:
            print("# POD for component", component)
            POD = self.POD[component]
            assert self.tol[component] == 0.
            # TODO first negelect tolerances, then compute the max of N for each aggregated pair
            (_, _, basis_functions[component],
# Copyright (C) 2015-2020 by the RBniCS authors
#
# This file is part of RBniCS.
#
# SPDX-License-Identifier: LGPL-3.0-or-later

from rbnics.reduction_methods.base import DifferentialProblemReductionMethod, LinearPODGalerkinReduction
from rbnics.utils.decorators import ReductionMethodFor
from problems import GeostrophicProblem
from .geostrophic_reduction_method import GeostrophicReductionMethod

GeostrophicPODGalerkinReduction_Base = LinearPODGalerkinReduction(
    GeostrophicReductionMethod(DifferentialProblemReductionMethod))


@ReductionMethodFor(GeostrophicProblem, "PODGalerkin")
class GeostrophicPODGalerkinReduction(GeostrophicPODGalerkinReduction_Base):
    pass
Exemple #4
0
# 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.backends import ProperOrthogonalDecomposition
from rbnics.utils.decorators import ReductionMethodFor
from rbnics.problems.stokes.stokes_problem import StokesProblem
from rbnics.reduction_methods.base import DifferentialProblemReductionMethod, LinearPODGalerkinReduction
from rbnics.reduction_methods.stokes.stokes_reduction_method import StokesReductionMethod

StokesPODGalerkinReduction_Base = LinearPODGalerkinReduction(
    StokesReductionMethod(DifferentialProblemReductionMethod))


@ReductionMethodFor(StokesProblem, "PODGalerkin")
class StokesPODGalerkinReduction(StokesPODGalerkinReduction_Base):

    # Initialize data structures required for the offline phase: overridden version because supremizer POD is different from a standard component
    def _init_offline(self):
        # We cannot use the standard initialization provided by PODGalerkinReduction because
        # supremizer POD requires a custom initialization. We thus duplicate here part of its code

        # Call parent of parent (!) to initialize inner product and reduced problem
        output = StokesPODGalerkinReduction_Base._init_offline(self)

        # Declare a new POD for each basis component
        self.POD = dict()
Exemple #5
0
#
# RBniCS is free software: you can redistribute it and/or modify
# it under the terms of the GNU Lesser General Public License as published by
# 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.elliptic_coercive.elliptic_coercive_problem import EllipticCoerciveProblem
from rbnics.reduction_methods.base import DifferentialProblemReductionMethod, LinearPODGalerkinReduction
from rbnics.reduction_methods.elliptic_coercive.elliptic_coercive_reduction_method import EllipticCoerciveReductionMethod
from rbnics.utils.decorators import ReductionMethodFor

EllipticCoercivePODGalerkinReduction_Base = LinearPODGalerkinReduction(
    EllipticCoerciveReductionMethod(DifferentialProblemReductionMethod))


# Base class containing the interface of a POD-Galerkin ROM
# for elliptic coercive problems
@ReductionMethodFor(EllipticCoerciveProblem, "PODGalerkin")
class EllipticCoercivePODGalerkinReduction(
        EllipticCoercivePODGalerkinReduction_Base):
    pass