Page Menu
Home
c4science
Search
Configure Global Search
Log In
Files
F78665269
bond_class2_omp.cpp
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
Thu, Aug 22, 06:58
Size
3 KB
Mime Type
text/x-c++
Expires
Sat, Aug 24, 06:58 (1 d, 23 h)
Engine
blob
Format
Raw Data
Handle
20081661
Attached To
rLAMMPS lammps
bond_class2_omp.cpp
View Options
/* ----------------------------------------------------------------------
LAMMPS - Large-scale Atomic/Molecular Massively Parallel Simulator
http://lammps.sandia.gov, Sandia National Laboratories
Steve Plimpton, sjplimp@sandia.gov
Copyright (2003) Sandia Corporation. Under the terms of Contract
DE-AC04-94AL85000 with Sandia Corporation, the U.S. Government retains
certain rights in this software. This software is distributed under
the GNU General Public License.
See the README file in the top-level LAMMPS directory.
------------------------------------------------------------------------- */
/* ----------------------------------------------------------------------
Contributing author: Axel Kohlmeyer (Temple U)
------------------------------------------------------------------------- */
#include "bond_class2_omp.h"
#include "atom.h"
#include "comm.h"
#include "force.h"
#include "neighbor.h"
#include "domain.h"
#include <math.h>
#include "suffix.h"
using
namespace
LAMMPS_NS
;
/* ---------------------------------------------------------------------- */
BondClass2OMP
::
BondClass2OMP
(
class
LAMMPS
*
lmp
)
:
BondClass2
(
lmp
),
ThrOMP
(
lmp
,
THR_BOND
)
{
suffix_flag
|=
Suffix
::
OMP
;
}
/* ---------------------------------------------------------------------- */
void
BondClass2OMP
::
compute
(
int
eflag
,
int
vflag
)
{
if
(
eflag
||
vflag
)
{
ev_setup
(
eflag
,
vflag
);
}
else
evflag
=
0
;
const
int
nall
=
atom
->
nlocal
+
atom
->
nghost
;
const
int
nthreads
=
comm
->
nthreads
;
const
int
inum
=
neighbor
->
nbondlist
;
#if defined(_OPENMP)
#pragma omp parallel default(none) shared(eflag,vflag)
#endif
{
int
ifrom
,
ito
,
tid
;
loop_setup_thr
(
ifrom
,
ito
,
tid
,
inum
,
nthreads
);
ThrData
*
thr
=
fix
->
get_thr
(
tid
);
thr
->
timer
(
Timer
::
START
);
ev_setup_thr
(
eflag
,
vflag
,
nall
,
eatom
,
vatom
,
thr
);
if
(
inum
>
0
)
{
if
(
evflag
)
{
if
(
eflag
)
{
if
(
force
->
newton_bond
)
eval
<
1
,
1
,
1
>
(
ifrom
,
ito
,
thr
);
else
eval
<
1
,
1
,
0
>
(
ifrom
,
ito
,
thr
);
}
else
{
if
(
force
->
newton_bond
)
eval
<
1
,
0
,
1
>
(
ifrom
,
ito
,
thr
);
else
eval
<
1
,
0
,
0
>
(
ifrom
,
ito
,
thr
);
}
}
else
{
if
(
force
->
newton_bond
)
eval
<
0
,
0
,
1
>
(
ifrom
,
ito
,
thr
);
else
eval
<
0
,
0
,
0
>
(
ifrom
,
ito
,
thr
);
}
}
thr
->
timer
(
Timer
::
BOND
);
reduce_thr
(
this
,
eflag
,
vflag
,
thr
);
}
// end of omp parallel region
}
template
<
int
EVFLAG
,
int
EFLAG
,
int
NEWTON_BOND
>
void
BondClass2OMP
::
eval
(
int
nfrom
,
int
nto
,
ThrData
*
const
thr
)
{
int
i1
,
i2
,
n
,
type
;
double
delx
,
dely
,
delz
,
ebond
,
fbond
;
double
rsq
,
r
,
dr
,
dr2
,
dr3
,
dr4
,
de_bond
;
const
dbl3_t
*
_noalias
const
x
=
(
dbl3_t
*
)
atom
->
x
[
0
];
dbl3_t
*
_noalias
const
f
=
(
dbl3_t
*
)
thr
->
get_f
()[
0
];
const
int3_t
*
_noalias
const
bondlist
=
(
int3_t
*
)
neighbor
->
bondlist
[
0
];
const
int
nlocal
=
atom
->
nlocal
;
ebond
=
0.0
;
for
(
n
=
nfrom
;
n
<
nto
;
n
++
)
{
i1
=
bondlist
[
n
].
a
;
i2
=
bondlist
[
n
].
b
;
type
=
bondlist
[
n
].
t
;
delx
=
x
[
i1
].
x
-
x
[
i2
].
x
;
dely
=
x
[
i1
].
y
-
x
[
i2
].
y
;
delz
=
x
[
i1
].
z
-
x
[
i2
].
z
;
rsq
=
delx
*
delx
+
dely
*
dely
+
delz
*
delz
;
r
=
sqrt
(
rsq
);
dr
=
r
-
r0
[
type
];
dr2
=
dr
*
dr
;
dr3
=
dr2
*
dr
;
dr4
=
dr3
*
dr
;
// force & energy
de_bond
=
2.0
*
k2
[
type
]
*
dr
+
3.0
*
k3
[
type
]
*
dr2
+
4.0
*
k4
[
type
]
*
dr3
;
if
(
r
>
0.0
)
fbond
=
-
de_bond
/
r
;
else
fbond
=
0.0
;
if
(
EFLAG
)
ebond
=
k2
[
type
]
*
dr2
+
k3
[
type
]
*
dr3
+
k4
[
type
]
*
dr4
;
// apply force to each of 2 atoms
if
(
NEWTON_BOND
||
i1
<
nlocal
)
{
f
[
i1
].
x
+=
delx
*
fbond
;
f
[
i1
].
y
+=
dely
*
fbond
;
f
[
i1
].
z
+=
delz
*
fbond
;
}
if
(
NEWTON_BOND
||
i2
<
nlocal
)
{
f
[
i2
].
x
-=
delx
*
fbond
;
f
[
i2
].
y
-=
dely
*
fbond
;
f
[
i2
].
z
-=
delz
*
fbond
;
}
if
(
EVFLAG
)
ev_tally_thr
(
this
,
i1
,
i2
,
nlocal
,
NEWTON_BOND
,
ebond
,
fbond
,
delx
,
dely
,
delz
,
thr
);
}
}
Event Timeline
Log In to Comment