Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
## Description

The `ADConservativeAdvectionBC` boundary condition pairs with the
[ADConservativeAdvection.md] kernel. It can be used for both Dirichlet and
[ConservativeAdvection.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
Expand Down
21 changes: 0 additions & 21 deletions framework/doc/content/source/kernels/ADConservativeAdvection.md

This file was deleted.

Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

!syntax description /Materials/CoupledGradientMaterial

This material provides the ability to create a material property from the gradient of a variable. In addition, the gradient can be scaled with a scalar material property allows for additional flexibility. This gradient material property can then be used in kernels such as [ADConservativeAdvection](/ADConservativeAdvection.md).
This material provides the ability to create a material property from the gradient of a variable. In addition, the gradient can be scaled with a scalar material property allows for additional flexibility. This gradient material property can then be used in kernels such as [ConservativeAdvection](/ConservativeAdvection.md).

## Example Input File Syntax

Expand Down
11 changes: 11 additions & 0 deletions framework/include/interfaces/Coupleable.h
Original file line number Diff line number Diff line change
Expand Up @@ -221,6 +221,17 @@ class Coupleable
const GenericVariableValue<is_ad> & coupledGenericValue(const std::string & var_name,
unsigned int comp = 0) const;

/**
* Returns value of a coupled vector variable for use in templated automatic differentiation
* classes
* @param var_name Name of coupled variable
* @param comp Component number for vector of coupled variables
* @return Reference to a GenericVariableVectorValue for the coupled variable
*/
template <bool is_ad>
const GenericVectorVariableValue<is_ad> & coupledGenericVectorValue(const std::string & var_name,
unsigned int comp = 0) const;

/**
* Returns the values for all of a coupled variable's components for use in templated automatic
* differentiation classes
Expand Down
33 changes: 0 additions & 33 deletions framework/include/kernels/ADConservativeAdvection.h

This file was deleted.

31 changes: 23 additions & 8 deletions framework/include/kernels/ConservativeAdvection.h
Original file line number Diff line number Diff line change
Expand Up @@ -9,27 +9,33 @@

#pragma once

#include "Kernel.h"
#include "GenericKernel.h"
#include "libmesh/dense_vector.h"

/**
* Advection of the variable by the velocity provided by the user.
* Options for numerical stabilization are: none; full upwinding
*/
class ConservativeAdvection : public Kernel
template <bool is_ad>
class ConservativeAdvectionTempl : public GenericKernel<is_ad>
{
public:
static InputParameters generalParams();
static InputParameters validParams();

ConservativeAdvection(const InputParameters & parameters);
ConservativeAdvectionTempl(const InputParameters & parameters);

protected:
virtual Real computeQpResidual() override;
virtual GenericReal<is_ad> computeQpResidual() override;
virtual Real computeQpJacobian() override;
virtual void computeResidual() override;
virtual void computeJacobian() override;

/// advection velocity
const VectorVariableValue & _velocity;
const MooseArray<GenericRealVectorValue<is_ad>> * _velocity;

/// advected quantity
const MooseArray<GenericReal<is_ad>> & _adv_quant;

/// enum to make the code clearer
enum class JacRes
Expand All @@ -42,17 +48,26 @@ class ConservativeAdvection : public Kernel
const enum class UpwindingType { none, full } _upwinding;

/// Nodal value of u, used for full upwinding
const VariableValue & _u_nodal;
const GenericVariableValue<is_ad> & _u_nodal;

/// In the full-upwind scheme, whether a node is an upwind node
std::vector<bool> _upwind_node;

/// In the full-upwind scheme d(total_mass_out)/d(variable_at_node_i)
std::vector<Real> _dtotal_mass_out;
std::vector<GenericReal<is_ad>> _dtotal_mass_out;

/// Returns - _grad_test * velocity
Real negSpeedQp() const;
GenericReal<is_ad> negSpeedQp() const;

/// Calculates the fully-upwind Residual and Jacobian (depending on res_or_jac)
void fullUpwind(JacRes res_or_jac);

usingGenericKernelMembers;

private:
/// A container for holding the local residuals
libMesh::DenseVector<GenericReal<is_ad>> _my_local_re;
};

typedef ConservativeAdvectionTempl<false> ConservativeAdvection;
typedef ConservativeAdvectionTempl<true> ADConservativeAdvection;
1 change: 1 addition & 0 deletions framework/include/kernels/GenericKernel.h
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,7 @@ class GenericKernel<true> : public ADKernel
using GenericKernel<is_ad>::_u; \
using GenericKernel<is_ad>::_phi; \
using GenericKernel<is_ad>::_test; \
using GenericKernel<is_ad>::_grad_test; \
using GenericKernel<is_ad>::_q_point; \
using GenericKernel<is_ad>::_var; \
using GenericKernel<is_ad>::getVar; \
Expand Down
2 changes: 2 additions & 0 deletions framework/include/utils/MooseTypes.h
Original file line number Diff line number Diff line change
Expand Up @@ -657,6 +657,8 @@ using GenericRankFourTensor = Moose::GenericType<RankFourTensor, is_ad>;
template <bool is_ad>
using GenericVariableValue = Moose::GenericType<VariableValue, is_ad>;
template <bool is_ad>
using GenericVectorVariableValue = Moose::GenericType<VectorVariableValue, is_ad>;
template <bool is_ad>
using GenericVariableGradient = Moose::GenericType<VariableGradient, is_ad>;
template <bool is_ad>
using GenericVariableSecond = Moose::GenericType<VariableSecond, is_ad>;
Expand Down
21 changes: 21 additions & 0 deletions framework/include/variables/MooseVariableField.h
Original file line number Diff line number Diff line change
Expand Up @@ -373,6 +373,9 @@ class MooseVariableField : public MooseVariableFieldBase,
virtual const MooseArray<libMesh::Number> & dofValuesDuDotDotDu() const = 0;
virtual const MooseArray<libMesh::Number> & dofValuesDuDotDotDuNeighbor() const = 0;

template <bool is_ad>
const MooseArray<GenericReal<is_ad>> & genericDofValues() const;

/**
* tag values getters
*/
Expand Down Expand Up @@ -409,6 +412,24 @@ class MooseVariableField : public MooseVariableFieldBase,
mutable ADReal _ad_real_dummy = 0;
};

template <>
template <>
const MooseArray<Real> & MooseVariableField<Real>::genericDofValues<false>() const;
template <>
template <>
const MooseArray<Real> & MooseVariableField<RealVectorValue>::genericDofValues<false>() const;
template <>
template <>
const MooseArray<Real> & MooseVariableField<RealEigenVector>::genericDofValues<false>() const;

template <typename OutputType>
template <bool is_ad>
const MooseArray<GenericReal<is_ad>> &
MooseVariableField<OutputType>::genericDofValues() const
{
return adDofValues();
}

#define usingMooseVariableFieldMembers \
usingMooseVariableFieldBaseMembers; \
using MooseVariableField<OutputType>::_time_integrator; \
Expand Down
14 changes: 14 additions & 0 deletions framework/src/interfaces/Coupleable.C
Original file line number Diff line number Diff line change
Expand Up @@ -478,6 +478,20 @@ Coupleable::coupledGenericValue<true>(const std::string & var_name, unsigned int
return adCoupledValue(var_name, comp);
}

template <>
const GenericVectorVariableValue<false> &
Coupleable::coupledGenericVectorValue<false>(const std::string & var_name, unsigned int comp) const
{
return coupledVectorValue(var_name, comp);
}

template <>
const GenericVectorVariableValue<true> &
Coupleable::coupledGenericVectorValue<true>(const std::string & var_name, unsigned int comp) const
{
return adCoupledVectorValue(var_name, comp);
}

const VariableValue &
Coupleable::coupledValue(const std::string & var_name, unsigned int comp) const
{
Expand Down
40 changes: 0 additions & 40 deletions framework/src/kernels/ADConservativeAdvection.C

This file was deleted.

Loading