forked from idaholab/moose
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
5 changed files
with
185 additions
and
0 deletions.
There are no files selected for viewing
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,38 @@ | ||
//* 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 "ArrayInitialCondition.h" | ||
|
||
// Forward Declarations | ||
class ArrayFunctionIC; | ||
class Function; | ||
|
||
template <> | ||
InputParameters validParams<ArrayFunctionIC>(); | ||
|
||
class ArrayFunctionIC : public ArrayInitialCondition | ||
{ | ||
public: | ||
ArrayFunctionIC(const InputParameters & parameters); | ||
|
||
protected: | ||
/** | ||
* The value of the variable at a point. | ||
*/ | ||
virtual RealArrayValue value(const Point & p) override; | ||
|
||
/** | ||
* The value of the gradient at a point. | ||
*/ | ||
virtual RealVectorArrayValue gradient(const Point & p) override; | ||
|
||
std::vector<Function *> _func; | ||
}; |
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,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 | ||
|
||
#include "ArrayFunctionIC.h" | ||
#include "Function.h" | ||
|
||
registerMooseObject("MooseApp", ArrayFunctionIC); | ||
|
||
template <> | ||
InputParameters | ||
validParams<ArrayFunctionIC>() | ||
{ | ||
InputParameters params = validParams<ArrayInitialCondition>(); | ||
params.addRequiredParam<std::vector<FunctionName>>("function", | ||
"The initial condition functions."); | ||
|
||
params.addClassDescription("An initial condition that uses a normal function of x, y, z to " | ||
"produce values (and optionally gradients) for a field variable."); | ||
return params; | ||
} | ||
|
||
ArrayFunctionIC::ArrayFunctionIC(const InputParameters & parameters) | ||
: ArrayInitialCondition(parameters) | ||
{ | ||
auto & funcs = getParam<std::vector<FunctionName>>("function"); | ||
if (_var.count() != funcs.size()) | ||
mooseError("Number of functions does not agree with the number of array variable components"); | ||
for (auto & func : funcs) | ||
_func.push_back(&getFunctionByName(func)); | ||
} | ||
|
||
RealArrayValue | ||
ArrayFunctionIC::value(const Point & p) | ||
{ | ||
RealArrayValue v(_var.count()); | ||
for (unsigned int i = 0; i < _var.count(); ++i) | ||
v(i) = _func[i]->value(_t, p); | ||
return v; | ||
} | ||
|
||
RealVectorArrayValue | ||
ArrayFunctionIC::gradient(const Point & p) | ||
{ | ||
RealVectorArrayValue v(_var.count(), LIBMESH_DIM); | ||
for (unsigned int i = 0; i < _var.count(); ++i) | ||
{ | ||
auto gd = _func[i]->gradient(_t, p); | ||
for (unsigned int j = 0; j < LIBMESH_DIM; ++j) | ||
v(i, j) = gd(j); | ||
} | ||
return v; | ||
} |
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,79 @@ | ||
[Mesh] | ||
type = GeneratedMesh | ||
dim = 2 | ||
nx = 10 | ||
ny = 8 | ||
[] | ||
|
||
[Problem] | ||
kernel_coverage_check = false | ||
solve = false | ||
[] | ||
|
||
[Variables] | ||
[u] | ||
component = 2 | ||
[] | ||
[u0] | ||
[] | ||
[u1] | ||
[] | ||
[] | ||
|
||
[Functions] | ||
[sinx] | ||
type = ParsedFunction | ||
value = sin(x) | ||
[] | ||
[siny] | ||
type = ParsedFunction | ||
value = sin(y) | ||
[] | ||
[] | ||
|
||
[ICs] | ||
[uic] | ||
type = ArrayFunctionIC | ||
variable = u | ||
function = 'sinx siny' | ||
[] | ||
[u0ic] | ||
type = FunctionIC | ||
variable = u0 | ||
function = sinx | ||
[] | ||
[u1ic] | ||
type = FunctionIC | ||
variable = u1 | ||
function = siny | ||
[] | ||
[] | ||
|
||
[Postprocessors] | ||
[uint0] | ||
type = ElementIntegralArrayVariablePostprocessor | ||
variable = u | ||
component = 0 | ||
[] | ||
[uint1] | ||
type = ElementIntegralArrayVariablePostprocessor | ||
variable = u | ||
component = 1 | ||
[] | ||
[u0int] | ||
type = ElementIntegralVariablePostprocessor | ||
variable = u0 | ||
[] | ||
[u1int] | ||
type = ElementIntegralVariablePostprocessor | ||
variable = u1 | ||
[] | ||
[] | ||
|
||
[Executioner] | ||
type = Steady | ||
[] | ||
|
||
[Outputs] | ||
exodus = true | ||
[] |
Binary file not shown.
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,10 @@ | ||
[Tests] | ||
[./vector_constant_ic] | ||
type = 'Exodiff' | ||
input = 'array_function_ic_test.i' | ||
exodiff = 'array_function_ic_test_out.e' | ||
design = 'ArrayFunctionIC.md' | ||
requirement = 'The system shall allow to set initial conditions for an array variable based on functions.' | ||
issues = '#6881' | ||
[../] | ||
[] |