#!/usr/bin/env python3 # -*- coding: utf-8 -*- """ Created on Fri Feb 1 08:49:11 2019 @author: bleyerj """ from dolfin import * import mfront_wrapper as mf N = 100 mesh = UnitSquareMesh(N, 2*N, "crossed") V = FunctionSpace(mesh, "CG", 1) def crack(x, on_boundary): return near(x[0], 0.5, 0.2) and near(x[1], 0.5) def border(x, on_boundary): return on_boundary bc = DirichletBC(V, Constant(1.), crack) d = Function(V, name="Damage") material = mf.MFrontNonlinearMaterial("materials/src/libBehaviour.so", "PhaseField", hypothesis="plane_strain", material_properties={"RegularizationLength": 0.02}) problem = mf.MFrontNonlinearProblem(d, material, quadrature_degree=0) problem.bc = bc problem.register_gradient("Damage", d) problem.register_gradient("DamageGradient", grad(d)) problem.solve(d.vector()) #TODO: manage state variables communication with external computation import matplotlib.pyplot as plt p=plot(d) plt.colorbar(p) plt.show()