Skip to content

Commit

Permalink
Add ability to compute residual and Jacobian together
Browse files Browse the repository at this point in the history
  • Loading branch information
lindsayad committed Feb 16, 2022
1 parent fbe1bbb commit 1efd4bf
Show file tree
Hide file tree
Showing 27 changed files with 953 additions and 171 deletions.
15 changes: 10 additions & 5 deletions framework/include/fvbcs/FVFluxBC.h
Original file line number Diff line number Diff line change
Expand Up @@ -13,20 +13,25 @@
#include "NeighborCoupleableMooseVariableDependencyIntermediateInterface.h"
#include "TwoMaterialPropertyInterface.h"
#include "MathFVUtils.h"
#include "FVFaceResidualObject.h"

// Provides an interface for computing residual contributions from finite
// volume numerical fluxes computed on faces to neighboring elements.
/**
* Provides an interface for computing residual contributions from finite
* volume numerical fluxes computed on faces to neighboring elements.
*/
class FVFluxBC : public FVBoundaryCondition,
public NeighborCoupleableMooseVariableDependencyIntermediateInterface,
public TwoMaterialPropertyInterface
public TwoMaterialPropertyInterface,
public FVFaceResidualObject
{
public:
FVFluxBC(const InputParameters & parameters);

static InputParameters validParams();

virtual void computeResidual(const FaceInfo & fi);
virtual void computeJacobian(const FaceInfo & fi);
void computeResidual(const FaceInfo & fi) override;
void computeJacobian(const FaceInfo & fi) override;
void computeResidualAndJacobian(const FaceInfo & fi) override;

protected:
virtual ADReal computeQpResidual() = 0;
Expand Down
16 changes: 6 additions & 10 deletions framework/include/fviks/FVInterfaceKernel.h
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,7 @@
#include "NeighborCoupleableMooseVariableDependencyIntermediateInterface.h"
#include "TwoMaterialPropertyInterface.h"
#include "FunctorInterface.h"
#include "FVFaceResidualObject.h"

#include <set>

Expand Down Expand Up @@ -54,7 +55,8 @@ class FVInterfaceKernel : public MooseObject,
public TaggingInterface,
public NeighborCoupleableMooseVariableDependencyIntermediateInterface,
public TwoMaterialPropertyInterface,
public FunctorInterface
public FunctorInterface,
public FVFaceResidualObject
{
public:
/**
Expand All @@ -71,15 +73,9 @@ class FVInterfaceKernel : public MooseObject,
*/
const SubProblem & subProblem() const { return _subproblem; }

/**
* Compute the residual on the supplied face
*/
virtual void computeResidual(const FaceInfo & fi);

/**
* Compute the jacobian on the supplied face
*/
virtual void computeJacobian(const FaceInfo & fi);
void computeResidual(const FaceInfo & fi) override;
void computeJacobian(const FaceInfo & fi) override;
void computeResidualAndJacobian(const FaceInfo & fi) override;

protected:
/**
Expand Down
1 change: 1 addition & 0 deletions framework/include/fvkernels/FVElementalKernel.h
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,7 @@ class FVElementalKernel : public FVKernel,
/// tricky stuff in them that you don't want to mess up!
///@{
virtual void computeResidual();
virtual void computeResidualAndJacobian();
virtual void computeJacobian();
virtual void computeOffDiagJacobian();
///@}
Expand Down
34 changes: 34 additions & 0 deletions framework/include/fvkernels/FVFaceResidualObject.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
//* 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

class FaceInfo;

/**
* Interface class for a finite volume residual object whose residuals are based on faces
*/
class FVFaceResidualObject
{
public:
/**
* Compute the residual on the supplied face
*/
virtual void computeResidual(const FaceInfo & fi) = 0;

/**
* Compute the jacobian on the supplied face
*/
virtual void computeJacobian(const FaceInfo & fi) = 0;

/**
* Compute the residual and Jacobian on the supplied face
*/
virtual void computeResidualAndJacobian(const FaceInfo & fi) = 0;
};
13 changes: 6 additions & 7 deletions framework/include/fvkernels/FVFluxKernel.h
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@
#include "TwoMaterialPropertyInterface.h"
#include "NeighborMooseVariableInterface.h"
#include "NeighborCoupleableMooseVariableDependencyIntermediateInterface.h"
#include "FVFaceResidualObject.h"

class FaceInfo;

Expand All @@ -28,18 +29,16 @@ class FaceInfo;
class FVFluxKernel : public FVKernel,
public TwoMaterialPropertyInterface,
public NeighborMooseVariableInterface<Real>,
public NeighborCoupleableMooseVariableDependencyIntermediateInterface
public NeighborCoupleableMooseVariableDependencyIntermediateInterface,
public FVFaceResidualObject
{
public:
static InputParameters validParams();
FVFluxKernel(const InputParameters & params);

/// Usually you should not override these functions - they have some super
/// tricky stuff in them that you don't want to mess up!
// @{
virtual void computeResidual(const FaceInfo & fi);
virtual void computeJacobian(const FaceInfo & fi);
/// @}
void computeResidual(const FaceInfo & fi) override;
void computeJacobian(const FaceInfo & fi) override;
void computeResidualAndJacobian(const FaceInfo & fi) override;

const MooseVariableFV<Real> & variable() const { return _var; }

Expand Down

0 comments on commit 1efd4bf

Please sign in to comment.