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
19f81e08
Commit
19f81e08
authored
6 years ago
by
Richard Berger
Browse files
Options
Downloads
Patches
Plain Diff
Add library functions for accessing LAMMPS configuration
parent
35f5a685
No related branches found
Branches containing commit
No related tags found
No related merge requests found
Changes
5
Hide whitespace changes
Inline
Side-by-side
Showing
5 changed files
python/lammps.py
+30
-6
30 additions, 6 deletions
python/lammps.py
src/info.cpp
+9
-0
9 additions, 0 deletions
src/info.cpp
src/info.h
+1
-0
1 addition, 0 deletions
src/info.h
src/library.cpp
+51
-0
51 additions, 0 deletions
src/library.cpp
src/library.h
+9
-0
9 additions, 0 deletions
src/library.h
with
100 additions
and
6 deletions
python/lammps.py
+
30
−
6
View file @
19f81e08
...
@@ -209,6 +209,7 @@ class lammps(object):
...
@@ -209,6 +209,7 @@ class lammps(object):
self
.
c_bigint
=
get_ctypes_int
(
self
.
extract_setting
(
"
bigint
"
))
self
.
c_bigint
=
get_ctypes_int
(
self
.
extract_setting
(
"
bigint
"
))
self
.
c_tagint
=
get_ctypes_int
(
self
.
extract_setting
(
"
tagint
"
))
self
.
c_tagint
=
get_ctypes_int
(
self
.
extract_setting
(
"
tagint
"
))
self
.
c_imageint
=
get_ctypes_int
(
self
.
extract_setting
(
"
imageint
"
))
self
.
c_imageint
=
get_ctypes_int
(
self
.
extract_setting
(
"
imageint
"
))
self
.
_installed_packages
=
None
# shut-down LAMMPS instance
# shut-down LAMMPS instance
...
@@ -562,13 +563,36 @@ class lammps(object):
...
@@ -562,13 +563,36 @@ class lammps(object):
shrinkexceed
)
shrinkexceed
)
@property
@property
def
use
s_exceptions
(
self
):
def
ha
s_exceptions
(
self
):
"""
Return whether the LAMMPS shared library was compiled with C++ exceptions handling enabled
"""
"""
Return whether the LAMMPS shared library was compiled with C++ exceptions handling enabled
"""
try
:
return
self
.
lib
.
lammps_config_has_exceptions
()
!=
0
if
self
.
lib
.
lammps_has_error
:
return
True
@property
except
(
AttributeError
):
def
has_gzip_support
(
self
):
return
False
return
self
.
lib
.
lammps_config_has_gzip_support
()
!=
0
@property
def
has_png_support
(
self
):
return
self
.
lib
.
lammps_config_has_png_support
()
!=
0
@property
def
has_jpeg_support
(
self
):
return
self
.
lib
.
lammps_config_has_jpeg_support
()
!=
0
@property
def
has_ffmpeg_support
(
self
):
return
self
.
lib
.
lammps_config_has_ffmpeg_support
()
!=
0
@property
def
installed_packages
(
self
):
if
self
.
_installed_packages
is
None
:
self
.
_installed_packages
=
[]
npackages
=
self
.
lib
.
lammps_config_package_count
()
sb
=
create_string_buffer
(
100
)
for
idx
in
range
(
npackages
):
self
.
lib
.
lammps_config_package_name
(
idx
,
sb
,
100
)
self
.
_installed_packages
.
append
(
sb
.
value
.
decode
())
return
self
.
_installed_packages
# -------------------------------------------------------------------------
# -------------------------------------------------------------------------
# -------------------------------------------------------------------------
# -------------------------------------------------------------------------
...
...
This diff is collapsed.
Click to expand it.
src/info.cpp
+
9
−
0
View file @
19f81e08
...
@@ -1190,6 +1190,15 @@ bool Info::has_exceptions() {
...
@@ -1190,6 +1190,15 @@ bool Info::has_exceptions() {
#endif
#endif
}
}
bool
Info
::
has_package
(
const
char
*
package_name
)
{
for
(
int
i
=
0
;
LAMMPS
::
installed_packages
[
i
]
!=
NULL
;
++
i
)
{
if
(
strcmp
(
package_name
,
LAMMPS
::
installed_packages
[
i
])
==
0
)
{
return
true
;
}
}
return
false
;
}
/* ---------------------------------------------------------------------- */
/* ---------------------------------------------------------------------- */
char
**
Info
::
get_variable_names
(
int
&
num
)
{
char
**
Info
::
get_variable_names
(
int
&
num
)
{
...
...
This diff is collapsed.
Click to expand it.
src/info.h
+
1
−
0
View file @
19f81e08
...
@@ -38,6 +38,7 @@ class Info : protected Pointers {
...
@@ -38,6 +38,7 @@ class Info : protected Pointers {
static
bool
has_jpeg_support
();
static
bool
has_jpeg_support
();
static
bool
has_ffmpeg_support
();
static
bool
has_ffmpeg_support
();
static
bool
has_exceptions
();
static
bool
has_exceptions
();
static
bool
has_package
(
const
char
*
package_name
);
char
**
get_variable_names
(
int
&
num
);
char
**
get_variable_names
(
int
&
num
);
...
...
This diff is collapsed.
Click to expand it.
src/library.cpp
+
51
−
0
View file @
19f81e08
...
@@ -38,6 +38,7 @@
...
@@ -38,6 +38,7 @@
#include
"memory.h"
#include
"memory.h"
#include
"error.h"
#include
"error.h"
#include
"force.h"
#include
"force.h"
#include
"info.h"
using
namespace
LAMMPS_NS
;
using
namespace
LAMMPS_NS
;
...
@@ -1522,6 +1523,56 @@ void lammps_create_atoms(void *ptr, int n, tagint *id, int *type,
...
@@ -1522,6 +1523,56 @@ void lammps_create_atoms(void *ptr, int n, tagint *id, int *type,
END_CAPTURE
END_CAPTURE
}
}
// ----------------------------------------------------------------------
// library API functions for accessing LAMMPS configuration
// ----------------------------------------------------------------------
int
lammps_config_has_package
(
char
*
package_name
)
{
return
Info
::
has_package
(
package_name
);
}
int
lammps_config_package_count
()
{
int
i
=
0
;
while
(
LAMMPS
::
installed_packages
[
i
]
!=
NULL
)
{
++
i
;
}
return
i
;
}
int
lammps_config_package_name
(
int
index
,
char
*
buffer
,
int
max_size
)
{
int
i
=
0
;
while
(
LAMMPS
::
installed_packages
[
i
]
!=
NULL
&&
i
<
index
)
{
++
i
;
}
if
(
LAMMPS
::
installed_packages
[
i
]
!=
NULL
)
{
strncpy
(
buffer
,
LAMMPS
::
installed_packages
[
i
],
max_size
);
return
true
;
}
return
false
;
}
int
lammps_config_has_gzip_support
()
{
return
Info
::
has_gzip_support
();
}
int
lammps_config_has_png_support
()
{
return
Info
::
has_png_support
();
}
int
lammps_config_has_jpeg_support
()
{
return
Info
::
has_jpeg_support
();
}
int
lammps_config_has_ffmpeg_support
()
{
return
Info
::
has_ffmpeg_support
();
}
int
lammps_config_has_exceptions
()
{
return
Info
::
has_exceptions
();
}
// ----------------------------------------------------------------------
// ----------------------------------------------------------------------
// library API functions for error handling
// library API functions for error handling
// ----------------------------------------------------------------------
// ----------------------------------------------------------------------
...
...
This diff is collapsed.
Click to expand it.
src/library.h
+
9
−
0
View file @
19f81e08
...
@@ -55,6 +55,15 @@ void lammps_gather_atoms_subset(void *, char *, int, int, int, int *, void *);
...
@@ -55,6 +55,15 @@ void lammps_gather_atoms_subset(void *, char *, int, int, int, int *, void *);
void
lammps_scatter_atoms
(
void
*
,
char
*
,
int
,
int
,
void
*
);
void
lammps_scatter_atoms
(
void
*
,
char
*
,
int
,
int
,
void
*
);
void
lammps_scatter_atoms_subset
(
void
*
,
char
*
,
int
,
int
,
int
,
int
*
,
void
*
);
void
lammps_scatter_atoms_subset
(
void
*
,
char
*
,
int
,
int
,
int
,
int
*
,
void
*
);
int
lammps_config_has_package
(
char
*
package_name
);
int
lammps_config_package_count
();
int
lammps_config_package_name
(
int
index
,
char
*
buffer
,
int
max_size
);
int
lammps_config_has_gzip_support
();
int
lammps_config_has_png_support
();
int
lammps_config_has_jpeg_support
();
int
lammps_config_has_ffmpeg_support
();
int
lammps_config_has_exceptions
();
// lammps_create_atoms() takes tagint and imageint as args
// lammps_create_atoms() takes tagint and imageint as args
// ifdef insures they are compatible with rest of LAMMPS
// ifdef insures they are compatible with rest of LAMMPS
// caller must match to how LAMMPS library is built
// caller must match to how LAMMPS library is built
...
...
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