Skip to content

Commit

Permalink
Added 1D current_carrying_wire test.
Browse files Browse the repository at this point in the history
  • Loading branch information
Alex Lindsay committed Aug 11, 2016
1 parent 4451248 commit 09c2955
Show file tree
Hide file tree
Showing 9 changed files with 275 additions and 0 deletions.
25 changes: 25 additions & 0 deletions include/kernels/AxisymmetricCurlZ.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
#ifndef AXISYMMETRICCURLZ_H
#define AXISYMMETRICCURLZ_H

#include "Kernel.h"

class AxisymmetricCurlZ;

template<>
InputParameters validParams<AxisymmetricCurlZ>();

class AxisymmetricCurlZ : public Kernel
{
public:
AxisymmetricCurlZ(const InputParameters & parameters);
virtual ~AxisymmetricCurlZ();

protected:

virtual Real computeQpResidual();
virtual Real computeQpJacobian();

};


#endif /* AXISYMMETRICCURLZ_H */
27 changes: 27 additions & 0 deletions include/kernels/UserSource.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
#ifndef USERSOURCE_H
#define USERSOURCE_H

#include "Kernel.h"

class UserSource;

template<>
InputParameters validParams<UserSource>();

class UserSource : public Kernel
{
public:
UserSource(const InputParameters & parameters);
virtual ~UserSource();

protected:

virtual Real computeQpResidual();
virtual Real computeQpJacobian();

Real _source;

};


#endif /* USERSOURCE_H */
76 changes: 76 additions & 0 deletions problems/current_carrying_wire.i
Original file line number Diff line number Diff line change
@@ -0,0 +1,76 @@
[Mesh]
type = GeneratedMesh
dim = 1
nx = 20
xmax = 2
xmin = 0
[]

[MeshModifiers]
[./vacuum]
type = SubdomainBoundingBox
bottom_left = '1 0 0'
top_right = '2 0 0'
block_id = 1
[../]
# [./interface]
# type = SideSetsBetweenSubdomains
# master_block = '1'
# paired_block = '0'
# new_boundary = 'interface'
# depends_on = 'vacuum'
# [../]
[]


[Problem]
[]

[Preconditioning]
[./smp]
type = SMP
full = true
[../]
[]

[Executioner]
type = Steady
solve_type = NEWTON
petsc_options_iname = '-pc_type -pc_factor_shift_type -pc_factor_shift_amount -ksp_type -snes_linesearch_minlambda'
petsc_options_value = 'lu NONZERO 1.e-10 preonly 1e-3'
[]

[Outputs]
print_perf_log = true
print_linear_residuals = false
[./out]
type = Exodus
[../]
[]

[Kernels]
[./curl_z]
type = AxisymmetricCurlZ
variable = Bphi
[../]
[./source]
type = UserSource
variable = Bphi
source_magnitude = 1
block = 0
[../]
[]

[Variables]
[./Bphi]
[../]
[]

[BCs]
[./center_of_wire]
type = DirichletBC
boundary = left
variable = Bphi
value = 0
[../]
[]
4 changes: 4 additions & 0 deletions src/base/ZapdosApp.C
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,8 @@
// #include "ModulesApp.h"

// Kernels
#include "UserSource.h"
#include "AxisymmetricCurlZ.h"
#include "TM0CylindricalEz.h"
#include "TM0CylindricalEr.h"
#include "TM0Cylindrical.h"
Expand Down Expand Up @@ -144,6 +146,8 @@ void
ZapdosApp::registerObjects(Factory & factory)
{
registerMeshModifier(NodeAndSidesetBetweenSubdomains);
registerKernel(AxisymmetricCurlZ);
registerKernel(UserSource);
registerKernel(TM0CylindricalEz);
registerKernel(TM0CylindricalEr);
registerKernel(TM0Cylindrical);
Expand Down
29 changes: 29 additions & 0 deletions src/kernels/AxisymmetricCurlZ.C
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
#include "AxisymmetricCurlZ.h"

template<>
InputParameters validParams<AxisymmetricCurlZ>()
{
InputParameters params = validParams<Kernel>();
return params;
}

AxisymmetricCurlZ::AxisymmetricCurlZ(const InputParameters & parameters) :
Kernel(parameters)
{
}

AxisymmetricCurlZ::~AxisymmetricCurlZ()
{
}

Real
AxisymmetricCurlZ::computeQpResidual()
{
return _test[_i][_qp] * (_u[_qp] / _q_point[_qp](0) + _grad_u[_qp](0));
}

Real
AxisymmetricCurlZ::computeQpJacobian()
{
return _test[_i][_qp] * (_phi[_j][_qp] / _q_point[_qp](0) + _grad_phi[_j][_qp](0));
}
31 changes: 31 additions & 0 deletions src/kernels/UserSource.C
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
#include "UserSource.h"

template<>
InputParameters validParams<UserSource>()
{
InputParameters params = validParams<Kernel>();
params.addRequiredParam<Real>("source_magnitude", "The numerical value of the source magnitude.");
return params;
}

UserSource::UserSource(const InputParameters & parameters) :
Kernel(parameters),
_source(getParam<Real>("source_magnitude"))
{
}

UserSource::~UserSource()
{
}

Real
UserSource::computeQpResidual()
{
return -_test[_i][_qp] * _source;
}

Real
UserSource::computeQpJacobian()
{
return 0.;
}
76 changes: 76 additions & 0 deletions tests/current_carrying_wire/current_carrying_wire.i
Original file line number Diff line number Diff line change
@@ -0,0 +1,76 @@
[Mesh]
type = GeneratedMesh
dim = 1
nx = 20
xmax = 2
xmin = 0
[]

[MeshModifiers]
[./vacuum]
type = SubdomainBoundingBox
bottom_left = '1 0 0'
top_right = '2 0 0'
block_id = 1
[../]
# [./interface]
# type = SideSetsBetweenSubdomains
# master_block = '1'
# paired_block = '0'
# new_boundary = 'interface'
# depends_on = 'vacuum'
# [../]
[]


[Problem]
[]

[Preconditioning]
[./smp]
type = SMP
full = true
[../]
[]

[Executioner]
type = Steady
solve_type = NEWTON
petsc_options_iname = '-pc_type -pc_factor_shift_type -pc_factor_shift_amount -ksp_type -snes_linesearch_minlambda'
petsc_options_value = 'lu NONZERO 1.e-10 preonly 1e-3'
[]

[Outputs]
print_perf_log = true
print_linear_residuals = false
[./out]
type = Exodus
[../]
[]

[Kernels]
[./curl_z]
type = AxisymmetricCurlZ
variable = Bphi
[../]
[./source]
type = UserSource
variable = Bphi
source_magnitude = 1
block = 0
[../]
[]

[Variables]
[./Bphi]
[../]
[]

[BCs]
[./center_of_wire]
type = DirichletBC
boundary = left
variable = Bphi
value = 0
[../]
[]
Binary file not shown.
7 changes: 7 additions & 0 deletions tests/current_carrying_wire/tests
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
[Tests]
[./current_carrying_wire]
type = 'Exodiff'
input = 'current_carrying_wire.i'
exodiff = 'current_carrying_wire_out.e'
[../]
[]

0 comments on commit 09c2955

Please sign in to comment.