Skip to content

Commit

Permalink
Merge branch 'Cantera:main' into main
Browse files Browse the repository at this point in the history
  • Loading branch information
corykinney authored Jan 16, 2023
2 parents ecd5017 + 1fa20b7 commit 5843e53
Show file tree
Hide file tree
Showing 111 changed files with 3,652 additions and 969 deletions.
253 changes: 201 additions & 52 deletions .github/workflows/main.yml

Large diffs are not rendered by default.

3 changes: 3 additions & 0 deletions .gitmodules
Original file line number Diff line number Diff line change
Expand Up @@ -13,3 +13,6 @@
[submodule "ext/yaml-cpp"]
path = ext/yaml-cpp
url = https://github.com/jbeder/yaml-cpp.git
[submodule "ext/HighFive"]
path = ext/HighFive
url = https://github.com/BlueBrain/HighFive.git
2 changes: 2 additions & 0 deletions AUTHORS
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,7 @@ Yuanjie Jiang
Benjamin Kee (@lionkey)
Gandhali Kogekar (@gkogekar)
Daniel Korff (@korffdm), Colorado School of Mines
Corey R. Randall (@c-randall), Colorado School of Mines
Jon Kristofer
Samesh Lakothia (@sameshl)
Kyle Linevitch, Jr. (@KyleLinevitchJr)
Expand Down Expand Up @@ -63,3 +64,4 @@ Armin Wehrfritz (@awehrfritz)
Richard West (@rwest), Northeastern University
Chao Xu (@12Chao), Northeastern University
Thorsten Zirwes (@g3bk47), Karlsruhe Institute of Technology
Su Sun (@ssun30), Northeastern University
4 changes: 2 additions & 2 deletions CONTRIBUTING.md
Original file line number Diff line number Diff line change
Expand Up @@ -102,8 +102,8 @@

* Style generally follows PEP8 (https://www.python.org/dev/peps/pep-0008/)
* Code in `.py` and `.pyx` files needs to be written to work with Python 3
* The minimum Python version that Cantera supports is Python 3.7, so code should only
use features added in Python 3.7 or earlier
* The minimum Python version that Cantera supports is Python 3.8, so code should only
use features added in Python 3.8 or earlier
* Indicate the version added for new functions and classes with an annotation like
`.. versionadded:: X.Y` where `X.Y` is the next Cantera version. Significant changes
in behavior should be indicated with `.. versionchanged:: X.Y`.
Expand Down
149 changes: 136 additions & 13 deletions SConstruct
Original file line number Diff line number Diff line change
Expand Up @@ -65,7 +65,7 @@ Additional command options:
# and simplest option that will reliably trigger an error in Python 2
# and provide actionable feedback for users.
f"""
Cantera must be built using Python 3.7 or higher. You can invoke SCons by executing
Cantera must be built using Python 3.8 or higher. You can invoke SCons by executing
python3 `which scons`
followed by any desired options.
"""
Expand Down Expand Up @@ -167,11 +167,25 @@ logger.info(
windows_options = [
Option(
"msvc_version",
"""Version of Visual Studio to use. The default is the newest
installed version. Specify '14.1' ('14.1x') Visual Studio 2017, '14.2'
('14.2x') for Visual Studio 2019, or '14.3' ('14.3x') for
Visual Studio 2022. For version numbers in parentheses,
'x' is a placeholder for a minor version number. Windows MSVC only.""",
"""Version of Visual Studio to use. The default is the newest installed version.
Note that since multiple MSVC toolsets can be installed for a single version of
Visual Studio, you probably want to use ``msvc_toolset_version`` unless you
specifically installed multiple versions of Visual Studio. Windows MSVC only.
""",
""),
Option(
"msvc_toolset_version",
"""Version of the MSVC toolset to use. The default is the default version for
the given ``msvc_version``. Note that the toolset selected here must be
installed in the MSVC version selected by ``msvc_version``. The default
toolsets associated with various Visual Studio versions are:
* '14.1' ('14.1x'): Visual Studio 2017
* '14.2' ('14.2x'): Visual Studio 2019
* '14.3' ('14.3x'): Visual Studio 2022.
For version numbers in parentheses, 'x' is a placeholder for a minor version
number. Windows MSVC only.""",
""),
EnumOption(
"target_arch",
Expand Down Expand Up @@ -342,6 +356,34 @@ config_options = [
must include the shared version of the library, for example,
'libfmt.so'.""",
"default", ("default", "y", "n")),
EnumOption(
"hdf_support",
"""Select whether to support HDF5 container files natively ('y'), disable HDF5
support ('n'), or to decide automatically based on the system configuration
('default'). Native HDF5 support uses the HDF5 library as well as the
header-only HighFive C++ wrapper (see option 'system_highfive'). Specifying
'hdf_include' or 'hdf_libdir' changes the default to 'y'.""",
"default", ("default", "y", "n")),
PathOption(
"hdf_include",
"""The directory where the HDF5 header files are installed. This should be the
directory that contains files 'H5Version.h' and 'H5Public.h', amongst others.
Not needed if the headers are installed in a standard location, for example,
'/usr/include'.""",
"", PathVariable.PathAccept),
PathOption(
"hdf_libdir",
"""The directory where the HDF5 libraries are installed. Not needed if the
libraries are installed in a standard location, for example, '/usr/lib'.""",
"", PathVariable.PathAccept),
EnumOption(
"system_highfive",
"""Select whether to use HighFive from a system installation ('y'), from a
Git submodule ('n'), or to decide automatically ('default'). If HighFive
is not installed directly into a system include directory, for example, it
is installed in '/opt/include/HighFive', then you will need to add
'/opt/include/HighFive' to 'extra_inc_dirs'.""",
"default", ("default", "y", "n")),
EnumOption(
"system_yamlcpp",
"""Select whether to use the yaml-cpp library from a system installation
Expand Down Expand Up @@ -428,7 +470,7 @@ config_options = [
"""Environment variables to propagate through to SCons. Either the
string 'all' or a comma separated list of variable names, for example,
'LD_LIBRARY_PATH,HOME'.""",
"PATH,LD_LIBRARY_PATH,DYLD_LIBRARY_PATH,PYTHONPATH"),
"PATH,LD_LIBRARY_PATH,DYLD_LIBRARY_PATH,PYTHONPATH,USERPROFILE"),
BoolOption(
"use_pch",
"Use a precompiled-header to speed up compilation",
Expand Down Expand Up @@ -722,7 +764,7 @@ if os.name == "nt":
if "64 bit" not in sys.version:
config["target_arch"].default = "x86"

opts.AddVariables(*config.to_scons(("msvc_version", "target_arch")))
opts.AddVariables(*config.to_scons(("msvc_version", "msvc_toolset_version", "target_arch")))

windows_compiler_env = Environment()
opts.Update(windows_compiler_env)
Expand All @@ -731,7 +773,7 @@ if os.name == "nt":
if which("g++") and not which("cl.exe"):
config["toolchain"].default = "mingw"

if windows_compiler_env["msvc_version"]:
if windows_compiler_env["msvc_version"] or windows_compiler_env["msvc_toolset_version"]:
config["toolchain"].default = "msvc"

opts.AddVariables(*config.to_scons("toolchain"))
Expand All @@ -741,9 +783,15 @@ if os.name == "nt":
toolchain = ["default"]
if windows_compiler_env["msvc_version"]:
extraEnvArgs["MSVC_VERSION"] = windows_compiler_env["msvc_version"]
if windows_compiler_env["msvc_toolset_version"]:
extraEnvArgs["MSVC_TOOLSET_VERSION"] = windows_compiler_env["msvc_toolset_version"]
msvc_version = (windows_compiler_env["msvc_version"] or
windows_compiler_env["MSVC_VERSION"])
logger.info(f"Compiling with MSVC {msvc_version}", print_level=False)
windows_compiler_env.get("MSVC_VERSION"))
logger.info(f"Compiling with MSVC version {msvc_version}", print_level=False)
msvc_toolset = (windows_compiler_env["msvc_toolset_version"] or
windows_compiler_env.get("MSVC_TOOLSET_VERSION") or
f"{msvc_version} (default)")
logger.info(f"Compiling with MSVC toolset {msvc_toolset}", print_level=False)

elif windows_compiler_env["toolchain"] == "mingw":
toolchain = ["mingw", "f90"]
Expand Down Expand Up @@ -1442,7 +1490,7 @@ if env['system_sundials'] == 'y':
if sundials_ver < parse_version("3.0") or sundials_ver >= parse_version("7.0"):
logger.error(f"Sundials version {env['sundials_version']!r} is not supported.")
sys.exit(1)
elif sundials_ver > parse_version("6.2"):
elif sundials_ver > parse_version("6.4.1"):
logger.warning(f"Sundials version {env['sundials_version']!r} has not been tested.")

logger.info(f"Using system installation of Sundials version {sundials_version!r}.")
Expand Down Expand Up @@ -1477,6 +1525,76 @@ else: # env['system_sundials'] == 'n'
env['sundials_version'] = '5.3'
env['has_sundials_lapack'] = int(env['use_lapack'])

if env["hdf_include"]:
env["hdf_include"] = Path(env["hdf_include"]).as_posix()
env.Append(CPPPATH=[env["hdf_include"]])
env["hdf_support"] = "y"
if env["hdf_libdir"]:
env["hdf_libdir"] = Path(env["hdf_libdir"]).as_posix()
env.Append(LIBPATH=[env["hdf_libdir"]])
env["hdf_support"] = "y"
if env["use_rpath_linkage"]:
env.Append(RPATH=env["hdf_libdir"])

if env["hdf_support"] == "n":
env["use_hdf5"] = False
else:
env["use_hdf5"] = conf.CheckLib("hdf5", autoadd=False)
if not env["use_hdf5"] and env["hdf_support"] == "y":
config_error("HDF5 support has been specified but libraries were not found.")

if env["use_hdf5"] and env["system_highfive"] in ("n", "default"):
env["system_highfive"] = False
if not os.path.exists("ext/eigen/HighFive/include"):
if not os.path.exists(".git"):
config_error("HighFive is missing. Install HighFive in ext/HighFive.")

try:
code = subprocess.call(["git", "submodule", "update", "--init",
"--recursive", "ext/HighFive"])
except Exception:
code = -1
if code:
config_error("HighFive not found and submodule checkout failed.\n"
"Try manually checking out the submodule with:\n\n"
" git submodule update --init --recursive ext/HighFive\n")

env["use_hdf5"] = conf.CheckLibWithHeader(
"hdf5", "../ext/HighFive/include/highfive/H5File.hpp",
language="C++", autoadd=False)

if env["use_hdf5"]:
logger.info("Using private installation of HighFive.")
elif env["hdf_support"] == "y":
config_error("HDF5 support has been specified but HighFive configuration failed.")
else:
logger.warning("HighFive is not configured correctly; skipping.")
env["use_hdf5"] = False

elif env["use_hdf5"]:
env["system_highfive"] = True
env["use_hdf5"] = conf.CheckLibWithHeader(
"hdf5", "highfive/H5File.hpp", language="C++", autoadd=False)
if env["use_hdf5"]:
logger.info("Using system installation of HighFive.")
else:
config_error("Unable to locate system HighFive installation.")

if env["use_hdf5"]:
hdf_version = textwrap.dedent("""\
#include <iostream>
#include "H5public.h"
int main(int argc, char** argv) {
std::cout << H5_VERS_MAJOR << "." << H5_VERS_MINOR << "." << H5_VERS_RELEASE;
return 0;
}
""")
retcode, hdf_version = conf.TryRun(hdf_version, ".cpp")
if retcode:
logger.info(f"Compiling against HDF5 version {hdf_version}")
else:
logger.warning("Failed to determine HDF5 version.")

def set_fortran(pattern, value):
# Set compiler / flags for all Fortran versions to be the same
for version in ("FORTRAN", "F77", "F90", "F95", "F03", "F08"):
Expand Down Expand Up @@ -1558,7 +1676,7 @@ logger.debug("\n".join(debug_message), print_level=False)
env['python_cmd_esc'] = quoted(env['python_cmd'])

# Python Package Settings
python_min_version = parse_version("3.7")
python_min_version = parse_version("3.8")
# The string is used to set python_requires in setup.cfg.in
env['py_min_ver_str'] = str(python_min_version)
# Note: cython_min_version is redefined below if the Python version is 3.8 or higher
Expand Down Expand Up @@ -2003,6 +2121,8 @@ cdefine('LAPACK_FTN_TRAILING_UNDERSCORE', 'lapack_ftn_trailing_underscore')
cdefine('FTN_TRAILING_UNDERSCORE', 'lapack_ftn_trailing_underscore')
cdefine('LAPACK_NAMES_LOWERCASE', 'lapack_names', 'lower')
cdefine('CT_USE_LAPACK', 'use_lapack')
cdefine("CT_USE_HDF5", "use_hdf5")
cdefine("CT_USE_SYSTEM_HIGHFIVE", "system_highfive")
cdefine("CT_USE_SYSTEM_EIGEN", "system_eigen")
cdefine("CT_USE_SYSTEM_EIGEN_PREFIXED", "system_eigen_prefixed")
cdefine('CT_USE_SYSTEM_FMT', 'system_fmt')
Expand Down Expand Up @@ -2092,6 +2212,9 @@ else:
env["external_libs"] = []
env["external_libs"].extend(env["sundials_libs"])

if env["use_hdf5"]:
env["external_libs"].append("hdf5")

if env["system_fmt"]:
env["external_libs"].append("fmt")

Expand Down
1 change: 1 addition & 0 deletions ext/HighFive
Submodule HighFive added at 5513f2
8 changes: 8 additions & 0 deletions ext/SConscript
Original file line number Diff line number Diff line change
Expand Up @@ -125,6 +125,14 @@ if not env['system_eigen']:
copyenv.Depends(copyenv['config_h_target'], h)
ext_copies.extend(h)

if not env["system_highfive"]:
localenv = prep_default(env)
license_files["HighFive"] = File("#ext/HighFive/LICENSE")
h = build(copyenv.Command('#include/cantera/ext/HighFive', '#ext/HighFive/include/highfive',
Copy('$TARGET', '$SOURCE')))
copyenv.Depends(copyenv['config_h_target'], h)
ext_copies.extend(h)

# Google Test: Used internally for Cantera unit tests.
if env['googletest'] == 'submodule':
localenv = prep_gtest(env)
Expand Down
5 changes: 5 additions & 0 deletions include/cantera/base/AnyMap.h
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@

#include <unordered_map>
#include <functional>
#include <set>

namespace boost
{
Expand Down Expand Up @@ -447,6 +448,10 @@ class AnyMap : public AnyBase
//! messages, for example
std::string keys_str() const;

//! Return an unordered set of keys
//! @since New in Cantera 3.0.
std::set<std::string> keys() const;

//! Set a metadata value that applies to this AnyMap and its children.
//! Mainly for internal use in reading or writing from files.
void setMetadata(const std::string& key, const AnyValue& value);
Expand Down
Loading

0 comments on commit 5843e53

Please sign in to comment.