https://mooseframework.inl.gov
Loading...
Searching...
No Matches
SwapBackSentinel.h
Go to the documentation of this file.
1//* This file is part of the MOOSE framework
2//* https://mooseframework.inl.gov
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
16class FEProblemBase;
17
33{
34public:
41
48 THREAD_ID tid,
49 const bool & predicate,
50 const bool store_pred_as_value = true)
51 : _fe_problem(fe_problem),
52 _func(func),
53 _thread_id(tid),
54 _predicate(store_pred_as_value ? (predicate ? _always_true : _always_false) : predicate)
55 {
56 }
57
59 : _fe_problem(fe_problem), _func(func), _thread_id(tid), _predicate(_always_true)
60 {
61 }
62
71
72private:
76 static constexpr bool _always_true = true;
77 static constexpr bool _always_false = false;
78 const bool & _predicate;
79};
unsigned int THREAD_ID
Definition MooseTypes.h:237
Specialization of SubProblem for solving nonlinear equations plus auxiliary equations.
The "SwapBackSentinel" class's destructor guarantees that FEProblemBase::swapBackMaterials{Face,...
~SwapBackSentinel()
The destructor calls swap back function only if the predicate is true.
static constexpr bool _always_true
SwapBackFunction _func
void(FEProblemBase::*)(THREAD_ID) SwapBackFunction
SwapBackFunction is a typedef for a pointer to an FEProblemBase member function taking a THREAD_ID an...
const bool & _predicate
SwapBackSentinel(FEProblemBase &fe_problem, SwapBackFunction func, THREAD_ID tid)
static constexpr bool _always_false
SwapBackSentinel(FEProblemBase &fe_problem, SwapBackFunction func, THREAD_ID tid, const bool &predicate, const bool store_pred_as_value=true)
Constructor taking an FEProblemBase reference, a function to call, and the THREAD_ID argument.
FEProblemBase & _fe_problem