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
def __init__(self, parameter_range=(0.1, 1.), name=None): super(DuneLinearEllipticCGDiscretization, self).__init__() Cachable.__init__(self, config=NO_CACHE_CONFIG) self.example = dune.LinearEllipticExampleCG() ops = list(self.example.operators()) f = self.example.functional() self.solution_dim = f.len() ops = [DuneLinearOperator(op, dim=self.solution_dim) for op in ops] operator = LinearAffinelyDecomposedOperator(ops[:-1], ops[-1], name='diffusion') operator.rename_parameter({'.coefficients': 'diffusion'}) functional = DuneLinearFunctional(f) self.operators = {'operator': operator, 'rhs': functional} self.build_parameter_type(inherits={'operator': operator}) self.h1_product = operator.assemble(mu={'diffusion': np.ones(self.example.paramSize())}) self.h1_norm = induced_norm(self.h1_product) self.parameter_space = CubicParameterSpace({'diffusion': self.example.paramSize()}, *parameter_range) self.name = name
def __init__(self, args): super(DetailedSim, self).__init__(args) Cachable.__init__(self.discretization, config=NO_CACHE_CONFIG)
def copy(self): c = copy.copy(self) c.operators = c.operators.copy() Cachable.__init__(c) return c
def __init__(self): Cachable.__init__(self, config=DEFAULT_DISK_CONFIG) Parametric.__init__(self)