Skip to content

Commit

Permalink
More fundamental testing of the Jacobian. (idaholab#5913)
Browse files Browse the repository at this point in the history
- Turned off currently_computing_jacobian flag in ExampleShapeElementUserObject
  because the storage was not getting assigned before the executeJacobian
  functions were getting called resulting in an index out-of-bounds error.
- Added hasActiveBlocks check to avoid segmentation faults
- Perform a dynamic pointer cast to test whether an elemental_object is a
  shape_elemental_object before performing executeJacobianWrapper
- Simplified jacobian.i test while trying to probe what's causing the wrong
  Jacobian
- I believe it's in the kernel: the kernel only loops over local _j when the
  ith residual is a function of dof's outside the local j's
  • Loading branch information
Alex Lindsay authored and SudiptaBiswas committed Aug 26, 2016
1 parent 07ec59d commit 2e9b619
Show file tree
Hide file tree
Showing 4 changed files with 18 additions and 14 deletions.
2 changes: 1 addition & 1 deletion framework/include/base/FEProblem.h
Original file line number Diff line number Diff line change
Expand Up @@ -340,7 +340,7 @@ class FEProblem :
/**
* Returns true if we are currently computing Jacobian
*/
virtual const bool & currentlyComputingJacobian() { return _currently_computing_jacobian; }
virtual bool currentlyComputingJacobian() { return _currently_computing_jacobian; }

/**
* Returns true if we are in or beyond the initialSetup stage
Expand Down
5 changes: 3 additions & 2 deletions framework/src/base/ComputeUserObjectsThread.C
Original file line number Diff line number Diff line change
Expand Up @@ -67,6 +67,7 @@ ComputeUserObjectsThread::subdomainChanged()
_fe_problem.prepareMaterials(_subdomain, _tid);

// ShapeElementUserObject requested Jacobian variables
if (_elemental_user_objects.hasActiveBlockObjects(_subdomain, _tid))
{
std::set<MooseVariable *> jacobian_moose_vars;

Expand All @@ -79,9 +80,9 @@ ComputeUserObjectsThread::subdomainChanged()
const std::set<MooseVariable *> & mv_deps = shape_element_uo->jacobianMooseVariables();
jacobian_moose_vars.insert(mv_deps.begin(), mv_deps.end());
}
}

_jacobian_moose_vars.assign(jacobian_moose_vars.begin(), jacobian_moose_vars.end());
_jacobian_moose_vars.assign(jacobian_moose_vars.begin(), jacobian_moose_vars.end());
}
}
}

Expand Down
2 changes: 1 addition & 1 deletion test/src/userobjects/ExampleShapeElementUserObject.C
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@ ExampleShapeElementUserObject::initialize()
// Jacobian term storage is up to the user. One option is using an std::vector
// We resize it to the total number of DOFs in the system and zero it out.
// WARNING: this can be large number (smart sparse storage could be a future improvement)
if (_currently_computing_jacobian)
// if (_currently_computing_jacobian)
_jacobian_storage.assign(_subproblem.es().n_dofs(), 0.0);
}

Expand Down
23 changes: 13 additions & 10 deletions test/tests/userobjects/shape_element_user_object/jacobian.i
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
[Mesh]
type = GeneratedMesh
dim = 2
nx = 3
ny = 3
dim = 1
nx = 2
# ny = 3
[]

[Variables]
Expand All @@ -15,11 +15,11 @@
[../]
[../]
[./v]
order = THIRD
family = HERMITE
order = FIRST
family = LAGRANGE
[./InitialCondition]
type = FunctionIC
function = (y-0.5)^2
function = (x-0.5)^2
[../]
[../]
[./w]
Expand Down Expand Up @@ -52,10 +52,10 @@
type = TimeDerivative
variable = v
[../]
[./time_w]
type = TimeDerivative
variable = w
[../]
# [./time_w]
# type = TimeDerivative
# variable = w
# [../]
[]

[UserObjects]
Expand All @@ -79,6 +79,9 @@
[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
[]

0 comments on commit 2e9b619

Please sign in to comment.