Page Menu
Home
c4science
Search
Configure Global Search
Log In
Files
F60643824
numpy_dumper.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
Wed, May 1, 16:31
Size
1 KB
Mime Type
text/x-python
Expires
Fri, May 3, 16:31 (1 d, 23 h)
Engine
blob
Format
Raw Data
Handle
17389199
Attached To
rTAMAAS tamaas
numpy_dumper.py
View Options
# @file
# @section LICENSE
#
# Copyright (©) 2016-19 EPFL (École Polytechnique Fédérale de Lausanne),
# Laboratory (LSMS - Laboratoire de Simulation en Mécanique des Solides)
#
# This program is free software: you can redistribute it and/or modify
# it under the terms of the GNU Affero General Public License as published
# by the Free Software Foundation, either version 3 of the License, or
# (at your option) any later version.
#
# This program 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 Affero General Public License for more details.
#
# You should have received a copy of the GNU Affero General Public License
# along with this program. If not, see <https://www.gnu.org/licenses/>.
from
._helper
import
FieldDumper
,
step_dump
,
directory_dump
import
os
import
numpy
as
np
__all__
=
[
'NumpyDumper'
]
@directory_dump
(
'numpys'
)
@step_dump
class
NumpyDumper
(
FieldDumper
):
"""Dumper to compressed numpy files"""
def
__init__
(
self
,
basename
,
*
fields
):
default_fields
=
[
'traction'
,
'displacement'
,
'stress'
,
'plastic_strain'
]
super
()
.
__init__
(
basename
,
default_fields
,
*
fields
)
def
dump
(
self
,
model
):
dump_fields
=
{
field
:
self
.
make_periodic
[
field
](
model
.
getField
(
field
))
for
field
in
self
.
fields
}
np
.
savez_compressed
(
self
.
file_path
(),
**
dump_fields
)
def
file_path
(
self
):
return
os
.
path
.
join
(
self
.
dirname
(),
"{}{}.npz"
.
format
(
self
.
basename
,
self
.
postfix
()))
Event Timeline
Log In to Comment