~chaffra/ufl/main-old

« back to all changes in this revision

Viewing changes to ufl/coefficient.py

  • Committer: Chaffra Affouda
  • Date: 2013-01-28 15:55:52 UTC
  • mfrom: (1170.1.374 trunk)
  • Revision ID: chaffra@gmail.com-20130128155552-dsr4pdytcvt2jgmc
merge

Show diffs side-by-side

added added

removed removed

Lines of Context:
1
1
"""This module defines the Coefficient class and a number
2
2
of related classes, including Constant."""
3
3
 
4
 
# Copyright (C) 2008-2012 Martin Sandve Alnes
 
4
# Copyright (C) 2008-2013 Martin Sandve Alnes
5
5
#
6
6
# This file is part of UFL.
7
7
#
78
78
    def cell(self):
79
79
        return self._element.cell()
80
80
 
 
81
    def domain(self):
 
82
        return self._element.domain()
 
83
 
81
84
    def __str__(self):
82
85
        count = str(self._count)
83
86
        if len(count) == 1:
109
112
    """UFL value: Represents a globally constant scalar valued coefficient."""
110
113
    __slots__ = ()
111
114
 
112
 
    def __init__(self, cell, count=None):
113
 
        e = FiniteElement("Real", cell, 0)
 
115
    def __init__(self, domain, count=None):
 
116
        e = FiniteElement("Real", domain, 0)
114
117
        ConstantBase.__init__(self, e, count)
115
 
        self._repr = "Constant(%r, %r)" % (e.cell(), self._count)
 
118
        self._repr = "Constant(%r, %r)" % (e.domain(), self._count)
116
119
 
117
120
    def _reconstruct(self, element, count):
118
 
        return Constant(element.cell(), count)
 
121
        return Constant(element.domain(), count)
119
122
 
120
123
    def __str__(self):
121
124
        count = str(self._count)
128
131
    """UFL value: Represents a globally constant vector valued coefficient."""
129
132
    __slots__ = ()
130
133
 
131
 
    def __init__(self, cell, dim=None, count=None):
132
 
        e = VectorElement("Real", cell, 0, dim)
 
134
    def __init__(self, domain, dim=None, count=None):
 
135
        e = VectorElement("Real", domain, 0, dim)
133
136
        ConstantBase.__init__(self, e, count)
134
137
        ufl_assert(self._repr is None, "Repr should not have been set yet!")
135
 
        self._repr = "VectorConstant(%r, %r, %r)" % (e.cell(), e.value_shape()[0], self._count)
 
138
        self._repr = "VectorConstant(%r, %r, %r)" % (e.domain(), e.value_shape()[0], self._count)
136
139
 
137
140
    def _reconstruct(self, element, count):
138
 
        return VectorConstant(element.cell(), element.value_shape()[0], count)
 
141
        return VectorConstant(element.domain(), element.value_shape()[0], count)
139
142
 
140
143
    def __str__(self):
141
144
        count = str(self._count)
148
151
    """UFL value: Represents a globally constant tensor valued coefficient."""
149
152
    __slots__ = ()
150
153
 
151
 
    def __init__(self, cell, shape=None, symmetry=None, count=None):
152
 
        e = TensorElement("Real", cell, 0, shape=shape, symmetry=symmetry)
 
154
    def __init__(self, domain, shape=None, symmetry=None, count=None):
 
155
        e = TensorElement("Real", domain, 0, shape=shape, symmetry=symmetry)
153
156
        ConstantBase.__init__(self, e, count)
154
157
        ufl_assert(self._repr is None, "Repr should not have been set yet!")
155
 
        self._repr = "TensorConstant(%r, %r, %r, %r)" % (e.cell(), e.value_shape(), e._symmetry, self._count)
 
158
        self._repr = "TensorConstant(%r, %r, %r, %r)" % (e.domain(), e.value_shape(), e._symmetry, self._count)
156
159
 
157
160
    def _reconstruct(self, element, count):
158
161
        e = element
159
 
        return TensorConstant(e.cell(), e.value_shape(), e._symmetry, count)
 
162
        return TensorConstant(e.domain(), e.value_shape(), e._symmetry, count)
160
163
 
161
164
    def __str__(self):
162
165
        count = str(self._count)