-
Notifications
You must be signed in to change notification settings - Fork 21
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
#125, started adding kernel and scalarKernel for offDiagonal terms be…
…tween variable and scalarVariable. Runs with offdiagjacscalar branch of https://github.com/pou036/moose.git
- Loading branch information
Showing
6 changed files
with
294 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,42 @@ | ||
/****************************************************************/ | ||
/* 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 REDBACKOFFDIAGONALSCALARJACOBIAN_H | ||
#define REDBACKOFFDIAGONALSCALARJACOBIAN_H | ||
|
||
#include "Kernel.h" | ||
|
||
class RedbackOffDiagonalScalarJacobian; | ||
|
||
template <> | ||
InputParameters validParams<RedbackOffDiagonalScalarJacobian>(); | ||
|
||
class RedbackOffDiagonalScalarJacobian : public Kernel | ||
{ | ||
public: | ||
RedbackOffDiagonalScalarJacobian(const InputParameters & parameters); | ||
virtual ~RedbackOffDiagonalScalarJacobian(); | ||
|
||
protected: | ||
virtual Real computeQpResidual(); | ||
virtual Real computeQpJacobian(); | ||
virtual Real computeQpOffDiagJacobian(unsigned int jvar); | ||
unsigned int _sc_var; | ||
const VariableValue & _sc; | ||
unsigned int _z_var; | ||
const VariableValue & _z; | ||
|
||
}; | ||
|
||
#endif /* REDBACKOFFDIAGONALSCALARJACOBIAN_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,37 @@ | ||
/****************************************************************/ | ||
/* DO NOT MODIFY THIS HEADER */ | ||
/* REDBACK - Rock mEchanics with Dissipative feedBACKs */ | ||
/* */ | ||
/* (c) 2014 CSIRO and UNSW Australia */ | ||
/* ALL RIGHTS RESERVED */ | ||
/* */ | ||
/* Prepared by CSIRO and UNSW Australia */ | ||
/* */ | ||
/* See COPYRIGHT for full restrictions */ | ||
/****************************************************************/ | ||
|
||
#ifndef REDBACKOFFDIAGONALNONSCALAR_H | ||
#define REDBACKOFFDIAGONALNONSCALAR_H | ||
|
||
#include "ODEKernel.h" | ||
|
||
class RedbackOffDiagonalNonScalar; | ||
|
||
template <> | ||
InputParameters validParams<RedbackOffDiagonalNonScalar>(); | ||
|
||
class RedbackOffDiagonalNonScalar : public ODEKernel | ||
{ | ||
public: | ||
RedbackOffDiagonalNonScalar(const InputParameters & parameters); | ||
|
||
protected: | ||
const VariableValue & _non_scalar_variable; | ||
unsigned int _non_scalar_variable_var; | ||
|
||
virtual Real computeQpResidual(); | ||
virtual Real computeQpJacobian(); | ||
virtual Real computeQpOffDiagJacobian(unsigned int jvar); | ||
}; | ||
|
||
#endif /* REDBACKOFFDIAGONALNONSCALAR_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
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,61 @@ | ||
/****************************************************************/ | ||
/* DO NOT MODIFY THIS HEADER */ | ||
/* REDBACK - Rock mEchanics with Dissipative feedBACKs */ | ||
/* */ | ||
/* (c) 2014 CSIRO and UNSW Australia */ | ||
/* ALL RIGHTS RESERVED */ | ||
/* */ | ||
/* Prepared by CSIRO and UNSW Australia */ | ||
/* */ | ||
/* See COPYRIGHT for full restrictions */ | ||
/****************************************************************/ | ||
|
||
#include "RedbackOffDiagonalScalarJacobian.h" | ||
|
||
template <> | ||
InputParameters | ||
validParams<RedbackOffDiagonalScalarJacobian>() | ||
{ | ||
InputParameters params = validParams<Kernel>(); | ||
params.addRequiredCoupledVar("scalar_variable", "Scalar variable coupled into this kernel"); | ||
params.addCoupledVar("normal_variable", "Normal variable Z coupled into this kernel"); | ||
return params; | ||
} | ||
|
||
RedbackOffDiagonalScalarJacobian::RedbackOffDiagonalScalarJacobian(const InputParameters & parameters) : | ||
Kernel(parameters), | ||
_sc_var(coupledScalar("scalar_variable")), | ||
_sc(coupledScalarValue("scalar_variable")), | ||
_z_var(isCoupled("normal_variable")?coupled("normal_variable"):0), | ||
_z(isCoupled("normal_variable")?coupledValue("normal_variable"):_zero) | ||
{ | ||
std::cout << "RedbackOffDiagonalScalarJacobian, _sc_var=" << _sc_var << std::endl; | ||
//std::cout << "RedbackOffDiagonalScalarJacobian, _z_var=" << _z_var << std::endl; | ||
} | ||
|
||
RedbackOffDiagonalScalarJacobian::~RedbackOffDiagonalScalarJacobian() | ||
{ | ||
} | ||
|
||
Real | ||
RedbackOffDiagonalScalarJacobian::computeQpResidual() | ||
{ | ||
return 0; | ||
} | ||
|
||
Real | ||
RedbackOffDiagonalScalarJacobian::computeQpJacobian() | ||
{ | ||
return 0; | ||
} | ||
|
||
Real | ||
RedbackOffDiagonalScalarJacobian::computeQpOffDiagJacobian(unsigned int jvar) | ||
{ | ||
// This code is only called for the (normal) variables | ||
//std::string name = _sys.system().variable_name(jvar); => doens't work :-( | ||
Real x = _u[_qp]; | ||
Real y = _sc[_i]; | ||
std::cout << "RedbackOffDiagonalScalarJacobian::computeQpOffDiagJacobian, jvar=" << jvar <<", x=" << x << ", y=" << y <<std::endl; | ||
return 0; | ||
} |
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,54 @@ | ||
/****************************************************************/ | ||
/* DO NOT MODIFY THIS HEADER */ | ||
/* REDBACK - Rock mEchanics with Dissipative feedBACKs */ | ||
/* */ | ||
/* (c) 2014 CSIRO and UNSW Australia */ | ||
/* ALL RIGHTS RESERVED */ | ||
/* */ | ||
/* Prepared by CSIRO and UNSW Australia */ | ||
/* */ | ||
/* See COPYRIGHT for full restrictions */ | ||
/****************************************************************/ | ||
|
||
#include "RedbackOffDiagonalNonScalar.h" | ||
|
||
/** | ||
* This function defines the valid parameters for | ||
* this Kernel and their default values | ||
*/ | ||
template <> | ||
InputParameters | ||
validParams<RedbackOffDiagonalNonScalar>() | ||
{ | ||
InputParameters params = validParams<ODEKernel>(); | ||
params.addRequiredCoupledVar("non_scalar_variable", "The (non scalar) variable to couple"); | ||
return params; | ||
} | ||
|
||
RedbackOffDiagonalNonScalar::RedbackOffDiagonalNonScalar(const InputParameters & parameters) : | ||
ODEKernel(parameters), | ||
_non_scalar_variable(coupledValue("non_scalar_variable")), | ||
_non_scalar_variable_var(coupled("non_scalar_variable")) | ||
{ | ||
} | ||
|
||
Real | ||
RedbackOffDiagonalNonScalar::computeQpResidual() | ||
{ | ||
return 0.; | ||
} | ||
|
||
Real | ||
RedbackOffDiagonalNonScalar::computeQpJacobian() | ||
{ | ||
return 0.; | ||
} | ||
|
||
Real | ||
RedbackOffDiagonalNonScalar::computeQpOffDiagJacobian(unsigned int jvar) | ||
{ | ||
if (jvar == _non_scalar_variable_var) | ||
return 0.; | ||
else | ||
return 0.; | ||
} |
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,96 @@ | ||
[Mesh] | ||
type = GeneratedMesh | ||
dim = 3 | ||
[] | ||
|
||
[Variables] | ||
[./diffused] | ||
order = FIRST | ||
family = LAGRANGE | ||
[../] | ||
[./z] | ||
[../] | ||
[./y] | ||
family = SCALAR | ||
initial_condition = 1.234 | ||
[../] | ||
[] | ||
|
||
[Functions] | ||
[./init_gradient] | ||
type = ParsedFunction | ||
value = z | ||
[../] | ||
[] | ||
|
||
[Kernels] | ||
active = 'diff td_z' | ||
[./diff] | ||
type = Diffusion | ||
variable = diffused | ||
[../] | ||
[./test] | ||
type = RedbackOffDiagonalScalarJacobian | ||
variable = diffused | ||
normal_variable = z | ||
scalar_variable = y | ||
[../] | ||
[./td_z] | ||
type = TimeDerivative | ||
variable = z | ||
[../] | ||
[] | ||
|
||
[BCs] | ||
[./bottom] | ||
type = DirichletBC | ||
variable = diffused | ||
boundary = bottom | ||
value = 1 | ||
[../] | ||
[./top] | ||
type = DirichletBC | ||
variable = diffused | ||
boundary = top | ||
value = 0 | ||
[../] | ||
[] | ||
|
||
[Preconditioning] | ||
[./smp] | ||
type = SMP | ||
full = true | ||
[../] | ||
[] | ||
|
||
[Executioner] | ||
type = Transient | ||
num_steps = 1 | ||
solve_type = PJFNK | ||
[] | ||
|
||
[Outputs] | ||
execute_on = 'timestep_end initial' | ||
exodus = true | ||
[] | ||
|
||
[ICs] | ||
[./diffused_init] | ||
function = init_gradient | ||
variable = diffused | ||
type = FunctionIC | ||
[../] | ||
[] | ||
|
||
[ScalarKernels] | ||
[./td_y] | ||
variable = y | ||
type = ODETimeDerivative | ||
[../] | ||
[./offidiag] | ||
variable = y | ||
type = RedbackOffDiagonalNonScalar | ||
non_scalar_variable = diffused | ||
[../] | ||
[] | ||
|