forked from idaholab/moose
-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Beginning construction of shape_side_uo test. (Issue idaholab#7980)
- Loading branch information
Alex Lindsay
committed
Nov 1, 2016
1 parent
a21fc47
commit bca59ed
Showing
3 changed files
with
189 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,40 @@ | ||
/****************************************************************/ | ||
/* DO NOT MODIFY THIS HEADER */ | ||
/* MOOSE - Multiphysics Object Oriented Simulation Environment */ | ||
/* */ | ||
/* (c) 2010 Battelle Energy Alliance, LLC */ | ||
/* ALL RIGHTS RESERVED */ | ||
/* */ | ||
/* Prepared by Battelle Energy Alliance, LLC */ | ||
/* Under Contract No. DE-AC07-05ID14517 */ | ||
/* With the U. S. Department of Energy */ | ||
/* */ | ||
/* See COPYRIGHT for full restrictions */ | ||
/****************************************************************/ | ||
#ifndef POTENTIALADVECTION_H_ | ||
#define POTENTIALADVECTION_H_ | ||
|
||
#include "Kernel.h" | ||
|
||
class PotentialAdvection; | ||
|
||
template<> | ||
InputParameters validParams<PotentialAdvection>(); | ||
|
||
class PotentialAdvection : public Kernel | ||
{ | ||
public: | ||
PotentialAdvection(const InputParameters & parameters); | ||
|
||
protected: | ||
virtual Real computeQpResidual(); | ||
virtual Real computeQpJacobian(); | ||
virtual Real computeQpOffDiagJacobian(unsigned int jvar); | ||
|
||
private: | ||
const VariableGradient & _grad_potential; | ||
unsigned int _potential_id; | ||
Real _sgn; | ||
}; | ||
|
||
#endif //POTENTIALADVECTION_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,52 @@ | ||
/****************************************************************/ | ||
/* DO NOT MODIFY THIS HEADER */ | ||
/* MOOSE - Multiphysics Object Oriented Simulation Environment */ | ||
/* */ | ||
/* (c) 2010 Battelle Energy Alliance, LLC */ | ||
/* ALL RIGHTS RESERVED */ | ||
/* */ | ||
/* Prepared by Battelle Energy Alliance, LLC */ | ||
/* Under Contract No. DE-AC07-05ID14517 */ | ||
/* With the U. S. Department of Energy */ | ||
/* */ | ||
/* See COPYRIGHT for full restrictions */ | ||
/****************************************************************/ | ||
#include "PotentialAdvection.h" | ||
|
||
template<> | ||
InputParameters validParams<PotentialAdvection>() | ||
{ | ||
InputParameters params = validParams<Kernel>(); | ||
params.addCoupledVar("potential", "The potential responsible for charge advection"); | ||
params.addParam<bool>("positive_charge", true, "Whether the potential is advecting positive charges. Should be set to false if charges are negative."); | ||
return params; | ||
} | ||
|
||
PotentialAdvection::PotentialAdvection(const InputParameters & parameters) : | ||
Kernel(parameters), | ||
_grad_potential(isCoupled("potential") ? coupledGradient("potential") : RealGradient(0.)), | ||
_potential_id(coupled("potential")), | ||
_sgn(getParam<bool>("positive_charge") ? 1 : -1) | ||
{} | ||
|
||
Real | ||
PotentialAdvection::computeQpResidual() | ||
{ | ||
return -_grad_test[_i][_qp] * _sgn * -_grad_potential[_qp] * _u[_qp]; | ||
} | ||
|
||
Real | ||
PotentialAdvection::computeQpJacobian() | ||
{ | ||
return -_grad_test[_i][_qp] * _sgn * -_grad_potential[_qp] * _phi[_j][_qp]; | ||
} | ||
|
||
Real | ||
PotentialAdvection::computeQpOffDiagJacobian(unsigned int jvar) | ||
{ | ||
if (jvar == _potential_id) | ||
return -_grad_test[_i][_qp] * _sgn * -_grad_phi[_j][_qp] * _u[_qp]; | ||
|
||
else | ||
return 0; | ||
} |
97 changes: 97 additions & 0 deletions
97
test/tests/userobjects/shape_element_user_object/shape_side_uo.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,97 @@ | ||
[Mesh] | ||
type = GeneratedMesh | ||
dim = 1 | ||
nx = 2 | ||
[] | ||
|
||
[Variables] | ||
[./u] | ||
order = FIRST | ||
family = LAGRANGE | ||
[./InitialCondition] | ||
type = FunctionIC | ||
function = (x-0.5)^2 | ||
[../] | ||
[../] | ||
[./v] | ||
order = FIRST | ||
family = LAGRANGE | ||
[./InitialCondition] | ||
type = FunctionIC | ||
function = (x-0.5)^2 | ||
[../] | ||
[../] | ||
[./w] | ||
order = FIRST | ||
family = LAGRANGE | ||
[./InitialCondition] | ||
type = FunctionIC | ||
function = (x-0.5)^2 | ||
[../] | ||
[../] | ||
[] | ||
|
||
[Kernels] | ||
[./diff_u] | ||
type = Diffusion | ||
variable = u | ||
[../] | ||
[./diff_v] | ||
type = Diffusion | ||
variable = v | ||
[../] | ||
[./shape_w] | ||
type = ExampleShapeElementKernel2 | ||
user_object = example_uo | ||
v = v | ||
u = u | ||
variable = w | ||
[../] | ||
[./time_w] | ||
type = TimeDerivative | ||
variable = w | ||
[../] | ||
[./time_u] | ||
type = TimeDerivative | ||
variable = u | ||
[../] | ||
[./time_v] | ||
type = TimeDerivative | ||
variable = v | ||
[../] | ||
[] | ||
|
||
[UserObjects] | ||
[./example_uo] | ||
type = ExampleShapeElementUserObject | ||
u = u | ||
v = v | ||
# as this userobject computes quantities for both the residual AND the jacobian | ||
# it needs to have these execute_on flags set. | ||
execute_on = 'linear nonlinear' | ||
[../] | ||
[] | ||
|
||
[Preconditioning] | ||
[./smp] | ||
type = SMP | ||
full = true | ||
#off_diag_row = 'w w' | ||
#off_diag_column = 'v u' | ||
[../] | ||
[] | ||
|
||
[Executioner] | ||
type = Transient | ||
solve_type = NEWTON | ||
petsc_options = '-snes_test_display' | ||
petsc_options_iname = '-snes_type' | ||
petsc_options_value = 'test' | ||
dt = 0.1 | ||
num_steps = 2 | ||
[] | ||
|
||
[Outputs] | ||
exodus = true | ||
print_perf_log = true | ||
[] |