cpp_disc = ElasticityExample(refine_steps=7) param = {"lambda": [1.], "mu": [1.]} # u = cpp_disc.solve(param) parameter_type = Parameter(param).parameter_type # cpp_disc.visualize(u, "highdim_solution_cpp.vtk") lambda_fn, mu_fn = [GenericParameterFunctional(lambda mu: mu[n], Parameter({n: [1.]}).parameter_type) for n in ['lambda', 'mu']] LOW, HIGH = 1, 10 ops = [DealIIMatrixOperator(getattr(cpp_disc, name)()) for name in ['lambda_mat', 'mu_mat']] op = LincombOperator(ops, (lambda_fn, mu_fn)) rhs = VectorFunctional(ListVectorArray([DealIIVector(cpp_disc.rhs())])) viz = PyVis(cpp_disc) h1_op = DealIIMatrixOperator(cpp_disc.h1_mat(), "h1_0_semi") energy_op = DealIIMatrixOperator(cpp_disc.mu_mat(), "energy") py_disc = StationaryDiscretization(op, rhs, products={"energy": energy_op}, visualizer=viz, parameter_space=CubicParameterSpace(parameter_type, LOW, HIGH)) coercivity_estimator = ExpressionParameterFunctional("max(mu)", parameter_type) reductor = partial(reduce_stationary_coercive, error_product=energy_op, coercivity_estimator=coercivity_estimator) greedy_data = greedy(py_disc, reductor, py_disc.parameter_space.sample_uniformly(3), use_estimator=True, extension_algorithm=gram_schmidt_basis_extension, max_extensions=3) rb_disc, reconstructor = greedy_data['reduced_discretization'], greedy_data['reconstructor'] half = (HIGH - LOW) / 2. values = itertools.product((LOW, HIGH, half), (LOW, HIGH, half))