Skip to content

Commit

Permalink
cleaning up compute off-diagonal jacobian after idaholab#13609
Browse files Browse the repository at this point in the history
  • Loading branch information
YaqiWang authored and lindsayad committed Nov 11, 2020
1 parent b543657 commit b4ef239
Show file tree
Hide file tree
Showing 116 changed files with 295 additions and 370 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -62,7 +62,7 @@ class ImplicitODEx : public ODEKernel
* Note that this can be an approximation or linearization. In this case it's
* not because the Jacobian of this operator is easy to calculate.
*/
virtual Real computeQpOffDiagJacobian(unsigned int jvar) override;
virtual Real computeQpOffDiagJacobianScalar(unsigned int jvar) override;

/**
* Needed for computing off-diagonal terms in Jacobian
Expand All @@ -74,4 +74,3 @@ class ImplicitODEx : public ODEKernel
*/
const VariableValue & _y;
};

Original file line number Diff line number Diff line change
Expand Up @@ -61,7 +61,7 @@ class ImplicitODEy : public ODEKernel
* This is essentially the partial derivative of the residual with respect to
* the variable that is coupled into this kernel.
*/
virtual Real computeQpOffDiagJacobian(unsigned int jvar) override;
virtual Real computeQpOffDiagJacobianScalar(unsigned int jvar) override;

/**
* Needed for computing off-diagonal terms in Jacobian
Expand All @@ -73,4 +73,3 @@ class ImplicitODEy : public ODEKernel
*/
const VariableValue & _x;
};

Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,7 @@ ImplicitODEx::computeQpJacobian()
}

Real
ImplicitODEx::computeQpOffDiagJacobian(unsigned int jvar)
ImplicitODEx::computeQpOffDiagJacobianScalar(unsigned int jvar)
{
if (jvar == _y_var)
return -2.; // dF/dy
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,7 @@ ImplicitODEy::computeQpJacobian()
}

Real
ImplicitODEy::computeQpOffDiagJacobian(unsigned int jvar)
ImplicitODEy::computeQpOffDiagJacobianScalar(unsigned int jvar)
{
if (jvar == _x_var)
return -4.; // dF/dx
Expand Down
2 changes: 1 addition & 1 deletion framework/include/bcs/ADNodalBC.h
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ class ADNodalBCTempl : public NodalBCBase, public MooseVariableInterface<T>
private:
void computeResidual() override final;
void computeJacobian() override final;
void computeOffDiagJacobian(unsigned int jvar) override final;
void computeOffDiagJacobian(MooseVariableFEBase & jvar) override final;
void computeOffDiagJacobianScalar(unsigned int jvar) override final;

protected:
Expand Down
2 changes: 1 addition & 1 deletion framework/include/bcs/ArrayNodalBC.h
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@ class ArrayNodalBC : public NodalBCBase, public MooseVariableInterface<RealEigen
virtual const ArrayMooseVariable & variable() const override { return _var; }
virtual void computeResidual() override;
virtual void computeJacobian() override;
virtual void computeOffDiagJacobian(unsigned int jvar) override;
virtual void computeOffDiagJacobian(MooseVariableFEBase & jvar) override;

protected:
ArrayMooseVariable & _var;
Expand Down
9 changes: 5 additions & 4 deletions framework/include/bcs/IntegratedBC.h
Original file line number Diff line number Diff line change
Expand Up @@ -36,10 +36,6 @@ class IntegratedBC : public IntegratedBCBase, public MooseVariableInterface<Real
* Computes d-ivar-residual / d-jvar...
*/
virtual void computeJacobianBlock(MooseVariableFEBase & jvar) override;
/**
* Deprecated method
*/
virtual void computeJacobianBlock(unsigned jvar);
/**
* Computes jacobian block with respect to a scalar variable
* @param jvar The number of the scalar variable
Expand All @@ -62,6 +58,11 @@ class IntegratedBC : public IntegratedBCBase, public MooseVariableInterface<Real
*/
virtual Real computeQpOffDiagJacobian(unsigned int /*jvar*/) { return 0; }

/**
* Method for computing an off-diagonal jacobian component from a scalar var.
*/
virtual Real computeQpOffDiagJacobianScalar(unsigned int /*jvar*/) { return 0; }

MooseVariable & _var;

/// normals at quadrature points
Expand Down
2 changes: 1 addition & 1 deletion framework/include/bcs/NodalBC.h
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@ class NodalBC : public NodalBCBase, public MooseVariableInterface<Real>
virtual const MooseVariable & variable() const override { return _var; }
virtual void computeResidual() override;
virtual void computeJacobian() override;
virtual void computeOffDiagJacobian(unsigned int jvar) override;
virtual void computeOffDiagJacobian(MooseVariableFEBase & jvar) override;

protected:
MooseVariable & _var;
Expand Down
11 changes: 0 additions & 11 deletions framework/include/bcs/NodalBCBase.h
Original file line number Diff line number Diff line change
Expand Up @@ -37,17 +37,6 @@ class NodalBCBase : public BoundaryCondition,

NodalBCBase(const InputParameters & parameters);

virtual void computeOffDiagJacobian(MooseVariableFEBase & jvar) override
{
computeOffDiagJacobian(jvar.number());
}
virtual void computeOffDiagJacobian(unsigned int jvar) = 0;

/**
* Compute the off-diagonal contributions from scalar variables
*/
virtual void computeOffDiagJacobianScalar(unsigned int /*jvar*/) override {}

/**
* Whether to verify that this object is acting on a nodal variable
*/
Expand Down
1 change: 0 additions & 1 deletion framework/include/bcs/NonlocalIntegratedBC.h
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,6 @@ class NonlocalIntegratedBC : public IntegratedBC
*/
virtual void computeJacobian() override;
virtual void computeJacobianBlock(MooseVariableFEBase & jvar) override;
using IntegratedBC::computeJacobianBlock;

/**
* computeNonlocalJacobian and computeNonlocalOffDiagJacobian methods are
Expand Down
2 changes: 1 addition & 1 deletion framework/include/bcs/OneDEqualValueConstraintBC.h
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ class OneDEqualValueConstraintBC : public IntegratedBC
protected:
virtual Real computeQpResidual() override;
virtual Real computeQpJacobian() override;
virtual Real computeQpOffDiagJacobian(unsigned jvar) override;
virtual Real computeQpOffDiagJacobianScalar(unsigned int jvar) override;

VariableValue & _lambda;
unsigned int _lambda_var_number;
Expand Down
5 changes: 5 additions & 0 deletions framework/include/bcs/VectorIntegratedBC.h
Original file line number Diff line number Diff line change
Expand Up @@ -58,6 +58,11 @@ class VectorIntegratedBC : public IntegratedBCBase, public MooseVariableInterfac
*/
virtual Real computeQpOffDiagJacobian(unsigned int /*jvar*/) { return 0; }

/**
* Method for computing an off-diagonal jacobian component from a scalar var.
*/
virtual Real computeQpOffDiagJacobianScalar(unsigned int /*jvar*/) { return 0; }

VectorMooseVariable & _var;

/// normals at quadrature points
Expand Down
2 changes: 1 addition & 1 deletion framework/include/bcs/VectorNodalBC.h
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@ class VectorNodalBC : public NodalBCBase, public MooseVariableInterface<RealVect
virtual const VectorMooseVariable & variable() const override { return _var; }
virtual void computeResidual() override;
virtual void computeJacobian() override;
virtual void computeOffDiagJacobian(unsigned int jvar) override;
virtual void computeOffDiagJacobian(MooseVariableFEBase & jvar) override;

protected:
VectorMooseVariable & _var;
Expand Down
1 change: 0 additions & 1 deletion framework/include/constraints/CoupledTiedValueConstraint.h
Original file line number Diff line number Diff line change
Expand Up @@ -41,4 +41,3 @@ class CoupledTiedValueConstraint : public NodeFaceConstraint
const Real _scaling;
NumericVector<Number> & _residual_copy;
};

Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ class EqualValueEmbeddedConstraint : public NodeElemConstraint
virtual void residualEnd() override{};

virtual void computeJacobian() override;
virtual void computeOffDiagJacobian(unsigned int jvar) override;
virtual void computeOffDiagJacobian(MooseVariableFEBase & jvar) override;

virtual bool addCouplingEntriesToJacobian() override { return true; }

Expand Down
6 changes: 1 addition & 5 deletions framework/include/constraints/NodeElemConstraint.h
Original file line number Diff line number Diff line change
Expand Up @@ -51,11 +51,7 @@ class NodeElemConstraint : public Constraint,
virtual void computeJacobian() override;

/// Computes d-residual / d-jvar...
virtual void computeOffDiagJacobian(MooseVariableFEBase & jvar) override
{
computeOffDiagJacobian(jvar.number());
}
virtual void computeOffDiagJacobian(unsigned int jvar);
virtual void computeOffDiagJacobian(MooseVariableFEBase & jvar) override;

/// Gets the indices for all dofs connected to the constraint
virtual void getConnectedDofIndices(unsigned int var_num);
Expand Down
6 changes: 1 addition & 5 deletions framework/include/constraints/NodeFaceConstraint.h
Original file line number Diff line number Diff line change
Expand Up @@ -63,11 +63,7 @@ class NodeFaceConstraint : public Constraint,
/**
* Computes d-residual / d-jvar...
*/
virtual void computeOffDiagJacobian(MooseVariableFEBase & jvar) override
{
computeOffDiagJacobian(jvar.number());
}
virtual void computeOffDiagJacobian(unsigned int jvar);
virtual void computeOffDiagJacobian(MooseVariableFEBase & jvar) override;

/**
* Gets the indices for all dofs connected to the constraint
Expand Down
4 changes: 2 additions & 2 deletions framework/include/dgkernels/ADDGKernel.h
Original file line number Diff line number Diff line change
Expand Up @@ -24,9 +24,9 @@ class ADDGKernel : public DGKernelBase, public NeighborMooseVariableInterface<Re
void computeElemNeighResidual(Moose::DGResidualType type) override final;
void computeElemNeighJacobian(Moose::DGJacobianType type) override final;
void computeOffDiagElemNeighJacobian(Moose::DGJacobianType type,
unsigned int jvar) override final;
MooseVariableFEBase & jvar) override final;
void computeJacobian() override final;
void computeOffDiagJacobian(unsigned int jvar) override final;
void computeOffDiagJacobian(MooseVariableFEBase & jvar) override final;

protected:
const MooseVariableFEBase & variable() const override { return _var; }
Expand Down
4 changes: 2 additions & 2 deletions framework/include/dgkernels/ArrayDGKernel.h
Original file line number Diff line number Diff line change
Expand Up @@ -54,13 +54,13 @@ class ArrayDGKernel : public DGKernelBase, public NeighborMooseVariableInterface
/**
* Computes d-residual / d-jvar...
*/
virtual void computeOffDiagJacobian(unsigned int jvar) override;
virtual void computeOffDiagJacobian(MooseVariableFEBase & jvar) override;

/**
* Computes the element-element off-diagonal Jacobian
*/
virtual void computeOffDiagElemNeighJacobian(Moose::DGJacobianType type,
unsigned int jvar) override;
MooseVariableFEBase & jvar) override;

protected:
/**
Expand Down
2 changes: 1 addition & 1 deletion framework/include/dgkernels/DGKernel.h
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,7 @@ class DGKernel : public DGKernelBase, public NeighborMooseVariableInterface<Real
* Computes the element-element off-diagonal Jacobian
*/
virtual void computeOffDiagElemNeighJacobian(Moose::DGJacobianType type,
unsigned int jvar) override;
MooseVariableFEBase & jvar) override;

protected:
/**
Expand Down
9 changes: 3 additions & 6 deletions framework/include/dgkernels/DGKernelBase.h
Original file line number Diff line number Diff line change
Expand Up @@ -75,16 +75,13 @@ class DGKernelBase : public ResidualObject,
/**
* Computes the element-element off-diagonal Jacobian
*/
virtual void computeOffDiagElemNeighJacobian(Moose::DGJacobianType type, unsigned int jvar) = 0;
virtual void computeOffDiagElemNeighJacobian(Moose::DGJacobianType type,
MooseVariableFEBase & jvar) = 0;

/**
* Computes d-residual / d-jvar...
*/
virtual void computeOffDiagJacobian(MooseVariableFEBase & jvar) override
{
computeOffDiagJacobian(jvar.number());
}
virtual void computeOffDiagJacobian(unsigned int jvar);
virtual void computeOffDiagJacobian(MooseVariableFEBase & jvar) override;

protected:
/// Current element
Expand Down
6 changes: 1 addition & 5 deletions framework/include/dirackernels/DiracKernel.h
Original file line number Diff line number Diff line change
Expand Up @@ -60,11 +60,7 @@ class DiracKernel : public ResidualObject,
/**
* Computes the off-diagonal Jacobian for variable jvar.
*/
virtual void computeOffDiagJacobian(MooseVariableFEBase & jvar) override
{
computeOffDiagJacobian(jvar.number());
}
virtual void computeOffDiagJacobian(unsigned int jvar);
virtual void computeOffDiagJacobian(MooseVariableFEBase & jvar) override;

virtual const MooseVariableField<Real> & variable() const override { return _var; }

Expand Down
11 changes: 5 additions & 6 deletions framework/include/kernels/AverageValueConstraint.h
Original file line number Diff line number Diff line change
Expand Up @@ -34,17 +34,16 @@ class AverageValueConstraint : public ScalarKernel
static InputParameters validParams();

AverageValueConstraint(const InputParameters & parameters);
virtual ~AverageValueConstraint();

virtual void reinit();
virtual void computeResidual();
virtual void computeJacobian();
virtual void computeOffDiagJacobian(unsigned int jvar);
virtual void reinit() override;
virtual void computeResidual() override;
virtual void computeJacobian() override;
virtual void computeOffDiagJacobianScalar(unsigned int jvar) override;

protected:
virtual Real computeQpResidual();
virtual Real computeQpJacobian();
virtual Real computeQpOffDiagJacobian(unsigned int jvar);
virtual Real computeQpOffDiagJacobianScalar(unsigned int jvar);

/// Local index
unsigned int _i;
Expand Down
1 change: 0 additions & 1 deletion framework/include/kernels/CoupledForce.h
Original file line number Diff line number Diff line change
Expand Up @@ -39,4 +39,3 @@ class CoupledForce : public Kernel
const VariableValue & _v;
Real _coef;
};

1 change: 0 additions & 1 deletion framework/include/kernels/CoupledTimeDerivative.h
Original file line number Diff line number Diff line change
Expand Up @@ -36,4 +36,3 @@ class CoupledTimeDerivative : public Kernel
const VariableValue & _dv_dot;
const unsigned int _v_var;
};

3 changes: 0 additions & 3 deletions framework/include/kernels/EigenKernel.h
Original file line number Diff line number Diff line change
Expand Up @@ -38,8 +38,6 @@ class EigenKernel : public Kernel
EigenKernel(const InputParameters & parameters);
virtual bool enabled() const override;

using Kernel::computeOffDiagJacobian;

protected:
/// flag for as an eigen kernel or a normal kernel
bool _eigen;
Expand All @@ -53,4 +51,3 @@ class EigenKernel : public Kernel
*/
const Real * _eigenvalue;
};

13 changes: 6 additions & 7 deletions framework/include/kernels/Kernel.h
Original file line number Diff line number Diff line change
Expand Up @@ -33,11 +33,6 @@ class Kernel : public KernelBase, public MooseVariableInterface<Real>
/// Computes d-residual / d-jvar... storing the result in Ke.
virtual void computeOffDiagJacobian(MooseVariableFEBase & jvar) override;

/**
* Deprecated method
*/
virtual void computeOffDiagJacobian(unsigned jvar);

/**
* Computes jacobian block with respect to a scalar variable
* @param jvar The number of the scalar variable
Expand All @@ -58,11 +53,15 @@ class Kernel : public KernelBase, public MooseVariableInterface<Real>
virtual Real computeQpJacobian() { return 0; }

/**
* This is the virtual that derived classes should override for computing an off-diagonal Jacobian
* component.
* For coupling standard variables
*/
virtual Real computeQpOffDiagJacobian(unsigned int /*jvar*/) { return 0; }

/**
* For coupling scalar variables
*/
virtual Real computeQpOffDiagJacobianScalar(unsigned int /*jvar*/) { return 0; }

/**
* For coupling array variables
*/
Expand Down
3 changes: 0 additions & 3 deletions framework/include/kernels/KernelGrad.h
Original file line number Diff line number Diff line change
Expand Up @@ -43,8 +43,6 @@ class KernelGrad : public Kernel

virtual void computeOffDiagJacobian(MooseVariableFEBase & jvar) override;

using Kernel::computeOffDiagJacobian;

protected:
/**
* Called before forming the residual for an element
Expand All @@ -58,4 +56,3 @@ class KernelGrad : public Kernel

virtual Real computeQpResidual() override;
};

3 changes: 0 additions & 3 deletions framework/include/kernels/KernelValue.h
Original file line number Diff line number Diff line change
Expand Up @@ -43,8 +43,6 @@ class KernelValue : public Kernel

virtual void computeOffDiagJacobian(MooseVariableFEBase & jvar) override;

using Kernel::computeOffDiagJacobian;

protected:
/**
* Called before forming the residual for an element
Expand All @@ -58,4 +56,3 @@ class KernelValue : public Kernel

virtual Real computeQpResidual() final;
};

8 changes: 4 additions & 4 deletions framework/include/kernels/MatDiffusionBase.h
Original file line number Diff line number Diff line change
Expand Up @@ -30,12 +30,12 @@ class MatDiffusionBase : public DerivativeMaterialInterface<JvarMapKernelInterfa

MatDiffusionBase(const InputParameters & parameters);

virtual void initialSetup();
virtual void initialSetup() override;

protected:
virtual Real computeQpResidual();
virtual Real computeQpJacobian();
virtual Real computeQpOffDiagJacobian(unsigned int jvar);
virtual Real computeQpResidual() override;
virtual Real computeQpJacobian() override;
virtual Real computeQpOffDiagJacobian(unsigned int jvar) override;
virtual Real computeQpCJacobian();

/// diffusion coefficient
Expand Down
3 changes: 1 addition & 2 deletions framework/include/kernels/NodalScalarKernel.h
Original file line number Diff line number Diff line change
Expand Up @@ -31,12 +31,11 @@ class NodalScalarKernel : public ScalarKernel,
NodalScalarKernel(const InputParameters & parameters);

virtual void reinit() override;
virtual void computeOffDiagJacobian(unsigned int jvar) override;
virtual void computeOffDiagJacobianScalar(unsigned int jvar) override;

protected:
/// List of node IDs
std::vector<dof_id_type> _node_ids;
/// List of node boundary names
std::vector<BoundaryName> _boundary_names;
};

Loading

0 comments on commit b4ef239

Please sign in to comment.