www.mooseframework.org
FloatingPointExceptionGuard.h
Go to the documentation of this file.
1 //* This file is part of the MOOSE framework
2 //* https://www.mooseframework.org
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 #pragma once
11 
12 #include "MooseApp.h"
13 #include "libmesh/libmesh.h"
14 
19 {
20 public:
27  : _trapping_enabled(moose_app.getFPTrapFlag())
28  {
30  libMesh::enableFPE(true);
31  }
32 
37  {
39  libMesh::enableFPE(false);
40  }
41 
42 private:
44  const bool _trapping_enabled;
45 };
46 
FloatingPointExceptionGuard(const MooseApp &moose_app)
Instantiation turns on FPE Trapping as long as trapping is enabled on the application.
Base class for MOOSE-based applications.
Definition: MooseApp.h:59
Scope guard for starting and stopping Floating Point Exception Trapping.
~FloatingPointExceptionGuard()
Stop FPE Trapping on destruction.
const bool _trapping_enabled
Determine whether or not PFE trapping needs to be toggled off.