idaholab / moose

Multiphysics Object Oriented Simulation Environment
https://www.mooseframework.org
GNU Lesser General Public License v2.1
1.72k stars 1.04k forks source link

PorousFlowPolyLineSink not working with plasticity #12962

Closed hsheldon closed 4 years ago

hsheldon commented 5 years ago

Rationale

PorousFlowPolyLineSink should work with plasticity @WilkAndy

Description

The following input file seg faults with git commit 7bb99349a8, but was working with git commit 7eb99a048b

# Example: Injection into a uniform aquifer 10 x 10 x 5 km
# Drucker-Prager deformation
# Darcy flow
# Using PorousFlow module
# Small example to test seg fault

[Mesh]
  type = GeneratedMesh
  dim = 3
  xmin = 0
  xmax = 1e4
  ymin = 0
  ymax = 1e4
  zmin = -5e3
  zmax = 0
  nx = 6
  ny = 6
  nz = 6
[]

[GlobalParams]
  block = '0'

  PorousFlowDictator = dictator
  gravity = '0 0 -9.81'
  biot_coefficient = 1.0
  solid_bulk = 1.0 # Required but irrelevant when biot_coefficient is unity

  displacements = 'disp_x disp_y disp_z'

  strain_at_nearest_qp = true

  # used by TensorMechanicsPlasticDruckerPragerHyperbolic
  yield_function_tolerance = 1
  internal_constraint_tolerance = 1E-6
  mc_interpolation_scheme = inner_tip # outer_tip, inner_tip or inner_edge
  use_custom_returnMap = true

  # Used in DruckerPrager materials:
  max_NR_iterations = 1000
  smoothing_tol = 1E5
  yield_function_tol = 1E-3
  perform_finite_strain_rotations = false
[]

[Modules]
  [./FluidProperties]
    [./simple_fluid]
      type = SimpleFluidProperties
      thermal_expansion = 0 # Set this to zero if you are not doing a thermal simualtion
      bulk_modulus = 2E9
      density0 = 1000
      viscosity = 5E-4
    [../]
  [../]
[]

[PorousFlowFullySaturated]
  coupling_type = HydroMechanical
  porepressure = pp
  dictator_name = dictator
  fp = simple_fluid
[]

[Variables]
  [./disp_x]
  [../]
  [./disp_y]
  [../]
  [./disp_z]
  [../]
  [./pp]
    scaling = 1E6
    [./InitialCondition]
      type = FunctionIC
      function = ini_pp
    [../]
  [../]
[]

[Functions]
  [./ini_stress]
    type = ParsedFunction
    vars = 'g rho_s rho_f poro' # gravity, solid density, fluid density, porosity
    vals = '-9.81 2350 1000 0.1'
    value = '-g*z*(rho_s-rho_f)*(1.0-poro)' # initial effective stress that should result from weight force
  [../]

  # Initial fluid pressure
  [./ini_pp]
    type = ParsedFunction
    vars = 'g rho_s rho_f'
    vals = '-9.81 2350 1000' # gravity, solid density, fluid density
    value = 'g*z*rho_f+1E5' 
  [../]
[]

[BCs]
  [./p_top]
    type = FunctionPresetBC
    variable = pp
    boundary = front
    function = ini_pp
  [../]

  [./xsides]
    type = PresetBC
    variable = disp_x
    boundary = 'left right'
    value = '0'
  [../]
  [./ysides]
    type = PresetBC
    variable = disp_y
    boundary = 'top bottom'
    value = '0'
  [../]
  [./z_sides]
    type = PresetBC
    variable = disp_z
    boundary = 'back front'
    value = '0'
  [../]
[]

[AuxVariables]
[]

[AuxKernels]
[]

[Postprocessors]
[]

[UserObjects]
  [./pls_total_outflow_mass]
    type = PorousFlowSumQuantity
  [../]

  # Cohesion
  [./mc_coh]
    type = TensorMechanicsHardeningConstant
    value = 6.0E6
  [../]

  # Friction angle
  [./mc_phi]
    type = TensorMechanicsHardeningConstant
    value = 35.0
    convert_to_radians = true
  [../]

  # Dilation angle
  [./mc_psi]
    type = TensorMechanicsHardeningConstant
    value = 2
    convert_to_radians = true
  [../]

  # Drucker-Prager objects
  [./dp]
    type = TensorMechanicsPlasticDruckerPragerHyperbolic
    mc_cohesion = mc_coh
    mc_friction_angle = mc_phi
    mc_dilation_angle = mc_psi
    smoother = 1E6
  [../]

  # Tensile strength
  [./tens]
    type = TensorMechanicsHardeningConstant
    value = 3.0E6
  [../]

  # Compressive strength (cap on yield envelope)
  [./compr_all]
    type = TensorMechanicsHardeningConstant
    value = 1E10
  [../]
[]

[Materials]  
  [./strain]
    type = ComputeIncrementalSmallStrain
    eigenstrain_names = eigenstrain_all
  [../]

  [./eigenstrain_all]
    type = ComputeEigenstrainFromInitialStress
    initial_stress = 'ini_stress 0 0  0 ini_stress 0  0 0 ini_stress'
    eigenstrain_name = eigenstrain_all
  [../]

  [./elasticity_tensor]
    type = ComputeIsotropicElasticityTensor
    bulk_modulus = 3.3333E9
    shear_modulus = 2.5E9
  [../]

  [./dp_mat]
    type = CappedDruckerPragerStressUpdate
    DP_model = 'dp'
    tensile_strength = 'tens'
    compressive_strength = 'compr_all'
    tip_smoother = 3.0E6
  [../]

  [./stress]
    type = ComputeMultipleInelasticStress
    inelastic_models = dp_mat
  [../]

  # Permeability
  [./permeability]
    type = PorousFlowPermeabilityConst
    permeability = '1E-13 0 0  0 1E-13 0  0 0 1E-13'
  [../]

  # Porosity 
  [./porosity_nodal]
    type = PorousFlowPorosity
    at_nodes = true
    porosity_zero = 0.1
    mechanical = true
    fluid = true
  [../]

  [./porosity_qp]
    type = PorousFlowPorosity
    porosity_zero = 0.1
    mechanical = true
    fluid = true
  [../]

 # Density of saturated rock
  [./density]
    type = PorousFlowTotalGravitationalDensityFullySaturatedFromPorosity
    rho_s = 2350
  [../]
[]

[DiracKernels]
  [./pls]
    type = PorousFlowPolyLineSink
    variable = pp
    SumQuantityUO = pls_total_outflow_mass
    point_file = two_nodes2.bh
    function_of = pressure
    fluid_phase = 0   
    p_or_t_vals = '0 1E7'
    fluxes = '-1.59 -1.59'
  [../]
[]

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

[Executioner]
  solve_type = Newton
  type = Transient
  line_search = bt

  dt = 2e5
  end_time = 1e6

  l_tol = 1E-5
  nl_abs_tol = 1E0
  nl_rel_tol = 1E-8
  l_max_its = 200
  nl_max_its = 30

  petsc_options_iname = '-pc_type -pc_asm_overlap -sub_pc_type -ksp_type -ksp_gmres_restart'
  petsc_options_value = ' asm      2              lu            gmres     200'
[]

[Outputs]
  file_base = uniform_genmesh_inject_SEGFAULT
  exodus = true
  csv = true
  execute_on = 'initial timestep_end'
[]

Impact

Necessary for users wishing to couple plasticity with PorousFlowPolyLineSink

hsheldon commented 5 years ago

Here's the .bh file for the above example:

1 5000.0 5000.0 -1400.0
1 5000.0 5000.0 -1500.0
WilkAndy commented 5 years ago

Start of debugging. Here is the trace:

/apps/gcc/4.9.3/include/c++/4.9.3/debug/vector:364:error: attempt to
    subscript container with out-of-bounds index 0, but container only
    holds 0 elements.

Objects involved in the operation:
sequence "this" @ 0x0x17ca890 {
  type = NSt7__debug6vectorIdSaIdEEE;
}

Thread 1 "porous_flow-dbg" received signal SIGABRT, Aborted.
0x00007fffe11bef67 in raise () from /lib64/libc.so.6
Missing separate debuginfos, use: zypper install libX11-6-debuginfo-1.6.2-12.5.1.x86_64 libXau6-debuginfo-1.0.8-4.58.x86_64 libcap2-debuginfo-2.22-13.1.x86_64 liblzma5-debuginfo-5.0.5-4.852.x86_64 libnl3-200-debuginfo-3.2.23-2.21.x86_64 libnuma1-debuginfo-2.0.9-9.1.x86_64 libpciaccess0-debuginfo-0.13.2-5.1.x86_64 libpcre1-debuginfo-8.39-8.3.1.x86_64 libselinux1-debuginfo-2.5-8.79.x86_64 libudev1-debuginfo-228-150.63.1.x86_64 libxcb1-debuginfo-1.10-4.3.1.x86_64 libxml2-2-debuginfo-2.9.4-46.15.1.x86_64 libz1-debuginfo-1.2.8-12.3.1.x86_64 sssd-debuginfo-1.13.4-34.23.1.x86_64 torque-debuginfo-6.1.1-335_cm8.1.x86_64
(gdb) bt
#0  0x00007fffe11bef67 in raise () from /lib64/libc.so.6
#1  0x00007fffe11c033a in abort () from /lib64/libc.so.6
#2  0x00007fffe73ff2c5 in __gnu_debug::_Error_formatter::_M_error (this=0x7fffffff8f70) at ../../../../../libstdc++-v3/src/c++11/debug.cc:782
#3  0x00007ffff75b44e9 in std::__debug::vector<double, std::allocator<double> >::operator[] (this=0x17ca890, __n=0)
    at /apps/gcc/4.9.3/include/c++/4.9.3/debug/vector:364
#4  0x00007ffff63ee5fa in CappedDruckerPragerStressUpdate::yieldFunctionValues (this=0x12ba670, p=-50060430, q=1.0753986783132436e-09, intnl=..., yf=...)
    at /projects/cmrp/projects_wil04q/moose/modules/tensor_mechanics/src/materials/CappedDruckerPragerStressUpdate.C:144
#5  0x00007ffff64a652b in TwoParameterPlasticityStressUpdate::yieldFunctionValuesV (this=0x12ba670, stress_params=..., intnl=..., yf=...)
    at /projects/cmrp/projects_wil04q/moose/modules/tensor_mechanics/src/materials/TwoParameterPlasticityStressUpdate.C:47
#6  0x00007ffff6491b19 in MultiParameterPlasticityStressUpdate::updateState (this=0x12ba670, strain_increment=..., inelastic_strain_increment=...,
    rotation_increment=..., stress_new=..., stress_old=..., elasticity_tensor=..., compute_full_tangent_operator=false, tangent_operator=...)
    at /projects/cmrp/projects_wil04q/moose/modules/tensor_mechanics/src/materials/MultiParameterPlasticityStressUpdate.C:165
#7  0x00007ffff64449e3 in ComputeMultipleInelasticStress::computeAdmissibleState (this=0x12f3750, model_number=0, elastic_strain_increment=...,
    inelastic_strain_increment=..., consistent_tangent_operator=...)
    at /projects/cmrp/projects_wil04q/moose/modules/tensor_mechanics/src/materials/ComputeMultipleInelasticStress.C:433
#8  0x00007ffff6444295 in ComputeMultipleInelasticStress::updateQpStateSingleModel (this=0x12f3750, model_number=0, elastic_strain_increment=...,
    combined_inelastic_strain_increment=...) at /projects/cmrp/projects_wil04q/moose/modules/tensor_mechanics/src/materials/ComputeMultipleInelasticStress.C:393
#9  0x00007ffff6442436 in ComputeMultipleInelasticStress::computeQpStressIntermediateConfiguration (this=0x12f3750)
    at /projects/cmrp/projects_wil04q/moose/modules/tensor_mechanics/src/materials/ComputeMultipleInelasticStress.C:206
#10 0x00007ffff6441fd3 in ComputeMultipleInelasticStress::computeQpStress (this=0x12f3750)
    at /projects/cmrp/projects_wil04q/moose/modules/tensor_mechanics/src/materials/ComputeMultipleInelasticStress.C:176
#11 0x00007ffff64543f4 in ComputeStressBase::computeQpProperties (this=0x12f3750)
    at /projects/cmrp/projects_wil04q/moose/modules/tensor_mechanics/src/materials/ComputeStressBase.C:53
#12 0x00007ffff3673565 in Material::computeProperties (this=0x12f3750) at /projects/cmrp/projects_wil04q/moose/framework/src/materials/Material.C:260
#13 0x00007ffff3673ca6 in MaterialData::reinit (this=0xe94fb0, mats=...) at /projects/cmrp/projects_wil04q/moose/framework/src/materials/MaterialData.C:70
#14 0x00007ffff37d1d0a in FEProblemBase::reinitMaterials (this=0xe74230, blk_id=0, tid=0, swap_stateful=false)
    at /projects/cmrp/projects_wil04q/moose/framework/src/problems/FEProblemBase.C:2524
#15 0x00007ffff3247ee0 in ComputeDiracThread::onElement (this=0x7fffffffaff0, elem=0xdf7c30)
    at /projects/cmrp/projects_wil04q/moose/framework/src/loops/ComputeDiracThread.C:103
#16 0x00007ffff3d07777 in ThreadedElementLoopBase<libMesh::StoredRange<__gnu_debug::_Safe_iterator<std::_Rb_tree_const_iterator<libMesh::Elem const*>, std::__debug::set<libMesh::Elem const*, std::less<libMesh::Elem const*>, std::allocator<libMesh::Elem const*> > >, libMesh::Elem const*> >::operator() (this=0x7fffffffaff0,
    range=..., bypass_threading=false) at /projects/cmrp/projects_wil04q/moose/framework/build/header_symlinks/ThreadedElementLoopBase.h:201
#17 0x00007ffff3ce13d0 in NonlinearSystemBase::computeDiracContributions (this=0xe959b0, tags=..., is_jacobian=false)
    at /projects/cmrp/projects_wil04q/moose/framework/src/systems/NonlinearSystemBase.C:2765
#18 0x00007ffff3cd88b6 in NonlinearSystemBase::computeResidualInternal (this=0xe959b0, tags=...)
    at /projects/cmrp/projects_wil04q/moose/framework/src/systems/NonlinearSystemBase.C:1427
#19 0x00007ffff3cd3d28 in NonlinearSystemBase::computeResidualTags (this=0xe959b0, tags=...)
    at /projects/cmrp/projects_wil04q/moose/framework/src/systems/NonlinearSystemBase.C:617
#20 0x00007ffff37dfc11 in FEProblemBase::computeResidualTags (this=0xe74230, tags=...)
    at /projects/cmrp/projects_wil04q/moose/framework/src/problems/FEProblemBase.C:4610
#21 0x00007ffff37df2a7 in FEProblemBase::computeResidualInternal (this=0xe74230, soln=..., residual=..., tags=...)
    at /projects/cmrp/projects_wil04q/moose/framework/src/problems/FEProblemBase.C:4474
#22 0x00007ffff37defbf in FEProblemBase::computeResidual (this=0xe74230, soln=..., residual=...)
    at /projects/cmrp/projects_wil04q/moose/framework/src/problems/FEProblemBase.C:4429
#23 0x00007ffff37dedeb in FEProblemBase::computeResidualSys (this=0xe74230, soln=..., residual=...)
    at /projects/cmrp/projects_wil04q/moose/framework/src/problems/FEProblemBase.C:4406
#24 0x00007ffff3cced36 in NonlinearSystem::solve (this=0xe959b0) at /projects/cmrp/projects_wil04q/moose/framework/src/systems/NonlinearSystem.C:154
#25 0x00007ffff37ddde6 in FEProblemBase::solve (this=0xe74230) at /projects/cmrp/projects_wil04q/moose/framework/src/problems/FEProblemBase.C:4166
#26 0x00007ffff3f83b8f in PicardSolve::solveStep (this=0xec9550, begin_norm_old=1.7976931348623157e+308, begin_norm=@0x1da9360: 0,
    end_norm_old=1.7976931348623157e+308, end_norm=@0x1d9e3c0: 0, relax=false, relaxed_dofs=...)
    at /projects/cmrp/projects_wil04q/moose/framework/src/executioners/PicardSolve.C:290
#27 0x00007ffff3f82c05 in PicardSolve::solve (this=0xec9550) at /projects/cmrp/projects_wil04q/moose/framework/src/executioners/PicardSolve.C:133
#28 0x00007ffff3653b19 in TimeStepper::step (this=0x1626f90) at /projects/cmrp/projects_wil04q/moose/framework/src/timesteppers/TimeStepper.C:156
#29 0x00007ffff3f89909 in Transient::takeStep (this=0xec9490, input_dt=-1) at /projects/cmrp/projects_wil04q/moose/framework/src/executioners/Transient.C:409
#30 0x00007ffff3f891a7 in Transient::execute (this=0xec9490) at /projects/cmrp/projects_wil04q/moose/framework/src/executioners/Transient.C:310
#31 0x00007ffff40c7d00 in MooseApp::executeExecutioner (this=0xb54810) at /projects/cmrp/projects_wil04q/moose/framework/src/base/MooseApp.C:846
#32 0x00007ffff40c85da in MooseApp::run (this=0xb54810) at /projects/cmrp/projects_wil04q/moose/framework/src/base/MooseApp.C:956
#33 0x00000000004187d0 in main (argc=3, argv=0x7fffffffc2c8) at /projects/cmrp/projects_wil04q/moose/modules/porous_flow/src/main.C:32
WilkAndy commented 5 years ago

The only change in tensor mechanics is:

git diff  7eb99a0 HEAD ../../modules/tensor_mechanics/src/materials/ComputeStressBase.C
diff --git a/modules/tensor_mechanics/src/materials/ComputeStressBase.C b/modules/tensor_mechanics/src/materials/ComputeStressBase.C
index f74e80da6b..c4bdda91b6 100644
--- a/modules/tensor_mechanics/src/materials/ComputeStressBase.C
+++ b/modules/tensor_mechanics/src/materials/ComputeStressBase.C
@@ -20,12 +20,6 @@ validParams<ComputeStressBase>()
                                "Optional parameter that allows the user to define "
                                "multiple mechanics material systems on the same "
                                "block, i.e. for multiple phases");
-  params.addParam<bool>("store_stress_old",
-                        false,
-                        "Parameter which indicates whether the old "
-                        "stress state, required for the HHT time "
-                        "integration scheme and Rayleigh damping, needs "
-                        "to be stored");
   params.suppressParameter<bool>("use_displaced_mesh");
   return params;
 }
@@ -39,8 +33,7 @@ ComputeStressBase::ComputeStressBase(const InputParameters & parameters)
     _elastic_strain(declareProperty<RankTwoTensor>(_base_name + "elastic_strain")),
     _elasticity_tensor(getMaterialPropertyByName<RankFourTensor>(_elasticity_tensor_name)),
     _extra_stress(getDefaultMaterialProperty<RankTwoTensor>(_base_name + "extra_stress")),
-    _Jacobian_mult(declareProperty<RankFourTensor>(_base_name + "Jacobian_mult")),
-    _store_stress_old(getParam<bool>("store_stress_old"))
+    _Jacobian_mult(declareProperty<RankFourTensor>(_base_name + "Jacobian_mult"))
 {

   if (getParam<bool>("use_displaced_mesh"))
WilkAndy commented 5 years ago

I don't have time to work on this full-time. But i do have lots of computer time available, so i'm going to do a bisection search on the git commit, to find the commit that introduced the segfault.

hsheldon commented 5 years ago

Sounds like a good plan.

WilkAndy commented 5 years ago

The above-mentioned git commit doesn't actually work. What we need instead, is this line added to the start of MultiParameterPlasticityStressUpdate::updateState:

if (_intnl[_qp].size() != _num_intnl || _yf[_qp].size() != _num_yf)
    initQpStatefulProperties();

At the very least, i need to add this line to the code, and add a test to ensure it works

WilkAndy commented 5 years ago

Just like your other recent issue (#12927), it looks like initQpStatefulProperties is not being called at the proper time.

WilkAndy commented 5 years ago

I think this is the same problem reported in #12545

WilkAndy commented 5 years ago

Closing this because it's fixed by #13477