phase_field.py 1.05 KB
Newer Older
 Jeremy BLEYER committed Mar 08, 2020 1 `````` `````` Jeremy BLEYER committed Mar 07, 2020 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 ``````#!/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()) `````` Jeremy BLEYER committed Mar 08, 2020 36 ``````#TODO: manage state variables communication with external computation `````` Jeremy BLEYER committed Mar 07, 2020 37 38 39 40 41 `````` import matplotlib.pyplot as plt p=plot(d) plt.colorbar(p) plt.show()``````