OGS
LinearSolverLibrarySetup.h
Go to the documentation of this file.
1// SPDX-FileCopyrightText: Copyright (c) OpenGeoSys Community (opengeosys.org)
2// SPDX-License-Identifier: BSD-3-Clause
3
4#pragma once
5
14
15#include "BaseLib/MPI.h"
17
18#if defined(USE_PETSC)
19#include <mpi.h>
20#include <petsc.h>
21
22#include "BaseLib/MPI.h"
23
25{
27{
28 LinearSolverLibrarySetup(int argc, char* argv[])
29 {
30 char help[] = "ogs6 with PETSc \n";
31 PETSC_COMM_WORLD = BaseLib::MPI::OGS_COMM_WORLD;
32 PetscInitialize(&argc, &argv, nullptr, help);
33 MPI_Comm_set_errhandler(PETSC_COMM_WORLD, MPI_ERRORS_RETURN);
34 }
35
41};
42} // namespace ApplicationsLib
43#elif defined(USE_LIS)
45namespace ApplicationsLib
46{
47struct LinearSolverLibrarySetup final
48{
49 LinearSolverLibrarySetup(int argc, char* argv[])
50 {
51 lis_initialize(&argc, &argv);
52 }
53
55 {
57 lis_finalize();
58 }
59};
60} // namespace ApplicationsLib
61#else
62namespace ApplicationsLib
63{
64struct LinearSolverLibrarySetup final
65{
66 LinearSolverLibrarySetup(int /*argc*/, char* /*argv*/[])
67 {
68#ifdef _OPENMP
69 const char* omp_num_threads_env = std::getenv("OMP_NUM_THREADS");
70 if (omp_num_threads_env)
71 {
72 INFO("OMP_NUM_THREADS is set to: {:s}", omp_num_threads_env);
73 }
74 else
75 {
76 WARN("OMP_NUM_THREADS is not set, falling back to: {:d}",
77 omp_get_max_threads());
78 }
79#endif
80 INFO("Eigen use {:d} threads", Eigen::nbThreads());
81 }
83};
84} // namespace ApplicationsLib
85#endif
void INFO(fmt::format_string< Args... > fmt, Args &&... args)
Definition Logging.h:28
void WARN(fmt::format_string< Args... > fmt, Args &&... args)
Definition Logging.h:34
MPI_Comm OGS_COMM_WORLD
Definition MPI.cpp:9
void cleanupGlobalMatrixProviders()