1
1
"""This module defines the Coefficient class and a number
2
2
of related classes, including Constant."""
4
# Copyright (C) 2008-2012 Martin Sandve Alnes
4
# Copyright (C) 2008-2013 Martin Sandve Alnes
6
6
# This file is part of UFL.
109
112
"""UFL value: Represents a globally constant scalar valued coefficient."""
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)
117
120
def _reconstruct(self, element, count):
118
return Constant(element.cell(), count)
121
return Constant(element.domain(), count)
120
123
def __str__(self):
121
124
count = str(self._count)
128
131
"""UFL value: Represents a globally constant vector valued coefficient."""
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)
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)
140
143
def __str__(self):
141
144
count = str(self._count)
148
151
"""UFL value: Represents a globally constant tensor valued coefficient."""
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)
157
160
def _reconstruct(self, element, count):
159
return TensorConstant(e.cell(), e.value_shape(), e._symmetry, count)
162
return TensorConstant(e.domain(), e.value_shape(), e._symmetry, count)
161
164
def __str__(self):
162
165
count = str(self._count)