MFEM
v4.9.0
Finite element discretization library
Loading...
Searching...
No Matches
config
config.hpp
Go to the documentation of this file.
1
// Copyright (c) 2010-2025, Lawrence Livermore National Security, LLC. Produced
2
// at the Lawrence Livermore National Laboratory. All Rights reserved. See files
3
// LICENSE and NOTICE for details. LLNL-CODE-806117.
4
//
5
// This file is part of the MFEM library. For more information and source code
6
// availability visit https://mfem.org.
7
//
8
// MFEM is free software; you can redistribute it and/or modify it under the
9
// terms of the BSD-3 license. We welcome feedback and contributions, see file
10
// CONTRIBUTING.md for details.
11
12
13
// Support out-of-source builds: if MFEM_CONFIG_FILE is defined, include it.
14
//
15
// Otherwise, use the local file: _config.hpp.
16
17
#ifndef MFEM_CONFIG_HPP
18
#define MFEM_CONFIG_HPP
19
20
#ifdef MFEM_CONFIG_FILE
21
#include MFEM_CONFIG_FILE
22
#else
23
#include "_config.hpp"
24
#endif
25
26
#include <cstdint>
27
#include <climits>
28
29
namespace
mfem
30
{
31
32
#if (defined(MFEM_USE_CUDA) && defined(__CUDACC__)) || \
33
(defined(MFEM_USE_HIP) && defined(__HIP__))
34
#define MFEM_HOST_DEVICE __host__ __device__
35
#else
36
#define MFEM_HOST_DEVICE
37
#endif
38
39
// MFEM precision configuration
40
41
#if defined MFEM_USE_SINGLE && defined MFEM_USE_DOUBLE
42
#error "DOUBLE and SINGLE precision cannot both be specified"
43
#endif
44
45
#ifdef MFEM_USE_SINGLE
46
typedef
float
real_t
;
47
#elif defined MFEM_USE_DOUBLE
48
typedef
double
real_t
;
49
#else
50
#error "Either DOUBLE or SINGLE precision must be specified"
51
#endif
52
53
MFEM_HOST_DEVICE
54
constexpr
real_t
operator
""
_r(
long
double
v)
55
{
56
return
static_cast<
real_t
>
(v);
57
}
58
59
MFEM_HOST_DEVICE
60
constexpr
real_t
operator
""
_r(
unsigned
long
long
v)
61
{
62
return
static_cast<
real_t
>
(v);
63
}
64
65
}
// namespace mfem
66
67
// Return value for main function in examples that should be skipped by testing
68
// in some case. This return value prevents failures in testing.
69
#define MFEM_SKIP_RETURN_VALUE 242
70
71
// Request a global object to be instantiated for each thread in its TLS.
72
#define MFEM_THREAD_LOCAL thread_local
73
74
// MFEM_DEPRECATED macro to mark obsolete functions and methods
75
// see https://stackoverflow.com/questions/295120/c-mark-as-deprecated
76
#if defined(__GNUC__) || defined(__clang__)
77
#define MFEM_DEPRECATED __attribute__((deprecated))
78
#elif defined(_MSC_VER)
79
#define MFEM_DEPRECATED __declspec(deprecated)
80
#else
81
#pragma message("WARNING: You need to implement MFEM_DEPRECATED for this compiler")
82
#define MFEM_DEPRECATED
83
#endif
84
85
// Common configuration macros
86
87
#if (__GNUC__ > 4 || (__GNUC__ == 4 && __GNUC_MINOR__ >= 7)) || defined(__clang__)
88
#define MFEM_HAVE_GCC_PRAGMA_DIAGNOSTIC
89
#endif
90
91
// Windows specific options
92
#if defined(_WIN32) && !defined(_USE_MATH_DEFINES)
93
// Macro needed to get defines like M_PI from <cmath>. (Visual Studio C++ only?)
94
#define _USE_MATH_DEFINES
95
#endif
96
// Macro MFEM_EXPORT: this macro is used when declaring exported global
97
// variables and static class variables in public header files, e.g.:
98
// extern MFEM_EXPORT Geometry Geometries;
99
// static MFEM_EXPORT Device device_singleton;
100
// In cases where a class contains multiple static variables, instead of marking
101
// all such variables with MFEM_EXPORT, one can mark the class with MFEM_EXPORT,
102
// e.g.:
103
// class MFEM_EXPORT MemoryManager ...
104
// Note: MFEM's GitHub CI includes a shared MSVC build that will fail if a
105
// variable that needs MFEM_EXPORT does not have it. However, builds with
106
// optional external libraries are not tested and may require separate checks to
107
// determine the necessity of MFEM_EXPORT.
108
#if defined(_MSC_VER) && defined(MFEM_SHARED_BUILD)
109
#ifdef mfem_EXPORTS
110
#define MFEM_EXPORT __declspec(dllexport)
111
#else
112
#define MFEM_EXPORT __declspec(dllimport)
113
#endif
114
#else
115
#define MFEM_EXPORT
116
#endif
117
// On Cygwin the option -std=c++11 prevents the definition of M_PI. Defining
118
// the following macro allows us to get M_PI and some needed functions, e.g.
119
// posix_memalign(), strdup(), strerror_r().
120
#ifdef __CYGWIN__
121
#define _XOPEN_SOURCE 600
122
#endif
123
124
// Check dependencies:
125
126
// Define MFEM_MPI_REAL_T to be the appropriate MPI real type
127
#ifdef MFEM_USE_MPI
128
#ifdef MFEM_USE_SINGLE
129
#define MFEM_MPI_REAL_T MPI_FLOAT
130
#elif defined MFEM_USE_DOUBLE
131
#define MFEM_MPI_REAL_T MPI_DOUBLE
132
#endif
133
#endif
134
135
// Options that require MPI
136
#ifndef MFEM_USE_MPI
137
#ifdef MFEM_USE_SUPERLU
138
#error Building with SuperLU_DIST (MFEM_USE_SUPERLU=YES) requires MPI (MFEM_USE_MPI=YES)
139
#endif
140
#ifdef MFEM_USE_MUMPS
141
#error Building with MUMPS (MFEM_USE_MUMPS=YES) requires MPI (MFEM_USE_MPI=YES)
142
#endif
143
#ifdef MFEM_USE_STRUMPACK
144
#error Building with STRUMPACK (MFEM_USE_STRUMPACK=YES) requires MPI (MFEM_USE_MPI=YES)
145
#endif
146
#ifdef MFEM_USE_MKL_CPARDISO
147
#error Building with MKL CPARDISO (MFEM_USE_MKL_CPARDISO=YES) requires MPI (MFEM_USE_MPI=YES)
148
#endif
149
#ifdef MFEM_USE_PETSC
150
#error Building with PETSc (MFEM_USE_PETSC=YES) requires MPI (MFEM_USE_MPI=YES)
151
#endif
152
#ifdef MFEM_USE_SLEPC
153
#error Building with SLEPc (MFEM_USE_SLEPC=YES) requires MPI (MFEM_USE_MPI=YES)
154
#endif
155
#ifdef MFEM_USE_PUMI
156
#error Building with PUMI (MFEM_USE_PUMI=YES) requires MPI (MFEM_USE_MPI=YES)
157
#endif
158
#endif
// MFEM_USE_MPI not defined
159
160
#endif
// MFEM_CONFIG_HPP
mfem
Definition
CodeDocumentation.dox:1
mfem::real_t
float real_t
Definition
config.hpp:46
Generated on Thu Dec 11 2025 11:52:53 for MFEM by
1.11.0