diff --git a/examples/python/cohesive/material.dat b/examples/python/cohesive/material.dat new file mode 100644 index 000000000..fe0c97f54 --- /dev/null +++ b/examples/python/cohesive/material.dat @@ -0,0 +1,22 @@ +model solid_mechanics_model_cohesive [ + cohesive_inserter [ + bounding_box = [[0,10],[-10, 10]] + ] + + + material elastic [ + name = virtual + rho = 1 # density + E = 1 # young's modulus + nu = 0.3 # poisson's ratio + finite_deformation = true + ] + + material cohesive_linear [ + name = cohesive + sigma_c = 0.1 + G_c = 1e-2 + beta = 1. + penalty = 10. + ] +] \ No newline at end of file diff --git a/examples/python/cohesive/plate.geo b/examples/python/cohesive/plate.geo new file mode 100644 index 000000000..8774dd2d4 --- /dev/null +++ b/examples/python/cohesive/plate.geo @@ -0,0 +1,36 @@ +h1 = .5; +h2 = 1.; +L = 10; +l = L/20.; +Point(1) = {0, 0, 0, h1}; +Point(2) = {L, 0, 0, h1}; +Point(3) = {L, L, 0, h2}; +Point(4) = {0, L, 0, h2}; +Point(5) = {l, 0, 0, h1}; + +Point(6) = {0, 0, 0, h1}; +Point(7) = {L, -L, 0, h2}; +Point(8) = {0, -L, 0, h2}; + + +Line(1) = {1, 5}; +Line(2) = {4, 1}; +Line(3) = {3, 4}; +Line(4) = {2, 3}; +Line(5) = {5, 2}; + +Line Loop(1) = {2, 3, 4, 5, 1}; +Plane Surface(1) = {1}; + +Line(6) = {5, 6}; +Line(7) = {6, 8}; +Line(8) = {8, 7}; +Line(9) = {7, 2}; +Line Loop(2) = {6, 7, 8, 9, -5}; +Plane Surface(2) = {2}; + + +Physical Surface(8) = {1,2}; +Physical Line("XBlocked") = {2,7}; +Physical Line("YBlocked") = {8}; +Physical Line("Traction") = {3}; diff --git a/examples/python/cohesive/plate.py b/examples/python/cohesive/plate.py new file mode 100644 index 000000000..57808ef0d --- /dev/null +++ b/examples/python/cohesive/plate.py @@ -0,0 +1,106 @@ +#!/usr/bin/env python3 + +from __future__ import print_function + +import akantu +import numpy as np + +################################################################ + + +def solve(material_file, mesh_file, traction): + akantu.parseInput(material_file) + spatial_dimension = 2 + + ################################################################ + # Initialization + ################################################################ + mesh = akantu.Mesh(spatial_dimension) + mesh.read(mesh_file) + + model = akantu.SolidMechanicsModelCohesive(mesh) + model.initFull(akantu.SolidMechanicsModelCohesiveOptions(akantu._static, + True)) + + model.initNewSolver(akantu._explicit_lumped_mass) + + model.setBaseName('plate') + model.addDumpFieldVector('displacement') + model.addDumpFieldVector('external_force') + model.addDumpField('strain') + model.addDumpField('stress') + model.addDumpField('blocked_dofs') + + model.setBaseNameToDumper('cohesive elements', 'cohesive') + model.addDumpFieldVectorToDumper('cohesive elements', 'displacement') + model.addDumpFieldToDumper('cohesive elements', 'damage') + model.addDumpFieldVectorToDumper('cohesive elements', 'traction') + model.addDumpFieldVectorToDumper('cohesive elements', 'opening') + + ################################################################ + # Boundary conditions + ################################################################ + + model.applyBC(akantu.FixedValue(0.0, akantu._x), 'XBlocked') + model.applyBC(akantu.FixedValue(0.0, akantu._y), 'YBlocked') + + trac = np.zeros(spatial_dimension) + trac[int(akantu._y)] = traction + + print('Solve for traction ', traction) + + model.getExternalForce()[:] = 0 + model.applyBC(akantu.FromTraction(trac), 'Traction') + + solver = model.getNonLinearSolver('static') + solver.set('max_iterations', 100) + solver.set('threshold', 1e-10) + solver.set('convergence_type', akantu._scc_residual) + + model.solveStep('static') + model.dump() + model.dump('cohesive elements') + + model.setTimeStep(model.getStableTimeStep()*0.1) + + maxsteps = 100 + for i in range(0, maxsteps): + print('{0}/{1}'.format(i, maxsteps)) + model.checkCohesiveStress() + model.solveStep('explicit_lumped') + if i % 10 == 0: + model.dump() + model.dump('cohesive elements') + # if i < 200: + # model.getVelocity()[:] *= .9 + + akantu.finalize() + +################################################################ +# main +################################################################ + + +def main(): + + import os + mesh_file = 'plate.msh' + + if not os.path.isfile(mesh_file): + import subprocess + ret = subprocess.call( + 'gmsh -format msh2 -2 plate.geo {0}'.format(mesh_file), + shell=True) + if not ret == 0: + raise Exception( + 'execution of GMSH failed: do you have it installed ?') + + material_file = 'material.dat' + + traction = .095 + solve(material_file, mesh_file, traction) + + +################################################################ +if __name__ == '__main__': + main()