Skip to content
Permalink
Browse files

Merge pull request #13018 from lindsayad/ad-navier-stokes

AD incompressible navier stokes
  • Loading branch information...
aeslaughter committed Mar 11, 2019
2 parents 52d2630 + d637c74 commit 87b036e45ba537df2a844d6ddb122de5a57b6e21
Showing with 2,469 additions and 222 deletions.
  1. +16 −0 framework/doc/content/source/auxkernels/VectorVariableComponentAux.md
  2. +45 −0 framework/include/auxkernels/VectorVariableComponentAux.h
  3. +4 −0 framework/include/functions/FunctionInterface.h
  4. +2 −0 framework/include/interfaces/BlockRestrictable.h
  5. +41 −0 framework/include/interfaces/Coupleable.h
  6. +4 −4 framework/include/kernels/ADDiffusion.h
  7. +4 −6 framework/include/kernels/ADKernel.h
  8. +17 −9 framework/include/kernels/ADKernelGrad.h
  9. +58 −0 framework/include/kernels/ADKernelSUPG.h
  10. +20 −10 framework/include/kernels/ADKernelValue.h
  11. +1 −1 framework/include/kernels/ADTimeDerivative.h
  12. +4 −4 framework/include/kernels/ADTimeKernel.h
  13. +1 −1 framework/include/kernels/ADVectorTimeDerivative.h
  14. +3 −1 framework/include/materials/ADMaterial.h
  15. +3 −0 framework/include/materials/Material.h
  16. +29 −0 framework/include/utils/MathUtils.h
  17. +3 −8 framework/include/utils/MooseTypes.h
  18. +43 −0 framework/src/auxkernels/VectorVariableComponentAux.C
  19. +5 −5 framework/src/kernels/ADDiffusion.C
  20. +0 −11 framework/src/kernels/ADKernel.C
  21. +69 −37 framework/src/kernels/ADKernelGrad.C
  22. +182 −0 framework/src/kernels/ADKernelSUPG.C
  23. +67 −37 framework/src/kernels/ADKernelValue.C
  24. +2 −2 framework/src/kernels/ADTimeDerivative.C
  25. +3 −3 framework/src/kernels/ADTimeKernel.C
  26. +3 −3 framework/src/kernels/ADVectorTimeDerivative.C
  27. +7 −1 framework/src/variables/MooseVariableFE.C
  28. +2 −2 modules/heat_conduction/include/kernels/ADHeatConduction.h
  29. +1 −1 modules/heat_conduction/include/kernels/ADHeatConductionTimeDerivative.h
  30. +3 −3 modules/heat_conduction/src/kernels/ADHeatConduction.C
  31. +3 −2 modules/heat_conduction/src/kernels/ADHeatConductionTimeDerivative.C
  32. +1 −1 modules/heat_conduction/test/tests/heat_source_bar/tests
  33. +2 −2 modules/misc/include/kernels/ADMatDiffusion.h
  34. +3 −3 modules/misc/src/kernels/ADMatDiffusion.C
  35. +2 −1 modules/modules.mk
  36. +1 −1 modules/navier_stokes/Makefile
  37. +3 −0 modules/navier_stokes/doc/config.yml
  38. +15 −0 modules/navier_stokes/doc/content/modules/navier_stokes/index.md
  39. +15 −0 modules/navier_stokes/doc/content/source/auxkernels/INSStressComponentAux.md
  40. +12 −0 modules/navier_stokes/doc/content/source/kernels/INSADMass.md
  41. +19 −0 modules/navier_stokes/doc/content/source/kernels/INSADMassPSPG.md
  42. +14 −0 modules/navier_stokes/doc/content/source/kernels/INSADMomentumAdvection.md
  43. +15 −0 modules/navier_stokes/doc/content/source/kernels/INSADMomentumForces.md
  44. +14 −0 modules/navier_stokes/doc/content/source/kernels/INSADMomentumPressure.md
  45. +16 −0 modules/navier_stokes/doc/content/source/kernels/INSADMomentumSUPG.md
  46. +13 −0 modules/navier_stokes/doc/content/source/kernels/INSADMomentumTimeDerivative.md
  47. +14 −0 modules/navier_stokes/doc/content/source/kernels/INSADMomentumViscous.md
  48. +15 −0 modules/navier_stokes/doc/content/source/kernels/INSADTemperatureAdvection.md
  49. +13 −0 modules/navier_stokes/doc/content/source/materials/INSADMaterial.md
  50. +12 −0 modules/navier_stokes/doc/content/source/materials/INSADTauMaterial.md
  51. +41 −0 modules/navier_stokes/include/auxkernels/INSStressComponentAux.h
  52. +41 −0 modules/navier_stokes/include/kernels/INSADMass.h
  53. +44 −0 modules/navier_stokes/include/kernels/INSADMassPSPG.h
  54. +40 −0 modules/navier_stokes/include/kernels/INSADMomentumAdvection.h
  55. +41 −0 modules/navier_stokes/include/kernels/INSADMomentumForces.h
  56. +42 −0 modules/navier_stokes/include/kernels/INSADMomentumPressure.h
  57. +40 −0 modules/navier_stokes/include/kernels/INSADMomentumSUPG.h
  58. +42 −0 modules/navier_stokes/include/kernels/INSADMomentumTimeDerivative.h
  59. +40 −0 modules/navier_stokes/include/kernels/INSADMomentumViscous.h
  60. +69 −0 modules/navier_stokes/include/kernels/INSADTemperatureAdvection.h
  61. +101 −0 modules/navier_stokes/include/materials/INSADMaterial.h
  62. +39 −0 modules/navier_stokes/include/materials/INSADTauMaterial.h
  63. +44 −0 modules/navier_stokes/src/auxkernels/INSStressComponentAux.C
  64. +2 −1 modules/navier_stokes/src/base/NavierStokesApp.C
  65. +34 −0 modules/navier_stokes/src/kernels/INSADMass.C
  66. +37 −0 modules/navier_stokes/src/kernels/INSADMassPSPG.C
  67. +32 −0 modules/navier_stokes/src/kernels/INSADMomentumAdvection.C
  68. +32 −0 modules/navier_stokes/src/kernels/INSADMomentumForces.C
  69. +40 −0 modules/navier_stokes/src/kernels/INSADMomentumPressure.C
  70. +31 −0 modules/navier_stokes/src/kernels/INSADMomentumSUPG.C
  71. +37 −0 modules/navier_stokes/src/kernels/INSADMomentumTimeDerivative.C
  72. +33 −0 modules/navier_stokes/src/kernels/INSADMomentumViscous.C
  73. +75 −0 modules/navier_stokes/src/kernels/INSADTemperatureAdvection.C
  74. +91 −0 modules/navier_stokes/src/materials/INSADMaterial.C
  75. +94 −0 modules/navier_stokes/src/materials/INSADTauMaterial.C
  76. +200 −0 modules/navier_stokes/test/tests/ins/lid_driven/ad_lid_driven.i
  77. +185 −0 modules/navier_stokes/test/tests/ins/lid_driven/ad_lid_driven_stabilized.i
  78. +1 −0 modules/navier_stokes/test/tests/ins/lid_driven/lid_driven.cmp
  79. +1 −0 modules/navier_stokes/test/tests/ins/lid_driven/lid_driven.i
  80. +6 −0 modules/navier_stokes/test/tests/ins/lid_driven/lid_driven_stabilized.cmp
  81. +21 −0 modules/navier_stokes/test/tests/ins/lid_driven/lid_driven_stabilized.i
  82. +48 −1 modules/navier_stokes/test/tests/ins/lid_driven/tests
  83. +0 −32 test/include/kernels/ADDiffusionPrecompute.h
  84. +0 −28 test/src/kernels/ADDiffusionPrecompute.C
  85. +1 −1 test/tests/kernels/kernel_precompute/adkernel_precompute_test.i
@@ -0,0 +1,16 @@
# VectorVariableComponentAux

The `VectorVariableComponentAux` class takes a vector variable, specified
through the `vector_variable` parameter, and generates an auxiliary variable
corresponding to one of the vector variable's components; the component is
specified through the `component` parameter. This object is only meant to be
used with `LAGRANGE_VEC` vector variables, and hence the auxiliary variable
should be of type `LAGRANGE`.

!syntax description /AuxKernels/VectorVariableComponentAux

!syntax parameters /AuxKernels/VectorVariableComponentAux

!syntax inputs /AuxKernels/VectorVariableComponentAux

!syntax children /AuxKernels/VectorVariableComponentAux
@@ -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

#ifndef VECTORVARIABLECOMPONENTAUX_H
#define VECTORVARIABLECOMPONENTAUX_H

// MOOSE includes
#include "AuxKernel.h"

// Forward declarations
class VectorVariableComponentAux;

template <>
InputParameters validParams<VectorVariableComponentAux>();

/**
* Extract a component from a vector variable
*/
class VectorVariableComponentAux : public AuxKernel
{
public:
/**
* Class constructor
* @param parameters Input parameters for the object
*/
VectorVariableComponentAux(const InputParameters & parameters);

protected:
virtual Real computeValue() override;

private:
/// Reference to the value of the coupled vector variable
const RealVectorValue & _vector_variable_value;

/// Desired component
int _component;
};

#endif // VECTORVARIABLECOMPONENTAUX_H
@@ -12,6 +12,10 @@

#include "MooseTypes.h"

#define usingFunctionInterfaceMembers \
using FunctionInterface::getFunction; \
using FunctionInterface::getFunctionByName

// Forward declarations
class Function;
class FEProblemBase;
@@ -16,6 +16,8 @@
#include "MaterialData.h"
#include "MooseObject.h"

#define usingBlockRestrictableMembers using BlockRestrictable::getBlockCoordSystem

// Forward declarations
class BlockRestrictable;
class FEProblemBase;
@@ -43,6 +43,7 @@ class DenseVector;
#define adCoupledGradient this->template adCoupledGradientTemplate<compute_stage>
#define adCoupledSecond this->template adCoupledSecondTemplate<compute_stage>
#define adCoupledDot this->template adCoupledDotTemplate<compute_stage>
#define adCoupledVectorDot this->template adCoupledVectorDotTemplate<compute_stage>
#define adCoupledVectorValue this->template adCoupledVectorValueTemplate<compute_stage>
#define adCoupledVectorGradient this->template adCoupledVectorGradientTemplate<compute_stage>
#define adCoupledVectorSecond this->template adCoupledVectorSecondTemplate<compute_stage>
@@ -512,6 +513,18 @@ class Coupleable
template <ComputeStage compute_stage>
const ADVariableValue & adCoupledDotTemplate(const std::string & var_name, unsigned int comp = 0);

/**
* Time derivative of a vector coupled variable for ad simulations
* @param var_name Name of vector coupled variable
* @param comp Component number
* @return Reference to a VectorVariableValue containing the time derivative of the coupled
* variable
* @see Kernel::dot
*/
template <ComputeStage compute_stage>
const ADVectorVariableValue & adCoupledVectorDotTemplate(const std::string & var_name,
unsigned int comp = 0);

/**
* Time derivative of a coupled vector variable
* @param var_name Name of coupled vector variable
@@ -1059,6 +1072,34 @@ Coupleable::adCoupledDotTemplate(const std::string & var_name, unsigned int comp
}
}

template <ComputeStage compute_stage>
const ADVectorVariableValue &
Coupleable::adCoupledVectorDotTemplate(const std::string & var_name, unsigned int comp)
{
checkVar(var_name);
if (!isCoupled(var_name)) // Return default 0
return *getADDefaultVectorValue<compute_stage>(var_name);

VectorMooseVariable * var = getVectorVar(var_name, comp);
if (var == nullptr)
mooseError("Try calling corresponding standard variable method");

if (!_coupleable_neighbor)
{
if (_c_nodal)
mooseError("Not implemented");
else
return var->adUDot<compute_stage>();
}
else
{
if (_c_nodal)
mooseError("Not implemented");
else
return var->adUDotNeighbor<compute_stage>();
}
}

template <ComputeStage compute_stage>
const ADVectorVariableValue &
Coupleable::adCoupledVectorValueTemplate(const std::string & var_name, unsigned int comp)
@@ -10,23 +10,23 @@
#ifndef ADDIFFUSION_H
#define ADDIFFUSION_H

#include "ADKernel.h"
#include "ADKernelGrad.h"

template <ComputeStage>
class ADDiffusion;

declareADValidParams(ADDiffusion);

template <ComputeStage compute_stage>
class ADDiffusion : public ADKernel<compute_stage>
class ADDiffusion : public ADKernelGrad<compute_stage>
{
public:
ADDiffusion(const InputParameters & parameters);

protected:
virtual ADResidual computeQpResidual() override;
virtual ADVectorResidual precomputeQpResidual() override;

usingKernelMembers;
usingKernelGradMembers;
};

#endif
@@ -17,6 +17,8 @@

#define usingTemplKernelMembers(type) \
usingCoupleableMembers; \
usingBlockRestrictableMembers; \
usingFunctionInterfaceMembers; \
using ADKernelTempl<type, compute_stage>::_test; \
using ADKernelTempl<type, compute_stage>::_qp; \
using ADKernelTempl<type, compute_stage>::_ad_q_point; \
@@ -43,16 +45,14 @@
using ADKernelTempl<type, compute_stage>::_dt; \
using ADKernelTempl<type, compute_stage>::_phi; \
using ADKernelTempl<type, compute_stage>::_grad_phi; \
using ADKernelTempl<type, compute_stage>::getBlockCoordSystem; \
using ADKernelTempl<type, compute_stage>::precalculateResidual; \
using ADKernelTempl<type, compute_stage>::prepareVectorTag; \
using ADKernelTempl<type, compute_stage>::prepareMatrixTag; \
using ADKernelTempl<type, compute_stage>::accumulateTaggedLocalResidual; \
using ADKernelTempl<type, compute_stage>::accumulateTaggedLocalMatrix; \
using ADKernelTempl<type, compute_stage>::variable; \
using ADKernelTempl<type, compute_stage>::paramError; \
using ADKernelTempl<type, compute_stage>::isParamValid; \
using ADKernelTempl<type, compute_stage>::getFunction
using ADKernelTempl<type, compute_stage>::isParamValid

#define usingKernelMembers usingTemplKernelMembers(Real)
#define usingVectorKernelMembers usingTemplKernelMembers(RealVectorValue)
@@ -75,12 +75,10 @@ class ADKernelTempl : public KernelBase, public MooseVariableInterface<T>
public:
ADKernelTempl(const InputParameters & parameters);

virtual ~ADKernelTempl();

// See KernelBase base for documentation of these overridden methods
virtual void computeResidual() override;
virtual void computeJacobian() override;
virtual void computeOffDiagJacobian(MooseVariableFEBase & jvar) override;
virtual void computeOffDiagJacobian(MooseVariableFEBase &) override final {}
virtual void computeADOffDiagJacobian() override;
virtual void computeOffDiagJacobianScalar(unsigned int jvar) override;

@@ -13,31 +13,39 @@
#include "ADKernel.h"

#define usingKernelGradMembers usingKernelMembers
#define usingVectorKernelGradMembers usingVectorKernelMembers

template <ComputeStage>
class ADKernelGrad;
template <typename, ComputeStage>
class ADKernelGradTempl;

template <ComputeStage compute_stage>
using ADKernelGrad = ADKernelGradTempl<Real, compute_stage>;
template <ComputeStage compute_stage>
using ADVectorKernelGrad = ADKernelGradTempl<RealVectorValue, compute_stage>;

declareADValidParams(ADKernelGrad);
declareADValidParams(ADVectorKernelGrad);

template <ComputeStage compute_stage>
class ADKernelGrad : public ADKernel<compute_stage>
template <typename T, ComputeStage compute_stage>
class ADKernelGradTempl : public ADKernelTempl<T, compute_stage>
{
public:
ADKernelGrad(const InputParameters & parameters);
ADKernelGradTempl(const InputParameters & parameters);

virtual void computeResidual() override;
virtual void computeJacobian() override;
virtual void computeOffDiagJacobian(MooseVariableFEBase & jvar) override;
virtual void computeADOffDiagJacobian() override;

protected:
/**
* Called before forming the residual for an element
*/
virtual ADGradResidual precomputeQpResidual() = 0;
virtual typename OutputTools<typename Moose::ValueType<T, compute_stage>::type>::OutputGradient
precomputeQpResidual() = 0;

virtual ADResidual computeQpResidual() final;
virtual ADResidual computeQpResidual() override final;

usingKernelMembers;
usingTemplKernelMembers(T);
};

#endif /* ADKERNELGRAD_H */
@@ -0,0 +1,58 @@
//* 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

#ifndef ADKERNELSUPG_H
#define ADKERNELSUPG_H

#include "ADKernel.h"

#define usingTemplKernelSUPGMembers(type) \
usingTemplKernelMembers(type); \
using ADKernelSUPGTempl<type, compute_stage>::_velocity; \
using ADKernelSUPGTempl<type, compute_stage>::_tau
#define usingKernelSUPGMembers usingTemplKernelSUPGMembers(Real)
#define usingVectorKernelSUPGMembers usingTemplKernelSUPGMembers(RealVectorValue)

template <typename, ComputeStage>
class ADKernelSUPGTempl;

template <ComputeStage compute_stage>
using ADKernelSUPG = ADKernelSUPGTempl<Real, compute_stage>;
template <ComputeStage compute_stage>
using ADVectorKernelSUPG = ADKernelSUPGTempl<RealVectorValue, compute_stage>;

declareADValidParams(ADKernelSUPG);
declareADValidParams(ADVectorKernelSUPG);

template <typename T, ComputeStage compute_stage>
class ADKernelSUPGTempl : public ADKernelTempl<T, compute_stage>
{
public:
ADKernelSUPGTempl(const InputParameters & parameters);

virtual void computeResidual() override;
virtual void computeJacobian() override;
virtual void computeADOffDiagJacobian() override;

protected:
/**
* Called before forming the residual for an element
*/
virtual typename OutputTools<typename Moose::ValueType<T, compute_stage>::type>::OutputValue
precomputeQpStrongResidual() = 0;

virtual ADResidual computeQpResidual() override final;

const ADMaterialProperty(Real) & _tau;
const ADVectorVariableValue & _velocity;

usingTemplKernelMembers(T);
};

#endif /* ADKERNELSUPG_H */
@@ -12,32 +12,42 @@

#include "ADKernel.h"

#define usingKernelValueMembers usingKernelMembers
#define usingTemplKernelValueMembers(T) usingTemplKernelMembers(T)
#define usingKernelValueMembers usingTemplKernelValueMembers(Real)
#define usingVectorKernelValueMembers usingTemplKernelMembers(RealVectorValue)

template <ComputeStage>
class ADKernelValue;
template <typename, ComputeStage>
class ADKernelValueTempl;

template <ComputeStage compute_stage>
using ADKernelValue = ADKernelValueTempl<Real, compute_stage>;
template <ComputeStage compute_stage>
using ADVectorKernelValue = ADKernelValueTempl<RealVectorValue, compute_stage>;

declareADValidParams(ADKernelValue);
declareADValidParams(ADVectorKernelValue);

template <ComputeStage compute_stage>
class ADKernelValue : public ADKernel<compute_stage>
template <typename T, ComputeStage compute_stage>
class ADKernelValueTempl : public ADKernelTempl<T, compute_stage>
{
public:
ADKernelValue(const InputParameters & parameters);
ADKernelValueTempl(const InputParameters & parameters);

// See KernelBase base for documentation of these overridden methods
virtual void computeResidual() override;
virtual void computeJacobian() override;
virtual void computeOffDiagJacobian(MooseVariableFEBase & jvar) override;
virtual void computeADOffDiagJacobian() override;

protected:
/**
* Called before forming the residual for an element
*/
virtual ADResidual precomputeQpResidual() = 0;
virtual typename OutputTools<typename Moose::ValueType<T, compute_stage>::type>::OutputValue
precomputeQpResidual() = 0;

virtual ADResidual computeQpResidual() final;
virtual ADResidual computeQpResidual() override final;

usingKernelMembers;
usingTemplKernelMembers(T);
};

#endif /* ADKERNELVALUE_H */
@@ -25,7 +25,7 @@ class ADTimeDerivative : public ADTimeKernel<compute_stage>
ADTimeDerivative(const InputParameters & parameters);

protected:
virtual ADResidual computeQpResidual() override;
virtual ADResidual precomputeQpResidual() override;

usingTimeKernelMembers;
};
Oops, something went wrong.

0 comments on commit 87b036e

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