https://mooseframework.inl.gov
Loading...
Searching...
No Matches
LinearFVGradientManager.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#include "MooseTypes.h"
14
15#include "libmesh/utility.h"
16
17#include <memory>
18#include <string>
19#include <unordered_map>
20#include <unordered_set>
21#include <vector>
22
23class SystemBase;
24class ElemInfo;
25class FaceInfo;
27
28namespace libMesh
29{
30template <typename T>
31class NumericVector;
32}
33
39{
40public:
45
51 const FVGradientMethod & resolveFVGradientMethod(const GradientMethodName & method_name);
52
59 LinearFVGradientReader registerFVGradient(unsigned int variable_number,
60 const FVGradientMethod & method,
61 unsigned int oldest_state = 0);
62
63protected:
66
69
72 std::vector<std::unique_ptr<libMesh::NumericVector<libMesh::Number>>>;
73
75 void computeGradients();
76
81 void updateFVGradient(const LinearFVGradientReader & reader);
82
91
100
105
114 bool skip_current_to_old);
115
118
120 bool hasLinearFVGradients() const;
121
126 void initializeContainer(OwnedGradientContainer & container) const;
127
156
162 void resizeGradientStateStorage(LinearFVGradientContainer & container, unsigned int oldest_state);
163
166
169 LinearFVGradientContainer & container);
170
172 static std::string gradientStateVectorName(const FVGradientMethod & method,
173 unsigned int state,
174 unsigned int component);
175
178
185
191
194
196 std::unordered_map<const FVGradientMethod *, LinearFVGradientContainer>
198};
Class used for caching additional information for elements such as the volume and centroid.
Definition ElemInfo.h:26
Base class for linear finite-volume cell-gradient methods.
This data structure is used to store geometric and variable related metadata about each cell face in ...
Definition FaceInfo.h:38
Registration, update, and allocation logic for linear finite-volume cell gradients.
LinearFVGradientManager(SystemBase &sys)
void resizeGradientStateStorage(LinearFVGradientContainer &container, unsigned int oldest_state)
Ensure that a method container stores every requested time state.
LinearFVGradientReader::GradientStateContainer GradientStateContainer
Gradient fields indexed by solution time state.
void setCurrentGradientState(LinearFVGradientContainer &container) const
Set solution state zero to the current gradient.
LinearFVGradientContainer & computeLinearFVGradientContainer(const FVGradientMethod &method)
Compute replacement field values for a registered gradient method.
LinearFVGradientReader::GradientContainer GradientContainer
Non-owning view with one vector per spatial component of a cell-centered gradient field.
void initializeContainer(OwnedGradientContainer &container) const
Allocate one zeroed vector per spatial component for gradient storage.
SystemBase & _sys
Reference to the system object.
void finalizeLinearFVGradientContainer(LinearFVGradientContainer &container)
Replace the current gradient storage with the freshly computed new gradients.
std::unordered_map< const FVGradientMethod *, LinearFVGradientContainer > _linear_fv_gradient_container_by_method
Gradient containers keyed by the method object that produces them.
void updateFVGradient(const LinearFVGradientReader &reader)
Update a registered gradient reader explicitly.
void computeGradients()
Compute and finalize all registered linear FV gradient fields.
static std::string gradientStateVectorName(const FVGradientMethod &method, unsigned int state, unsigned int component)
Return the stable system-vector name for one old gradient component.
void rebuildLinearFVGradientStorage()
Rebuild cached gradient values and reusable scratch storage after mesh/DOF changes.
void copyPreviousGradientStates(Moose::SolutionIterationType iteration_type, bool skip_current_to_old)
Copy published gradient values into requested older states.
void initializeGradientStatesForTimeAdvance()
Compute and publish uninitialized gradients before their first time-state advancement.
const FVGradientMethod & resolveFVGradientMethod(const GradientMethodName &method_name)
Resolve a named gradient method, constructing a built-in method when needed.
LinearFVGradientReader registerFVGradient(unsigned int variable_number, const FVGradientMethod &method, unsigned int oldest_state=0)
Register a variable for gradient values produced by a method object.
void checkRestartedGradientHistory(const FVGradientMethod &method, LinearFVGradientContainer &container)
Validate and mark gradient history loaded during restart or recovery.
std::vector< std::unique_ptr< libMesh::NumericVector< libMesh::Number > > > OwnedGradientContainer
Owned vectors used for the current gradient and its replacement.
bool hasLinearFVGradients() const
Whether any linear finite-volume gradient fields have been registered to this object.
void restoreGradientStates()
Restore current gradients from state one after a failed timestep.
void initializeLinearFVGradientHistoryStorage()
Register named system vectors for requested historical gradient states.
void initializeLinearFVGradientStorage()
Initialize private current and replacement gradient storage.
Read-only view of one variable's cell-centered linear finite-volume gradient values.
std::vector< GradientContainer > GradientStateContainer
Gradient fields indexed by solution time state.
std::vector< libMesh::NumericVector< libMesh::Number > * > GradientContainer
One vector per spatial component of the cell-centered gradient.
Base class for a system (of equations)
Definition SystemBase.h:87
SolutionIterationType
Definition MooseTypes.h:270
The following methods are specializations for using the libMesh::Parallel::packed_range_* routines fo...
Gradient values for all variables using the same gradient method.
bool has_computed_gradient
Whether the current gradient has received a computed value.
bool has_initialized_history
Whether the old gradient states contain valid values.
OwnedGradientContainer current_values
Owned current gradient values.
GradientStateContainer state_values
Published gradient values indexed by solution time state.
bool has_checked_restart_history
Whether restart data has been checked for this gradient method.
std::unordered_set< unsigned int > variable_numbers
Variable numbers whose gradients are stored in the gradient containers.
OwnedGradientContainer next_values
Replacement gradient values computed before publication.