Page Menu
Home
c4science
Search
Configure Global Search
Log In
Files
F86811506
LMPOST.cc
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, Oct 8, 18:22
Size
5 KB
Mime Type
text/x-c
Expires
Thu, Oct 10, 18:22 (2 d)
Engine
blob
Format
Raw Data
Handle
21485795
Attached To
rLIBMULTISCALE LibMultiScale
LMPOST.cc
View Options
/* ./amel/LMPOST.cpp
*********************************
Copyright EPFL and INRIA
author : Guillaume ANCIAUX (guillaume.anciaux@epfl.ch, g.anciaux@laposte.net)
The LibMultiScale is a C++ parallel framework for the multiscale
coupling methods dedicated to material simulations. This framework
provides an API which makes it possible to program coupled simulations
and integration of already existing codes.
This Project is done in a collaboration between
EPFL within ENAC-LSMS (http://lsms.epfl.ch/) and
INRIA Bordeaux, ScAlApplix (http://www.labri.fr/projet/scalapplix/).
This software is governed by the CeCILL-C license under French law and
abiding by the rules of distribution of free software. You can use,
modify and/ or redistribute the software under the terms of the CeCILL-C
license as circulated by CEA, CNRS and INRIA at the following URL
"http://www.cecill.info".
As a counterpart to the access to the source code and rights to copy,
modify and redistribute granted by the license, users are provided only
with a limited warranty and the software's author, the holder of the
economic rights, and the successive licensors have only limited
liability.
In this respect, the user's attention is drawn to the risks associated
with loading, using, modifying and/or developing or reproducing the
software by the user in light of its specific status of free software,
that may mean that it is complicated to manipulate, and that also
therefore means that it is reserved for developers and experienced
professionals having in-depth computer knowledge. Users are therefore
encouraged to load and test the software's suitability as regards their
requirements in conditions enabling the security of their systems and/or
data to be ensured and, more generally, to use and operate it in the
same conditions as regards security.
The fact that you are presently reading this means that you have had
knowledge of the CeCILL-C license and that you accept its terms.
***********************************/
#define TIMER
#define MAIN_SOURCE
#include "lm_common.hh"
#include "domain_multiscale.hh"
#include "algebraic_parser.hh"
#include "action_manager.hh"
#include "lm_parser.hh"
using
namespace
libmultiscale
;
/* -------------------------------------------------------------------------- */
#include <iostream>
#include <iomanip>
#include <cstdlib>
#include <cstdio>
#include <cstring>
#ifdef USING_QVIEW
#include <libqview.h>
#endif
static
UInt
numLines
=
UINT_MAX
;
FILE
*
open_restart
(
const
std
::
string
&
fname
)
{
FILE
*
res
=
fopen
(
fname
.
c_str
(),
"rb"
);
if
(
res
==
NULL
)
LM_FATAL
(
"cannot open multiscale restart file : "
<<
fname
);
char
buffer
[
512
];
char
*
buf
=
NULL
;
while
(
!
feof
(
res
)){
buf
=
fgets
(
buffer
,
512
,
res
);
numLines
++
;
}
fclose
(
res
);
res
=
fopen
(
fname
.
c_str
(),
"rb"
);
buf
=
fgets
(
buffer
,
512
,
res
);
if
(
strcmp
(
buf
,
"LMRESTART
\n
"
))
LM_FATAL
(
"invalid restart file : "
<<
fname
<<
"first line read : "
<<
buffer
);
return
res
;
}
UInt
parseRestartLine
(
const
std
::
string
&
line
,
DomainMultiScale
&
dom
){
Real
value
;
DomainID
dom_index
;
std
::
string
f
;
UInt
cpt
=
0
;
std
::
stringstream
sline
(
line
);
Parser
::
parse
(
value
,
sline
);
dom_index
=
(
int
)
value
;
sline
>>
f
;
while
(
sline
.
good
()){
if
(
f
==
""
)
break
;
DUMP
(
"reload file "
<<
f
<<
" dom index = "
<<
dom_index
<<
" "
<<
line
,
DBG_MESSAGE
);
if
(
dom
.
getObject
(
dom_index
)){
dom
.
getObject
(
dom_index
)
->
readXMLFile
(
f
.
c_str
());
dom
.
getObject
(
dom_index
)
->
performStep2
();
}
++
cpt
;
Parser
::
parse
(
value
,
sline
);
dom_index
=
(
int
)
value
;
sline
>>
f
;
}
return
cpt
;
}
UInt
readRestartLine
(
FILE
*
frestart
,
DomainMultiScale
&
dom
){
char
buffer
[
512
];
char
*
test
=
fgets
(
buffer
,
512
,
frestart
);
if
(
!
test
)
return
0
;
return
parseRestartLine
(
buffer
,
dom
);
}
int
main
(
int
argc
,
char
**
argv
)
{
loadModules
(
argc
,
argv
);
// loading the modules macro
// int a = 1;
// while (a) {};
char
restart_file
[
255
];
strcpy
(
restart_file
,
argv
[
2
]);
FILE
*
frestart
=
open_restart
(
restart_file
);
DomainMultiScale
&
dom
=
DomainMultiScale
::
getManager
();
dom
.
build
(
argv
[
1
]);
ActionManager
&
actions
=
dom
.
getActionManager
();
current_stage
=
PRE_STEP1
;
actions
.
action
();
UInt
more
=
readRestartLine
(
frestart
,
dom
);
UInt
current_line
=
0
;
UInt
sav_current_step
=
current_step
;
UInt
increment_step
=
0
;
#ifdef USING_QVIEW
QView
qv
;
qv
.
setMode
(
NET_MODE
);
qv
.
initLibQview
();
qv
.
beginTask
(
"main"
,
numLines
);
#endif
//USING_QVIEW
while
(
more
)
{
#ifdef USING_QVIEW
qv
.
setCurrentStep
(
current_line
);
#else
std
::
cerr
<<
"passing step "
<<
current_line
<<
"/"
<<
numLines
<<
std
::
endl
;
#endif
//make dump
current_stage
=
PRE_STEP1
;
actions
.
action
();
//reload restart file
more
=
readRestartLine
(
frestart
,
dom
);
if
(
sav_current_step
==
current_step
)
{
current_step
=
++
increment_step
;
}
else
{
sav_current_step
=
current_step
;
}
++
current_line
;
}
#ifdef USING_QVIEW
qv
.
endTask
();
#endif
//USING_QVIEW
closeModules
();
// closing the modules macro
return
0
;
}
Event Timeline
Log In to Comment