Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
L
lammps
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Wiki
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
Container Registry
Model registry
Operate
Environments
Monitor
Incidents
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
multiscale
lammps
Commits
0b5a2e19
Commit
0b5a2e19
authored
7 years ago
by
Richard Berger
Browse files
Options
Downloads
Patches
Plain Diff
Add way of getting correct ctypes integer type for bigint, tagint, and imageint
parent
09bb6879
No related branches found
No related tags found
No related merge requests found
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
python/lammps.py
+19
-0
19 additions, 0 deletions
python/lammps.py
with
19 additions
and
0 deletions
python/lammps.py
+
19
−
0
View file @
0b5a2e19
...
@@ -32,6 +32,13 @@ import select
...
@@ -32,6 +32,13 @@ import select
import
re
import
re
import
sys
import
sys
def
get_ctypes_int
(
size
):
if
size
==
4
:
return
c_int32
elif
size
==
8
:
return
c_int64
return
c_int
class
MPIAbortException
(
Exception
):
class
MPIAbortException
(
Exception
):
def
__init__
(
self
,
message
):
def
__init__
(
self
,
message
):
self
.
message
=
message
self
.
message
=
message
...
@@ -165,6 +172,11 @@ class lammps(object):
...
@@ -165,6 +172,11 @@ class lammps(object):
# optional numpy support (lazy loading)
# optional numpy support (lazy loading)
self
.
_numpy
=
None
self
.
_numpy
=
None
# set default types
self
.
c_bigint
=
get_ctypes_int
(
self
.
extract_setting
(
"
bigint
"
))
self
.
c_tagint
=
get_ctypes_int
(
self
.
extract_setting
(
"
tagint
"
))
self
.
c_imageint
=
get_ctypes_int
(
self
.
extract_setting
(
"
imageint
"
))
def
__del__
(
self
):
def
__del__
(
self
):
if
self
.
lmp
and
self
.
opened
:
if
self
.
lmp
and
self
.
opened
:
self
.
lib
.
lammps_close
(
self
.
lmp
)
self
.
lib
.
lammps_close
(
self
.
lmp
)
...
@@ -239,6 +251,13 @@ class lammps(object):
...
@@ -239,6 +251,13 @@ class lammps(object):
ptr
=
self
.
lib
.
lammps_extract_atom
(
self
.
lmp
,
name
)
ptr
=
self
.
lib
.
lammps_extract_atom
(
self
.
lmp
,
name
)
return
ptr
return
ptr
# extract lammps type byte sizes
def
extract_setting
(
self
,
name
):
if
name
:
name
=
name
.
encode
()
self
.
lib
.
lammps_extract_atom
.
restype
=
c_int
return
int
(
self
.
lib
.
lammps_extract_setting
(
self
.
lmp
,
name
))
@property
@property
def
numpy
(
self
):
def
numpy
(
self
):
if
not
self
.
_numpy
:
if
not
self
.
_numpy
:
...
...
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment