Page Menu
Home
c4science
Search
Configure Global Search
Log In
Files
F91707304
compute_lammps.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
Wed, Nov 13, 17:10
Size
4 KB
Mime Type
text/x-c++
Expires
Fri, Nov 15, 17:10 (1 d, 23 h)
Engine
blob
Format
Raw Data
Handle
22311352
Attached To
rLIBMULTISCALE LibMultiScale
compute_lammps.cc
View Options
/**
* @file compute_lammps.cc
*
* @author Guillaume Anciaux <guillaume.anciaux@epfl.ch>
*
* @date Mon Oct 28 19:23:14 2013
*
* @brief Generic compute which actually uses a LAMMPS compute
*
* @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 "lm_common.hh"
#include "lib_md.hh"
#include "compute_lammps.hh"
#include "fix.h"
/* -------------------------------------------------------------------------- */
__BEGIN_LIBMULTISCALE__
/* -------------------------------------------------------------------------- */
template
<
typename
Comp
>
void
ComputeLammps
<
Comp
>::
copyScalar
(){
this
->
setDim
(
1
);
Real
res
=
this
->
comp_obj
.
compute_scalar
();
this
->
add
(
res
);
this
->
name_computed
.
push_back
(
this
->
comp_obj
.
id
);
}
/* -------------------------------------------------------------------------- */
template
<
typename
Comp
>
void
ComputeLammps
<
Comp
>::
copyArray
(){
LM_TOIMPLEMENT
;
}
/* -------------------------------------------------------------------------- */
template
<>
void
ComputeLammps
<
LAMMPS_NS
::
Fix
>::
copyArray
(){
this
->
setDim
(
this
->
comp_obj
.
size_array_cols
);
UInt
m
=
this
->
comp_obj
.
size_array_rows
;
UInt
n
=
this
->
comp_obj
.
size_array_cols
;
for
(
UInt
i
=
0
;
i
<
m
;
++
i
)
{
for
(
UInt
j
=
0
;
j
<
n
;
++
j
)
{
Real
res
=
this
->
comp_obj
.
compute_array
(
i
,
j
);
this
->
add
(
res
);
}
}
for
(
UInt
i
=
0
;
i
<
n
;
++
i
)
{
std
::
stringstream
sstr
;
sstr
<<
this
->
comp_obj
.
id
<<
"["
<<
i
<<
"]"
;
this
->
name_computed
.
push_back
(
sstr
.
str
());
}
}
/* -------------------------------------------------------------------------- */
template
<
typename
Comp
>
void
ComputeLammps
<
Comp
>::
copyPerAtom
(){
LM_TOIMPLEMENT
;
}
/* -------------------------------------------------------------------------- */
template
<>
void
ComputeLammps
<
LAMMPS_NS
::
Compute
>::
copyPerAtom
(){
this
->
comp_obj
.
compute_peratom
();
UInt
ncol
=
this
->
comp_obj
.
size_peratom_cols
;
Real
*
_ptr
=
NULL
;
if
(
ncol
==
0
)
{
ncol
=
1
;
this
->
name_computed
.
push_back
(
this
->
comp_obj
.
id
);
_ptr
=
&
this
->
comp_obj
.
vector_atom
[
0
];
}
else
{
for
(
UInt
i
=
0
;
i
<
ncol
;
++
i
)
{
std
::
stringstream
sstr
;
sstr
<<
this
->
getID
()
<<
"["
<<
i
<<
"]"
;
this
->
name_computed
.
push_back
(
sstr
.
str
());
}
_ptr
=
&
this
->
comp_obj
.
array_atom
[
0
][
0
];
}
this
->
setDim
(
ncol
);
UInt
sz
=
lmp
.
atom
->
nlocal
*
ncol
;
this
->
resize
(
sz
);
for
(
UInt
i
=
0
;
i
<
sz
;
++
i
)
(
*
this
)[
i
]
=
_ptr
[
i
];
}
/* -------------------------------------------------------------------------- */
template
<>
void
ComputeLammps
<
LAMMPS_NS
::
Fix
>::
copyPerAtom
(){
UInt
ncol
=
this
->
comp_obj
.
size_peratom_cols
;
Real
*
_ptr
=
NULL
;
if
(
ncol
==
0
)
{
ncol
=
1
;
this
->
name_computed
.
push_back
(
this
->
comp_obj
.
id
);
_ptr
=
&
this
->
comp_obj
.
vector_atom
[
0
];
}
else
{
for
(
UInt
i
=
0
;
i
<
ncol
;
++
i
)
{
std
::
stringstream
sstr
;
sstr
<<
this
->
getID
()
<<
"["
<<
i
<<
"]"
;
this
->
name_computed
.
push_back
(
sstr
.
str
());
}
_ptr
=
&
this
->
comp_obj
.
array_atom
[
0
][
0
];
}
this
->
setDim
(
ncol
);
UInt
sz
=
lmp
.
atom
->
nlocal
*
ncol
;
this
->
resize
(
sz
);
for
(
UInt
i
=
0
;
i
<
sz
;
++
i
)
(
*
this
)[
i
]
=
_ptr
[
i
];
}
/* -------------------------------------------------------------------------- */
template
<
typename
Comp
>
void
ComputeLammps
<
Comp
>::
build
(){
if
(
this
->
getRelease
()
>=
getGlobalCurrentRelease
())
return
;
this
->
clear
();
this
->
name_computed
.
clear
();
if
(
this
->
comp_obj
.
scalar_flag
)
copyScalar
();
else
if
(
this
->
comp_obj
.
peratom_flag
)
copyPerAtom
();
else
if
(
this
->
comp_obj
.
array_flag
)
copyArray
();
else
if
(
this
->
comp_obj
.
vector_flag
){
LM_TOIMPLEMENT
;
}
else
if
(
this
->
comp_obj
.
local_flag
){
LM_TOIMPLEMENT
;
}
else
LM_TOIMPLEMENT
;
this
->
setRelease
(
getGlobalCurrentRelease
());
}
/* -------------------------------------------------------------------------- */
template
class
ComputeLammps
<
LAMMPS_NS
::
Compute
>
;
template
class
ComputeLammps
<
LAMMPS_NS
::
Fix
>
;
__END_LIBMULTISCALE__
Event Timeline
Log In to Comment