-
Notifications
You must be signed in to change notification settings - Fork 8
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #12 from smpark7/function-flow
Add support for function-based velocity advection on constant and higher order discontinuous variables
- Loading branch information
Showing
9 changed files
with
240 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,16 @@ | ||
# PostprocessorPenaltyDirichletBC | ||
|
||
!syntax description /BCs/PostprocessorPenaltyDirichletBC | ||
|
||
## Overview | ||
|
||
Enforces a Postprocessor Dirichlet boundary condition in a weak sense by penalizing differences | ||
between the current solution and the Dirichlet data. See | ||
[PenaltyDirichletBC](https://mooseframework.inl.gov/source/bcs/PenaltyDirichletBC.html) for more | ||
information on penalty BCs. | ||
|
||
!syntax parameters /BCs/PostprocessorPenaltyDirichletBC | ||
|
||
!syntax inputs /BCs/PostprocessorPenaltyDirichletBC | ||
|
||
!syntax children /BCs/PostprocessorPenaltyDirichletBC |
14 changes: 14 additions & 0 deletions
14
doc/content/source/bcs/PostprocessorVelocityFunctionInflowBC.md
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,14 @@ | ||
# PostprocessorVelocityFunctionInflowBC | ||
|
||
!syntax description /BCs/PostprocessorVelocityFunctionInflowBC | ||
|
||
## Overview | ||
|
||
Sets inflow boundary conditions for a problem with function-based velocity profile and inlet | ||
concentration postprocessor. | ||
|
||
!syntax parameters /BCs/PostprocessorVelocityFunctionInflowBC | ||
|
||
!syntax inputs /BCs/PostprocessorVelocityFunctionInflowBC | ||
|
||
!syntax children /BCs/PostprocessorVelocityFunctionInflowBC |
15 changes: 15 additions & 0 deletions
15
doc/content/source/kernels/VelocityFunctionConservativeAdvection.md
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,15 @@ | ||
# VelocityFunctionConservativeAdvection | ||
|
||
!syntax description /Kernels/VelocityFunctionConservativeAdvection | ||
|
||
## Overview | ||
|
||
Implements a variant of | ||
[ConservativeAdvection](https://mooseframework.inl.gov/source/kernels/ConservativeAdvection.html) | ||
with the velocity set by a user-provided function. | ||
|
||
!syntax parameters /Kernels/VelocityFunctionConservativeAdvection | ||
|
||
!syntax inputs /Kernels/VelocityFunctionConservativeAdvection | ||
|
||
!syntax children /Kernels/VelocityFunctionConservativeAdvection |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,23 @@ | ||
#pragma once | ||
|
||
#include "IntegratedBC.h" | ||
|
||
/** | ||
* Weakly enforce a Dirichlet BC using a penalty term similar to PenaltyDirichletBC, but with a | ||
* postprocessor value instead of a scalar. | ||
*/ | ||
class PostprocessorPenaltyDirichletBC : public IntegratedBC | ||
{ | ||
public: | ||
static InputParameters validParams(); | ||
|
||
PostprocessorPenaltyDirichletBC(const InputParameters & parameters); | ||
|
||
protected: | ||
virtual Real computeQpResidual() override; | ||
virtual Real computeQpJacobian() override; | ||
|
||
private: | ||
Real _penalty; | ||
const PostprocessorValue & _postprocessor; | ||
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,26 @@ | ||
#pragma once | ||
|
||
#include "IntegratedBC.h" | ||
|
||
/** | ||
* Computes the inflow boundary condition contribution with inlet concentration set by a | ||
* postprocessor, and the velocity set by functions. | ||
*/ | ||
class PostprocessorVelocityFunctionInflowBC : public IntegratedBC | ||
{ | ||
public: | ||
PostprocessorVelocityFunctionInflowBC(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; | ||
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,24 @@ | ||
#pragma once | ||
|
||
#include "Kernel.h" | ||
|
||
/** | ||
* Computes the conservative advection residual and jacobian contributions with velocity | ||
* set by functions. | ||
*/ | ||
class VelocityFunctionConservativeAdvection : public Kernel | ||
{ | ||
public: | ||
VelocityFunctionConservativeAdvection(const InputParameters & parameters); | ||
|
||
static InputParameters validParams(); | ||
|
||
protected: | ||
virtual Real computeQpResidual() override; | ||
virtual Real computeQpJacobian() override; | ||
|
||
// velocity functions | ||
const Function & _vel_x_func; | ||
const Function & _vel_y_func; | ||
const Function & _vel_z_func; | ||
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,36 @@ | ||
#include "PostprocessorPenaltyDirichletBC.h" | ||
|
||
registerMooseObject("SquirrelApp", PostprocessorPenaltyDirichletBC); | ||
|
||
InputParameters | ||
PostprocessorPenaltyDirichletBC::validParams() | ||
{ | ||
InputParameters params = IntegratedBC::validParams(); | ||
params.addRequiredParam<Real>("penalty", "Penalty scalar"); | ||
params.addRequiredParam<PostprocessorName>("postprocessor", | ||
"Postprocessor to set the boundary value of the variable"); | ||
params.addClassDescription("Enforces a Dirichlet boundary condition " | ||
"in a weak sense by penalizing differences between the current " | ||
"solution and the Dirichlet postprocessor value."); | ||
return params; | ||
} | ||
|
||
PostprocessorPenaltyDirichletBC::PostprocessorPenaltyDirichletBC( | ||
const InputParameters & parameters) | ||
: IntegratedBC(parameters), | ||
_penalty(getParam<Real>("penalty")), | ||
_postprocessor(getPostprocessorValue("postprocessor")) | ||
{ | ||
} | ||
|
||
Real | ||
PostprocessorPenaltyDirichletBC::computeQpResidual() | ||
{ | ||
return _penalty * _test[_i][_qp] * (-_postprocessor + _u[_qp]); | ||
} | ||
|
||
Real | ||
PostprocessorPenaltyDirichletBC::computeQpJacobian() | ||
{ | ||
return _penalty * _phi[_j][_qp] * _test[_i][_qp]; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,45 @@ | ||
#include "PostprocessorVelocityFunctionInflowBC.h" | ||
|
||
registerMooseObject("SquirrelApp", PostprocessorVelocityFunctionInflowBC); | ||
|
||
InputParameters | ||
PostprocessorVelocityFunctionInflowBC::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; | ||
} | ||
|
||
PostprocessorVelocityFunctionInflowBC::PostprocessorVelocityFunctionInflowBC( | ||
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 | ||
PostprocessorVelocityFunctionInflowBC::computeQpResidual() | ||
{ | ||
RealVectorValue velocity = {_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 inlet_conc = _scale * _pp_value + _offset; | ||
return _test[_i][_qp] * inlet_conc * velocity * _normals[_qp]; | ||
} | ||
|
||
Real | ||
PostprocessorVelocityFunctionInflowBC::computeQpJacobian() | ||
{ | ||
return 0.; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,41 @@ | ||
#include "VelocityFunctionConservativeAdvection.h" | ||
#include "Function.h" | ||
|
||
registerMooseObject("SquirrelApp", VelocityFunctionConservativeAdvection); | ||
|
||
InputParameters | ||
VelocityFunctionConservativeAdvection::validParams() | ||
{ | ||
InputParameters params = Kernel::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"); | ||
return params; | ||
} | ||
|
||
VelocityFunctionConservativeAdvection::VelocityFunctionConservativeAdvection( | ||
const InputParameters & parameters) | ||
: Kernel(parameters), | ||
_vel_x_func(getFunction("vel_x_func")), | ||
_vel_y_func(getFunction("vel_y_func")), | ||
_vel_z_func(getFunction("vel_z_func")) | ||
{ | ||
} | ||
|
||
Real | ||
VelocityFunctionConservativeAdvection::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])}; | ||
return -_grad_test[_i][_qp] * v * _u[_qp]; | ||
} | ||
|
||
Real | ||
VelocityFunctionConservativeAdvection::computeQpJacobian() | ||
{ | ||
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])}; | ||
return -_grad_test[_i][_qp] * v * _phi[_j][_qp]; | ||
} |