- functionsThis function will return Sum_over_i(w_i * functions_i)
C++ Type:std::vector<FunctionName>
Unit:(no unit assumed)
Controllable:No
Description:This function will return Sum_over_i(w_i * functions_i)
- wThis function will return Sum_over_i(w_i * functions_i)
C++ Type:std::vector<double>
Unit:(no unit assumed)
Controllable:No
Description:This function will return Sum_over_i(w_i * functions_i)
LinearCombinationFunction
Returns the linear combination of the functions
Example input syntax
In this input file, we show how a LinearCombinationFunction
may be used to combine a variety of different functions, then compare the results to a manually computed linear combination.
[Functions]
[./xtimes]
type = ParsedFunction
expression = 1.1*x
[../]
[./twoxplus1]
type = ParsedFunction
expression = 2*x+1
[../]
[./xsquared]
type = ParsedFunction
expression = (x-2)*x
[../]
[./tover2]
type = ParsedFunction
expression = 0.5*t
[../]
[./the_linear_combo]
type = LinearCombinationFunction
functions = 'xtimes twoxplus1 xsquared tover2'
w = '3 -1.2 0.4 3'
[../]
[./should_be_answer]
type = ParsedFunction
expression = 3*1.1*x-1.2*(2*x+1)+0.4*(x-2)*x+3*0.5*t
[../]
[]
Input Parameters
- control_tagsAdds user-defined labels for accessing object parameters via control logic.
C++ Type:std::vector<std::string>
Controllable:No
Description:Adds user-defined labels for accessing object parameters via control logic.
- enableTrueSet the enabled status of the MooseObject.
Default:True
C++ Type:bool
Controllable:No
Description:Set the enabled status of the MooseObject.
Advanced Parameters
Input Files
- (python/peacock/tests/input_tab/InputTree/gold/lcf1.i)
- (test/tests/functions/linear_combination_function/lcf_grad.i)
- (test/tests/functions/linear_combination_function/lcf_vector.i)
- (test/tests/functions/linear_combination_function/lcf1.i)
- (test/tests/functions/linear_combination_function/except1.i)
- (python/peacock/tests/common/lcf1.i)
(test/tests/functions/linear_combination_function/lcf1.i)
# LinearCombinationFunction function test
# See [Functions] block for a description of the tests
[Mesh]
type = GeneratedMesh
dim = 1
xmin = 0
xmax = 2
nx = 10
[]
[Variables]
[./dummy]
[../]
[]
[Kernels]
[./dummy_u]
type = TimeDerivative
variable = dummy
[../]
[]
[AuxVariables]
[./the_linear_combo]
[../]
[]
[AuxKernels]
[./the_linear_combo]
type = FunctionAux
variable = the_linear_combo
function = the_linear_combo
[../]
[]
[Functions]
[./xtimes]
type = ParsedFunction
expression = 1.1*x
[../]
[./twoxplus1]
type = ParsedFunction
expression = 2*x+1
[../]
[./xsquared]
type = ParsedFunction
expression = (x-2)*x
[../]
[./tover2]
type = ParsedFunction
expression = 0.5*t
[../]
[./the_linear_combo]
type = LinearCombinationFunction
functions = 'xtimes twoxplus1 xsquared tover2'
w = '3 -1.2 0.4 3'
[../]
[./should_be_answer]
type = ParsedFunction
expression = 3*1.1*x-1.2*(2*x+1)+0.4*(x-2)*x+3*0.5*t
[../]
[]
[Postprocessors]
[./should_be_zero]
type = NodalL2Error
function = should_be_answer
variable = the_linear_combo
[../]
[]
[Executioner]
type = Transient
dt = 0.5
end_time = 1
[]
[Outputs]
execute_on = 'timestep_end'
file_base = lcf1
hide = dummy
exodus = false
csv = true
[]
(python/peacock/tests/input_tab/InputTree/gold/lcf1.i)
# LinearCombinationFunction function test
# See [Functions] block for a description of the tests
[Mesh]
type = GeneratedMesh
dim = 1
xmin = 0
xmax = 2
nx = 10
[]
[Variables]
[dummy]
[]
[]
[Kernels]
[dummy_u]
type = TimeDerivative
variable = dummy
[]
[]
[AuxVariables]
[the_linear_combo]
[]
[]
[AuxKernels]
[the_linear_combo]
type = FunctionAux
variable = the_linear_combo
function = the_linear_combo
[]
[]
[Functions]
[xtimes]
type = ParsedFunction
expression = '1.1*x'
[]
[twoxplus1]
type = ParsedFunction
expression = '2*x+1'
[]
[xsquared]
type = ParsedFunction
expression = '(x-2)*x'
[]
[tover2]
type = ParsedFunction
expression = '0.5*t'
[]
[the_linear_combo]
type = LinearCombinationFunction
functions = 'xtimes twoxplus1 xsquared tover2'
w = '3 -1.2 0.4 3'
[]
[should_be_answer]
type = ParsedFunction
expression = '3*1.1*x-1.2*(2*x+1)+0.4*(x-2)*x+3*0.5*t'
[]
[]
[Postprocessors]
[should_be_zero]
type = NodalL2Error
function = should_be_answer
variable = 'the_linear_combo'
[]
[]
[Executioner]
type = Transient
dt = 0.5
end_time = 1
[]
[Outputs]
execute_on = 'timestep_end'
file_base = lcf1
hide = 'dummy'
exodus = false
csv = true
[]
(test/tests/functions/linear_combination_function/lcf_grad.i)
# LinearCombinationFunction function test
# See [Functions] block for a description of the tests
[Mesh]
type = GeneratedMesh
dim = 2
xmin = 0
xmax = 1
nx = 3
ny = 3
[]
[Variables]
[./dummy]
[../]
[]
[Kernels]
[./dummy_u]
type = TimeDerivative
variable = dummy
[../]
[]
[AuxVariables]
[./the_linear_combo_x]
order = CONSTANT
family = MONOMIAL
[../]
[./the_linear_combo_y]
order = CONSTANT
family = MONOMIAL
[../]
[]
[AuxKernels]
[./the_linear_combo_x]
type = FunctionDerivativeAux
component = x
variable = the_linear_combo_x
function = the_linear_combo
[../]
[./the_linear_combo_y]
type = FunctionDerivativeAux
component = y
variable = the_linear_combo_y
function = the_linear_combo
[../]
[]
[Functions]
[./xtimes]
type = ParsedGradFunction
value = '1.1*x+y'
grad_x = '1.1'
grad_y = '1'
[../]
[./twoxplus1]
type = ParsedGradFunction
value = '2*x+1'
grad_x = '2'
[../]
[./tover2]
type = ParsedGradFunction
value = '0.5*t-y*7'
grad_y = '-7'
[../]
[./the_linear_combo]
type = LinearCombinationFunction
functions = 'xtimes twoxplus1 tover2'
w = '3 -1.2 3'
[../]
[./should_be_answer_x]
type = ParsedFunction
expression = '3*1.1-1.2*2'
[../]
[./should_be_answer_y]
type = ParsedFunction
expression = '3*1+3*(-7)'
[../]
[]
[Postprocessors]
[./should_be_zero_x]
type = ElementL2Error
function = should_be_answer_x
variable = the_linear_combo_x
[../]
[./should_be_zero_y]
type = ElementL2Error
function = should_be_answer_y
variable = the_linear_combo_y
[../]
[]
[Executioner]
type = Transient
dt = 0.5
end_time = 1
[]
[Outputs]
execute_on = 'timestep_end'
file_base = lcf_grad
hide = dummy
exodus = false
csv = true
[]
(test/tests/functions/linear_combination_function/lcf_vector.i)
# use the vectorValue of a LinearCombinationFunction
[Mesh]
type = GeneratedMesh
dim = 2
nx = 10
ny = 10
uniform_refine = 1
[]
[Variables]
[./u]
[../]
[]
[Functions]
[./conductivity_1]
type = ParsedVectorFunction
expression_y = '0.1+x'
expression_x = '0.5*(1+x*y)'
[../]
[./conductivity_2]
type = ParsedVectorFunction
expression_y = '0.1+2*x'
expression_x = '0.2+x*y'
[../]
[./conductivity]
type = LinearCombinationFunction # yields value_y=0.1, value_x=0.8
functions = 'conductivity_1 conductivity_2'
w = '2 -1'
[../]
[]
[Kernels]
[./diff]
type = DiffTensorKernel
variable = u
conductivity = conductivity
[../]
[]
[BCs]
[./left]
type = DirichletBC
variable = u
boundary = left
value = 0
[../]
[./bottom]
type = DirichletBC
variable = u
boundary = bottom
value = 1
[../]
[]
[Executioner]
type = Steady
solve_type = 'PJFNK'
petsc_options_iname = '-pc_type -pc_hypre_type'
petsc_options_value = 'hypre boomeramg'
[]
[Outputs]
exodus = true
[]
(test/tests/functions/linear_combination_function/lcf1.i)
# LinearCombinationFunction function test
# See [Functions] block for a description of the tests
[Mesh]
type = GeneratedMesh
dim = 1
xmin = 0
xmax = 2
nx = 10
[]
[Variables]
[./dummy]
[../]
[]
[Kernels]
[./dummy_u]
type = TimeDerivative
variable = dummy
[../]
[]
[AuxVariables]
[./the_linear_combo]
[../]
[]
[AuxKernels]
[./the_linear_combo]
type = FunctionAux
variable = the_linear_combo
function = the_linear_combo
[../]
[]
[Functions]
[./xtimes]
type = ParsedFunction
expression = 1.1*x
[../]
[./twoxplus1]
type = ParsedFunction
expression = 2*x+1
[../]
[./xsquared]
type = ParsedFunction
expression = (x-2)*x
[../]
[./tover2]
type = ParsedFunction
expression = 0.5*t
[../]
[./the_linear_combo]
type = LinearCombinationFunction
functions = 'xtimes twoxplus1 xsquared tover2'
w = '3 -1.2 0.4 3'
[../]
[./should_be_answer]
type = ParsedFunction
expression = 3*1.1*x-1.2*(2*x+1)+0.4*(x-2)*x+3*0.5*t
[../]
[]
[Postprocessors]
[./should_be_zero]
type = NodalL2Error
function = should_be_answer
variable = the_linear_combo
[../]
[]
[Executioner]
type = Transient
dt = 0.5
end_time = 1
[]
[Outputs]
execute_on = 'timestep_end'
file_base = lcf1
hide = dummy
exodus = false
csv = true
[]
(test/tests/functions/linear_combination_function/except1.i)
# LinearCombinationFunction function test
# See [Functions] block for a description of the tests
[Mesh]
type = GeneratedMesh
dim = 1
xmin = 0
xmax = 2
nx = 10
[]
[Variables]
[./dummy]
[../]
[]
[Kernels]
[./dummy_u]
type = TimeDerivative
variable = dummy
[../]
[]
[AuxVariables]
[./the_linear_combo]
[../]
[]
[AuxKernels]
[./the_linear_combo]
type = FunctionAux
variable = the_linear_combo
function = the_linear_combo
[../]
[]
[Functions]
[./twoxplus1]
type = ParsedFunction
expression = 2*x+1
[../]
[./xsquared]
type = ParsedFunction
expression = x*x
[../]
[./the_linear_combo]
type = LinearCombinationFunction
functions = 'x twoxplus1 xsquared'
w = '0.5 5 0.4 0.3'
[../]
[./should_be_answer]
type = ParsedFunction
expression = 0.5*x+5*(2*x+1)*0.4*x*x+0.3*7
[../]
[]
[Postprocessors]
[./should_be_zero]
type = NodalL2Error
function = should_be_answer
variable = the_linear_combo
[../]
[]
[Executioner]
type = Transient
dt = 0.5
end_time = 1
[]
[Outputs]
execute_on = 'timestep_end'
hide = dummy
exodus = false
csv = true
[]
(python/peacock/tests/common/lcf1.i)
# LinearCombinationFunction function test
# See [Functions] block for a description of the tests
[Mesh]
type = GeneratedMesh
dim = 1
xmin = 0
xmax = 2
nx = 10
[]
[Variables]
[./dummy]
[../]
[]
[Kernels]
[./dummy_u]
type = TimeDerivative
variable = dummy
[../]
[]
[AuxVariables]
[./the_linear_combo]
[../]
[]
[AuxKernels]
[./the_linear_combo]
type = FunctionAux
variable = the_linear_combo
function = the_linear_combo
[../]
[]
[Functions]
[./xtimes]
type = ParsedFunction
expression = 1.1*x
[../]
[./twoxplus1]
type = ParsedFunction
expression = 2*x+1
[../]
[./xsquared]
type = ParsedFunction
expression = (x-2)*x
[../]
[./tover2]
type = ParsedFunction
expression = 0.5*t
[../]
[./the_linear_combo]
type = LinearCombinationFunction
functions = 'xtimes twoxplus1 xsquared tover2'
w = '3 -1.2 0.4 3'
[../]
[./should_be_answer]
type = ParsedFunction
expression = 3*1.1*x-1.2*(2*x+1)+0.4*(x-2)*x+3*0.5*t
[../]
[]
[Postprocessors]
[./should_be_zero]
type = NodalL2Error
function = should_be_answer
variable = the_linear_combo
[../]
[]
[Executioner]
type = Transient
dt = 0.5
end_time = 1
[]
[Outputs]
execute_on = 'timestep_end'
file_base = lcf1
hide = dummy
exodus = false
csv = true
[]