https://mooseframework.inl.gov
LinearFVGradientInterface.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"
13 #include "GradientLimiterType.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 
23 class SystemBase;
24 
25 namespace libMesh
26 {
27 template <typename T>
28 class NumericVector;
29 }
30 
36 {
37 public:
39 
44  const std::vector<std::unique_ptr<libMesh::NumericVector<libMesh::Number>>> &
46  {
47  return _raw_grad_container;
48  }
49 
56  unsigned int variable_number);
57 
63  const std::vector<std::unique_ptr<libMesh::NumericVector<libMesh::Number>>> &
65 
71  const std::unordered_set<Moose::FV::GradientLimiterType> &
73  {
75  }
76 
77 protected:
81  void computeGradients();
82 
87 
93  std::vector<std::unique_ptr<libMesh::NumericVector<libMesh::Number>>> &
95  {
96  return _temporary_gradient;
97  }
98 
105  std::vector<std::unique_ptr<libMesh::NumericVector<libMesh::Number>>> &
107  {
108  return _temporary_limited_gradient[limiter_type];
109  }
110 
116  std::vector<std::unique_ptr<libMesh::NumericVector<libMesh::Number>>> &
118  {
119  return _raw_limited_grad_containers[limiter_type];
120  }
121 
127  const std::unordered_set<unsigned int> &
129  {
130  return libmesh_map_find(_requested_limited_gradient_variables, limiter_type);
131  }
132 
133  bool needsLinearFVGradientStorage() const;
134 
135  void initializeContainer(
136  std::vector<std::unique_ptr<libMesh::NumericVector<libMesh::Number>>> & container) const;
137 
140 
142  std::vector<std::unique_ptr<libMesh::NumericVector<libMesh::Number>>> _temporary_gradient;
143 
145  std::vector<std::unique_ptr<libMesh::NumericVector<libMesh::Number>>> _raw_grad_container;
146 
148  std::unordered_set<Moose::FV::GradientLimiterType> _requested_limited_gradient_types;
149 
151  std::unordered_map<Moose::FV::GradientLimiterType, std::unordered_set<unsigned int>>
153 
155  std::unordered_map<Moose::FV::GradientLimiterType,
156  std::vector<std::unique_ptr<libMesh::NumericVector<libMesh::Number>>>>
158 
160  std::unordered_map<Moose::FV::GradientLimiterType,
161  std::vector<std::unique_ptr<libMesh::NumericVector<libMesh::Number>>>>
163 };
void rebuildLinearFVGradientStorage()
Rebuild persistent raw and temporary gradient storage after mesh/DOF changes.
GradientLimiterType
Cell-gradient limiter variants used for MUSCL-style reconstructions.
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 > > > _temporary_gradient
Scratch storage for raw gradients assembled during the current compute pass.
SystemBase & _sys
Reference to the system object.
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.
std::vector< std::unique_ptr< libMesh::NumericVector< libMesh::Number > > > & temporaryLinearFVGradientContainer()
Return temporary storage for gradients during gradient assembly.
std::unordered_set< Moose::FV::GradientLimiterType > _requested_limited_gradient_types
Set of requested limiter types for which limited gradients should be computed.
The following methods are specializations for using the libMesh::Parallel::packed_range_* routines fo...
Base class for a system (of equations)
Definition: SystemBase.h:85
std::vector< std::unique_ptr< libMesh::NumericVector< libMesh::Number > > > _raw_grad_container
Persisted raw cell-centered gradient components keyed by spatial direction.
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::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.
void requestLinearFVLimitedGradients(const Moose::FV::GradientLimiterType limiter_type, unsigned int variable_number)
Request storage and assembly of limiter-specific cell gradients.
void initializeContainer(std::vector< std::unique_ptr< libMesh::NumericVector< libMesh::Number >>> &container) const
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.
const std::unordered_set< Moose::FV::GradientLimiterType > & requestedLinearFVLimitedGradientTypes() const
Access the limiter types requested for this system.
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.
const std::vector< std::unique_ptr< libMesh::NumericVector< libMesh::Number > > > & linearFVGradientContainer() const
Access the stored raw cell-centered gradient components.
void computeGradients()
Compute and store raw and requested limited Green-Gauss gradients for linear FV variables.
Shared storage and allocation logic for linear finite-volume cell gradients for variables in the syst...
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.