Page Menu
Home
c4science
Search
Configure Global Search
Log In
Files
F85637184
test_boussinesq_surface.py
No One
Temporary
Actions
Download File
Edit File
Delete File
View Transforms
Subscribe
Mute Notifications
Award Token
Subscribers
None
File Metadata
Details
File Info
Storage
Attached
Created
Mon, Sep 30, 13:50
Size
2 KB
Mime Type
text/x-python
Expires
Wed, Oct 2, 13:50 (2 d)
Engine
blob
Format
Raw Data
Handle
21174654
Attached To
rTAMAAS tamaas
test_boussinesq_surface.py
View Options
#!/usr/bin/env python3
# coding: utf-8
# -----------------------------------------------------------------------------
# @author Lucas Frérot <lucas.frerot@epfl.ch>
#
# @section LICENSE
#
# Copyright (©) 2016 EPFL (Ecole Polytechnique Fédérale de
# Lausanne) Laboratory (LSMS - Laboratoire de Simulation en Mécanique des
# Solides)
#
# Tamaas is free software: you can redistribute it and/or modify it under the
# terms of the GNU Lesser General Public License as published by the Free
# Software Foundation, either version 3 of the License, or (at your option) any
# later version.
#
# Tamaas is distributed in the hope that it will be useful, but WITHOUT ANY
# WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR
# A PARTICULAR PURPOSE. See the GNU Lesser General Public License for more
# details.
#
# You should have received a copy of the GNU Lesser General Public License
# along with Tamaas. If not, see <http://www.gnu.org/licenses/>.
# -----------------------------------------------------------------------------
import
numpy
as
np
import
tamaas
as
tm
from
numpy.linalg
import
norm
def
test_boussinesq_surface
(
tamaas_fixture
):
# Definition of modeled domain
model_type
=
tm
.
model_type
.
volume_2d
discretization
=
[
2
,
128
,
128
]
system_size
=
[
1.
,
1.
,
1.
]
x
,
y
=
[
np
.
linspace
(
0
,
size
,
n
,
endpoint
=
False
)
for
size
,
n
in
zip
(
system_size
[
1
:],
discretization
[
1
:])]
xx
,
yy
=
np
.
meshgrid
(
x
,
y
,
sparse
=
True
)
tractions
=
np
.
zeros
(
discretization
[
1
:]
+
[
3
])
for
i
in
range
(
3
):
omega
=
np
.
random
.
randint
(
1
,
20
,
(
2
,))
*
2
*
np
.
pi
tractions
[:,
:,
i
]
=
np
.
cos
(
omega
[
0
]
*
xx
)
*
np
.
cos
(
omega
[
1
]
*
yy
)
# Material contants
E
=
1.
# Young's modulus
nu
=
0.3
# Poisson's ratio
# Creation of model
model_vol
=
tm
.
ModelFactory
.
createModel
(
model_type
,
system_size
,
discretization
)
model_surf
=
tm
.
ModelFactory
.
createModel
(
tm
.
model_type
.
surface_2d
,
[
1
,
1
],
tractions
.
shape
[:
-
1
])
model_vol
.
E
=
E
model_vol
.
nu
=
nu
model_surf
.
E
=
E
model_surf
.
nu
=
nu
# Setup for integral operators
tm
.
ModelFactory
.
createResidual
(
model_vol
,
0
,
0
)
# Pressure definition
model_vol
.
getTraction
()[
...
]
=
tractions
model_surf
.
getTraction
()[
...
]
=
tractions
model_surf
.
solveNeumann
()
# Applying operator
boussinesq
=
model_vol
.
getIntegralOperator
(
"boussinesq"
)
boussinesq
.
apply
(
model_vol
.
getTraction
(),
model_vol
.
getDisplacement
())
# # Dumper
# dumper_helper = UVWDumper(residual, args.name)
# model.setDumper(dumper_helper)
# model.dump()
# print("Done")
for
i
in
range
(
3
):
error
=
norm
(
model_vol
.
getDisplacement
()[
0
,
:,
:,
i
]
-
model_surf
.
getDisplacement
()[:,
:,
i
])
\
/
norm
(
tractions
[:,
:,
i
])
assert
error
<
1e-16
Event Timeline
Log In to Comment