www.mooseframework.org
SwapBackSentinel.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 // MOOSE includes
13 #include "MooseTypes.h"
14 
15 // Forward declarations
16 class FEProblemBase;
17 
33 {
34 public:
41 
47  SwapBackFunction func,
48  THREAD_ID tid,
49  bool predicate = true)
50  : _fe_problem(fe_problem), _func(func), _thread_id(tid), _predicate(predicate)
51  {
52  }
53 
58  {
59  if (_predicate)
61  }
62 
63 private:
67  bool _predicate;
68 };
69 
void(FEProblemBase::*)(THREAD_ID) SwapBackFunction
SwapBackFunction is a typedef for a pointer to an FEProblemBase member function taking a THREAD_ID an...
~SwapBackSentinel()
The destructor calls swap back function only if the predicate is true.
Specialization of SubProblem for solving nonlinear equations plus auxiliary equations.
FEProblemBase & _fe_problem
SwapBackSentinel(FEProblemBase &fe_problem, SwapBackFunction func, THREAD_ID tid, bool predicate=true)
Constructor taking an FEProblemBase reference, a function to call, and the THREAD_ID argument...
SwapBackFunction _func
unsigned int THREAD_ID
Definition: MooseTypes.h:161
The "SwapBackSentinel" class's destructor guarantees that FEProblemBase::swapBackMaterials{Face,Neighbor}() is called even when an exception is thrown from FEProblemBase::reinitMaterials{Face,Neighbor}.