12 #include "nlohmann/json.h" 21 #include "libmesh/libmesh_config.h" 22 #include "petscconf.h" 23 #include "petscpkg_version.h" 25 #ifdef MOOSE_LIBTORCH_ENABLED 26 #include <torch/version.h> 29 #if __has_include(<torch/xpu.h>) 30 #include <torch/xpu.h> 31 #define MOOSE_HAVE_XPU 1 34 #ifdef MOOSE_MFEM_ENABLED 35 #include "mfem/config/config.hpp" 38 #ifdef LIBMESH_HAVE_NETGEN 39 #include "netgen/netgen_version.hpp" 57 if (!capability_registry)
59 return *capability_registry;
68 auto & entry = root[
name];
69 std::visit([&entry](
const auto & v) { entry[
"value"] = v; }, capability.getValue());
70 entry[
"doc"] = capability.getDoc();
71 if (
const auto enumeration_ptr = capability.queryEnumeration())
72 entry[
"enumeration"] = *enumeration_ptr;
73 if (!capability.hasBoolValue())
74 entry[
"explicit"] = capability.getExplicit();
82 for (
const auto & [name_json, entry] : input.items())
84 const std::string
name = name_json;
86 const auto error = [&
name](
const std::string & message)
90 if (
const auto it = entry.find(
"doc"); it != entry.end())
93 error(
"missing 'doc' entry");
96 if (
const auto it = entry.find(
"value"); it != entry.end())
99 value = it->get<
bool>();
100 else if (it->is_number_integer())
101 value = it->get<
int>();
103 value = it->get<std::string>();
106 error(
"missing 'value' entry");
110 if (
const auto it = entry.find(
"explicit"); it != entry.end() && it->get<
bool>())
111 capability.setExplicit();
113 if (
const auto it = entry.find(
"enumeration"); it != entry.end())
114 capability.setEnumeration(it->get<std::set<std::string>>());
121 const auto & capability =
get(
"installation_type");
122 mooseAssert(capability.getEnumeration().count(installation_type),
"Not a valid enumeration");
123 return capability.getStringValue() == installation_type;
130 const auto add_bool = [&](
const std::string_view capability,
133 {
return add(capability,
value, doc); };
134 const auto add_int = [&](
const std::string_view capability,
137 {
return add(capability,
value, doc); };
138 const auto add_string = [&](
const std::string_view capability,
139 const std::string_view
value,
141 {
return add(capability, std::string(
value), doc); };
144 const auto have = [&](
const std::string & capability,
const std::string & doc) ->
Capability &
145 {
return add_bool(capability,
true, doc +
" is available."); };
146 const auto missing = [&](
const std::string & capability,
147 const std::string & doc,
149 {
return add_bool(capability,
false, doc +
" is not available. " +
help); };
151 const auto have_version = [&](
const std::string & capability,
152 const std::string & doc,
154 {
return add_string(capability, version, doc +
" version " + version +
" is available."); };
155 const auto petsc_missing = [&](
const std::string & capability,
159 capability,
false, doc +
" is not available. Check your PETSc configure options.");
161 const auto libmesh_missing = [&](
const std::string & capability,
162 const std::string & doc,
163 const std::string & config_option) ->
Capability &
165 return add_bool(capability,
167 doc +
" is not available. It is controlled by the `" + config_option +
168 "` libMesh configure option.");
172 const auto doc =
"LibTorch machine learning and parallel tensor algebra library";
173 #ifdef MOOSE_LIBTORCH_ENABLED 174 add_string(
"libtorch", TORCH_VERSION, doc);
179 "https://mooseframework.inl.gov/moose/getting_started/installation/" 180 "install_libtorch.html for " 181 "instructions on how to configure and build moose with libTorch.");
186 const auto doc =
"MFEM finite element library";
187 #ifdef MOOSE_MFEM_ENABLED 188 add_string(
"mfem", MFEM_VERSION_STRING, doc);
192 "Install mfem using the scripts/update_and_rebuild_mfem.sh script after " 193 "first running scripts/update_and_rebuild_conduit.sh. Finally, configure " 194 "moose with ./configure --with-mfem");
199 const auto doc =
"New Engineering Material model Library, version 2";
205 "Install neml2 using the scripts/update_and_rebuild_neml2.sh script, then " 206 "configure moose with ./configure --with-neml2 --with-libtorch");
211 const auto doc =
"gperftools code performance analysis and profiling library";
212 #ifdef HAVE_GPERFTOOLS 213 have(
"gperftools", doc);
215 missing(
"gperftools",
217 "Check https://mooseframework.inl.gov/application_development/profiling.html " 218 "for instructions on profiling MOOSE based applications.");
223 const auto doc =
"libPNG portable network graphics format library";
224 #ifdef MOOSE_HAVE_LIBPNG 229 "Install libpng through conda or your distribution and check that it gets " 230 "detected through pkg-config, then reconfigure and rebuild MOOSE.");
235 const auto doc =
"NVIDIA GPU parallel computing platform";
236 #ifdef PETSC_HAVE_CUDA 237 const std::string version = QUOTE(PETSC_PKG_CUDA_VERSION_MAJOR)
"." QUOTE(
238 PETSC_PKG_CUDA_VERSION_MINOR)
"." QUOTE(PETSC_PKG_CUDA_VERSION_SUBMINOR);
239 add_string(
"cuda", version, doc);
241 missing(
"cuda", doc,
"Add the CUDA bin directory to your path and rebuild PETSc.");
246 const auto doc =
"AMD GPU parallel computing platform";
247 #ifdef PETSC_HAVE_HIPROCM 248 const std::string version = QUOTE(PETSC_PKG_HIP_VERSION_MAJOR)
"." QUOTE(
249 PETSC_PKG_HIP_VERSION_MINOR)
"." QUOTE(PETSC_PKG_HIP_VERSION_SUBMINOR);
250 add_string(
"hip", version, doc);
252 missing(
"hip", doc,
"Add the HIP bin directory to your path and rebuild PETSc.");
257 const auto doc =
"Intel GPU parallel computing platform";
258 #ifdef PETSC_HAVE_SYCL 259 const std::string version = QUOTE(PETSC_PKG_SYCL_VERSION_MAJOR)
"." QUOTE(
260 PETSC_PKG_SYCL_VERSION_MINOR)
"." QUOTE(PETSC_PKG_SYCL_VERSION_SUBMINOR);
261 add_string(
"sycl", version, doc);
263 missing(
"sycl", doc,
"Add the SYCL bin directory to your path and rebuild PETSc.");
268 const auto doc =
"Kokkos performance portability programming ecosystem";
269 #ifdef MOOSE_KOKKOS_ENABLED 270 const std::string version = QUOTE(PETSC_PKG_KOKKOS_VERSION_MAJOR)
"." QUOTE(
271 PETSC_PKG_KOKKOS_VERSION_MINOR)
"." QUOTE(PETSC_PKG_KOKKOS_VERSION_SUBMINOR);
272 add_string(
"kokkos", version, doc);
276 "Rebuild PETSc with Kokkos support and libMesh. Then, reconfigure MOOSE with " 282 const auto doc =
"Kokkos support for PETSc";
283 #ifdef PETSC_HAVE_KOKKOS 284 const std::string version = QUOTE(PETSC_PKG_KOKKOS_VERSION_MAJOR)
"." QUOTE(
285 PETSC_PKG_KOKKOS_VERSION_MINOR)
"." QUOTE(PETSC_PKG_KOKKOS_VERSION_SUBMINOR);
286 add_string(
"petsc_kokkos", version, doc);
289 "petsc_kokkos", doc,
"Rebuild PETSc with Kokkos support, then rebuild libMesh and MOOSE.");
294 const auto doc =
"Intel OneAPI XPU accelerator support";
295 #ifdef MOOSE_HAVE_XPU 296 if (torch::xpu::is_available())
299 missing(
"xpu", doc,
"No usable XPU devices have been found.");
301 missing(
"xpu", doc,
"The torch version used to build this app has no XPU support.");
307 MOOSE_AD_MAX_DOFS_PER_ELEM,
308 "MOOSE was configured and built with a dual number backing store size of " +
310 ". Complex simulations with many variables or contact problems may require larger " 311 "values. Reconfigure MOOSE with the --with-derivative-size=<n> option in the root of the " 316 const std::string method = QUOTE(METHOD);
317 add_string(
"method", method,
"The executable was built with METHOD=\"" + method +
"\"")
319 .setEnumeration({
"dbg",
"devel",
"oprof",
"opt"});
323 const std::string version = QUOTE(LIBMESH_DETECTED_PETSC_VERSION_MAJOR)
"." QUOTE(
324 LIBMESH_DETECTED_PETSC_VERSION_MINOR)
"." QUOTE(LIBMESH_DETECTED_PETSC_VERSION_SUBMINOR);
325 add_string(
"petsc", version,
"Using PETSc version " + version +
".");
328 #ifdef LIBMESH_PETSC_USE_DEBUG 329 add_bool(
"petsc_debug",
true,
"PETSc was built with debugging options.");
331 add_bool(
"petsc_debug",
false,
"PETSc was built without debugging options.");
335 const auto doc =
"SuperLU direct solver";
336 #ifdef LIBMESH_PETSC_HAVE_SUPERLU_DIST 337 const std::string version = QUOTE(PETSC_PKG_SUPERLU_DIST_VERSION_MAJOR)
"." QUOTE(
338 PETSC_PKG_SUPERLU_DIST_VERSION_MINOR)
"." QUOTE(PETSC_PKG_SUPERLU_DIST_VERSION_SUBMINOR);
339 add_string(
"superlu", version, doc);
341 petsc_missing(
"superlu", doc);
346 const auto doc =
"MUltifrontal Massively Parallel sparse direct Solver (MUMPS)";
347 #ifdef LIBMESH_PETSC_HAVE_MUMPS 348 const std::string version = QUOTE(PETSC_PKG_MUMPS_VERSION_MAJOR)
"." QUOTE(
349 PETSC_PKG_MUMPS_VERSION_MINOR)
"." QUOTE(PETSC_PKG_MUMPS_VERSION_SUBMINOR);
350 add_string(
"mumps", version, doc);
352 petsc_missing(
"mumps", doc);
357 const auto doc =
"STRUMPACK - STRUctured Matrix PACKage solver library";
358 #ifdef LIBMESH_PETSC_HAVE_STRUMPACK 359 const std::string version = QUOTE(PETSC_PKG_STRUMPACK_VERSION_MAJOR)
"." QUOTE(
360 PETSC_PKG_STRUMPACK_VERSION_MINOR)
"." QUOTE(PETSC_PKG_STRUMPACK_VERSION_SUBMINOR);
361 add_string(
"strumpack", version, doc);
363 petsc_missing(
"strumpack", doc);
368 const auto doc =
"Parmetis partitioning library";
369 #if defined(LIBMESH_PETSC_HAVE_PARMETIS) 370 const std::string version = QUOTE(PETSC_PKG_PARMETIS_VERSION_MAJOR)
"." QUOTE(
371 PETSC_PKG_PARMETIS_VERSION_MINOR)
"." QUOTE(PETSC_PKG_PARMETIS_VERSION_SUBMINOR);
372 add_string(
"parmetis", version, doc);
373 #elif defined(LIBMESH_HAVE_PARMETIS) 374 have(
"parmetis", doc);
376 petsc_missing(
"parmetis", doc);
381 const auto doc =
"Chaco graph partitioning library";
382 #ifdef LIBMESH_PETSC_HAVE_CHACO 385 petsc_missing(
"chaco", doc);
390 const auto doc =
"Party matrix or graph partitioning library";
391 #ifdef LIBMESH_PETSC_HAVE_PARTY 394 petsc_missing(
"party", doc);
399 const auto doc =
"PT-Scotch graph partitioning library";
400 #ifdef LIBMESH_PETSC_HAVE_PTSCOTCH 401 const std::string version = QUOTE(PETSC_PKG_PTSCOTCH_VERSION_MAJOR)
"." QUOTE(
402 PETSC_PKG_PTSCOTCH_VERSION_MINOR)
"." QUOTE(PETSC_PKG_PTSCOTCH_VERSION_SUBMINOR);
403 add_string(
"ptscotch", version, doc);
405 petsc_missing(
"ptscotch", doc);
410 const auto doc =
"Optimized BLAS library";
411 #ifdef PETSC_HAVE_OPENBLAS 412 const std::string version = QUOTE(PETSC_PKG_OPENBLAS_VERSION_MAJOR)
"." QUOTE(
413 PETSC_PKG_OPENBLAS_VERSION_MINOR)
"." QUOTE(PETSC_PKG_OPENBLAS_VERSION_SUBMINOR);
414 add_string(
"openblas", version, doc);
416 petsc_missing(
"openblas", doc);
421 const auto doc =
"Umpire resource management library";
422 #ifdef PETSC_HAVE_UMPIRE 425 petsc_missing(
"umpire", doc);
430 const auto doc =
"Scalable Library for Eigenvalue Problem Computations (SLEPc)";
431 #ifdef LIBMESH_HAVE_SLEPC 432 const auto version = QUOTE(LIBMESH_DETECTED_SLEPC_VERSION_MAJOR)
"." QUOTE(
433 LIBMESH_DETECTED_SLEPC_VERSION_MINOR)
"." QUOTE(LIBMESH_DETECTED_SLEPC_VERSION_SUBMINOR);
434 have_version(
"slepc", doc, version);
436 petsc_missing(
"slepc", doc);
441 const auto doc =
"Exodus mesh file format library";
442 #ifdef LIBMESH_HAVE_EXODUS_API 443 const std::string version = QUOTE(LIBMESH_DETECTED_EXODUS_VERSION_MAJOR)
"." QUOTE(
444 LIBMESH_DETECTED_EXODUS_VERSION_MINOR);
445 have_version(
"exodus", doc, version);
447 libmesh_missing(
"exodus", doc,
"--enable-exodus");
452 const auto doc =
"Netgen meshing library";
453 #ifdef LIBMESH_HAVE_NETGEN 454 const std::string version =
455 QUOTE(NETGEN_VERSION_MAJOR)
"." QUOTE(NETGEN_VERSION_MINOR)
"." QUOTE(NETGEN_VERSION_PATCH);
456 add_string(
"netgen", version, doc);
458 libmesh_missing(
"netgen", doc,
"--enable-netgen");
463 const auto doc =
"Visualization Toolkit (VTK)";
464 #ifdef LIBMESH_HAVE_VTK 465 const std::string version = QUOTE(LIBMESH_DETECTED_VTK_VERSION_MAJOR)
"." QUOTE(
466 LIBMESH_DETECTED_VTK_VERSION_MINOR)
"." QUOTE(LIBMESH_DETECTED_VTK_VERSION_SUBMINOR);
467 have_version(
"vtk", doc, version);
469 libmesh_missing(
"vtk", doc,
"--disable-vtk and --enable-vtk-required");
474 const auto doc =
"libcurl - the multiprotocol file transfer library";
475 #ifdef LIBMESH_HAVE_CURL 478 libmesh_missing(
"curl", doc,
"--enable-curl");
483 const auto doc =
"Tecplot post-processing tools API";
484 #ifdef LIBMESH_HAVE_TECPLOT_API 485 have(
"tecplot", doc);
487 libmesh_missing(
"tecplot", doc,
"--enable-tecplot");
492 const auto doc =
"NVIDIA Tools Extension Library API";
493 #ifdef LIBMESH_HAVE_NVTX_API 494 have(
"nvtx_api", doc);
496 libmesh_missing(
"nvtx_api", doc,
"--with-nvtx");
501 const auto doc =
"libMesh performance logging";
502 #ifdef LIBMESH_ENABLE_PERFORMANCE_LOGGING 503 have(
"libmesh_perflog", doc);
505 libmesh_missing(
"libmesh_perflog", doc,
"--enable-perflog");
510 const auto doc =
"Boost C++ library";
511 #ifdef LIBMESH_HAVE_EXTERNAL_BOOST 514 libmesh_missing(
"boost", doc,
"--with-boost");
520 const auto doc =
"Adaptive mesh refinement";
521 #ifdef LIBMESH_ENABLE_AMR 524 libmesh_missing(
"amr", doc,
"--disable-amr");
529 const auto doc =
"nanoflann library for Nearest Neighbor (NN) search with KD-trees";
530 #ifdef LIBMESH_HAVE_NANOFLANN 531 have(
"nanoflann", doc);
533 libmesh_missing(
"nanoflann", doc,
"--disable-nanoflann");
538 const auto doc =
"sfcurves library for space filling curves (required by geometric " 539 "partitioners such as SFCurves, Hilbert and Morton - not LGPL compatible)";
540 #ifdef LIBMESH_HAVE_SFCURVES 541 have(
"sfcurves", doc);
543 libmesh_missing(
"sfcurves", doc,
"--disable-sfc");
548 #ifdef LIBMESH_HAVE_FPARSER 549 #ifdef LIBMESH_HAVE_FPARSER_JIT 550 const auto value =
"jit";
551 const auto doc =
"FParser enabled with just in time compilation support.";
553 const auto value =
"byte_code";
554 const auto doc =
"FParser enabled.";
556 add_string(
"fparser",
value, doc);
560 "FParser is disabled, libMesh was likely configured with --disable-fparser.");
564 #ifdef LIBMESH_HAVE_DLOPEN 565 add_bool(
"dlopen",
true,
"The dlopen() system call is available to dynamically load libraries.");
569 "The dlopen() system call is not available. Dynamic library loading is " 570 "not supported on this system.");
574 const auto doc =
"LibMesh support for threaded execution";
575 #ifdef LIBMESH_USING_THREADS 576 have(
"threads", doc);
578 libmesh_missing(
"threads", doc,
"--with-thread-model=tbb,pthread,openmp,auto,none");
583 const auto doc =
"OpenMP multi-platform shared-memory parallel programming API";
584 #ifdef LIBMESH_HAVE_OPENMP 587 libmesh_missing(
"openmp", doc,
"--with-thread-model=tbb,pthread,openmp,auto,none");
591 const auto doc =
"POSIX Threads API";
592 #ifdef LIBMESH_HAVE_PTHREAD 593 have(
"pthread", doc);
595 libmesh_missing(
"pthread", doc,
"--with-thread-model=tbb,pthread,openmp,auto,none");
599 const auto doc =
"oneAPI Threading Building Blocks (TBB) API";
600 #ifdef LIBMESH_HAVE_TBB_API 603 libmesh_missing(
"tbb", doc,
"--with-thread-model=tbb,pthread,openmp,auto,none");
608 const auto doc =
"libMesh unique ID support";
609 #ifdef LIBMESH_ENABLE_UNIQUE_ID 610 have(
"unique_id", doc);
612 libmesh_missing(
"unique_id", doc,
"--enable-unique-id");
617 #ifdef LIBMESH_ENABLE_PARMESH 618 const auto value =
"distributed";
620 const auto value =
"replicated";
622 add_string(
"mesh_mode",
value,
"libMesh default mesh mode")
624 .setEnumeration({
"distributed",
"replicated"});
627 add_int(
"dof_id_bytes",
630 " bytes for storage. This is controlled by the " 631 "--with-dof-id-bytes=<1|2|4|8> libMesh configure option.")
635 #ifdef LIBMESH_HAVE_STATIC_LIBS 636 const auto value =
"static";
638 const auto value =
"dynamic";
640 add_string(
"library_mode",
642 "The libMesh library mode. This is controlled by the --enable-static libMesh " 645 .setEnumeration({
"dynamic",
"static"});
650 const auto doc =
"Compiler used to build the MOOSE framework.";
651 #if defined(__INTEL_LLVM_COMPILER) 652 const auto value =
"intel";
653 #elif defined(__clang__) 654 const auto value =
"clang";
655 #elif defined(__GNUC__) || defined(__GNUG__) 656 const auto value =
"gcc";
657 #elif defined(_MSC_VER) 658 const auto value =
"msvc";
660 mooseDoOnce(
mooseWarning(
"Failed to determine compiler; setting capability compiler=unknown"));
661 const auto value =
"unknown";
663 add_string(
"compiler",
value, doc)
665 .setEnumeration({
"clang",
"gcc",
"intel",
"msvc",
"unknown"});
671 const auto value =
"darwin";
673 const auto value =
"win32";
675 const auto value =
"linux";
677 const auto value =
"unix";
679 mooseDoOnce(
mooseWarning(
"Failed to determine platform; setting capability platform=unknown"));
680 const auto value =
"unknown";
682 add_string(
"platform",
value,
"Operating system this executable is running on.")
684 .setEnumeration({
"darwin",
"linux",
"unix",
"unknown",
"win32"});
690 std::optional<std::string> executable_path;
702 std::string
value =
"unknown";
708 const auto resolved_path =
709 std::filesystem::weakly_canonical(std::filesystem::path(*executable_path), ec);
711 mooseDoOnce(
mooseWarning(
"Failed to resolve executable path '",
715 "\n\nSetting capability installation_type=unknown"));
721 value = resolved_path.parent_path().filename() ==
"bin" ?
"relocated" :
"in_tree";
726 "Failed to determine executable path; setting capability installation_type=unknown"));
728 add_string(
"installation_type",
value,
"The installation type of the application.")
730 .setEnumeration({
"in_tree",
"relocated",
"unknown"});
std::string name(const ElemQuality q)
void registerMooseCapabilities()
Register the MOOSE capabilities.
static Capabilities & getCapabilities(const GetCapabilitiesPassKey)
Get the singleton Capabilities.
void mooseWarning(Args &&... args)
Emit a warning message with the given stringified, concatenated args.
std::string dump() const
create a JSON dump of the capabilities registry
std::string getExec()
Gets the full path to the running executable on Mac OS X and linux.
void augment(const nlohmann::json &input, const AugmentPassKey)
Augment the capabilities with the given input capabilities.
std::variant< bool, int, std::string > Value
A capability can have a bool, int, or string value.
Holds the public (to MooseApp) facing CapabilityRegistry for storing and checking capabilities...
RegistryType _registry
Registry storage.
Real value(unsigned n, unsigned alpha, unsigned beta, Real x)
Capability & add(const std::string_view name, const Moose::Capability::Value &value, const std::string_view doc)
Add a capability.
An entry for a single capability.
std::string stringify(const T &t)
conversion to string
Common execption to be thrown when interacting with capabilities.
Provides a way for users to bail out of the current solve.
Registry of capabilities that checks capability requirements.
Scoped helper for setting Moose::_throw_on_error during this scope.
bool isInstallationType(const std::string &installation_type) const
Helper for isRelocated() and isInTree()