forked from idaholab/moose
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add tests for newmark beta and central difference (idaholab#18178)
- Loading branch information
1 parent
289fc83
commit fdc65c1
Showing
9 changed files
with
268 additions
and
4 deletions.
There are no files selected for viewing
29 changes: 29 additions & 0 deletions
29
test/include/postprocessors/ADElementAverageSecondTimeDerivative.h
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,29 @@ | ||
//* 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 "ElementAverageValue.h" | ||
|
||
/** | ||
* This postprocessor computes a volume integral of the second time derivative of a given AD variable. | ||
*/ | ||
class ADElementAverageSecondTimeDerivative : public ElementAverageValue | ||
{ | ||
public: | ||
static InputParameters validParams(); | ||
|
||
ADElementAverageSecondTimeDerivative(const InputParameters & parameters); | ||
|
||
protected: | ||
virtual Real computeQpIntegral() override; | ||
|
||
/// Holds the solution second derivative wrt time at the current quadrature points | ||
const ADVariableValue & _u_dotdot; | ||
}; |
32 changes: 32 additions & 0 deletions
32
test/src/postprocessors/ADElementAverageSecondTimeDerivative.C
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,32 @@ | ||
//* 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 "ADElementAverageSecondTimeDerivative.h" | ||
|
||
registerMooseObject("MooseTestApp", ADElementAverageSecondTimeDerivative); | ||
|
||
InputParameters | ||
ADElementAverageSecondTimeDerivative::validParams() | ||
{ | ||
InputParameters params = ElementAverageValue::validParams(); | ||
params.addClassDescription("Computes the element averaged second derivative of variable"); | ||
return params; | ||
} | ||
|
||
ADElementAverageSecondTimeDerivative::ADElementAverageSecondTimeDerivative( | ||
const InputParameters & parameters) | ||
: ElementAverageValue(parameters), _u_dotdot(_is_transient ? adCoupledDotDot("variable") : _ad_zero) | ||
{ | ||
} | ||
|
||
Real | ||
ADElementAverageSecondTimeDerivative::computeQpIntegral() | ||
{ | ||
return MetaPhysicL::raw_value(_u_dotdot[_qp]); | ||
} |
86 changes: 86 additions & 0 deletions
86
test/tests/time_integrators/central-difference/ad_central_difference_dotdot.i
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,86 @@ | ||
########################################################### | ||
# This is a simple test with a time-dependent problem | ||
# demonstrating the use of the TimeIntegrator system. | ||
# | ||
# Testing that the second time derivative is calculated | ||
# correctly using the Central Difference method for an AD | ||
# variable. | ||
# | ||
# @Requirement F1.30 | ||
########################################################### | ||
|
||
[Mesh] | ||
type = GeneratedMesh | ||
dim = 2 | ||
xmin = -1 | ||
xmax = 1 | ||
ymin = -1 | ||
ymax = 1 | ||
nx = 1 | ||
ny = 1 | ||
[] | ||
|
||
[Variables] | ||
[./u] | ||
[../] | ||
[] | ||
|
||
[Functions] | ||
[./forcing_fn] | ||
type = PiecewiseLinear | ||
x = '0.0 0.1 0.2 0.3 0.4 0.5 0.6' | ||
y = '0.0 0.0 0.0025 0.01 0.0175 0.02 0.02' | ||
[../] | ||
[] | ||
|
||
[Kernels] | ||
[./ie] | ||
type = ADTimeDerivative | ||
variable = u | ||
[../] | ||
|
||
[./diff] | ||
type = ADDiffusion | ||
variable = u | ||
[../] | ||
[] | ||
|
||
[BCs] | ||
[./left] | ||
type = ADFunctionDirichletBC | ||
variable = u | ||
boundary = 'left' | ||
function = forcing_fn | ||
preset = false | ||
[../] | ||
[./right] | ||
type = ADFunctionDirichletBC | ||
variable = u | ||
boundary = 'right' | ||
function = forcing_fn | ||
preset = false | ||
[../] | ||
[] | ||
|
||
[Executioner] | ||
type = Transient | ||
|
||
[./TimeIntegrator] | ||
type = CentralDifference | ||
[] | ||
|
||
start_time = 0.0 | ||
num_steps = 6 | ||
dt = 0.1 | ||
[] | ||
|
||
[Postprocessors] | ||
[./udotdot] | ||
type = ElementAverageSecondTimeDerivative | ||
variable = u | ||
[../] | ||
[] | ||
|
||
[Outputs] | ||
csv = true | ||
[] |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
8 changes: 8 additions & 0 deletions
8
test/tests/time_integrators/central-difference/gold/ad_central_difference_dotdot_out.csv
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,8 @@ | ||
time,udotdot | ||
0,0 | ||
0.1,0 | ||
0.2,0 | ||
0.3,0.25 | ||
0.4,0.5 | ||
0.5,1.3010426069826e-16 | ||
0.6,-0.5 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
84 changes: 84 additions & 0 deletions
84
test/tests/time_integrators/newmark-beta/ad_newmark_beta_dotdot.i
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,84 @@ | ||
########################################################### | ||
# This is a simple test with a time-dependent problem | ||
# demonstrating the use of the TimeIntegrator system. | ||
# | ||
# Testing that the second time derivative is calculated | ||
# correctly using the Newmark-Beta method for an AD variable | ||
# | ||
# @Requirement F1.30 | ||
########################################################### | ||
|
||
[Mesh] | ||
type = GeneratedMesh | ||
dim = 2 | ||
xmin = -1 | ||
xmax = 1 | ||
ymin = -1 | ||
ymax = 1 | ||
nx = 1 | ||
ny = 1 | ||
[] | ||
|
||
[Variables] | ||
[./u] | ||
[../] | ||
[] | ||
|
||
[Functions] | ||
[./forcing_fn] | ||
type = PiecewiseLinear | ||
x = '0.0 0.1 0.2 0.3 0.4 0.5 0.6' | ||
y = '0.0 0.0 0.0025 0.01 0.0175 0.02 0.02' | ||
[../] | ||
[] | ||
|
||
[Kernels] | ||
[./ie] | ||
type = ADTimeDerivative | ||
variable = u | ||
[../] | ||
|
||
[./diff] | ||
type = ADDiffusion | ||
variable = u | ||
[../] | ||
[] | ||
|
||
[BCs] | ||
[./left] | ||
type = ADFunctionDirichletBC | ||
variable = u | ||
preset = false | ||
boundary = 'left' | ||
function = forcing_fn | ||
[../] | ||
[./right] | ||
type = ADFunctionDirichletBC | ||
variable = u | ||
preset = false | ||
boundary = 'right' | ||
function = forcing_fn | ||
[../] | ||
[] | ||
|
||
[Executioner] | ||
type = Transient | ||
|
||
# Time integrator scheme | ||
scheme = "newmark-beta" | ||
|
||
start_time = 0.0 | ||
num_steps = 6 | ||
dt = 0.1 | ||
[] | ||
|
||
[Postprocessors] | ||
[./udotdot] | ||
type = ADElementAverageSecondTimeDerivative | ||
variable = u | ||
[../] | ||
[] | ||
|
||
[Outputs] | ||
csv = true | ||
[] |
8 changes: 8 additions & 0 deletions
8
test/tests/time_integrators/newmark-beta/gold/ad_newmark_beta_dotdot_out.csv
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,8 @@ | ||
time,udotdot | ||
0,0 | ||
0.1,0 | ||
0.2,1 | ||
0.3,-5.7732263414323e-11 | ||
0.4,-1.0000000000423 | ||
0.5,6.8312333567633e-10 | ||
0.6,-1.7013536690591e-09 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters