Skip to content

Commit

Permalink
Create function-based inlet and outlet BCs, and fix PrecursorAction. F…
Browse files Browse the repository at this point in the history
…ixes arfc#183
  • Loading branch information
smpark7 committed Feb 4, 2022
1 parent a92b524 commit 87a0cec
Show file tree
Hide file tree
Showing 3 changed files with 77 additions and 5 deletions.
22 changes: 22 additions & 0 deletions include/bcs/PostprocessorFunctionInflowBC.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
#pragma once

#include "IntegratedBC.h"

class PostprocessorFunctionInflowBC : public IntegratedBC
{
public:
PostprocessorFunctionInflowBC(const InputParameters & parameters);

static InputParameters validParams();

protected:
virtual Real computeQpResidual() override;
virtual Real computeQpJacobian() override;

const Function & _vel_x_func;
const Function & _vel_y_func;
const Function & _vel_z_func;
const PostprocessorValue & _pp_value;
const Real & _scale;
const Real & _offset;
};
13 changes: 8 additions & 5 deletions src/actions/PrecursorAction.C
Original file line number Diff line number Diff line change
Expand Up @@ -356,15 +356,18 @@ PrecursorAction::addInflowBC(const std::string & var_name)
else
{
// if using prespecified functions
InputParameters params = _factory.getValidParams("PostprocessorInflowBC");
InputParameters params = _factory.getValidParams("PostprocessorFunctionInflowBC");
params.set<NonlinearVariableName>("variable") = var_name;
params.set<std::vector<BoundaryName>>("boundary") =
getParam<std::vector<BoundaryName>>("inlet_boundaries");
params.set<FunctionName>("vel_x_func") = getParam<FunctionName>("u_func");
params.set<FunctionName>("vel_y_func") = getParam<FunctionName>("v_func");
params.set<FunctionName>("vel_z_func") = getParam<FunctionName>("w_func");
params.set<PostprocessorName>("postprocessor") =
"Inlet_Average_" + var_name + "_" + _object_suffix;

std::string bc_name = "PostprocessorInflowBC_" + var_name + "_" + _object_suffix;
_problem->addBoundaryCondition("PostprocessorInflowBC", bc_name, params);
std::string bc_name = "PostprocessorFunctionInflowBC_" + var_name + "_" + _object_suffix;
_problem->addBoundaryCondition("PostprocessorFunctionInflowBC", bc_name, params);
}
}

Expand Down Expand Up @@ -395,9 +398,9 @@ PrecursorAction::addOutletPostprocessor(const std::string & var_name)
// looping precursors requires connecting outlet of core problem
// to the inlet of the loop subproblem. In addition, the outlet of the
// loop must be connected to the core problem.
if (getParam<bool>("constant_velocity_values"))
if (getParam<bool>("constant_velocity_values") || !isParamValid("uvel"))
{
// Area-averaged precursor conc at outlet for constant and uniform flow
// Area-averaged precursor conc at outlet for constant and uniform flow, or prespecified flow function
std::string postproc_name = "Outlet_Average_" + var_name + "_" + _object_suffix;
InputParameters params = _factory.getValidParams("SideAverageValue");
std::vector<VariableName> varvec(1);
Expand Down
47 changes: 47 additions & 0 deletions src/bcs/PostprocessorFunctionInflowBC.C
Original file line number Diff line number Diff line change
@@ -0,0 +1,47 @@
#include "PostprocessorFunctionInflowBC.h"
#include "Function.h"

registerMooseObject("MoltresApp", PostprocessorFunctionInflowBC);

InputParameters
PostprocessorFunctionInflowBC::validParams()
{
InputParameters params = IntegratedBC::validParams();
params.addRequiredParam<FunctionName>("vel_x_func", "The x velocity function");
params.addRequiredParam<FunctionName>("vel_y_func", "The y velocity function");
params.addRequiredParam<FunctionName>("vel_z_func", "The z velocity function");
params.addRequiredParam<PostprocessorName>(
"postprocessor", "The postprocessor from which to derive the inlet concentration.");
params.addParam<Real>("scale", 1, "The amount to scale the postprocessor value by");
params.addParam<Real>("offset", 0, "The amount to offset the scaled postprocessor by");
return params;
}

PostprocessorFunctionInflowBC::PostprocessorFunctionInflowBC(const InputParameters & parameters)
: IntegratedBC(parameters),
_vel_x_func(getFunction("vel_x_func")),
_vel_y_func(getFunction("vel_y_func")),
_vel_z_func(getFunction("vel_z_func")),
_pp_value(getPostprocessorValue("postprocessor")),
_scale(getParam<Real>("scale")),
_offset(getParam<Real>("offset"))
{
}

Real
PostprocessorFunctionInflowBC::computeQpResidual()
{
RealVectorValue v = {_vel_x_func.value(_t, _q_point[_qp]),
_vel_y_func.value(_t, _q_point[_qp]),
_vel_z_func.value(_t, _q_point[_qp])};
Real vdotn = v * _normals[_qp];
Real inlet_conc = _scale * _pp_value + _offset;

return _test[_i][_qp] * inlet_conc * vdotn;
}

Real
PostprocessorFunctionInflowBC::computeQpJacobian()
{
return 0.;
}

0 comments on commit 87a0cec

Please sign in to comment.