Skip to content

Commit

Permalink
Okay have it both ways
Browse files Browse the repository at this point in the history
  • Loading branch information
reverendbedford committed Apr 10, 2024
1 parent 26cdb09 commit 1d3feae
Show file tree
Hide file tree
Showing 16 changed files with 460 additions and 199 deletions.
6 changes: 6 additions & 0 deletions .vscode/settings.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
{
"files.associations": {
"ADStokesStressDivergence.C": "cpp",
"ADStokesIncompressibility.C": "cpp"
}
}
25 changes: 25 additions & 0 deletions include/kernels/ADStokesPressure.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
//* 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

#include "ADVectorKernel.h"

class ADStokesPressure : public ADVectorKernel
{
public:
static InputParameters validParams();

ADStokesPressure(const InputParameters & parameters);

protected:
virtual ADReal computeQpResidual() override;

const ADVariableGradient & _grad_pressure;
};
25 changes: 25 additions & 0 deletions include/kernels/ADStokesPressureByParts.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
//* 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

#include "ADVectorKernel.h"

class ADStokesPressureByParts : public ADVectorKernel
{
public:
static InputParameters validParams();

ADStokesPressureByParts(const InputParameters & parameters);

protected:
virtual ADReal computeQpResidual() override;

const ADVariableValue & _pressure;
};
3 changes: 1 addition & 2 deletions include/kernels/ADStokesStressDivergence.h
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,5 @@ class ADStokesStressDivergence : public ADVectorKernel
protected:
virtual ADReal computeQpResidual() override;

const ADMaterialProperty<RankTwoTensor> & _stress;
const ADVariableGradient & _pressure;
const ADMaterialProperty<RankTwoTensor> & _deviatoric_stress;
};
35 changes: 35 additions & 0 deletions src/kernels/ADStokesPressure.C
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@
//* 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

#include "ADStokesPressure.h"

registerMooseObject("DeerApp", ADStokesPressure);

InputParameters
ADStokesPressure::validParams()
{
InputParameters params = ADVectorKernel::validParams();
params.addClassDescription("The pressure part of the velocity kernel for Stokes flow, do not integrate by parts");

params.addRequiredCoupledVar("pressure", "The pressure");

return params;
}

ADStokesPressure::ADStokesPressure(const InputParameters & parameters)
: ADVectorKernel(parameters),
_grad_pressure(adCoupledGradient("pressure"))
{
}

ADReal
ADStokesPressure::computeQpResidual()
{
return _test[_i][_qp] * _grad_pressure[_qp];
}
35 changes: 35 additions & 0 deletions src/kernels/ADStokesPressureByParts.C
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@
//* 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

#include "ADStokesPressureByParts.h"

registerMooseObject("DeerApp", ADStokesPressureByParts);

InputParameters
ADStokesPressureByParts::validParams()
{
InputParameters params = ADVectorKernel::validParams();
params.addClassDescription("The pressure part of the velocity kernel for Stokes flow, do not integrate by parts");

params.addRequiredCoupledVar("pressure", "The pressure");

return params;
}

ADStokesPressureByParts::ADStokesPressureByParts(const InputParameters & parameters)
: ADVectorKernel(parameters),
_pressure(adCoupledValue("pressure"))
{
}

ADReal
ADStokesPressureByParts::computeQpResidual()
{
return -_grad_test[_i][_qp].tr() * _pressure[_qp];
}
7 changes: 2 additions & 5 deletions src/kernels/ADStokesStressDivergence.C
Original file line number Diff line number Diff line change
Expand Up @@ -17,20 +17,17 @@ ADStokesStressDivergence::validParams()
InputParameters params = ADVectorKernel::validParams();
params.addClassDescription("The unstabilized stress diveregence kernel for Stokes flow");

params.addRequiredCoupledVar("pressure", "The pressure");

return params;
}

ADStokesStressDivergence::ADStokesStressDivergence(const InputParameters & parameters)
: ADVectorKernel(parameters),
_stress(getADMaterialPropertyByName<RankTwoTensor>("stress")),
_pressure(adCoupledGradient("pressure"))
_deviatoric_stress(getADMaterialPropertyByName<RankTwoTensor>("deviatoric_stress"))
{
}

ADReal
ADStokesStressDivergence::computeQpResidual()
{
return _stress[_qp].contract(_grad_test[_i][_qp]) + _test[_i][_qp] * _pressure[_qp];
return _deviatoric_stress[_qp].contract(_grad_test[_i][_qp]);
}
4 changes: 2 additions & 2 deletions src/materials/StokesLinearViscous.C
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ StokesLinearViscous::validParams()

StokesLinearViscous::StokesLinearViscous(const InputParameters & parameters)
: DerivativeMaterialInterface<Material>(parameters),
_stress(declareADProperty<RankTwoTensor>("stress")),
_stress(declareADProperty<RankTwoTensor>("deviatoric_stress")),
_strain_rate(getADMaterialPropertyByName<RankTwoTensor>("strain_rate")),
_mu(getADMaterialProperty<Real>("mu"))
{
Expand All @@ -34,4 +34,4 @@ void
StokesLinearViscous::computeQpProperties()
{
_stress[_qp] = 2.0 * _strain_rate[_qp] * _mu[_qp];
}
}
6 changes: 3 additions & 3 deletions src/materials/StokesPowerLawCreep.C
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ StokesPowerLawCreep::validParams()

StokesPowerLawCreep::StokesPowerLawCreep(const InputParameters & parameters)
: DerivativeMaterialInterface<Material>(parameters),
_stress(declareADProperty<RankTwoTensor>("stress")),
_stress(declareADProperty<RankTwoTensor>("deviatoric_stress")),
_strain_rate(getADMaterialPropertyByName<RankTwoTensor>("strain_rate")),
_A(getADMaterialProperty<Real>("A")),
_n(getADMaterialProperty<Real>("n"))
Expand All @@ -41,6 +41,6 @@ StokesPowerLawCreep::computeQpProperties()

auto effective_strain_rate = std::sqrt(2.0 / 3.0 * dev_strain_rate.contract(dev_strain_rate));
auto effective_stress = std::pow(effective_strain_rate / A, 1.0 / n);

_stress[_qp] = 2.0 / 3.0 * dev_strain_rate / (A * std::pow(effective_stress, n - 1.0));
}
}
3 changes: 2 additions & 1 deletion src/materials/StokesStrainRate.C
Original file line number Diff line number Diff line change
Expand Up @@ -32,4 +32,5 @@ void
StokesStrainRate::computeQpProperties()
{
_strain_rate[_qp] = 0.5 * (_grad_vel[_qp] + _grad_vel[_qp].transpose());
}
_strain_rate[_qp] = _strain_rate[_qp].deviatoric();
}
155 changes: 0 additions & 155 deletions tests/stokes/flow.i

This file was deleted.

Binary file removed tests/stokes/gold/flow_out.e
Binary file not shown.
4 changes: 4 additions & 0 deletions tests/stokes/manufactured.i → tests/stokes/patch.i
Original file line number Diff line number Diff line change
Expand Up @@ -77,6 +77,10 @@
[equil]
type = ADStokesStressDivergence
variable = u
[]
[pressure]
type = ADStokesPressure
variable = u
pressure = p
[]
[incompressible]
Expand Down
Loading

0 comments on commit 1d3feae

Please sign in to comment.