def apply(self, U, ind=None, mu=None): assert isinstance(U, DuneVectorArray) assert self.check_parameter(mu) vectors = U._list if ind is None else [U._list[i] for i in ind] if len(vectors) == 0: return NumpyVectorArray.empty(dim=1) else: return NumpyVectorArray([[self.dune_vec.dot(v._vector)] for v in vectors])
def reduce_generic_rb(discretization, RB, product=None, disable_caching=True): '''Generic reduced basis reductor. Reduces a discretization by applying `operators.project_operator` to each of its `operators`. Parameters ---------- discretization The discretization which is to be reduced. RB The reduced basis (i.e. an array of vectors) on which to project. product Scalar product for the projection. (See `operators.constructions.ProjectedOperator`) disable_caching If `True`, caching of the solutions of the reduced discretization is disabled. Returns ------- rd The reduced discretization. rc The reconstructor providing a `reconstruct(U)` method which reconstructs high-dimensional solutions from solutions U of the reduced discretization. ''' if RB is None: RB = NumpyVectorArray.empty(max(op.dim_source for op in discretization.operators.itervalues())) projected_operators = {k: rb_project_operator(op, RB, product=product) for k, op in discretization.operators.iteritems()} rd = discretization.with_projected_operators(projected_operators) if disable_caching and isinstance(rd, Cachable): Cachable.__init__(rd, config=NO_CACHE_CONFIG) rd.name += '_reduced' rd.disable_logging = True rc = GenericRBReconstructor(RB) return rd, rc