33import numpy
44import os
55import ufl
6- import weakref
76from itertools import chain
87from pyop2 .mpi import COMM_WORLD , dup_comm
98from pyop2 .datatypes import IntType
@@ -414,12 +413,10 @@ def __init__(self, filename, project_output=False, comm=None, mode="w",
414413
415414 self ._fnames = None
416415 self ._topology = None
417- self ._output_functions = weakref .WeakKeyDictionary ()
418- self ._mappers = weakref .WeakKeyDictionary ()
419416
420417 def _prepare_output (self , function , max_elem ):
421418 from firedrake import FunctionSpace , VectorFunctionSpace , \
422- TensorFunctionSpace , Function , Projector , Interpolator
419+ TensorFunctionSpace , Function
423420 from tsfc .finatinterface import create_element as create_finat_element
424421
425422 name = function .name ()
@@ -430,39 +427,27 @@ def _prepare_output(self, function, max_elem):
430427 return OFunction (array = get_array (function ),
431428 name = name , function = function )
432429 # OK, let's go and do it.
430+ # Build appropriate space for output function.
433431 shape = function .ufl_shape
434- output = self ._output_functions .get (function )
435- if output is None :
436- # Build appropriate space for output function.
437- shape = function .ufl_shape
438- if len (shape ) == 0 :
439- V = FunctionSpace (function .ufl_domain (), max_elem )
440- elif len (shape ) == 1 :
441- if numpy .prod (shape ) > 3 :
442- raise ValueError ("Can't write vectors with more than 3 components" )
443- V = VectorFunctionSpace (function .ufl_domain (), max_elem ,
444- dim = shape [0 ])
445- elif len (shape ) == 2 :
446- if numpy .prod (shape ) > 9 :
447- raise ValueError ("Can't write tensors with more than 9 components" )
448- V = TensorFunctionSpace (function .ufl_domain (), max_elem ,
449- shape = shape )
450- else :
451- raise ValueError ("Unsupported shape %s" % (shape , ))
452- output = Function (V )
453- self ._output_functions [function ] = output
432+ if len (shape ) == 0 :
433+ V = FunctionSpace (function .ufl_domain (), max_elem )
434+ elif len (shape ) == 1 :
435+ if numpy .prod (shape ) > 3 :
436+ raise ValueError ("Can't write vectors with more than 3 components" )
437+ V = VectorFunctionSpace (function .ufl_domain (), max_elem ,
438+ dim = shape [0 ])
439+ elif len (shape ) == 2 :
440+ if numpy .prod (shape ) > 9 :
441+ raise ValueError ("Can't write tensors with more than 9 components" )
442+ V = TensorFunctionSpace (function .ufl_domain (), max_elem ,
443+ shape = shape )
444+ else :
445+ raise ValueError ("Unsupported shape %s" % (shape , ))
446+ output = Function (V )
454447 if self .project :
455- projector = self ._mappers .get (function )
456- if projector is None :
457- projector = Projector (function , output )
458- self ._mappers [function ] = projector
459- projector .project ()
448+ output .project (function )
460449 else :
461- interpolator = self ._mappers .get (function )
462- if interpolator is None :
463- interpolator = Interpolator (function , output )
464- self ._mappers [function ] = interpolator
465- interpolator .interpolate ()
450+ output .interpolate (function )
466451
467452 return OFunction (array = get_array (output ), name = name , function = output )
468453
0 commit comments