Commit 937f99dd authored by florez's avatar florez
Browse files

add files

parent 8a0a4a14
%% Cell type:code id:59a9f2d7-aadb-4d96-9b19-0cfcf7c950dc tags:
``` python
import numpy as np
import akantu as aka
```
%% Cell type:code id:c1339e28-e6b1-4155-b25e-f3b848025838 tags:
``` python
material_file = """
material elastic [
name = steel
rho = 1 # density
E = 1 # young's modulus
nu = 0.3 # poisson's ratio
]"""
# writing the material file
open('material.dat', 'w').write(material_file)
#reading the material file
material_file = 'material.dat'
aka.parseInput(material_file)
```
%% Cell type:code id:e70a5ac5-9f8e-4cd7-af1d-931ccb725052 tags:
``` python
mesh = aka.Mesh(3)
mesh.read('cyl_01.msh')
model = aka.SolidMechanicsModel(mesh)
model.initFull(_analysis_method=aka._static)
```
%% Cell type:code id:18ffad89-ec5f-41ae-9705-21ba5ac967d6 tags:
``` python
for dir in [aka._x, aka._y, aka._z]:
model.applyBC(aka.FixedValue(0, dir), "bottom")
trac = [0, 0, 1]
model.applyBC(aka.FromTraction(trac), "top")
model.solveStep()
```
%% Output
---------------------------------------------------------------------------
Exception Traceback (most recent call last)
<ipython-input-19-52b1c10eaa2d> in <module>
5 model.applyBC(aka.FromTraction(trac), "top")
6
----> 7 model.solveStep()
Exception: akantu::debug::CriticalError : Error in mumps during solve process, check mumps user guide INFO(1) = -3 [/tmp/app/spack-stage/spack-stage-akantu-master-t5tv2fws2j5an4dr4sqytng27g7b3fyr/spack-src/src/solver/sparse_solver_mumps.cc:445]
//+
SetFactory("OpenCASCADE");
//+
t = 0.05;
Circle(1) = {0, -0, 0, 0.5, 0, 2*Pi};
Circle(2) = {0, -0, 0, 0.5+t, 0, 2*Pi};
//+
Extrude {0, 0, 5} {
Curve{1};
}
Extrude {0, 0, 5} {
Curve{2};
}
//+
Physical Surface("Inside") = {1};
//+
Physical Curve("top") = {1};
//+
Physical Point("fixpoint") = {3,4};
//+
//+
Curve Loop(3) = {6};
//+
Curve Loop(4) = {4};
//+
Plane Surface(3) = {3, 4};
Physical Surface("bottom") = {3};
//+
Curve Loop(5) = {2};
//+
Curve Loop(6) = {1};
Plane Surface(4) = {5, 6};
//+
Surface Loop(1) = {3, 2, 4, 1};
//+
Volume(1) = {1};
%% Cell type:code id:1dbbab78-6ef1-4e97-8440-f6db326755e9 tags:
``` python
import akantu as aka
import numpy as np
import pygmsh
# import the pyplot submodule to draw figures
import matplotlib.pyplot as plt
# import triangluation routine to plot meshes
import matplotlib.tri as tri
# setting a default image size large enough
plt.rcParams['figure.figsize'] = [10, 10]
```
%% Cell type:code id:4f3b63d5-abe9-43ce-9eca-80cd47fb4d49 tags:
``` python
# reading the mesh
spatial_dimension = 3
mesh_file = 'shell_cyl_2.msh'
mesh = aka.Mesh(spatial_dimension)
mesh.read(mesh_file)
```
%% Cell type:code id:ac11734f-f415-43aa-a1a3-92edca236554 tags:
``` python
material_file = """
material elastic [
name = steel
rho = 1 # density
E = 1 # young's modulus
nu = 0.3 # poisson's ratio
]"""
# writing the material file
open('material.dat', 'w').write(material_file)
#reading the material file
material_file = 'material.dat'
aka.parseInput(material_file)
# creating the solid mechanics model
model = aka.SolidMechanicsModel(mesh)
# initialize a static solver
model.initFull(_analysis_method=aka._static)
```
%% Cell type:code id:e2379428-0b40-406f-bfed-160eb297f730 tags:
``` python
# Bottom ring 'bottom', top ring 'top', cylinder surface 'surface'
# set the displacement/Dirichlet boundary conditions
for dir in [aka._x, aka._y, aka._z]:
model.applyBC(aka.FixedValue(0, dir), "bottom")
# set the force/Neumann boundary conditions
trac = np.eye(3) # Newtons/m^2
trac = [0,0,1]
model.applyBC(aka.FromTraction(trac), "top")
```
%% Cell type:code id:6d82b932-ca93-45eb-8e3e-c0ec2c24f381 tags:
``` python
np.set_printoptions(threshold=20)
model.getExternalForce()[:]
# np.size(model.getExternalForce(),0)
# model.getBlockedDOFs()
```
%% Output
array([[0., 0., 0.],
[0., 0., 0.],
[0., 0., 0.],
...,
[0., 0., 0.],
[0., 0., 0.],
[0., 0., 0.]])
%% Cell type:code id:09675758-79eb-4314-b23f-f34fe359dc9f tags:
``` python
# configure the linear algebra solver
solver = model.getNonLinearSolver()
solver.set("max_iterations", 3)
solver.set("threshold", 1e-8)
solver.set("convergence_type", aka.SolveConvergenceCriteria.residual)
# compute the solution
model.solveStep()
u = model.getDisplacement()
np.set_printoptions(threshold=120)
u
```
%% Output
array([[0., 0., 0.],
[0., 0., 0.],
[0., 0., 0.],
...,
[0., 0., 0.],
[0., 0., 0.],
[0., 0., 0.]])
%% Cell type:code id:a81b557e-7adb-452a-9982-efeef3070962 tags:
``` python
# specify what field to output into paraview files
model.setBaseName("shell_cyl")
model.addDumpFieldVector("displacement")
model.addDumpFieldVector("external_force")
model.addDumpField("strain")
model.addDumpField("stress")
model.addDumpField("blocked_dofs")
# generate paraview files
model.dump()
```
%% Output
---------------------------------------------------------------------------
Exception Traceback (most recent call last)
<ipython-input-7-254e5de967ab> in <module>
8
9 # generate paraview files
---> 10 model.dump()
Exception: akantu::debug::Exception : No element of type (not_ghost:_cohesive_2d_4) in this const ElementTypeMapArray<unsigned int> class("mesh:connectivities") [/tmp/app/spack-stage/spack-stage-akantu-master-t5tv2fws2j5an4dr4sqytng27g7b3fyr/spack-src/src/mesh/element_type_map_tmpl.hh:293]
%% Cell type:code id:b9caba6a-e863-495b-989c-fd3bc3cf44ab tags:
``` python
```
# florez_akantu
SetFactory("OpenCASCADE");
Point(1) = {0, 0, 0};
Point(2) = {0, .5, 0};
Circle(1) = {0,0,0,0.5,0,2*Pi};
Extrude {0, 0, 1} {
Curve{1};
}
//+
Curve Loop(2) = {3};
//+
Plane Surface(2) = {2};
Curve Loop(3) = {1};
Plane Surface(3) = {3};
Physical Surface("bottom") = {3};
Physical Surface("top") = {2};
Physical Surface("surface") = {1};