diff --git a/framework/doc/content/source/bcs/ADConservativeAdvectionBC.md b/framework/doc/content/source/bcs/ADConservativeAdvectionBC.md new file mode 100644 index 000000000000..e0bd55c1d53d --- /dev/null +++ b/framework/doc/content/source/bcs/ADConservativeAdvectionBC.md @@ -0,0 +1,31 @@ +# ADConservativeAdvectionBC + +## Description + +The `ADConservativeAdvectionBC` boundary condition pairs with the +[ADConservativeAdvection.md] kernel. It can be used for both Dirichlet and +"implicit" boundary conditions which use only information from the equation +systems solution vectors. Velocity must be provided, either through the +`velocity_mat_prop` parameter (implicit information) or through the +`velocity_function` parameter (Dirichlet information). Similarly, for Dirichlet +conditions, a `primal_dirichlet_value` should be supplied. Otherwise the +advected quantity will be determined from implicit information either through +the supplied `advected_quantity` or if that is not supplied, the `variable` +solution. If `primal_dirichlet_value` is supplied, then a `primal_coefficient` +material property name may be supplied which will multiply the +`primal_dirichlet_value`. + +An example of this boundary condition's use is shown in the listing below for +both an inlet and outlet condition. At the inlet (`boundary = left`) both the velocity and primal +value (the `variable` `u` in this case) are prescribed. At the outlet +(`boundary= right`) due to the absence of `primal_dirichlet_value`, the current +solution value of `u` is used. Additionally, the velocity is also determined +implicitly through `velocity_mat_prop`. + +!listing test/tests/dgkernels/passive-scalar-channel-flow/test.i block=BCs + +!syntax parameters /BCs/ADConservativeAdvectionBC + +!syntax inputs /BCs/ADConservativeAdvectionBC + +!syntax children /BCs/ADConservativeAdvectionBC diff --git a/framework/doc/content/source/dgkernels/ADDGConvection.md b/framework/doc/content/source/dgkernels/ADDGConvection.md new file mode 100644 index 000000000000..d9ce84b484b7 --- /dev/null +++ b/framework/doc/content/source/dgkernels/ADDGConvection.md @@ -0,0 +1,31 @@ +# ADDGConvection + +!syntax description /DGKernels/ADDGConvection + +This is the automatic differentiation analog of [DGConvection.md] but with a +couple distinctions: + +- The [!param](/DGKernels/ADDGConvection/velocity) parameter is a material + property instead of a constant. This allows this object's use in a + simulation where the velocity is being solved for + and/or changing spatially. Additionally, the use of a material property as + opposed to a coupled variable allows more straightforward + propagation of derivatives for automatic differentiation. +- A [!param](/DGKernels/ADDGConvection/advected_quantity) paramter is + available which allows for advecting different quantities than the `variable` + this object is acting upon + +## Example input syntax + +In this example, a field `u` is advected from a boundary condition on its left to the right boundary +with a `1 0 0` velocity. In addition to advection, the simulation is governed by +loss of `u` through diffusion out of the top +and bottom boundaries of the domain. + +!listing test/tests/dgkernels/passive-scalar-channel-flow/test.i block=DGKernels + +!syntax parameters /DGKernels/ADDGConvection + +!syntax inputs /DGKernels/ADDGConvection + +!syntax children /DGKernels/ADDGConvection diff --git a/framework/doc/content/source/kernels/ADConservativeAdvection.md b/framework/doc/content/source/kernels/ADConservativeAdvection.md new file mode 100644 index 000000000000..df9631c671de --- /dev/null +++ b/framework/doc/content/source/kernels/ADConservativeAdvection.md @@ -0,0 +1,21 @@ +# ADConservativeAdvection + +## Description + +The `ADConservativeAdvection` kernel implements the same advection term as +[ConservativeAdvection.md]. A few differences from that object are: + +- The [!param](/Kernels/ADConservativeAdvection/velocity) parameter is a material + property instead of a coupled variable. This allows more straightforward + propagation of derivatives for automatic differentiation +- No upwinding option is currently implemented. In that vein this object may be + best used within a discontinuous Galerkin scheme with [ADDGConvection.md]. +- A [!param](/Kernels/ADConservativeAdvection/advected_quantity) paramter is + available which allows for advecting different quantities than the `variable` + this object is acting upon + +!syntax parameters /Kernels/ADConservativeAdvection + +!syntax inputs /Kernels/ADConservativeAdvection + +!syntax children /Kernels/ADConservativeAdvection diff --git a/framework/doc/content/source/materials/VectorFromVariableComponentsMaterial.md b/framework/doc/content/source/materials/VectorFromVariableComponentsMaterial.md new file mode 100644 index 000000000000..449b7906d922 --- /dev/null +++ b/framework/doc/content/source/materials/VectorFromVariableComponentsMaterial.md @@ -0,0 +1,24 @@ +# VectorFromVariableComponentsMaterial + +## Description + +`VectorFromVariableComponentsMaterial` computes a vector material property with +name specified by the `vector_prop_name` parameter from coupled variable +components. The x-component is computed through the `u` coupled +variable. Optional coupled variables `v` and `w` compute the y- and z-components +respectively. + +An example of this object's use is shown in the listing below where in this case +a velocity material property is being declared. The ability to pass constants to +the coupled variables is leveraged in this example. Actual coupled variable +instances would be used in, for example, a Navier-Stokes simulation in which the +nonlinear system solves for velocity components and the vector velocity needs to +be constructed. + +!listing test/tests/dgkernels/passive-scalar-channel-flow/test.i block=Materials + +!syntax parameters /Materials/VectorFromVariableComponentsMaterial + +!syntax inputs /Materials/VectorFromVariableComponentsMaterial + +!syntax children /Materials/VectorFromVariableComponentsMaterial diff --git a/framework/include/bcs/ADConservativeAdvectionBC.h b/framework/include/bcs/ADConservativeAdvectionBC.h new file mode 100644 index 000000000000..28a13266f05a --- /dev/null +++ b/framework/include/bcs/ADConservativeAdvectionBC.h @@ -0,0 +1,45 @@ +//* This file is part of the MOOSE framework +//* https://www.mooseframework.org +//* +//* All rights reserved, see COPYRIGHT for full restrictions +//* https://github.com/idaholab/moose/blob/master/COPYRIGHT +//* +//* Licensed under LGPL 2.1, please see LICENSE for details +//* https://www.gnu.org/licenses/lgpl-2.1.html + +#pragma once + +#include "ADIntegratedBC.h" + +class Function; + +/** + * A boundary condition for when the advection term is integrated by parts. This can be used at both + * inlet and outlet boundaries for imposing both "explicit" (e.g. Dirichlet) and "implicit" (use + * interior information) boundary conditions + */ +class ADConservativeAdvectionBC : public ADIntegratedBC +{ +public: + static InputParameters validParams(); + + ADConservativeAdvectionBC(const InputParameters & parameters); + +protected: + virtual ADReal computeQpResidual() override; + + /// The velocity as a material property + const ADMaterialProperty * const _velocity_mat_prop; + + /// The velocity as a function + const Function * const _velocity_function; + + /// The advected quantity + const MooseArray & _adv_quant; + + /// Dirichlet value for the primal variable + const Function * const _primal_dirichlet; + + /// Coefficient for multiplying the primal Dirichlet value + const ADMaterialProperty & _primal_coeff; +}; diff --git a/framework/include/dgkernels/ADDGConvection.h b/framework/include/dgkernels/ADDGConvection.h new file mode 100644 index 000000000000..589832c6b563 --- /dev/null +++ b/framework/include/dgkernels/ADDGConvection.h @@ -0,0 +1,37 @@ +//* This file is part of the MOOSE framework +//* https://www.mooseframework.org +//* +//* All rights reserved, see COPYRIGHT for full restrictions +//* https://github.com/idaholab/moose/blob/master/COPYRIGHT +//* +//* Licensed under LGPL 2.1, please see LICENSE for details +//* https://www.gnu.org/licenses/lgpl-2.1.html + +#pragma once + +#include "ADDGKernel.h" + +/** + * Adds residual/Jacobian contributions for a convection term from internal faces for a + * discontinuous Galerkin formulation + */ +class ADDGConvection : public ADDGKernel +{ +public: + static InputParameters validParams(); + + ADDGConvection(const InputParameters & parameters); + +protected: + virtual ADReal computeQpResidual(Moose::DGResidualType type) override; + + /// The velocity on the element + const ADMaterialProperty & _velocity; + /// The velocity on the neighbor + const ADMaterialProperty & _velocity_neighbor; + + /// The advected quantity value on the element side of the face + const MooseArray & _adv_quant_elem; + /// The advected quantity value on the neighbor side of the face + const MooseArray & _adv_quant_neighbor; +}; diff --git a/framework/include/kernels/ADConservativeAdvection.h b/framework/include/kernels/ADConservativeAdvection.h new file mode 100644 index 000000000000..cff2d41bb8ea --- /dev/null +++ b/framework/include/kernels/ADConservativeAdvection.h @@ -0,0 +1,33 @@ +//* This file is part of the MOOSE framework +//* https://www.mooseframework.org +//* +//* All rights reserved, see COPYRIGHT for full restrictions +//* https://github.com/idaholab/moose/blob/master/COPYRIGHT +//* +//* Licensed under LGPL 2.1, please see LICENSE for details +//* https://www.gnu.org/licenses/lgpl-2.1.html + +#pragma once + +#include "ADKernel.h" + +/** + * A conservative formulation of advection, e.g. no assumptions are made about whether the velocity + * is divergence-free and the convection term is integrated by parts + */ +class ADConservativeAdvection : public ADKernel +{ +public: + static InputParameters validParams(); + + ADConservativeAdvection(const InputParameters & parameters); + +protected: + virtual ADReal computeQpResidual() override; + + /// advection velocity + const ADMaterialProperty & _velocity; + + /// advected quantity + const MooseArray & _adv_quant; +}; diff --git a/framework/include/materials/VectorFromVariableComponentsMaterial.h b/framework/include/materials/VectorFromVariableComponentsMaterial.h new file mode 100644 index 000000000000..9e2c85ded849 --- /dev/null +++ b/framework/include/materials/VectorFromVariableComponentsMaterial.h @@ -0,0 +1,39 @@ +//* This file is part of the MOOSE framework +//* https://www.mooseframework.org +//* +//* All rights reserved, see COPYRIGHT for full restrictions +//* https://github.com/idaholab/moose/blob/master/COPYRIGHT +//* +//* Licensed under LGPL 2.1, please see LICENSE for details +//* https://www.gnu.org/licenses/lgpl-2.1.html + +#pragma once + +#include "Material.h" + +/** + * Computes a vector material property from coupled variables + */ +template +class VectorFromVariableComponentsMaterialTempl : public Material +{ +public: + static InputParameters validParams(); + + VectorFromVariableComponentsMaterialTempl(const InputParameters & parameters); + +protected: + virtual void computeQpProperties() override; + + /// The velocity + GenericMaterialProperty & _vector; + /// The x-component + const GenericVariableValue & _u; + /// The y-component + const GenericVariableValue & _v; + /// The z-component + const GenericVariableValue & _w; +}; + +typedef VectorFromVariableComponentsMaterialTempl VectorFromVariableComponentsMaterial; +typedef VectorFromVariableComponentsMaterialTempl ADVectorFromVariableComponentsMaterial; diff --git a/framework/src/bcs/ADConservativeAdvectionBC.C b/framework/src/bcs/ADConservativeAdvectionBC.C new file mode 100644 index 000000000000..911a9794b96d --- /dev/null +++ b/framework/src/bcs/ADConservativeAdvectionBC.C @@ -0,0 +1,75 @@ +//* This file is part of the MOOSE framework +//* https://www.mooseframework.org +//* +//* All rights reserved, see COPYRIGHT for full restrictions +//* https://github.com/idaholab/moose/blob/master/COPYRIGHT +//* +//* Licensed under LGPL 2.1, please see LICENSE for details +//* https://www.gnu.org/licenses/lgpl-2.1.html + +#include "ADConservativeAdvectionBC.h" +#include "Function.h" + +registerMooseObject("MooseApp", ADConservativeAdvectionBC); + +InputParameters +ADConservativeAdvectionBC::validParams() +{ + InputParameters params = ADIntegratedBC::validParams(); + params.addParam( + "velocity_mat_prop", + "Velocity vector as a material property. Should be provided when we want the velocity value " + "to be determined implicitly (e.g. we don't have a Dirichlet condition)"); + params.addParam("velocity_function", + "Function describing the values of velocity on the boundary."); + params.addClassDescription("DG for convection"); + params.addParam("advected_quantity", + "An optional material property to be advected. If not " + "supplied, then the variable will be used."); + params.addParam("primal_dirichlet_value", + "The value of the primal variable on the boundary."); + params.addParam( + "primal_coefficient", + 1, + "If a primal Dirichlet value is supplied, then a coefficient may be optionally multiplied " + "that multiples the Dirichlet value"); + return params; +} + +ADConservativeAdvectionBC::ADConservativeAdvectionBC(const InputParameters & parameters) + : ADIntegratedBC(parameters), + _velocity_mat_prop(isParamValid("velocity_mat_prop") + ? &getADMaterialProperty("velocity_mat_prop") + : nullptr), + _velocity_function(isParamValid("velocity_function") ? &getFunction("velocity_function") + : nullptr), + _adv_quant(isParamValid("advected_quantity") + ? getADMaterialProperty("advected_quantity").get() + : _u), + _primal_dirichlet( + isParamValid("primal_dirichlet_value") ? &getFunction("primal_dirichlet_value") : nullptr), + _primal_coeff(getADMaterialProperty("primal_coefficient")) +{ + if (isParamSetByUser("primal_coefficient") && !_primal_dirichlet) + paramError("primal_coefficient", + "This parameter should only be provided when 'primal_dirichlet_value' is provided"); + if (static_cast(_primal_dirichlet) + isParamValid("advected_quantity") > 1) + mooseError("Only one of 'primal_dirichlet_value' or 'advected_quantity' should be provided"); + if (static_cast(_velocity_mat_prop) + static_cast(_velocity_function) != 1) + mooseError("Exactly one of 'velocity_mat_prop' or 'velocity_function' should be provided"); +} + +ADReal +ADConservativeAdvectionBC::computeQpResidual() +{ + const auto vdotn = + (_velocity_mat_prop ? (*_velocity_mat_prop)[_qp] + : ADRealVectorValue(_velocity_function->vectorValue(_t, _q_point[_qp]))) * + _normals[_qp]; + + if (_primal_dirichlet) + return _test[_i][_qp] * vdotn * _primal_dirichlet->value(_t, _q_point[_qp]) * + _primal_coeff[_qp]; + else + return _test[_i][_qp] * vdotn * _adv_quant[_qp]; +} diff --git a/framework/src/dgkernels/ADDGConvection.C b/framework/src/dgkernels/ADDGConvection.C new file mode 100644 index 000000000000..5104d45a7168 --- /dev/null +++ b/framework/src/dgkernels/ADDGConvection.C @@ -0,0 +1,69 @@ +//* This file is part of the MOOSE framework +//* https://www.mooseframework.org +//* +//* All rights reserved, see COPYRIGHT for full restrictions +//* https://github.com/idaholab/moose/blob/master/COPYRIGHT +//* +//* Licensed under LGPL 2.1, please see LICENSE for details +//* https://www.gnu.org/licenses/lgpl-2.1.html + +#include "ADDGConvection.h" + +registerMooseObject("MooseApp", ADDGConvection); + +InputParameters +ADDGConvection::validParams() +{ + InputParameters params = ADDGKernel::validParams(); + params.addRequiredParam("velocity", "Velocity vector"); + params.addClassDescription("DG for convection"); + params.addParam("advected_quantity", + "An optional material property to be advected. If not " + "supplied, then the variable will be used."); + return params; +} + +ADDGConvection::ADDGConvection(const InputParameters & parameters) + : ADDGKernel(parameters), + _velocity(getADMaterialProperty("velocity")), + _velocity_neighbor(getNeighborADMaterialProperty("velocity")), + _adv_quant_elem(isParamValid("advected_quantity") + ? getADMaterialProperty("advected_quantity").get() + : _u), + _adv_quant_neighbor(isParamValid("advected_quantity") + ? getNeighborADMaterialProperty("advected_quantity").get() + : _u_neighbor) +{ +} + +ADReal +ADDGConvection::computeQpResidual(Moose::DGResidualType type) +{ + ADReal r = 0; + + auto average = [](const auto & elem_value, const auto & neighbor_value) + { return (elem_value + neighbor_value) / 2; }; + + const auto vdotn = average(_velocity[_qp], _velocity_neighbor[_qp]) * _normals[_qp]; + + const auto face_u = [&]() + { + if (vdotn >= 0) + return _adv_quant_elem[_qp]; + else + return _adv_quant_neighbor[_qp]; + }(); + + switch (type) + { + case Moose::Element: + r += vdotn * face_u * _test[_i][_qp]; + break; + + case Moose::Neighbor: + r -= vdotn * face_u * _test_neighbor[_i][_qp]; + break; + } + + return r; +} diff --git a/framework/src/kernels/ADConservativeAdvection.C b/framework/src/kernels/ADConservativeAdvection.C new file mode 100644 index 000000000000..aad93fb8503f --- /dev/null +++ b/framework/src/kernels/ADConservativeAdvection.C @@ -0,0 +1,41 @@ +//* This file is part of the MOOSE framework +//* https://www.mooseframework.org +//* +//* All rights reserved, see COPYRIGHT for full restrictions +//* https://github.com/idaholab/moose/blob/master/COPYRIGHT +//* +//* Licensed under LGPL 2.1, please see LICENSE for details +//* https://www.gnu.org/licenses/lgpl-2.1.html + +#include "ADConservativeAdvection.h" +#include "SystemBase.h" + +registerMooseObject("MooseApp", ADConservativeAdvection); + +InputParameters +ADConservativeAdvection::validParams() +{ + InputParameters params = ADKernel::validParams(); + params.addClassDescription("Conservative form of $\\nabla \\cdot \\vec{v} u$ which in its weak " + "form is given by: $(-\\nabla \\psi_i, \\vec{v} u)$."); + params.addRequiredParam("velocity", "Velocity vector"); + params.addParam("advected_quantity", + "An optional material property to be advected. If not " + "supplied, then the variable will be used."); + return params; +} + +ADConservativeAdvection::ADConservativeAdvection(const InputParameters & parameters) + : ADKernel(parameters), + _velocity(getADMaterialProperty("velocity")), + _adv_quant(isParamValid("advected_quantity") + ? getADMaterialProperty("advected_quantity").get() + : _u) +{ +} + +ADReal +ADConservativeAdvection::computeQpResidual() +{ + return -_grad_test[_i][_qp] * _velocity[_qp] * _adv_quant[_qp]; +} diff --git a/framework/src/materials/VectorFromVariableComponentsMaterial.C b/framework/src/materials/VectorFromVariableComponentsMaterial.C new file mode 100644 index 000000000000..86551b2e7142 --- /dev/null +++ b/framework/src/materials/VectorFromVariableComponentsMaterial.C @@ -0,0 +1,48 @@ +//* This file is part of the MOOSE framework +//* https://www.mooseframework.org +//* +//* All rights reserved, see COPYRIGHT for full restrictions +//* https://github.com/idaholab/moose/blob/master/COPYRIGHT +//* +//* Licensed under LGPL 2.1, please see LICENSE for details +//* https://www.gnu.org/licenses/lgpl-2.1.html + +#include "VectorFromVariableComponentsMaterial.h" + +registerMooseObject("MooseApp", VectorFromVariableComponentsMaterial); +registerMooseObject("MooseApp", ADVectorFromVariableComponentsMaterial); + +template +InputParameters +VectorFromVariableComponentsMaterialTempl::validParams() +{ + InputParameters params = Material::validParams(); + params.addClassDescription("Computes a vector material property from coupled variables"); + params.addRequiredParam( + "vector_prop_name", "The name to give the declared vector material property"); + params.addRequiredCoupledVar("u", "x-component"); + params.addCoupledVar("v", 0, "y-component"); + params.addCoupledVar("w", 0, "z-component"); + return params; +} + +template +VectorFromVariableComponentsMaterialTempl::VectorFromVariableComponentsMaterialTempl( + const InputParameters & parameters) + : Material(parameters), + _vector(declareGenericProperty("vector_prop_name")), + _u(coupledGenericValue("u")), + _v(isCoupled("v") ? coupledGenericValue("v") : genericZeroValue()), + _w(isCoupled("w") ? coupledGenericValue("w") : genericZeroValue()) +{ +} + +template +void +VectorFromVariableComponentsMaterialTempl::computeQpProperties() +{ + _vector[_qp] = GenericRealVectorValue{_u[_qp], _v[_qp], _w[_qp]}; +} + +template class VectorFromVariableComponentsMaterialTempl; +template class VectorFromVariableComponentsMaterialTempl; diff --git a/test/include/dgkernels/ADDGConvection.h b/test/include/dgkernels/ADDGConvection.h deleted file mode 100644 index 8d26ad1b9662..000000000000 --- a/test/include/dgkernels/ADDGConvection.h +++ /dev/null @@ -1,25 +0,0 @@ -//* This file is part of the MOOSE framework -//* https://www.mooseframework.org -//* -//* All rights reserved, see COPYRIGHT for full restrictions -//* https://github.com/idaholab/moose/blob/master/COPYRIGHT -//* -//* Licensed under LGPL 2.1, please see LICENSE for details -//* https://www.gnu.org/licenses/lgpl-2.1.html - -#pragma once - -#include "ADDGKernel.h" - -class ADDGConvection : public ADDGKernel -{ -public: - static InputParameters validParams(); - - ADDGConvection(const InputParameters & parameters); - -protected: - ADReal computeQpResidual(Moose::DGResidualType type) override; - - RealVectorValue _velocity; -}; diff --git a/test/src/dgkernels/ADDGConvection.C b/test/src/dgkernels/ADDGConvection.C deleted file mode 100644 index e3c94675b2d1..000000000000 --- a/test/src/dgkernels/ADDGConvection.C +++ /dev/null @@ -1,53 +0,0 @@ -//* This file is part of the MOOSE framework -//* https://www.mooseframework.org -//* -//* All rights reserved, see COPYRIGHT for full restrictions -//* https://github.com/idaholab/moose/blob/master/COPYRIGHT -//* -//* Licensed under LGPL 2.1, please see LICENSE for details -//* https://www.gnu.org/licenses/lgpl-2.1.html - -#include "ADDGConvection.h" - -registerMooseObject("MooseTestApp", ADDGConvection); - -InputParameters -ADDGConvection::validParams() -{ - InputParameters params = ADDGKernel::validParams(); - params.addRequiredParam("velocity", "Velocity vector"); - params.addClassDescription("DG upwinding for the convection"); - return params; -} - -ADDGConvection::ADDGConvection(const InputParameters & parameters) - : ADDGKernel(parameters), _velocity(getParam("velocity")) -{ -} - -ADReal -ADDGConvection::computeQpResidual(Moose::DGResidualType type) -{ - ADReal r = 0; - - Real vdotn = _velocity * _normals[_qp]; - - switch (type) - { - case Moose::Element: - if (vdotn >= 0) - r += vdotn * _u[_qp] * _test[_i][_qp]; - else - r += vdotn * _u_neighbor[_qp] * _test[_i][_qp]; - break; - - case Moose::Neighbor: - if (vdotn >= 0) - r -= vdotn * _u[_qp] * _test_neighbor[_i][_qp]; - else - r -= vdotn * _u_neighbor[_qp] * _test_neighbor[_i][_qp]; - break; - } - - return r; -} diff --git a/test/tests/dgkernels/ad_dg_convection/ad_dg_convection.i b/test/tests/dgkernels/ad_dg_convection/ad_dg_convection.i index f3c7e4a8f88c..3b6f44f173cf 100644 --- a/test/tests/dgkernels/ad_dg_convection/ad_dg_convection.i +++ b/test/tests/dgkernels/ad_dg_convection/ad_dg_convection.i @@ -23,7 +23,7 @@ [convection] type = ADDGConvection variable = u - velocity = '1 0 0' + velocity = velocity [] [] @@ -37,6 +37,14 @@ [] [] +[Materials] + [vel] + type = ADGenericConstantVectorMaterial + prop_names = 'velocity' + prop_values = '1 0 0' + [] +[] + [Executioner] type = Transient solve_type = NEWTON diff --git a/test/tests/dgkernels/passive-scalar-channel-flow/gold/test_out.e b/test/tests/dgkernels/passive-scalar-channel-flow/gold/test_out.e new file mode 100644 index 000000000000..04ad666cb1d8 Binary files /dev/null and b/test/tests/dgkernels/passive-scalar-channel-flow/gold/test_out.e differ diff --git a/test/tests/dgkernels/passive-scalar-channel-flow/test.i b/test/tests/dgkernels/passive-scalar-channel-flow/test.i new file mode 100644 index 000000000000..a2594531c3ab --- /dev/null +++ b/test/tests/dgkernels/passive-scalar-channel-flow/test.i @@ -0,0 +1,97 @@ +[Mesh] + [gen] + type = GeneratedMeshGenerator + dim = 2 + xmin = 0 + xmax = 10 + ymin = -1 + ymax = 1 + nx = 20 + ny = 4 + [] +[] + +[Variables] + [u] + family = MONOMIAL + [] +[] + +[Kernels] + [convection] + type = ADConservativeAdvection + variable = u + velocity = 'velocity' + [] + [diffusion] + type = MatDiffusion + variable = u + diffusivity = 1 + [] +[] + +[DGKernels] + [convection] + type = ADDGConvection + variable = u + velocity = 'velocity' + [] + [diffusion] + type = DGDiffusion + variable = u + sigma = 6 + epsilon = -1 + diff = 1 + [] +[] + +[Functions] + [v_inlet] + type = ParsedVectorFunction + expression_x = '1' + [] +[] + +[BCs] + [u_walls] + type = DGFunctionDiffusionDirichletBC + boundary = 'bottom top' + variable = u + sigma = 6 + epsilon = -1 + function = '0' + diff = 1 + [] + [u_in] + type = ADConservativeAdvectionBC + boundary = 'left' + variable = u + velocity_function = v_inlet + primal_dirichlet_value = 1 + [] + [u_out] + type = ADConservativeAdvectionBC + boundary = 'right' + variable = u + velocity_mat_prop = 'velocity' + [] +[] + +[Materials] + [vel] + type = ADVectorFromVariableComponentsMaterial + vector_prop_name = 'velocity' + u = 1 + v = 0 + [] +[] + +[Executioner] + type = Steady + solve_type = 'NEWTON' + nl_rel_tol = 1e-12 +[] + +[Outputs] + exodus = true +[] diff --git a/test/tests/dgkernels/passive-scalar-channel-flow/tests b/test/tests/dgkernels/passive-scalar-channel-flow/tests new file mode 100644 index 000000000000..9a6e46f8bdd6 --- /dev/null +++ b/test/tests/dgkernels/passive-scalar-channel-flow/tests @@ -0,0 +1,10 @@ +[Tests] + issues = '#24055' + design = 'ADConservativeAdvection.md ADDGConvection.md ADConservativeAdvectionBC.md MatDiffusion.md DGDiffusion.md DGFunctionDiffusionDirichletBC.md VectorFromVariableComponentsMaterial.md' + [test] + type = Exodiff + input = test.i + exodiff = test_out.e + requirement = 'The system shall be ablve to solve an advection-diffusion problem discretized with discontinuous Galerkin, using some hand-coded Jacobians and automatic differentiation Jacobians.' + [] +[]