Line data Source code
1 : //* This file is part of the MOOSE framework
2 : //* https://mooseframework.inl.gov
3 : //*
4 : //* All rights reserved, see COPYRIGHT for full restrictions
5 : //* https://github.com/idaholab/moose/blob/master/COPYRIGHT
6 : //*
7 : //* Licensed under LGPL 2.1, please see LICENSE for details
8 : //* https://www.gnu.org/licenses/lgpl-2.1.html
9 :
10 : // Needs to be included before Capabilities.h, which
11 : // includes nlohmann/json_fwd.h
12 : #include "nlohmann/json.h"
13 :
14 : #include "Capabilities.h"
15 : #include "CapabilityException.h"
16 : #include "MooseUtils.h"
17 : #include "Conversion.h"
18 :
19 : #include <vector>
20 :
21 : #include "libmesh/libmesh_config.h"
22 : #include "petscconf.h"
23 : #include "petscpkg_version.h"
24 :
25 : #ifdef MOOSE_LIBTORCH_ENABLED
26 : #include <torch/version.h>
27 : #endif
28 :
29 : #if __has_include(<torch/xpu.h>)
30 : #include <torch/xpu.h>
31 : #define MOOSE_HAVE_XPU 1
32 : #endif
33 :
34 : #ifdef MOOSE_MFEM_ENABLED
35 : #include "mfem/config/config.hpp"
36 : #endif
37 :
38 : #ifdef LIBMESH_HAVE_NETGEN
39 : #include "netgen/netgen_version.hpp"
40 : #endif
41 :
42 : namespace Moose::internal
43 : {
44 :
45 54400 : Capabilities::Capabilities() : CapabilityRegistry()
46 : {
47 : // Register the moose capabilities, just once
48 54400 : registerMooseCapabilities();
49 54400 : }
50 :
51 : Capabilities &
52 636627 : Capabilities::getCapabilities(const Capabilities::GetCapabilitiesPassKey)
53 : {
54 : // We need a naked new here (_not_ a smart pointer or object instance) due to what seems like a
55 : // bug in clang's static object destruction when using dynamic library loading.
56 : static Capabilities * capability_registry = nullptr;
57 636627 : if (!capability_registry)
58 54400 : capability_registry = new Capabilities();
59 636627 : return *capability_registry;
60 : }
61 :
62 : std::string
63 34 : Capabilities::dump() const
64 : {
65 34 : nlohmann::json root;
66 1841 : for (const auto & [name, capability] : _registry)
67 : {
68 1807 : auto & entry = root[name];
69 3614 : std::visit([&entry](const auto & v) { entry["value"] = v; }, capability.getValue());
70 1807 : entry["doc"] = capability.getDoc();
71 1807 : if (const auto enumeration_ptr = capability.queryEnumeration())
72 1807 : entry["enumeration"] = *enumeration_ptr;
73 1807 : if (!capability.hasBoolValue())
74 909 : entry["explicit"] = capability.getExplicit();
75 : }
76 68 : return root.dump(2);
77 34 : }
78 :
79 : void
80 389 : Capabilities::augment(const nlohmann::json & input, const Capabilities::AugmentPassKey)
81 : {
82 828 : for (const auto & [name_json, entry] : input.items())
83 : {
84 445 : const std::string name = name_json;
85 :
86 6 : const auto error = [&name](const std::string & message)
87 6 : { throw CapabilityException("Capabilities::augment: Capability '" + name + "' " + message); };
88 :
89 445 : std::string doc;
90 445 : if (const auto it = entry.find("doc"); it != entry.end())
91 441 : doc = *it;
92 : else
93 8 : error("missing 'doc' entry");
94 :
95 441 : Moose::Capability::Value value;
96 441 : if (const auto it = entry.find("value"); it != entry.end())
97 : {
98 439 : if (it->is_boolean())
99 124 : value = it->get<bool>();
100 315 : else if (it->is_number_integer())
101 16 : value = it->get<int>();
102 : else
103 299 : value = it->get<std::string>();
104 : }
105 : else
106 4 : error("missing 'value' entry");
107 :
108 439 : auto & capability = add(name, value, doc);
109 :
110 439 : if (const auto it = entry.find("explicit"); it != entry.end() && it->get<bool>())
111 291 : capability.setExplicit();
112 :
113 439 : if (const auto it = entry.find("enumeration"); it != entry.end())
114 283 : capability.setEnumeration(it->get<std::set<std::string>>());
115 848 : }
116 383 : }
117 :
118 : bool
119 24 : Capabilities::isInstallationType(const std::string & installation_type) const
120 : {
121 48 : const auto & capability = get("installation_type");
122 : mooseAssert(capability.getEnumeration().count(installation_type), "Not a valid enumeration");
123 24 : return capability.getStringValue() == installation_type;
124 : }
125 :
126 : void
127 54406 : Capabilities::registerMooseCapabilities()
128 : {
129 : // helper lambdas for explicitly adding typed capabilities
130 1330551 : const auto add_bool = [&](const std::string_view capability,
131 : const bool value,
132 : const std::string_view doc) -> Capability &
133 1330551 : { return add(capability, value, doc); };
134 108812 : const auto add_int = [&](const std::string_view capability,
135 : const int value,
136 : const std::string_view doc) -> Capability &
137 108812 : { return add(capability, value, doc); };
138 1117719 : const auto add_string = [&](const std::string_view capability,
139 : const std::string_view value,
140 : const std::string_view doc) -> Capability &
141 3353157 : { return add(capability, std::string(value), doc); };
142 :
143 : // helper lambdas for adding capabilities
144 440113 : const auto have = [&](const std::string & capability, const std::string & doc) -> Capability &
145 440113 : { return add_bool(capability, true, doc + " is available."); };
146 295180 : const auto missing = [&](const std::string & capability,
147 : const std::string & doc,
148 : const std::string & help = "") -> Capability &
149 295180 : { return add_bool(capability, false, doc + " is not available. " + help); };
150 :
151 163218 : const auto have_version = [&](const std::string & capability,
152 : const std::string & doc,
153 : const std::string & version) -> Capability &
154 163218 : { return add_string(capability, version, doc + " version " + version + " is available."); };
155 108812 : const auto petsc_missing = [&](const std::string & capability,
156 : const std::string & doc) -> Capability &
157 : {
158 108812 : return add_bool(
159 217624 : capability, false, doc + " is not available. Check your PETSc configure options.");
160 54406 : };
161 377634 : const auto libmesh_missing = [&](const std::string & capability,
162 : const std::string & doc,
163 : const std::string & config_option) -> Capability &
164 : {
165 377634 : return add_bool(capability,
166 : false,
167 755268 : doc + " is not available. It is controlled by the `" + config_option +
168 755268 : "` libMesh configure option.");
169 54406 : };
170 :
171 : {
172 54406 : const auto doc = "LibTorch machine learning and parallel tensor algebra library";
173 : #ifdef MOOSE_LIBTORCH_ENABLED
174 1657 : add_string("libtorch", TORCH_VERSION, doc);
175 : #else
176 263745 : missing("libtorch",
177 : doc,
178 : "Check "
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.");
182 : #endif
183 : }
184 :
185 : {
186 54406 : const auto doc = "MFEM finite element library";
187 : #ifdef MOOSE_MFEM_ENABLED
188 40372 : add_string("mfem", MFEM_VERSION_STRING, doc);
189 : #else
190 70170 : missing("mfem",
191 : 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");
195 : #endif
196 : }
197 :
198 : {
199 54406 : const auto doc = "New Engineering Material model Library, version 2";
200 : #ifdef NEML2_ENABLED
201 4971 : have("neml2", doc);
202 : #else
203 263745 : missing("neml2",
204 : doc,
205 : "Install neml2 using the scripts/update_and_rebuild_neml2.sh script, then "
206 : "configure moose with ./configure --with-neml2 --with-libtorch");
207 : #endif
208 : }
209 :
210 : {
211 54406 : const auto doc = "gperftools code performance analysis and profiling library";
212 : #ifdef HAVE_GPERFTOOLS
213 : have("gperftools", doc);
214 : #else
215 272030 : missing("gperftools",
216 : doc,
217 : "Check https://mooseframework.inl.gov/application_development/profiling.html "
218 : "for instructions on profiling MOOSE based applications.");
219 : #endif
220 : }
221 :
222 : {
223 54406 : const auto doc = "libPNG portable network graphics format library";
224 : #ifdef MOOSE_HAVE_LIBPNG
225 163218 : have("libpng", doc);
226 : #else
227 : missing("libpng",
228 : doc,
229 : "Install libpng through conda or your distribution and check that it gets "
230 : "detected through pkg-config, then reconfigure and rebuild MOOSE.");
231 : #endif
232 : }
233 :
234 : {
235 54406 : 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 1604 : PETSC_PKG_CUDA_VERSION_MINOR) "." QUOTE(PETSC_PKG_CUDA_VERSION_SUBMINOR);
239 1604 : add_string("cuda", version, doc);
240 : #else
241 264010 : missing("cuda", doc, "Add the CUDA bin directory to your path and rebuild PETSc.");
242 : #endif
243 1604 : }
244 :
245 : {
246 54406 : const auto doc = "Kokkos performance portability programming ecosystem";
247 : #ifdef MOOSE_KOKKOS_ENABLED
248 : const std::string version = QUOTE(PETSC_PKG_KOKKOS_VERSION_MAJOR) "." QUOTE(
249 40372 : PETSC_PKG_KOKKOS_VERSION_MINOR) "." QUOTE(PETSC_PKG_KOKKOS_VERSION_SUBMINOR);
250 40372 : add_string("kokkos", version, doc);
251 : #else
252 70170 : missing("kokkos",
253 : doc,
254 : "Rebuild PETSc with Kokkos support and libMesh. Then, reconfigure MOOSE with "
255 : "--with-kokkos.");
256 : #endif
257 40372 : }
258 :
259 : {
260 54406 : const auto doc = "Kokkos support for PETSc";
261 : #ifdef PETSC_HAVE_KOKKOS
262 : const std::string version = QUOTE(PETSC_PKG_KOKKOS_VERSION_MAJOR) "." QUOTE(
263 54406 : PETSC_PKG_KOKKOS_VERSION_MINOR) "." QUOTE(PETSC_PKG_KOKKOS_VERSION_SUBMINOR);
264 54406 : add_string("petsc_kokkos", version, doc);
265 : #else
266 : missing(
267 : "petsc_kokkos", doc, "Rebuild PETSc with Kokkos support, then rebuild libMesh and MOOSE.");
268 : #endif
269 54406 : }
270 :
271 : {
272 54406 : const auto doc = "Intel OneAPI XPU accelerator support";
273 : #ifdef MOOSE_HAVE_XPU
274 1657 : if (torch::xpu::is_available())
275 0 : have("xpu", doc);
276 : else
277 9942 : missing("xpu", doc, "No usable XPU devices have been found.");
278 : #else
279 263745 : missing("xpu", doc, "The torch version used to build this app has no XPU support.");
280 : #endif
281 : }
282 :
283 54406 : add_int(
284 : "ad_size",
285 : MOOSE_AD_MAX_DOFS_PER_ELEM,
286 108812 : "MOOSE was configured and built with a dual number backing store size of " +
287 217624 : Moose::stringify(MOOSE_AD_MAX_DOFS_PER_ELEM) +
288 : ". Complex simulations with many variables or contact problems may require larger "
289 : "values. Reconfigure MOOSE with the --with-derivative-size=<n> option in the root of the "
290 : "repository.")
291 54406 : .setExplicit();
292 :
293 : {
294 54406 : const std::string method = QUOTE(METHOD);
295 108812 : add_string("method", method, "The executable was built with METHOD=\"" + method + "\"")
296 54406 : .setExplicit()
297 54406 : .setEnumeration({"dbg", "devel", "oprof", "opt"});
298 54406 : }
299 :
300 : {
301 : const std::string version = QUOTE(LIBMESH_DETECTED_PETSC_VERSION_MAJOR) "." QUOTE(
302 54406 : LIBMESH_DETECTED_PETSC_VERSION_MINOR) "." QUOTE(LIBMESH_DETECTED_PETSC_VERSION_SUBMINOR);
303 54406 : add_string("petsc", version, "Using PETSc version " + version + ".");
304 54406 : }
305 :
306 : #ifdef LIBMESH_PETSC_USE_DEBUG
307 54406 : add_bool("petsc_debug", true, "PETSc was built with debugging options.");
308 : #else
309 : add_bool("petsc_debug", false, "PETSc was built without debugging options.");
310 : #endif
311 :
312 : {
313 54406 : const auto doc = "SuperLU direct solver";
314 : #ifdef LIBMESH_PETSC_HAVE_SUPERLU_DIST
315 : const std::string version = QUOTE(PETSC_PKG_SUPERLU_DIST_VERSION_MAJOR) "." QUOTE(
316 54406 : PETSC_PKG_SUPERLU_DIST_VERSION_MINOR) "." QUOTE(PETSC_PKG_SUPERLU_DIST_VERSION_SUBMINOR);
317 54406 : add_string("superlu", version, doc);
318 : #else
319 : petsc_missing("superlu", doc);
320 : #endif
321 54406 : }
322 :
323 : {
324 54406 : const auto doc = "MUltifrontal Massively Parallel sparse direct Solver (MUMPS)";
325 : #ifdef LIBMESH_PETSC_HAVE_MUMPS
326 : const std::string version = QUOTE(PETSC_PKG_MUMPS_VERSION_MAJOR) "." QUOTE(
327 54406 : PETSC_PKG_MUMPS_VERSION_MINOR) "." QUOTE(PETSC_PKG_MUMPS_VERSION_SUBMINOR);
328 54406 : add_string("mumps", version, doc);
329 : #else
330 : petsc_missing("mumps", doc);
331 : #endif
332 54406 : }
333 :
334 : {
335 54406 : const auto doc = "STRUMPACK - STRUctured Matrix PACKage solver library";
336 : #ifdef LIBMESH_PETSC_HAVE_STRUMPACK
337 : const std::string version = QUOTE(PETSC_PKG_STRUMPACK_VERSION_MAJOR) "." QUOTE(
338 54406 : PETSC_PKG_STRUMPACK_VERSION_MINOR) "." QUOTE(PETSC_PKG_STRUMPACK_VERSION_SUBMINOR);
339 54406 : add_string("strumpack", version, doc);
340 : #else
341 : petsc_missing("strumpack", doc);
342 : #endif
343 54406 : }
344 :
345 : {
346 54406 : const auto doc = "Parmetis partitioning library";
347 : #if defined(LIBMESH_PETSC_HAVE_PARMETIS) || defined(LIBMESH_HAVE_PARMETIS)
348 : const std::string version = QUOTE(PETSC_PKG_PARMETIS_VERSION_MAJOR) "." QUOTE(
349 54406 : PETSC_PKG_PARMETIS_VERSION_MINOR) "." QUOTE(PETSC_PKG_PARMETIS_VERSION_SUBMINOR);
350 54406 : add_string("parmetis", version, doc);
351 : #else
352 : petsc_missing("parmetis", doc);
353 : #endif
354 54406 : }
355 :
356 : {
357 54406 : const auto doc = "Chaco graph partitioning library";
358 : #ifdef LIBMESH_PETSC_HAVE_CHACO
359 : have("chaco", doc);
360 : #else
361 163218 : petsc_missing("chaco", doc);
362 : #endif
363 : }
364 :
365 : {
366 54406 : const auto doc = "Party matrix or graph partitioning library";
367 : #ifdef LIBMESH_PETSC_HAVE_PARTY
368 : have("party", doc);
369 : #else
370 163218 : petsc_missing("party", doc);
371 : #endif
372 : }
373 :
374 : {
375 54406 : const auto doc = "PT-Scotch graph partitioning library";
376 : #ifdef LIBMESH_PETSC_HAVE_PTSCOTCH
377 : const std::string version = QUOTE(PETSC_PKG_PTSCOTCH_VERSION_MAJOR) "." QUOTE(
378 54406 : PETSC_PKG_PTSCOTCH_VERSION_MINOR) "." QUOTE(PETSC_PKG_PTSCOTCH_VERSION_SUBMINOR);
379 54406 : add_string("ptscotch", version, doc);
380 : #else
381 : petsc_missing("ptscotch", doc);
382 : #endif
383 54406 : }
384 :
385 : {
386 54406 : const auto doc = "Optimized BLAS library";
387 : #ifdef PETSC_HAVE_OPENBLAS
388 : const std::string version = QUOTE(PETSC_PKG_OPENBLAS_VERSION_MAJOR) "." QUOTE(
389 54406 : PETSC_PKG_OPENBLAS_VERSION_MINOR) "." QUOTE(PETSC_PKG_OPENBLAS_VERSION_SUBMINOR);
390 54406 : add_string("openblas", version, doc);
391 : #else
392 : petsc_missing("openblas", doc);
393 : #endif
394 54406 : }
395 :
396 : {
397 54406 : const auto doc = "Umpire resource management library";
398 : #ifdef PETSC_HAVE_UMPIRE
399 163218 : have("umpire", doc);
400 : #else
401 : petsc_missing("umpire", doc);
402 : #endif
403 : }
404 :
405 : {
406 54406 : const auto doc = "Scalable Library for Eigenvalue Problem Computations (SLEPc)";
407 : #ifdef LIBMESH_HAVE_SLEPC
408 54406 : const auto version = QUOTE(LIBMESH_DETECTED_SLEPC_VERSION_MAJOR) "." QUOTE(
409 : LIBMESH_DETECTED_SLEPC_VERSION_MINOR) "." QUOTE(LIBMESH_DETECTED_SLEPC_VERSION_SUBMINOR);
410 272030 : have_version("slepc", doc, version);
411 : #else
412 : petsc_missing("slepc", doc);
413 : #endif
414 : }
415 :
416 : {
417 54406 : const auto doc = "Exodus mesh file format library";
418 : #ifdef LIBMESH_HAVE_EXODUS_API
419 108812 : const std::string version = QUOTE(LIBMESH_DETECTED_EXODUS_VERSION_MAJOR) "." QUOTE(
420 : LIBMESH_DETECTED_EXODUS_VERSION_MINOR);
421 163218 : have_version("exodus", doc, version);
422 : #else
423 : libmesh_missing("exodus", doc, "--enable-exodus");
424 : #endif
425 54406 : }
426 :
427 : {
428 54406 : const auto doc = "Netgen meshing library";
429 : #ifdef LIBMESH_HAVE_NETGEN
430 : const std::string version =
431 54406 : QUOTE(NETGEN_VERSION_MAJOR) "." QUOTE(NETGEN_VERSION_MINOR) "." QUOTE(NETGEN_VERSION_PATCH);
432 54406 : add_string("netgen", version, doc);
433 : #else
434 : libmesh_missing("netgen", doc, "--enable-netgen");
435 : #endif
436 54406 : }
437 :
438 : {
439 54406 : const auto doc = "Visualization Toolkit (VTK)";
440 : #ifdef LIBMESH_HAVE_VTK
441 : const std::string version = QUOTE(LIBMESH_DETECTED_VTK_VERSION_MAJOR) "." QUOTE(
442 108812 : LIBMESH_DETECTED_VTK_VERSION_MINOR) "." QUOTE(LIBMESH_DETECTED_VTK_VERSION_SUBMINOR);
443 163218 : have_version("vtk", doc, version);
444 : #else
445 : libmesh_missing("vtk", doc, "--disable-vtk and --enable-vtk-required");
446 : #endif
447 54406 : }
448 :
449 : {
450 54406 : const auto doc = "libcurl - the multiprotocol file transfer library";
451 : #ifdef LIBMESH_HAVE_CURL
452 : have("curl", doc);
453 : #else
454 272030 : libmesh_missing("curl", doc, "--enable-curl");
455 : #endif
456 : }
457 :
458 : {
459 54406 : const auto doc = "Tecplot post-processing tools API";
460 : #ifdef LIBMESH_HAVE_TECPLOT_API
461 : have("tecplot", doc);
462 : #else
463 272030 : libmesh_missing("tecplot", doc, "--enable-tecplot");
464 : #endif
465 : }
466 :
467 : {
468 54406 : const auto doc = "NVIDIA Tools Extension Library API";
469 : #ifdef LIBMESH_HAVE_NVTX_API
470 4812 : have("nvtx_api", doc);
471 : #else
472 264010 : libmesh_missing("nvtx_api", doc, "--with-nvtx");
473 : #endif
474 : }
475 :
476 : {
477 54406 : const auto doc = "libMesh performance logging";
478 : #ifdef LIBMESH_ENABLE_PERFORMANCE_LOGGING
479 4812 : have("libmesh_perflog", doc);
480 : #else
481 264010 : libmesh_missing("libmesh_perflog", doc, "--enable-perflog");
482 : #endif
483 : }
484 :
485 : {
486 54406 : const auto doc = "Boost C++ library";
487 : #ifdef LIBMESH_HAVE_EXTERNAL_BOOST
488 : have("boost", doc);
489 : #else
490 272030 : libmesh_missing("boost", doc, "--with-boost");
491 : #endif
492 : }
493 :
494 : // libmesh stuff
495 : {
496 54406 : const auto doc = "Adaptive mesh refinement";
497 : #ifdef LIBMESH_ENABLE_AMR
498 163218 : have("amr", doc);
499 : #else
500 : libmesh_missing("amr", doc, "--disable-amr");
501 : #endif
502 : }
503 :
504 : {
505 54406 : const auto doc = "nanoflann library for Nearest Neighbor (NN) search with KD-trees";
506 : #ifdef LIBMESH_HAVE_NANOFLANN
507 163218 : have("nanoflann", doc);
508 : #else
509 : libmesh_missing("nanoflann", doc, "--disable-nanoflann");
510 : #endif
511 : }
512 :
513 : {
514 54406 : const auto doc = "sfcurves library for space filling curves (required by geometric "
515 : "partitioners such as SFCurves, Hilbert and Morton - not LGPL compatible)";
516 : #ifdef LIBMESH_HAVE_SFCURVES
517 : have("sfcurves", doc);
518 : #else
519 272030 : libmesh_missing("sfcurves", doc, "--disable-sfc");
520 : #endif
521 : }
522 :
523 : {
524 : #ifdef LIBMESH_HAVE_FPARSER
525 : #ifdef LIBMESH_HAVE_FPARSER_JIT
526 54406 : const auto value = "jit";
527 54406 : const auto doc = "FParser enabled with just in time compilation support.";
528 : #else
529 : const auto value = "byte_code";
530 : const auto doc = "FParser enabled.";
531 : #endif
532 54406 : add_string("fparser", value, doc);
533 : #else
534 : add_bool("fparser",
535 : false,
536 : "FParser is disabled, libMesh was likely configured with --disable-fparser.");
537 : #endif
538 : }
539 :
540 : #ifdef LIBMESH_HAVE_DLOPEN
541 54406 : add_bool("dlopen", true, "The dlopen() system call is available to dynamically load libraries.");
542 : #else
543 : add_bool("dlopen",
544 : false,
545 : "The dlopen() system call is not available. Dynamic library loading is "
546 : "not supported on this system.");
547 : #endif
548 :
549 : {
550 54406 : const auto doc = "LibMesh support for threaded execution";
551 : #ifdef LIBMESH_USING_THREADS
552 163218 : have("threads", doc);
553 : #else
554 : libmesh_missing("threads", doc, "--with-thread-model=tbb,pthread,openmp,auto,none");
555 : #endif
556 : }
557 :
558 : {
559 54406 : const auto doc = "OpenMP multi-platform shared-memory parallel programming API";
560 : #ifdef LIBMESH_HAVE_OPENMP
561 163218 : have("openmp", doc);
562 : #else
563 : libmesh_missing("openmp", doc, "--with-thread-model=tbb,pthread,openmp,auto,none");
564 : #endif
565 : }
566 : {
567 54406 : const auto doc = "POSIX Threads API";
568 : #ifdef LIBMESH_HAVE_PTHREAD
569 163218 : have("pthread", doc);
570 : #else
571 : libmesh_missing("pthread", doc, "--with-thread-model=tbb,pthread,openmp,auto,none");
572 : #endif
573 : }
574 : {
575 54406 : const auto doc = "oneAPI Threading Building Blocks (TBB) API";
576 : #ifdef LIBMESH_HAVE_TBB_API
577 : have("tbb", doc);
578 : #else
579 272030 : libmesh_missing("tbb", doc, "--with-thread-model=tbb,pthread,openmp,auto,none");
580 : #endif
581 : }
582 :
583 : {
584 54406 : const auto doc = "libMesh unique ID support";
585 : #ifdef LIBMESH_ENABLE_UNIQUE_ID
586 163218 : have("unique_id", doc);
587 : #else
588 : libmesh_missing("unique_id", doc, "--enable-unique-id");
589 : #endif
590 : }
591 :
592 : {
593 : #ifdef LIBMESH_ENABLE_PARMESH
594 : const auto value = "distributed";
595 : #else
596 54406 : const auto value = "replicated";
597 : #endif
598 54406 : add_string("mesh_mode", value, "libMesh default mesh mode")
599 54406 : .setExplicit()
600 54406 : .setEnumeration({"distributed", "replicated"});
601 : }
602 :
603 54406 : add_int("dof_id_bytes",
604 : static_cast<int>(sizeof(dof_id_type)),
605 108812 : "Degree of freedom (DOF) identifiers use " + Moose::stringify(sizeof(dof_id_type)) +
606 : " bytes for storage. This is controlled by the "
607 : "--with-dof-id-bytes=<1|2|4|8> libMesh configure option.")
608 54406 : .setExplicit();
609 :
610 : {
611 : #ifdef LIBMESH_HAVE_STATIC_LIBS
612 : const auto value = "static";
613 : #else
614 54406 : const auto value = "dynamic";
615 : #endif
616 54406 : add_string("library_mode",
617 : value,
618 : "The libMesh library mode. This is controlled by the --enable-static libMesh "
619 : "configure option.")
620 54406 : .setExplicit()
621 54406 : .setEnumeration({"dynamic", "static"});
622 : }
623 :
624 : // compiler
625 : {
626 54406 : const auto doc = "Compiler used to build the MOOSE framework.";
627 : #if defined(__INTEL_LLVM_COMPILER)
628 : const auto value = "intel";
629 : #elif defined(__clang__)
630 : const auto value = "clang";
631 : #elif defined(__GNUC__) || defined(__GNUG__)
632 54406 : const auto value = "gcc";
633 : #elif defined(_MSC_VER)
634 : const auto value = "msvc";
635 : #else
636 : mooseDoOnce(mooseWarning("Failed to determine compiler; setting capability compiler=unknown"));
637 : const auto value = "unknown";
638 : #endif
639 54406 : add_string("compiler", value, doc)
640 54406 : .setExplicit()
641 54406 : .setEnumeration({"clang", "gcc", "intel", "msvc", "unknown"});
642 : }
643 :
644 : // OS related
645 : {
646 : #ifdef __APPLE__
647 : const auto value = "darwin";
648 : #elif __WIN32__
649 : const auto value = "win32";
650 : #elif __linux__
651 54406 : const auto value = "linux";
652 : #elif __unix__
653 : const auto value = "unix";
654 : #else
655 : mooseDoOnce(mooseWarning("Failed to determine platform; setting capability platform=unknown"));
656 : const auto value = "unknown";
657 : #endif
658 54406 : add_string("platform", value, "Operating system this executable is running on.")
659 54406 : .setExplicit()
660 54406 : .setEnumeration({"darwin", "linux", "unix", "unknown", "win32"});
661 : }
662 :
663 : // Installation type (in tree or installed)
664 : {
665 : // Try to find the path to the running executable
666 54406 : std::optional<std::string> executable_path;
667 : {
668 54406 : Moose::ScopedThrowOnError scoped_throw_on_error;
669 : try
670 : {
671 54406 : executable_path = Moose::getExec();
672 : }
673 0 : catch (const MooseException &)
674 : {
675 0 : }
676 54406 : }
677 :
678 54406 : std::string value = "unknown";
679 :
680 54406 : if (executable_path)
681 : {
682 : // Try to follow all symlinks to get the real path
683 54406 : std::error_code ec;
684 : const auto resolved_path =
685 54406 : std::filesystem::weakly_canonical(std::filesystem::path(*executable_path), ec);
686 54406 : if (ec)
687 0 : mooseDoOnce(mooseWarning("Failed to resolve executable path '",
688 : *executable_path,
689 : "':\n",
690 : ec.message(),
691 : "\n\nSetting capability installation_type=unknown"));
692 : else
693 : {
694 : // If the binary is in a folder "bin", we'll consider it installed.
695 : // This isn't the best check, but it works with how we currently
696 : // install applications in app.mk
697 54406 : value = resolved_path.parent_path().filename() == "bin" ? "relocated" : "in_tree";
698 : }
699 54406 : }
700 : else
701 0 : mooseDoOnce(mooseWarning(
702 : "Failed to determine executable path; setting capability installation_type=unknown"));
703 :
704 54406 : add_string("installation_type", value, "The installation type of the application.")
705 54406 : .setExplicit()
706 54406 : .setEnumeration({"in_tree", "relocated", "unknown"});
707 :
708 : mooseAssert(isInstallationType(value), "Value mismatch");
709 54406 : }
710 54406 : }
711 :
712 : } // namespace Moose
|