https://mooseframework.inl.gov
Loading...
Searching...
No Matches
NavierStokesPhysicsBase.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
12#include "NSFVUtils.h"
13#include "RelationshipManager.h"
14#include "WCNSFVFlowPhysics.h"
15
18{
21 "Base class to define the Navier Stokes incompressible and weakly-compressible equation");
22
23 params.addParam<bool>(
24 "define_variables",
25 true,
26 "Whether to define variables if the variables with the specified names do not exist. Note "
27 "that if the variables are defined externally from the Physics, the initial conditions will "
28 "not be created in the Physics either.");
29
30 params.addParam<unsigned short>(
31 "ghost_layers", 2, "Number of layers of elements to ghost near process domain boundaries");
32 params.addParamNamesToGroup("define_variables ghost_layers", "Advanced");
33
34 return params;
35}
36
38 : PhysicsBase(parameters), _define_variables(getParam<bool>("define_variables"))
39{
40}
41
42void
44{
45 const std::string method_name = interpolation_method;
46 if (getProblem().hasFVInterpolationMethod(method_name))
47 return;
48
49 const auto method_type = NS::fvAdvectedInterpolationMethodType(interpolation_method);
50
51 InputParameters params = getFactory().getValidParams(method_type);
52 getProblem().addFVInterpolationMethod(method_type, method_name, params);
53}
54
55MooseFunctorName
56NavierStokesPhysicsBase::addPorosityScaledFunctor(const MooseFunctorName & porosity,
57 const MooseFunctorName & functor)
58{
59 const MooseFunctorName product_name = prefix() + porosity + "_times_" + functor;
60 if (getProblem().hasFunctor(product_name, /*thread_id=*/0))
61 return product_name;
62
63 // Numbers go directly in the expression. Functors get symbols because their names, such as
64 // the turbulent diffusivity 'mu_t/Sc_t', need not be valid parser identifiers.
65 std::vector<std::string> functor_names;
66 std::vector<std::string> functor_symbols;
67 std::vector<std::string> factors;
68 for (const auto & name : {porosity, functor})
70 factors.push_back(name);
71 else
72 {
73 functor_names.push_back(name);
74 functor_symbols.push_back("f" + std::to_string(functor_symbols.size()));
75 factors.push_back(functor_symbols.back());
76 }
77
78 const std::string object_type = "ParsedFunctorMaterial";
79 InputParameters params = getFactory().getValidParams(object_type);
80 assignBlocks(params, _blocks);
81 params.set<std::string>("expression") = factors[0] + " * " + factors[1];
82 params.set<std::vector<std::string>>("functor_names") = functor_names;
83 params.set<std::vector<std::string>>("functor_symbols") = functor_symbols;
84 params.set<std::string>("property_name") = product_name;
85 getProblem().addMaterial(object_type, product_name + "_material", params);
86
87 return product_name;
88}
89
92{
93 unsigned short necessary_layers = getParam<unsigned short>("ghost_layers");
94 necessary_layers = std::max(necessary_layers, getNumberAlgebraicGhostingLayersNeeded());
95
96 // Just an object that has a ghost_layers parameter
97 const std::string kernel_type = "INSFVMixingLengthReynoldsStress";
98 InputParameters params = getFactory().getValidParams(kernel_type);
99 params.template set<unsigned short>("ghost_layers") = necessary_layers;
100
101 return params;
102}
virtual void addMaterial(const std::string &material_name, const std::string &name, InputParameters &parameters)
virtual void addFVInterpolationMethod(const std::string &method_type, const std::string &name, InputParameters &parameters)
InputParameters getValidParams(const std::string &name) const
void addParamNamesToGroup(const std::string &space_delim_names, const std::string group_name)
void addParam(const std::string &name, const std::initializer_list< typename T::value_type > &value, const std::string &doc_string)
void addClassDescription(const std::string &doc_string)
T & set(const std::string &name, bool quiet_mode=false)
const std::string & name() const
static InputParameters validParams()
InputParameters getAdditionalRMParams() const override
Parameters to change or add relationship managers.
NavierStokesPhysicsBase(const InputParameters &parameters)
void addFVAdvectedInterpolationMethod(const MooseEnum &interpolation_method)
Add the FVInterpolationMethod object for an advected interpolation method if absent.
MooseFunctorName addPorosityScaledFunctor(const MooseFunctorName &porosity, const MooseFunctorName &functor)
Add, if absent, a non-AD functor material defining the product of a porosity and another functor on t...
virtual unsigned short getNumberAlgebraicGhostingLayersNeeded() const =0
Return the number of ghosting layers needed.
static InputParameters validParams()
virtual FEProblemBase & getProblem()
Factory & getFactory()
void assignBlocks(InputParameters &params, const std::vector< SubdomainName > &blocks) const
std::string prefix() const
std::vector< SubdomainName > _blocks
bool parsesToReal(const std::string &input, Real *parsed_real)
std::string fvAdvectedInterpolationMethodType(const MooseEnum &interpolation_method)
Gets the FVInterpolationMethod object type for an advected interpolation method.
Definition NSFVUtils.C:67