Advanced Multi-Physics (AMP)
On-Line Documentation
DeferConsistency.h
Go to the documentation of this file.
1#ifndef included_AMP_DeferConsistency
2#define included_AMP_DeferConsistency
3
4#include "AMP/vectors/Vector.h"
5
6namespace AMP::Solver::AMG {
7
17template<class P>
19 using P::P;
20 // Enable copy construction directly from P
21 explicit HasDeferConsistency( const P &p ) : P( p ) {}
22 struct defer_guard {
24 : d_target( tgt ),
25 d_inner_scope( d_target.defer_consistency ) // inner scope of another guard
26 {
27 d_target.defer_consistency = true;
28 }
29 ~defer_guard() noexcept
30 {
31 if ( !d_inner_scope ) // give precedence to outer guard
32 d_target.defer_consistency = false;
33 }
34
35 defer_guard( const defer_guard & ) = delete;
36 defer_guard( defer_guard && ) = delete;
37 defer_guard &operator=( const defer_guard & ) = delete;
39
40 private:
42 bool d_inner_scope = false;
43 };
44
50 void applyDeferConsistency( std::shared_ptr<const AMP::LinearAlgebra::Vector> u,
51 std::shared_ptr<AMP::LinearAlgebra::Vector> f )
52 {
53 ( defer_guard{ *this }, static_cast<P *>( this )->apply( u, f ) );
54 }
55
56
64 void residual( std::shared_ptr<const AMP::LinearAlgebra::Vector> f,
65 std::shared_ptr<const AMP::LinearAlgebra::Vector> u,
66 std::shared_ptr<AMP::LinearAlgebra::Vector> r ) final override
67 {
68 ( defer_guard{ *this }, P::residual( f, u, r ) );
69 }
70
71protected:
72 // used to indicate to derived type P that output vector consistency should be deferred.
73 bool defer_consistency = false;
74};
75
76
77} // namespace AMP::Solver::AMG
78
79#endif
defer_guard & operator=(defer_guard &&)=delete
defer_guard & operator=(const defer_guard &)=delete
void residual(std::shared_ptr< const AMP::LinearAlgebra::Vector > f, std::shared_ptr< const AMP::LinearAlgebra::Vector > u, std::shared_ptr< AMP::LinearAlgebra::Vector > r) final override
void applyDeferConsistency(std::shared_ptr< const AMP::LinearAlgebra::Vector > u, std::shared_ptr< AMP::LinearAlgebra::Vector > f)



Advanced Multi-Physics (AMP)
Oak Ridge National Laboratory
Idaho National Laboratory
Los Alamos National Laboratory
This page automatically produced from the
source code by doxygen
Last updated: Tue Mar 10 2026 13:06:41.
Comments on this page