22#include "libmesh/numeric_vector.h"
36 "Temporary and raw gradient containers must have the same size.");
37 for (
auto & vec : temporary_gradient)
42 mooseAssert(perf_graph_interface,
43 "LinearFVGradientInterface requires its owning system to implement "
44 "PerfGraphInterface.");
45 const auto perf_id = perf_graph_interface->registerTimedSection(
"LinearVariableFV_Gradients", 3);
46 mooseAssert(!
Threads::in_threads,
"PerfGraph timing cannot be used within threaded sections");
47 PerfGuard time_guard(perf_graph_interface->perfGraph(), perf_id);
52 FaceInfoRange face_info_range(fe_problem.mesh().ownedFaceInfoBegin(),
53 fe_problem.mesh().ownedFaceInfoEnd());
56 fe_problem,
_sys, temporary_gradient);
59 fe_problem.checkExceptionAndStopSolve();
61 for (
auto & vec : temporary_gradient)
67 ElemInfoRange elem_info_range(fe_problem.mesh().ownedElemInfoBegin(),
68 fe_problem.mesh().ownedElemInfoEnd());
71 fe_problem,
_sys, temporary_gradient);
74 fe_problem.checkExceptionAndStopSolve();
77 temporary_gradient[i]->close();
84 ElemInfoRange elem_info_range(fe_problem.mesh().ownedElemInfoBegin(),
85 fe_problem.mesh().ownedElemInfoEnd());
94 mooseAssert(temporary_container.size() == raw_container.size(),
95 "Temporary and raw limited gradient containers must have the same size.");
96 for (
auto & vec : temporary_container)
110 fe_problem.checkExceptionAndStopSolve();
112 for (
auto & vec : temporary_container)
115 raw_container.swap(temporary_container);
124 if (field_var->needsGradientVectorStorage())
136 "Current solution must exist before building FV gradient storage.");
137 for (
unsigned int i = 0; i <
_sys.
mesh().dimension(); ++i)
172 auto *
const variable =
175 mooseError(
"Limited gradients were requested for variable number ",
179 "', but no field variable with that number exists on the system.");
181 if (!variable->needsGradientVectorStorage())
182 mooseError(
"Limited gradients were requested for variable '",
186 "', but regular gradients were not requested for that variable.");
197const std::vector<std::unique_ptr<NumericVector<Number>>> &
206 mooseError(
"Limited gradient container was requested but not initialized on system '",
void mooseError(Args &&... args)
Emit an error message with the given stringified, concatenated args and terminate the application.
The gradient in a volume using Green Gauss theorem and a cell-centered finite-volume approximation ca...
The gradient in a volume using Green Gauss theorem and a cell-centered finite-volume approximation ca...
Compute limited cell gradients for linear FV variables.
void rebuildLinearFVGradientStorage()
Rebuild persistent raw and temporary gradient storage after mesh/DOF changes.
std::vector< std::unique_ptr< libMesh::NumericVector< libMesh::Number > > > & temporaryLinearFVLimitedGradientContainer(const Moose::FV::GradientLimiterType limiter_type)
Return temporary storage for limited gradients during gradient assembly.
std::vector< std::unique_ptr< libMesh::NumericVector< libMesh::Number > > > & temporaryLinearFVGradientContainer()
Return temporary storage for gradients during gradient assembly.
SystemBase & _sys
Reference to the system object.
std::vector< std::unique_ptr< libMesh::NumericVector< libMesh::Number > > > _raw_grad_container
Persisted raw cell-centered gradient components keyed by spatial direction.
const std::unordered_set< unsigned int > & requestedLinearFVLimitedGradientVariables(const Moose::FV::GradientLimiterType limiter_type) const
Access the variable numbers that requested limited gradients for a specific limiter.
std::unordered_map< Moose::FV::GradientLimiterType, std::vector< std::unique_ptr< libMesh::NumericVector< libMesh::Number > > > > _temporary_limited_gradient
Scratch storage for limited gradients assembled during the current compute pass.
void initializeContainer(std::vector< std::unique_ptr< libMesh::NumericVector< libMesh::Number > > > &container) const
bool needsLinearFVGradientStorage() const
std::vector< std::unique_ptr< libMesh::NumericVector< libMesh::Number > > > _temporary_gradient
Scratch storage for raw gradients assembled during the current compute pass.
void requestLinearFVLimitedGradients(const Moose::FV::GradientLimiterType limiter_type, unsigned int variable_number)
Request storage and assembly of limiter-specific cell gradients.
const std::vector< std::unique_ptr< libMesh::NumericVector< libMesh::Number > > > & linearFVLimitedGradientContainer(const Moose::FV::GradientLimiterType limiter_type) const
Access the stored raw or limited cell-centered gradient components.
std::unordered_map< Moose::FV::GradientLimiterType, std::unordered_set< unsigned int > > _requested_limited_gradient_variables
Variable numbers requesting limited gradients, keyed by limiter type.
const std::unordered_set< Moose::FV::GradientLimiterType > & requestedLinearFVLimitedGradientTypes() const
Access the limiter types requested for this system.
std::unordered_set< Moose::FV::GradientLimiterType > _requested_limited_gradient_types
Set of requested limiter types for which limited gradients should be computed.
void computeGradients()
Compute and store raw and requested limited Green-Gauss gradients for linear FV variables.
std::unordered_map< Moose::FV::GradientLimiterType, std::vector< std::unique_ptr< libMesh::NumericVector< libMesh::Number > > > > _raw_limited_grad_containers
Persisted limited gradient components keyed by limiter type.
std::vector< std::unique_ptr< libMesh::NumericVector< libMesh::Number > > > & rawLinearFVLimitedGradientContainer(const Moose::FV::GradientLimiterType limiter_type)
Access the persisted limited-gradient storage for a specific limiter.
This class provides an interface for common operations on field variables of both FE and FV types wit...
Interface for objects interacting with the PerfGraph.
Scope guard for starting and stopping timing for a node.
virtual const NumericVector< Number > *const & currentSolution() const =0
The solution vector that is currently being operated on.
FEProblemBase & feProblem()
virtual const std::string & name() const
const VariableWarehouse & variableWarehouse(THREAD_ID tid=0) const
MooseVariableBase * getVariable(const std::string &var_name) const
Get a variable from the warehouse.
const std::vector< MooseVariableFieldBase * > & fieldVariables() const
Get the list of variables.
virtual std::unique_ptr< NumericVector< T > > zero_clone() const=0
GradientLimiterType
Cell-gradient limiter variants used for MUSCL-style reconstructions.
@ None
No gradient limiting.
void parallel_reduce(const Range &range, Body &body, unsigned int n_threads=libMesh::n_threads())
The following methods are specializations for using the libMesh::Parallel::packed_range_* routines fo...
auto index_range(const T &sizable)