Ejemplo n.º 1
0
 def with_(self, **kwargs):
     assert 'vector_operators' not in kwargs or not kwargs['vector_operators']
     if 'operators' in kwargs and 'functionals' in kwargs:
         operators = kwargs.pop('operators')
         functionals = kwargs.pop('functionals')
         assert set(operators.keys()) == {'operator'}
         assert set(functionals.keys()) == {'rhs'}
         operator = operators['operator']
         rhs = functionals['rhs']
         d = StationaryDiscretization(operator=operator, rhs=rhs, parameter_space=self.parameter_space)
         return d.with_(**kwargs)
     elif 'cache_region' in kwargs:
         d = type(self)(self._impl)
         d.unlock()
         d.enable_caching(kwargs.pop('cache_region'))
         d.lock()
         return d.with_(**kwargs)
     else:
         d = type(self)(self._impl)
         d.unlock()
         for attr in ('solver_options', 'parameter_space'):
             if attr in dir(self):
                 setattr(d, attr, getattr(self, attr))
         if 'parameter_space' in kwargs:
             d.parameter_space = kwargs.pop('parameter_space')
         assert len(kwargs) == 0
         d.lock()
         return d
Ejemplo n.º 2
0
 def with_(self, **kwargs):
     assert 'operators' and 'functionals' in kwargs or kwargs.keys() == ['parameter_space']
     assert 'vector_operators' not in kwargs or not kwargs['vector_operators']
     if 'operators' in kwargs:
         operators = kwargs.pop('operators')
         functionals = kwargs.pop('functionals')
         assert set(operators.keys()) == {'operator'}
         assert set(functionals.keys()) == {'rhs'}
         operator = operators['operator']
         rhs = functionals['rhs']
         assert all(op.source.type == NumpyVectorArray or op.source.type == BlockVectorArray for op in (operator, rhs))
         assert all(op.range.type  == NumpyVectorArray or op.range.type  == BlockVectorArray for op in (operator, rhs))
         d = StationaryDiscretization(operator=operator, rhs=rhs)
         return d.with_(**kwargs)
     else:
         d = type(self)(self._impl)
         d.unlock()
         d.parameter_space = kwargs['parameter_space']
         d.lock()
         return d