~fenics-core/ufl/spatder2grad

« back to all changes in this revision

Viewing changes to ufl/geometry.py

  • Committer: Martin Sandve Alnæs
  • Date: 2012-11-30 13:52:54 UTC
  • Revision ID: martinal@simula.no-20121130135254-w20k8n3sa1io65lq
Fixes in == behaviour, making sure that e.g.
grad(v) != grad(v2) if v != v2 based on
subclassed behaviour in Argument.

Distinguish between FloatValue(1.0) and IntValue(1).
This is now the correct behaviour, but may break some
code, hopefully not much.

Show diffs side-by-side

added added

removed removed

Lines of Context:
22
22
# Modified by Marie E. Rognes 2012
23
23
#
24
24
# First added:  2008-03-14
25
 
# Last changed: 2012-10-22
 
25
# Last changed: 2012-11-30
26
26
 
27
27
from ufl.log import warning
28
28
from ufl.assertions import ufl_assert
78
78
        "Return whether this expression is spatially constant over each cell."
79
79
        return True # NB! Assuming all geometric quantities in here are are cellwise constant by default!
80
80
 
 
81
    def __eq__(self, other):
 
82
        return isinstance(other, self._uflclass) and other._cell == self._cell
 
83
 
81
84
class SpatialCoordinate(GeometricQuantity):
82
85
    "Representation of a spatial coordinate."
83
86
    __slots__ = ("_repr",)
108
111
    def __repr__(self):
109
112
        return self._repr
110
113
 
111
 
    def __eq__(self, other):
112
 
        return isinstance(other, SpatialCoordinate) and other._cell == self._cell
113
 
 
114
114
class LocalCoordinate(GeometricQuantity):
115
115
    "(EXPERIMENTAL) Representation of a local coordinate on the reference cell."
116
116
    __slots__ = ("_repr",)
135
135
    def __repr__(self):
136
136
        return self._repr
137
137
 
138
 
    def __eq__(self, other):
139
 
        return isinstance(other, LocalCoordinate) and other._cell == self._cell
140
 
 
141
138
class GeometryJacobi(GeometricQuantity):
142
139
    "(EXPERIMENTAL) Representation of the Jacobi of the mapping from local to global coordinates."
143
140
    __slots__ = ("_repr",)
162
159
    def __repr__(self):
163
160
        return self._repr
164
161
 
165
 
    def __eq__(self, other):
166
 
        return isinstance(other, GeometryJacobi) and other._cell == self._cell
167
 
 
168
162
class GeometryJacobiDeterminant(GeometricQuantity):
169
163
    "(EXPERIMENTAL) Representation of the determinant of the Jacobi of the mapping from local to global coordinates."
170
164
    __slots__ = ("_repr",)
188
182
    def __repr__(self):
189
183
        return self._repr
190
184
 
191
 
    def __eq__(self, other):
192
 
        return isinstance(other, GeometryJacobiDeterminant) and other._cell == self._cell
193
 
 
194
185
class InverseGeometryJacobi(GeometricQuantity):
195
186
    "(EXPERIMENTAL) Representation of the Jacobi of the mapping from local to global coordinates."
196
187
    __slots__ = ("_repr",)
215
206
    def __repr__(self):
216
207
        return self._repr
217
208
 
218
 
    def __eq__(self, other):
219
 
        return isinstance(other, InverseGeometryJacobi) and other._cell == self._cell
220
 
 
221
209
class FacetNormal(GeometricQuantity):
222
210
    "Representation of a facet normal."
223
211
    __slots__ = ()
234
222
    def __repr__(self):
235
223
        return "FacetNormal(%r)" % self._cell
236
224
 
237
 
    def __eq__(self, other):
238
 
        return isinstance(other, FacetNormal) and other._cell == self._cell
239
 
 
240
225
class CellVolume(GeometricQuantity):
241
226
    "Representation of a cell volume."
242
227
    __slots__ = ()
252
237
    def __repr__(self):
253
238
        return "CellVolume(%r)" % self._cell
254
239
 
255
 
    def __eq__(self, other):
256
 
        return isinstance(other, CellVolume) and other._cell == self._cell
257
 
 
258
240
class Circumradius(GeometricQuantity):
259
241
    "Representation of the circumradius of a cell."
260
242
    __slots__ = ()
270
252
    def __repr__(self):
271
253
        return "Circumradius(%r)" % self._cell
272
254
 
273
 
    def __eq__(self, other):
274
 
        return isinstance(other, Circumradius) and other._cell == self._cell
275
 
 
276
255
class CellSurfaceArea(GeometricQuantity):
277
256
    "Representation of the total surface area of a cell."
278
257
    __slots__ = ()
288
267
    def __repr__(self):
289
268
        return "CellSurfaceArea(%r)" % self._cell
290
269
 
291
 
    def __eq__(self, other):
292
 
        return isinstance(other, CellSurfaceArea) and other._cell == self._cell
293
 
 
294
270
class FacetArea(GeometricQuantity):
295
271
    "Representation of the area of a cell facet."
296
272
    __slots__ = ()
306
282
    def __repr__(self):
307
283
        return "FacetArea(%r)" % self._cell
308
284
 
309
 
    def __eq__(self, other):
310
 
        return isinstance(other, FacetArea) and other._cell == self._cell
311
 
 
312
285
# TODO: If we include this here, we must define exactly what is meant by the mesh size, possibly adding multiple kinds of mesh sizes (hmin, hmax, havg, ?)
313
286
#class MeshSize(GeometricQuantity):
314
287
#    __slots__ = ()
323
296
#
324
297
#    def __repr__(self):
325
298
#        return "MeshSize(%r)" % self._cell
326
 
#
327
 
#    def __eq__(self, other):
328
 
#        return isinstance(other, MeshSize) and other._cell == self._cell
329
299
 
330
300
# --- Basic space and cell representation classes
331
301