Commit fb4e7fea by Jeremy BLEYER

### Working tangent block formulation

parent 323faba3
 ... @@ -32,19 +32,13 @@ ds = Measure("ds", subdomain_data=facets) ... @@ -32,19 +32,13 @@ ds = Measure("ds", subdomain_data=facets) material = mf.MFrontNonlinearMaterial("../materials/src/libBehaviour.so", material = mf.MFrontNonlinearMaterial("materials/src/libBehaviour.so", "HeatTransfer", "StationaryHeatTransfer", hypothesis="plane_strain") hypothesis="plane_strain") problem = mf.MFrontNonlinearProblem(T, material, quadrature_degree=0) problem = mf.MFrontNonlinearProblem(T, material, quadrature_degree=0) problem.bc = bc problem.bc = bc flux = mf.ThermalFlux(T) problem.register_gradient("TemperatureGradient", grad(T)) problem.define_form(flux) import mgis.behaviour as mgis_bv for t in problem.material.behaviour.tangent_operator_blocks: print('d{}_d{} size {}x{}'.format(t[0].name,t[1].name, mgis_bv.getVariableSize(t[0], problem.material.hypothesis), mgis_bv.getVariableSize(t[0], problem.material.hypothesis))) T.interpolate(Constant(Tl)) T.interpolate(Constant(Tl)) ... ...
 #!/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 import numpy as np from ufl import diag width = 1. height = 1. mesh = RectangleMesh(Point(0., 0.), Point(width, height), 20, 10) Ve = VectorElement("CG", mesh.ufl_cell(), 1) V = FunctionSpace(mesh, MixedElement([Ve, Ve])) u = Function(V, name="Displacements") (u1, u2) = split(u) def bottom(x, on_boundary): return near(x[1], 0) and on_boundary def top(x, on_boundary): return near(x[1], height) and on_boundary def left(x, on_boundary): return near(x[0], 0) and on_boundary bc = [DirichletBC(V.sub(0).sub(0), Constant(0), left), DirichletBC(V.sub(1).sub(0), Constant(0), left), DirichletBC(V.sub(0).sub(1), Constant(0), bottom), DirichletBC(V.sub(1).sub(1), Constant(0), bottom), DirichletBC(V.sub(0).sub(1), Constant(-1), top), DirichletBC(V.sub(1).sub(1), Constant(-1), top)] facets = MeshFunction("size_t", mesh, 1) ds = Measure("ds", subdomain_data=facets) material = mf.MFrontNonlinearMaterial("materials/src/libBehaviour.so", "TwoPhasesGeneralizedElasticity", hypothesis="plane_strain") problem = mf.MFrontNonlinearProblem(u, material, quadrature_degree=0) problem.bc = bc problem.register_gradient("MatrixStrain", sym(grad(u1)), symmetric=True) problem.register_gradient("InclusionStrain", sym(grad(u2)), symmetric=True) problem.register_gradient("RelativeDisplacement", diag(u2-u1), symmetric=True) problem.solve(u.vector()) u1 = u.sub(0, True) u2 = u.sub(1, True) x = np.linspace(0, width, 100) import matplotlib.pyplot as plt plt.figure() plt.plot(x, np.array([u1(xi, height/2)[0] for xi in x]), label=r"\$u_x\$ (matrix)") plt.plot(x, np.array([u2(xi, height/2)[0] for xi in x]), label=r"\$u_x\$ (inclusion)") plt.legend() plt.show() \ No newline at end of file