Page Menu
Home
c4science
Search
Configure Global Search
Log In
Files
F106408581
AMEL.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
Tue, Mar 25, 12:44
Size
5 KB
Mime Type
text/x-python
Expires
Thu, Mar 27, 12:44 (1 d, 23 h)
Engine
blob
Format
Raw Data
Handle
25137698
Attached To
rLIBMULTISCALE LibMultiScale
AMEL.py
View Options
#!/usr/bin/python3
# -*- coding: utf-8 -*-
################################################################
# ./python/AMEL.py
################################################################
# author : Guillaume ANCIAUX (guillaume.anciaux@epfl.ch, g.anciaux@laposte.net)
# @author Guillaume Anciaux <guillaume.anciaux@epfl.ch>
#
# @date Mon Sep 08 23:40:22 2014
#
# @brief This describe the root objects to be combined
# into valid LM components
#
# @section LICENSE
#
# Copyright (©) 2010-2011 EPFL (Ecole Polytechnique Fédérale de Lausanne)
# Laboratory (LSMS - Laboratoire de Simulation en Mécanique des Solides)
#
# LibMultiScale 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.
#
# LibMultiScale 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 LibMultiScale. If not, see <http://www.gnu.org/licenses/>.
################################################################
import
time
import
datetime
import
os
import
argparse
import
pylibmultiscale
as
lm
from
mpi4py
import
MPI
################################################################
lastdump
=
-
1e30
lastStep
=
0
nb_step
=
0
################################################################
def
printState
():
if
lm
.
lm_my_proc_id
!=
0
:
return
global
lastdump
,
lastStep
,
nb_step
gtime
=
time
.
time
()
if
(
gtime
-
lastdump
)
<
2
:
return
nstep_done
=
-
lastStep
+
lm
.
current_step
info_steps
=
"{0:>2d} % - passing step {1:>5d}/{2:<5d}"
.
format
(
100
*
lm
.
current_step
/
nb_step
,
lm
.
current_step
,
nb_step
)
if
lm
.
current_step
>
0
:
step_per_seconds
=
nstep_done
/
(
gtime
-
lastdump
)
time_per_step
=
datetime
.
timedelta
(
seconds
=
(
gtime
-
lastdump
)
/
nstep_done
)
remaining_time
=
time_per_step
*
(
nb_step
-
lm
.
current_step
)
step_per_seconds
=
"{0:.2f}"
.
format
(
step_per_seconds
)
info_steps
+=
" {0: >5s} steps/seconds"
.
format
(
step_per_seconds
)
info_steps
+=
" remaining {0}"
.
format
(
remaining_time
)
print
(
info_steps
)
lastStep
=
lm
.
current_step
lastdump
=
gtime
################################################################
def
Usage
():
parser
=
argparse
.
ArgumentParser
(
description
=
'AMEL: LibMultiScale basic client, Python version'
)
parser
.
add_argument
(
'input_file'
,
help
=
'global config file of the simulation'
)
parser
.
add_argument
(
'nsteps'
,
type
=
int
,
help
=
'Number of step wanted to be run (>=0)'
)
try
:
args
=
parser
.
parse_args
()
except
SystemExit
as
e
:
print
(
"
\n
Generated release file: release.info"
)
open
(
'release.info'
,
'w'
)
.
write
(
lm
.
release_info
)
raise
e
return
args
.
input_file
,
args
.
nsteps
################################################################
def
main
():
lm
.
loadModules
()
global
nb_step
conf
,
nb_step
=
Usage
()
try
:
os
.
mkdir
(
'paraview'
)
except
Exception
:
pass
print
(
nb_step
)
nb_step_next_event
=
nb_step
comm
=
MPI
.
COMM_WORLD
comm
.
Barrier
()
dom
=
lm
.
DomainMultiScale
.
getManager
()
dom
.
build
(
conf
)
print
(
type
(
dom
))
md
=
dom
.
getObject
(
'md'
)
print
(
type
(
md
))
# cont = md.getContainer()
# print(cont.size())
# for i in range(0, cont.size()/100):
# at = cont.get(i)
# print(
# at.position(0).value(),
# at.position(1).value(),
# at.position(2).value())
actions
=
lm
.
ActionManager
.
getManager
()
print
(
actions
)
nb_step
+=
lm
.
current_step
.
fget
()
comm
.
Barrier
()
shouldPrintState
=
True
min_dt
=
dom
.
getTimeStep
()
current_time
=
lm
.
current_step
.
fget
()
*
min_dt
for
current_step
in
range
(
lm
.
current_step
.
fget
(),
nb_step
):
lm
.
current_step
.
fset
(
current_step
)
current_time
+=
min_dt
if
shouldPrintState
:
printState
()
print
(
'current_stage: '
,
lm
.
current_stage
.
fget
())
lm
.
current_stage
.
fset
(
lm
.
PRE_DUMP
)
actions
.
action
()
lm
.
current_stage
.
fset
(
lm
.
PRE_STEP1
)
actions
.
action
()
dom
.
performStep1
()
dom
.
coupling
(
lm
.
COUPLING_STEP1
)
lm
.
current_stage
.
fset
(
lm
.
PRE_STEP2
)
actions
.
action
()
dom
.
performStep2
()
dom
.
coupling
(
lm
.
COUPLING_STEP2
)
lm
.
current_stage
.
fset
(
lm
.
PRE_STEP3
)
actions
.
action
()
dom
.
performStep3
()
dom
.
coupling
(
lm
.
COUPLING_STEP3
)
lm
.
current_stage
.
fset
(
lm
.
PRE_STEP4
)
actions
.
action
()
dom
.
coupling
(
lm
.
COUPLING_STEP4
)
comm
.
Barrier
()
lm
.
current_stage
.
fset
(
lm
.
PRE_DUMP
)
actions
.
action
()
lm
.
current_stage
.
fset
(
lm
.
PRE_STEP1
)
actions
.
action
()
# dom.destroy()
lm
.
closeModules
()
print
(
"Done"
)
################################################################
if
__name__
==
"__main__"
:
main
()
Event Timeline
Log In to Comment