MFEM v4.8.0
Finite element discretization library
Loading...
Searching...
No Matches
globals.cpp
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#ifdef _WIN32
13// Turn off CRT deprecation warnings for getenv
14#define _CRT_SECURE_NO_WARNINGS
15#endif
16
17#include "../config/config.hpp"
18#include "globals.hpp"
19#include <iostream>
20#include <sstream>
21#include <iomanip>
22#include <cstdlib> // getenv
23
24namespace mfem
25{
26
27OutStream out(std::cout);
28OutStream err(std::cerr);
29
30namespace internal
31{
32bool mfem_out_initialized = false;
33bool mfem_err_initialized = false;
34}
35
37{
38 if (this == &mfem::out)
39 {
40 internal::mfem_out_initialized = true;
41 }
42 else if (this == &mfem::err)
43 {
44 internal::mfem_err_initialized = true;
45 }
46}
47
48std::string MakeParFilename(const std::string &prefix, const int myid,
49 const std::string suffix, const int width)
50{
51 std::stringstream fname;
52 fname << prefix << std::setw(width) << std::setfill('0') << myid << suffix;
53 return fname.str();
54}
55
56#ifdef MFEM_COUNT_FLOPS
57namespace internal
58{
59long long flop_count;
60}
61#endif
62
63#ifdef MFEM_USE_MPI
64
65MPI_Comm MFEM_COMM_WORLD = MPI_COMM_WORLD;
66
68{
69 return MFEM_COMM_WORLD;
70}
71
72void SetGlobalMPI_Comm(MPI_Comm comm)
73{
74 MFEM_COMM_WORLD = comm;
75}
76
77#endif
78
79const char *GetEnv(const char* name)
80{
81 return getenv(name);
82}
83
84}
std::string MakeParFilename(const std::string &prefix, const int myid, const std::string suffix, const int width)
Construct a string of the form "<prefix><myid><suffix>" where the integer myid is padded with leading...
Definition globals.cpp:48
const char * GetEnv(const char *name)
Wrapper for std::getenv.
Definition globals.cpp:79
OutStream out(std::cout)
Global stream used by the library for standard output. Initially it uses the same std::streambuf as s...
Definition globals.hpp:66
MPI_Comm MFEM_COMM_WORLD
Definition globals.cpp:65
OutStream err(std::cerr)
Global stream used by the library for standard error output. Initially it uses the same std::streambu...
Definition globals.hpp:71
void SetGlobalMPI_Comm(MPI_Comm comm)
Set MFEM's "global" MPI communicator.
Definition globals.cpp:72
MPI_Comm GetGlobalMPI_Comm()
Get MFEM's "global" MPI communicator.
Definition globals.cpp:67