Hot-keys on this page

r m x p   toggle line displays

j k   next/prev highlighted chunk

0   (zero) top of page

1   (one) first highlighted chunk

1

2

3

4

5

6

7

8

9

10

11

12

13

14

15

16

17

18

19

20

21

22

23

24

25

26

27

28

29

30

31

32

33

34

35

36

37

38

39

40

41

42

43

44

45

46

47

48

49

50

51

52

53

54

55

56

57

58

59

60

61

62

63

64

65

66

67

68

69

70

71

72

73

74

75

76

77

78

79

# This file is part of the pyMOR project (http://www.pymor.org). 

# Copyright Holders: Rene Milk, Stephan Rave, Felix Schindler 

# License: BSD 2-Clause License (http://opensource.org/licenses/BSD-2-Clause) 

 

from __future__ import absolute_import, division, print_function 

 

from pymor.core.cache import CacheableInterface, cached 

from pymor.core.interfaces import abstractmethod 

from pymor.parameters import Parametric 

from pymor.tools import Named 

 

 

class DiscretizationInterface(CacheableInterface, Parametric, Named): 

    '''Describes a discretization. 

 

    Note that we do not make any distinction between detailed and reduced 

    discretizations. 

 

    Attributes 

    ---------- 

    dim_solution 

        Dimension of the |VectorArrays| returned by solve. 

    type_solution 

        Type of the |VectorArrays| returned by solve. 

    linear 

        `True` if the discretization describes a linear Problem. 

    operators 

        Dictionary of all |Operators| contained in the discretization. 

        (Compare the implementation of :func:`pymor.reductors.basic.reduce_generic_rb`.) 

    functionals 

        Same as operators but for |Functionals|. 

    vector_operators 

        Same as operators but for |Operators| representing vectors, i.e. 

        linear |Operators| with `dim_source == 1`. 

    products 

        Same as |Operators| but for inner product operators associated to the 

        discretization. 

 

    Optional Methods: 

 

        def estimate(self, U, mu=None): 

            Estimate the error of the discrete solution `U` to the |Parameter| `mu` against 

            the real solution. (For a reduced discretization, the 'real' solution will 

            be the solution of a detailed discretization, in general.) 

 

        def visualize(self, U): 

            Visualize a solution given by the |VectorArray| U. 

    ''' 

 

    dim_solution = None 

    type_solution = None 

    linear = False 

    operators = dict() 

    functionals = dict() 

    vector_operators = dict() 

    products = dict() 

    with_arguments = frozenset({'operators', 'functionals', 'vector_operators, products'}) 

 

    @abstractmethod 

    def _solve(self, mu=None): 

        '''Perform the actual solving.''' 

        pass 

 

    @cached 

    def solve(self, mu=None): 

        '''Solve for the |Parameter| `mu`. 

 

        The result is cached by default. 

 

        Parameters 

        ---------- 

        mu 

            |Parameter| for which to solve. 

 

        Returns 

        ------- 

        The solution given by a |VectorArray|. 

        ''' 

        return self._solve(mu)