Skip to content
Permalink
Browse files

Merge pull request #13359 from cticenhour/interface-kernels-refactor

Vector interface kernel
  • Loading branch information...
lindsayad committed May 24, 2019
2 parents 2d0a3a4 + df60826 commit 3ca651dd48afaa252e127d48115c81d103434f7b
@@ -10,246 +10,127 @@
#pragma once

// local includes
#include "MooseArray.h"
#include "MooseObject.h"
#include "BoundaryRestrictable.h"
#include "SetupInterface.h"
#include "TransientInterface.h"
#include "UserObjectInterface.h"
#include "NeighborCoupleableMooseVariableDependencyIntermediateInterface.h"
#include "FunctionInterface.h"
#include "Restartable.h"
#include "MeshChangedInterface.h"
#include "TwoMaterialPropertyInterface.h"
#include "TaggingInterface.h"
#include "InterfaceKernelBase.h"

#define TemplateVariableValue typename OutputTools<T>::VariableValue
#define TemplateVariableGradient typename OutputTools<T>::VariableGradient
#define TemplateVariablePhiValue typename OutputTools<T>::VariablePhiValue
#define TemplateVariablePhiGradient typename OutputTools<T>::VariablePhiGradient
#define TemplateVariableTestValue typename OutputTools<T>::VariableTestValue
#define TemplateVariableTestGradient typename OutputTools<T>::VariableTestGradient

// Forward Declarations
class InterfaceKernel;
template <typename T>
class InterfaceKernelTempl;

typedef InterfaceKernelTempl<Real> InterfaceKernel;
typedef InterfaceKernelTempl<RealVectorValue> VectorInterfaceKernel;

template <>
InputParameters validParams<InterfaceKernel>();

template <>
InputParameters validParams<VectorInterfaceKernel>();

/**
* InterfaceKernel is responsible for interfacing physics across subdomains
* InterfaceKernel and VectorInterfaceKernel is responsible for interfacing physics across
* subdomains
*/

class InterfaceKernel : public MooseObject,
public BoundaryRestrictable,
public SetupInterface,
public TransientInterface,
public FunctionInterface,
public UserObjectInterface,
public NeighborCoupleableMooseVariableDependencyIntermediateInterface,
public NeighborMooseVariableInterface<Real>,
public Restartable,
public MeshChangedInterface,
public TwoMaterialPropertyInterface,
public TaggingInterface
template <typename T>
class InterfaceKernelTempl : public InterfaceKernelBase, public NeighborMooseVariableInterface<T>
{
public:
InterfaceKernel(const InputParameters & parameters);
InterfaceKernelTempl(const InputParameters & parameters);

/// The master variable that this interface kernel operates on
MooseVariable & variable() const;
virtual MooseVariableFE<T> & variable() const override { return _var; }

/// The neighbor variable number that this interface kernel operates on
const MooseVariable & neighborVariable() const;

/// Return a reference to the subproblem.
SubProblem & subProblem();
virtual const MooseVariableFE<T> & neighborVariable() const override { return _neighbor_var; }

/**
* Using the passed DGResidual type, selects the correct test function space and residual block,
* and then calls computeQpResidual
*/
virtual void computeElemNeighResidual(Moose::DGResidualType type);
virtual void computeElemNeighResidual(Moose::DGResidualType type) override;

/**
* Using the passed DGJacobian type, selects the correct test function and trial function spaces
* and
* jacobian block, and then calls computeQpJacobian
*/
virtual void computeElemNeighJacobian(Moose::DGJacobianType type);
virtual void computeElemNeighJacobian(Moose::DGJacobianType type) override;

/**
* Using the passed DGJacobian type, selects the correct test function and trial function spaces
* and
* jacobian block, and then calls computeQpOffDiagJacobian with the passed jvar
*/
virtual void computeOffDiagElemNeighJacobian(Moose::DGJacobianType type, unsigned int jvar);
virtual void computeOffDiagElemNeighJacobian(Moose::DGJacobianType type,
unsigned int jvar) override;

/// Selects the correct Jacobian type and routine to call for the master variable jacobian
virtual void computeElementOffDiagJacobian(unsigned int jvar);
virtual void computeElementOffDiagJacobian(unsigned int jvar) override;

/// Selects the correct Jacobian type and routine to call for the slave variable jacobian
virtual void computeNeighborOffDiagJacobian(unsigned int jvar);
virtual void computeNeighborOffDiagJacobian(unsigned int jvar) override;

/// Computes the residual for the current side.
virtual void computeResidual();
virtual void computeResidual() override;

/// Computes the jacobian for the current side.
virtual void computeJacobian();
virtual void computeJacobian() override;

protected:
/// Compute residuals at quadrature points
virtual Real computeQpResidual(Moose::DGResidualType type) = 0;

/// Compute jacobians at quadrature points
virtual Real computeQpJacobian(Moose::DGJacobianType type) = 0;

/// compute off-diagonal jacobian components at quadrature points
virtual Real computeQpOffDiagJacobian(Moose::DGJacobianType type, unsigned int jvar);

/// The volume of the current neighbor
const Real & getNeighborElemVolume();

/// Reference to the controlling finite element problem
SubProblem & _subproblem;

/// Reference to the nonlinear system
SystemBase & _sys;

/// The thread ID
THREAD_ID _tid;

/// Problem assembly
Assembly & _assembly;

protected:
/// The master side MooseVariable
MooseVariable & _var;

/// The problem mesh
MooseMesh & _mesh;

/// Pointer reference to the current element
const Elem * const & _current_elem;

/// The volume (or length) of the current element
const Real & _current_elem_volume;

/// The neighboring element
const Elem * const & _neighbor_elem;

/// Current side
const unsigned int & _current_side;

/// Current side element
const Elem * const & _current_side_elem;

/// The volume (or length) of the current side
const Real & _current_side_volume;

/// Coordinate system
const Moose::CoordinateSystemType & _coord_sys;

/// Current quadrature point
unsigned int _qp;

/// Array that holds element quadrature point coordinates
const MooseArray<Point> & _q_point;

/// Quadrature rule
const QBase * const & _qrule;

/// Elemtn Jacobian/quadrature weight
const MooseArray<Real> & _JxW;
MooseVariableFE<T> & _var;

/// Coordinate transformation value; relevant in axisymmetric simulations for example
const MooseArray<Real> & _coord;

/// Index for test and trial functions
unsigned int _i, _j;
/// Normal vectors at the quadrature points
const MooseArray<Point> & _normals;

/// Holds the current solution at the current quadrature point on the face.
const VariableValue & _u;
const TemplateVariableValue & _u;

/// Holds the current solution gradient at the current quadrature point on the face.
const VariableGradient & _grad_u;
const TemplateVariableGradient & _grad_u;

/// shape function
const VariablePhiValue & _phi;
const TemplateVariablePhiValue & _phi;

/// Shape function gradient
const VariablePhiGradient & _grad_phi;
const TemplateVariablePhiGradient & _grad_phi;

/// Side shape function.
const VariableTestValue & _test;
const TemplateVariableTestValue & _test;

/// Gradient of side shape function
const VariableTestGradient & _grad_test;
/// Normal vectors at the quadrature points
const MooseArray<Point> & _normals;
const TemplateVariableTestGradient & _grad_test;

/// Coupled neighbor variable
MooseVariable & _neighbor_var;
MooseVariableFE<T> & _neighbor_var;

/// Coupled neighbor variable value
const VariableValue & _neighbor_value;
const TemplateVariableValue & _neighbor_value;

/// Coupled neighbor variable gradient
const VariableGradient & _grad_neighbor_value;
const TemplateVariableGradient & _grad_neighbor_value;

/// Side neighbor shape function.
const VariablePhiValue & _phi_neighbor;
const TemplateVariablePhiValue & _phi_neighbor;

/// Gradient of side neighbor shape function
const VariablePhiGradient & _grad_phi_neighbor;
const TemplateVariablePhiGradient & _grad_phi_neighbor;

/// Side neighbor test function
const VariableTestValue & _test_neighbor;
const TemplateVariableTestValue & _test_neighbor;

/// Gradient of side neighbor shape function
const VariableTestGradient & _grad_test_neighbor;
const TemplateVariableTestGradient & _grad_test_neighbor;

/// Holds residual entries as they are accumulated by this InterfaceKernel
/// This variable is temporarily reserved for RattleSnake
DenseMatrix<Number> _local_kxx;

/** MultiMooseEnum specifying whether residual save-in
* aux variables correspond to master or slave side
*/
MultiMooseEnum _save_in_var_side;

/** The names of the aux variables that will be used to save-in residuals
* (includes both master and slave variable names)
*/
std::vector<AuxVariableName> _save_in_strings;

/// Whether there are master residual aux variables
bool _has_master_residuals_saved_in;

/// The aux variables to save the master residual contributions to
std::vector<MooseVariableFEBase *> _master_save_in_residual_variables;

/// Whether there are slave residual aux variables
bool _has_slave_residuals_saved_in;

/// The aux variables to save the slave contributions to
std::vector<MooseVariableFEBase *> _slave_save_in_residual_variables;

/** MultiMooseEnum specifying whether jacobian save-in
* aux variables correspond to master or slave side
*/
MultiMooseEnum _diag_save_in_var_side;

/** The names of the aux variables that will be used to save-in jacobians
* (includes both master and slave variable names)
*/
std::vector<AuxVariableName> _diag_save_in_strings;

/// Whether there are master jacobian aux variables
bool _has_master_jacobians_saved_in;

/// The aux variables to save the diagonal Jacobian contributions of the master variables to
std::vector<MooseVariableFEBase *> _master_save_in_jacobian_variables;

/// Whether there are slave jacobian aux variables
bool _has_slave_jacobians_saved_in;

/// The aux variables to save the diagonal Jacobian contributions of the slave variables to
std::vector<MooseVariableFEBase *> _slave_save_in_jacobian_variables;

/// Mutex that prevents multiple threads from saving into the residual aux_var at the same time
static Threads::spin_mutex _resid_vars_mutex;

/// Mutex that prevents multiple threads from saving into the jacobian aux_var at the same time
static Threads::spin_mutex _jacoby_vars_mutex;
};

0 comments on commit 3ca651d

Please sign in to comment.
You can’t perform that action at this time.