Skip to content
GitLab
Projects
Groups
Snippets
Help
Loading...
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
HO_homog
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Issues
14
Issues
14
List
Boards
Labels
Service Desk
Milestones
Operations
Operations
Incidents
Analytics
Analytics
Repository
Value Stream
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Commits
Issue Boards
Open sidebar
Baptiste Durand
HO_homog
Commits
53d274f3
Commit
53d274f3
authored
Jan 20, 2020
by
Baptiste Durand
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
black formatting
parent
6a598503
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
34 additions
and
28 deletions
+34
-28
ho_homog/materials.py
ho_homog/materials.py
+27
-19
test/test_mesh_generate_2D.py
test/test_mesh_generate_2D.py
+7
-9
No files found.
ho_homog/materials.py
View file @
53d274f3
...
...
@@ -18,42 +18,43 @@ PLANE_IDX = np.array([0, 1, 5])
class
Material
(
object
):
def
__init__
(
self
,
E
,
nu
,
cas_elast
=
'cp'
):
def
__init__
(
self
,
E
,
nu
,
cas_elast
=
"cp"
):
""" Définir un nouveau comportement élastique, exclusivement isotrope pour le moment.
cas_elast : Choisir entre 'cp' contraintes planes, 'dp' déformations planes ou '3D'.
"""
self
.
E
=
E
self
.
nu
=
nu
self
.
G
=
self
.
E
/
(
2.
*
(
1
+
self
.
nu
))
self
.
G
=
self
.
E
/
(
2.
0
*
(
1
+
self
.
nu
))
self
.
cas_elast
=
cas_elast
self
.
S_3D
=
np
.
array
((
(
1.
/
self
.
E
,
-
self
.
nu
/
self
.
E
,
-
self
.
nu
/
self
.
E
,
0.
,
0.
,
0.
),
(
-
self
.
nu
/
self
.
E
,
1.
/
self
.
E
,
-
self
.
nu
/
self
.
E
,
0.
,
0.
,
0.
),
(
-
self
.
nu
/
self
.
E
,
-
self
.
nu
/
self
.
E
,
1.
/
self
.
E
,
0.
,
0.
,
0.
),
(
0.
,
0.
,
0.
,
1.
/
(
2.
*
self
.
G
),
0.
,
0.
),
(
0.
,
0.
,
0.
,
0.
,
1.
/
(
2.
*
self
.
G
),
0.
),
(
0.
,
0.
,
0.
,
0.
,
0.
,
1.
/
(
2.
*
self
.
G
))
))
self
.
S_3D
=
np
.
array
(
(
(
1.0
/
self
.
E
,
-
self
.
nu
/
self
.
E
,
-
self
.
nu
/
self
.
E
,
0.0
,
0.0
,
0.0
),
(
-
self
.
nu
/
self
.
E
,
1.0
/
self
.
E
,
-
self
.
nu
/
self
.
E
,
0.0
,
0.0
,
0.0
),
(
-
self
.
nu
/
self
.
E
,
-
self
.
nu
/
self
.
E
,
1.0
/
self
.
E
,
0.0
,
0.0
,
0.0
),
(
0.0
,
0.0
,
0.0
,
1.0
/
(
2.0
*
self
.
G
),
0.0
,
0.0
),
(
0.0
,
0.0
,
0.0
,
0.0
,
1.0
/
(
2.0
*
self
.
G
),
0.0
),
(
0.0
,
0.0
,
0.0
,
0.0
,
0.0
,
1.0
/
(
2.0
*
self
.
G
)),
)
)
self
.
C_3D
=
np
.
linalg
.
inv
(
self
.
S_3D
)
self
.
set_elast
[
cas_elast
](
self
)
def
set_cp
(
self
):
self
.
S
=
self
.
S_3D
[
PLANE_IDX
[:,
None
],
PLANE_IDX
]
self
.
C
=
np
.
linalg
.
inv
(
self
.
S
)
self
.
cas_elast
=
'cp'
self
.
cas_elast
=
"cp"
def
set_dp
(
self
):
self
.
C
=
self
.
C_3D
[
PLANE_IDX
[:,
None
],
PLANE_IDX
]
self
.
S
=
np
.
linalg
.
inv
(
self
.
C
)
self
.
cas_elast
=
'dp'
self
.
cas_elast
=
"dp"
def
set_3D
(
self
):
self
.
S
=
self
.
S_3D
self
.
C
=
self
.
C_3D
self
.
cas_elast
=
'3D'
self
.
cas_elast
=
"3D"
# Dictionnaire des méthodes set
set_elast
=
{
"cp"
:
set_cp
,
"dp"
:
set_dp
,
"3D"
:
set_3D
}
...
...
@@ -70,14 +71,15 @@ class Material(object):
class
StiffnessComponent
(
fe
.
UserExpression
):
""" FEniCS Expression that represent one component of the stiffness tensor on a mesh that contain several subdomains."""
def
__init__
(
self
,
cell_function
,
mat_dict
,
i
,
j
,
**
kwargs
):
self
.
cell_function
=
cell_function
self
.
mat_dict
=
mat_dict
self
.
i
=
i
self
.
j
=
j
super
().
__init__
(
degree
=
kwargs
[
"degree"
])
#? Info : https://docs.python.org/fr/3/library/functions.html#super,
#? and http://folk.uio.no/kent-and/hpl-fem-book/doc/pub/book/pdf/fem-book-4print-2up.pdf
#
? Info : https://docs.python.org/fr/3/library/functions.html#super,
#
? and http://folk.uio.no/kent-and/hpl-fem-book/doc/pub/book/pdf/fem-book-4print-2up.pdf
def
eval_cell
(
self
,
values
,
x
,
cell
):
subdomain_id
=
self
.
cell_function
[
cell
.
index
]
...
...
@@ -106,7 +108,7 @@ def mat_per_subdomains(cell_function, mat_dict, topo_dim):
"""
C
=
[]
nb_val
=
int
(
topo_dim
*
(
topo_dim
+
1
)
/
2
)
nb_val
=
int
(
topo_dim
*
(
topo_dim
+
1
)
/
2
)
for
i
in
range
(
nb_val
):
Cj
=
[]
for
j
in
range
(
nb_val
):
...
...
@@ -117,7 +119,9 @@ def mat_per_subdomains(cell_function, mat_dict, topo_dim):
def
epsilon
(
u
):
return
fe
.
as_vector
((
u
[
0
].
dx
(
0
),
u
[
1
].
dx
(
1
),
(
u
[
0
].
dx
(
1
)
+
u
[
1
].
dx
(
0
))
/
math
.
sqrt
(
2
)))
return
fe
.
as_vector
(
(
u
[
0
].
dx
(
0
),
u
[
1
].
dx
(
1
),
(
u
[
0
].
dx
(
1
)
+
u
[
1
].
dx
(
0
))
/
math
.
sqrt
(
2
))
)
def
sigma
(
C
,
eps
):
...
...
@@ -128,14 +132,18 @@ def strain_cross_energy(sig, eps, mesh, area):
"""
Calcul de l'energie croisée des champs de contrainte sig et de deformation eps.
"""
# TODO : Redondant. Voir si cela est nécessaire.
return
fe
.
assemble
(
fe
.
inner
(
sig
,
eps
)
*
fe
.
dx
(
mesh
))
/
area
return
fe
.
assemble
(
fe
.
inner
(
sig
,
eps
)
*
fe
.
dx
(
mesh
))
/
area
def
cross_energy
(
sig
,
eps
,
mesh
):
"""
Calcul de l'energie croisée des champs de contrainte sig et de deformation eps.
"""
return
fe
.
assemble
(
fe
.
inner
(
sig
,
eps
)
*
fe
.
dx
(
mesh
))
# def energy_norm()
# return fe.assemble(fe.inner(sig, eps) * fe.dx(mesh))/area
...
...
test/test_mesh_generate_2D.py
View file @
53d274f3
...
...
@@ -35,19 +35,17 @@ def test_rve_2_part():
def
test_pantograph_offset
():
geo
.
set_gmsh_option
(
'Mesh.MshFileVersion'
,
4.1
)
geo
.
set_gmsh_option
(
"Mesh.MshFileVersion"
,
4.1
)
a
=
1
b
,
k
=
a
,
a
/
3
b
,
k
=
a
,
a
/
3
t
=
0.02
panto_test
=
mesh2D
.
pantograph_offset_RVE
(
a
,
b
,
k
,
t
,
nb_cells
=
(
1
,
1
),
soft_mat
=
False
,
name
=
'panto_rve_1x1'
)
lc_ratio
=
1
/
6
lc_min_max
=
(
lc_ratio
*
t
*
a
,
lc_ratio
*
a
)
panto_test
.
main_mesh_refinement
((
2
*
t
*
a
,
a
),
lc_min_max
,
False
)
a
,
b
,
k
,
t
,
nb_cells
=
(
1
,
1
),
soft_mat
=
False
,
name
=
"panto_rve_1x1"
)
lc_ratio
=
1
/
6
lc_min_max
=
(
lc_ratio
*
t
*
a
,
lc_ratio
*
a
)
panto_test
.
main_mesh_refinement
((
2
*
t
*
a
,
a
),
lc_min_max
,
False
)
panto_test
.
mesh_generate
()
gmsh
.
model
.
mesh
.
renumberNodes
()
gmsh
.
model
.
mesh
.
renumberElements
()
gmsh
.
write
(
"panto_rve_offset.msh"
)
test_pantograph_offset
()
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
.
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment