15#include "libmesh/mesh_base.h"
16#include "libmesh/elem_range.h"
17#include "libmesh/numeric_vector.h"
18#include "libmesh/mesh_tools.h"
36 params.suppressParameter<
bool>(
"force_preic");
38 params.addParam<NonlinearVariableName>(
"variable",
NS::pressure,
"Pressure variable");
39 params.addParam<PostprocessorName>(
"phi0",
"0",
"Pressure pin value");
40 MooseEnum pin_types(
"point-value average");
41 params.addRequiredParam<
MooseEnum>(
"pin_type", pin_types,
"How to pin the pressure");
42 params.addParam<Point>(
44 "The XYZ coordinates of a point inside an element where the pinned value shall be enforced.");
45 params.addParam<PostprocessorName>(
46 "pressure_average",
"A postprocessor that computes the average of the pressure variable");
48 params.addClassDescription(
"Pins the pressure after a solve");
49 params.registerBase(
"Corrector");
59 _p(
UserObject::_subproblem.getVariable(0, getParam<NonlinearVariableName>(
"variable"))),
60 _p0(getPostprocessorValue(
"phi0")),
61 _pressure_pin_type(getParam<
MooseEnum>(
"pin_type")),
62 _pressure_pin_point(_pressure_pin_type ==
"point-value" ? getParam<Point>(
"point")
64 _current_pressure_average(
65 _pressure_pin_type ==
"average" ? &getPostprocessorValue(
"pressure_average") : nullptr)
72 mooseAssert(!Threads::in_threads,
"paramError is not safe in threaded mode");
80 "Pressure average postprocessor must include the pin execute_on flags");
96 if (MooseUtils::absoluteFuzzyEqual(point_value, 0.0))
98 auto pl =
_mesh.sub_point_locator();
99 pl->enable_out_of_mesh_mode();
102 auto elem_id = elem ? elem->id() : DofObject::invalid_id;
105 if (elem_id == DofObject::invalid_id)
108 pl->disable_out_of_mesh_mode();
111 pin_value =
_p0 - point_value;
118 std::set<dof_id_type> local_dofs;
120 for (
const auto dof : local_dofs)
121 sln.add(dof, pin_value);
const ExecFlagType EXEC_TIMESTEP_END
const ExecFlagType EXEC_TIMESTEP_BEGIN
const ExecFlagType EXEC_LINEAR
const ExecFlagType EXEC_NONE
registerMooseObject("NavierStokesApp", NSPressurePin)
registerMooseObjectRenamed("NavierStokesApp", NSFVPressurePin, "01/19/2025 00:00", NSPressurePin)
static InputParameters validParams()
void removeAvailableFlags(const ExecFlagType &flag, Args... flags)
const UserObject & getUserObjectBase(const std::string &name, const THREAD_ID tid=0) const
static InputParameters validParams()
void paramError(const std::string ¶m, Args... args) const
void mooseError(Args &&... args) const
unsigned int number() const
bool isValueSet(const std::string &value) const
This user-object corrects the pressure.
NSPressurePin(const InputParameters ¶ms)
const PostprocessorValue & _p0
Value of the pressure pin.
const Point _pressure_pin_point
If using point-value pressure pin, the point at which to apply the pin.
const PostprocessorValue *const _current_pressure_average
If using average pressure pin, provides the average pressure value.
MeshBase & _mesh
LibMesh mesh class for the current simulation mesh.
const MooseVariableFieldBase & _p
The thread 0 copy of the pressure variable.
const MooseEnum _pressure_pin_type
Pressure pin type.
virtual void initialSetup() override
static InputParameters validParams()
virtual void execute() override
const ExecFlagEnum & getExecuteOnEnum() const
NumericVector< Number > & solution()
virtual libMesh::System & system()=0
FEProblemBase & _fe_problem
Number point_value(unsigned int var, const Point &p, const bool insist_on_success=true, const NumericVector< Number > *sol=nullptr) const
void local_dof_indices(const unsigned int var, std::set< dof_id_type > &var_indices) const
static const std::string pressure