Page Menu
Home
c4science
Search
Configure Global Search
Log In
Files
F82005062
stress_hook.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
Mon, Sep 9, 01:59
Size
2 KB
Mime Type
text/x-c
Expires
Wed, Sep 11, 01:59 (1 d, 23 h)
Engine
blob
Format
Raw Data
Handle
20643356
Attached To
rLIBMULTISCALE LibMultiScale
stress_hook.cc
View Options
/**
* @file stress_hook.cc
*
* @author Guillaume Anciaux <guillaume.anciaux@epfl.ch>
*
* @date Mon Oct 28 19:23:14 2013
*
* @brief LAMMPS hook to recompute stress
*
* @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/>.
*
*/
#include "stress_hook.hh"
#include "lammps_common.hh"
/* -------------------------------------------------------------------------- */
__BEGIN_LIBMULTISCALE__
StressHookLammps
::~
StressHookLammps
(){
if
(
lammps_stress
)
delete
lammps_stress
;
lammps_stress
=
NULL
;
}
/* -------------------------------------------------------------------------- */
StressHookLammps
::
StressHookLammps
(
UInt
kinetic_flag
,
LAMMPS_NS
::
LAMMPS
*
lmp
){
computed
=
false
;
time
=
0
;
char
arg0
[
10
]
=
"1"
;
char
arg1
[
10
]
=
"all"
;
char
arg2
[
10
]
=
"atom"
;
char
arg3
[
10
];
if
(
kinetic_flag
)
strcpy
(
arg3
,
"ke"
);
else
strcpy
(
arg3
,
"pair"
);
char
*
args
[]
=
{
arg0
,
arg1
,
arg2
,
arg3
};
lammps_object
=
lmp
;
lammps_stress
=
new
LAMMPS_NS
::
ComputeStressAtom
(
lammps_object
,
4
,
args
);
}
/* -------------------------------------------------------------------------- */
bool
StressHookLammps
::
Computed
(){
return
((
time
==
current_step
)
&&
computed
==
true
);
}
/* -------------------------------------------------------------------------- */
void
StressHookLammps
::
ComputeStress
(){
DUMP
(
"Asking Lammps to compute stress for all atoms"
,
DBG_MESSAGE
);
UInt
nall
;
if
(
lammps_object
->
force
->
newton
)
nall
=
lammps_object
->
atom
->
nlocal
+
lammps_object
->
atom
->
nghost
;
else
nall
=
lammps_object
->
atom
->
nlocal
;
Real
**
f
=
lammps_object
->
atom
->
f
;
for
(
UInt
i
=
0
;
i
<
nall
;
i
++
)
{
f
[
i
][
0
]
=
0.0
;
f
[
i
][
1
]
=
0.0
;
f
[
i
][
2
]
=
0.0
;
}
int
sav
=
lammps_object
->
update
->
vflag_atom
;
lammps_object
->
update
->
vflag_atom
=
lammps_object
->
update
->
ntimestep
;
lammps_object
->
force
->
pair
->
compute
(
0
,
4
);
lammps_object
->
comm
->
reverse_comm
();
lammps_stress
->
compute_peratom
();
lammps_object
->
update
->
vflag_atom
=
sav
;
computed
=
true
;
time
=
current_step
;
}
/* -------------------------------------------------------------------------- */
__END_LIBMULTISCALE__
Event Timeline
Log In to Comment