Skip to content

Commit

Permalink
Add test correct spelling (idaholab#14220)
Browse files Browse the repository at this point in the history
  • Loading branch information
dschwen committed Oct 29, 2019
1 parent ab7e1b9 commit 83eefd4
Show file tree
Hide file tree
Showing 7 changed files with 84 additions and 14 deletions.
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
# PiecewiseLinear

!syntax description /Functions/CoarsendPiecewiseLinear
!syntax description /Functions/CoarsenedPiecewiseLinear

## Description

The `CoarsendPiecewiseLinear` performs preprocessing and linear interpolation
The `CoarsenedPiecewiseLinear` performs preprocessing and linear interpolation
on an x/y data set. The object acts like
[`PiecewiseLinear`](/PiecewiseLinear.md) except that it reduces the number of
function point at the start of the simulation. It uses the
Expand All @@ -15,8 +15,8 @@ for data reduction.

!listing test/tests/misc/check_error/function_file_test1.i block=Functions

!syntax parameters /Functions/CoarsendPiecewiseLinear
!syntax parameters /Functions/CoarsenedPiecewiseLinear

!syntax inputs /Functions/CoarsendPiecewiseLinear
!syntax inputs /Functions/CoarsenedPiecewiseLinear

!syntax children /Functions/CoarsendPiecewiseLinear
!syntax children /Functions/CoarsenedPiecewiseLinear
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
!syntax description /VectorPostprocessors/PiecewiseFunctionTabulate

This object can be used to check the function generated by a
[`CoarsendPicewiseLinear`](/CoarsendPicewiseLinear.md) function.
[`CoarsenedPicewiseLinear`](/CoarsenedPicewiseLinear.md) function.

!syntax parameters /VectorPostprocessors/PiecewiseFunctionTabulate

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,16 +11,16 @@

#include "PiecewiseLinearBase.h"

class CoarsendPiecewiseLinear;
class CoarsenedPiecewiseLinear;

template <>
InputParameters validParams<CoarsendPiecewiseLinear>();
InputParameters validParams<CoarsenedPiecewiseLinear>();

/**
* Perform a point reduction of the tabulated data upon initialization.
*/
class CoarsendPiecewiseLinear : public PiecewiseLinearBase
class CoarsenedPiecewiseLinear : public PiecewiseLinearBase
{
public:
CoarsendPiecewiseLinear(const InputParameters & parameters);
CoarsenedPiecewiseLinear(const InputParameters & parameters);
};
Original file line number Diff line number Diff line change
Expand Up @@ -7,15 +7,15 @@
//* Licensed under LGPL 2.1, please see LICENSE for details
//* https://www.gnu.org/licenses/lgpl-2.1.html

#include "CoarsendPiecewiseLinear.h"
#include "CoarsenedPiecewiseLinear.h"
#include "PointReduction.h"
#include "TimedPrint.h"

registerMooseObject("MooseApp", CoarsendPiecewiseLinear);
registerMooseObject("MooseApp", CoarsenedPiecewiseLinear);

template <>
InputParameters
validParams<CoarsendPiecewiseLinear>()
validParams<CoarsenedPiecewiseLinear>()
{
InputParameters params = validParams<PiecewiseLinearBase>();
params.addClassDescription("Perform a point reduction of the tabulated data upon initialization, "
Expand All @@ -36,7 +36,7 @@ validParams<CoarsendPiecewiseLinear>()
return params;
}

CoarsendPiecewiseLinear::CoarsendPiecewiseLinear(const InputParameters & parameters)
CoarsenedPiecewiseLinear::CoarsenedPiecewiseLinear(const InputParameters & parameters)
: PiecewiseLinearBase(parameters)
{
const Real x_scale = getParam<Real>("x_scale");
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,45 @@
[Mesh]
type = GeneratedMesh
dim = 1
[]

[Variables]
[./dummy]
[../]
[]

[Problem]
solve = false
kernel_coverage_check = false
[]

[Functions]
[./input]
type = CoarsenedPiecewiseLinear
data_file = input.csv
format = columns
epsilon = 0.1
x_scale = 0.03
[../]
[]

[VectorPostprocessors]
[./F]
type = PiecewiseFunctionTabulate
function = input
execute_on = INITIAL
outputs = vpp
[../]
[]

[Executioner]
type = Transient
num_steps = 1
[]

[Outputs]
[./vpp]
type = CSV
execute_vector_postprocessors_on = INITIAL
[../]
[]
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
#!/usr/bin/env python

import numpy as np

x = np.linspace(0, np.pi*10, 10000)
y = np.cos(x) * np.exp(-x/10.0)

np.savetxt("input.csv", np.transpose([x,y]), delimiter=",")
17 changes: 17 additions & 0 deletions test/tests/functions/coarsened_piecewise_linear/tests
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
[Tests]
issues = '#2272'
design = 'source/functions/CoarsenedPiecewiseLinear.md'

[./prepare_data]
type = RunCommand
command = './generate_data.py'
requirement = "Generate the fine tabulated function data for the coarsened_piecewise_linear test"
[../]
[./coarsened_piecewise_linear]
type = 'CSVDiff'
input = 'coarsened_piecewise_linear.i'
csvdiff = 'coarsened_piecewise_linear_vpp_F_0000.csv'
requirement = "The Function system shall include an object that creates a function based on x- and y-data pairs and returns an explicit value from the supplied data when queried (i.e., linear interpolation is not performed)."
prereq = 'prepare_data'
[../]
[]

0 comments on commit 83eefd4

Please sign in to comment.