https://mooseframework.inl.gov
Loading...
Searching...
No Matches
FVGradientMethod.C
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#include "FVGradientMethod.h"
11
13#include "FEProblemBase.h"
14#include "SystemBase.h"
15
16#include "libmesh/numeric_vector.h"
17
18namespace
19{
21selectGradientLimiter(const std::string & limiter_name)
22{
23 if (limiter_name == "none")
25 if (limiter_name == "venkatakrishnan")
27
28 mooseError("Linear FV gradient limiter '", limiter_name, "' is not currently supported.");
29}
30}
31
34{
36 params.registerBase("FVGradientMethod");
37 params.registerSystemAttributeName("FVGradientMethod");
38 params.addClassDescription("Base class for defining cell-centered gradient methods used by "
39 "linear finite volume objects. The method produces final gradient "
40 "values, including the selected limiter when requested.");
41 params.addParam<MooseEnum>("limiter",
42 MooseEnum("none venkatakrishnan", "none"),
43 "Limiter to apply to gradients produced by this method.");
44 return params;
45}
46
48 : MooseObject(params), _limiter_type(selectGradientLimiter(getParam<MooseEnum>("limiter")))
49{
50}
51
52void
54 GradientContainer & gradient,
55 const std::unordered_set<unsigned int> & variable_numbers) const
56{
57 for (auto & vec : gradient)
58 vec->zero();
59
60 computeGradientWithoutLimiter(system, gradient, variable_numbers);
61
62 for (auto & vec : gradient)
63 vec->close();
64
66 return;
67
68 auto & fe_problem = system.feProblem();
70 ElemInfoRange elem_info_range(fe_problem.mesh().ownedElemInfoBegin(),
71 fe_problem.mesh().ownedElemInfoEnd());
72
73 PARALLEL_TRY
74 {
75 ComputeLinearFVLimitedGradientThread limited_gradient_thread(
76 fe_problem, system, gradient, _limiter_type, variable_numbers);
77 Threads::parallel_reduce(elem_info_range, limited_gradient_thread);
78 }
79 fe_problem.checkExceptionAndStopSolve();
80
81 for (auto & vec : gradient)
82 vec->close();
83}
void mooseError(Args &&... args)
Emit an error message with the given stringified, concatenated args and terminate the application.
Definition MooseError.h:311
Compute limited cell gradients for linear FV variables.
StoredRange< MooseMesh::const_elem_info_iterator, const ElemInfo * > ElemInfoRange
FVGradientMethod(const InputParameters &params)
Constructor.
static InputParameters validParams()
Input parameters shared by all the gradient methods.
const Moose::FV::GradientLimiterType _limiter_type
Limiter applied after method-specific pre-limiter gradient computation.
std::vector< std::unique_ptr< libMesh::NumericVector< libMesh::Number > > > GradientContainer
One vector per spatial component of the cell-centered gradient.
void computeGradient(SystemBase &system, GradientContainer &gradient, const std::unordered_set< unsigned int > &variable_numbers) const
Compute the final gradient values for the requested variables.
virtual void computeGradientWithoutLimiter(SystemBase &system, GradientContainer &gradient, const std::unordered_set< unsigned int > &variable_numbers) const =0
Compute the method-specific gradient before this base class applies any limiter.
The main MOOSE class responsible for handling user-defined parameters in almost every MOOSE system.
void registerSystemAttributeName(const std::string &value)
This method is used to define the MOOSE system name that is used by the TheWarehouse object for stori...
void addParam(const std::string &name, const S &value, const std::string &doc_string)
These methods add an optional parameter and a documentation string to the InputParameters object.
void registerBase(const std::string &value)
This method must be called from every base "Moose System" to create linkage with the Action System.
void addClassDescription(const std::string &doc_string)
This method adds a description of the class that will be displayed in the input file syntax dump.
This is a "smart" enum class intended to replace many of the shortcomings in the C++ enum type It sho...
Definition MooseEnum.h:55
Every object that can be built by the factory should be derived from this class.
Definition MooseObject.h:31
static InputParameters validParams()
Definition MooseObject.C:25
Base class for a system (of equations)
Definition SystemBase.h:87
FEProblemBase & feProblem()
Definition SystemBase.h:104
GradientLimiterType
Cell-gradient limiter variants used for MUSCL-style reconstructions.
@ Venkatakrishnan
Venkatakrishnan limiter (smooth, multidimensional).
@ None
No gradient limiting.
void parallel_reduce(const Range &range, Body &body, unsigned int n_threads=libMesh::n_threads())