コード例 #1
0
ファイル: PorousFlowWaterNCG.C プロジェクト: idaholab/moose
PorousFlowWaterNCG::PorousFlowWaterNCG(const InputParameters & parameters)
  : PorousFlowFluidStateMultiComponentBase(parameters),
    _water_fp(getUserObject<SinglePhaseFluidProperties>("water_fp")),
    _ncg_fp(getUserObject<SinglePhaseFluidProperties>("gas_fp")),
    _Mh2o(_water_fp.molarMass()),
    _Mncg(_ncg_fp.molarMass()),
    _water_triple_temperature(_water_fp.triplePointTemperature()),
    _water_critical_temperature(_water_fp.criticalTemperature())
{
  // Check that the correct FluidProperties UserObjects have been provided
  if (_water_fp.fluidName() != "water")
    paramError("water_fp", "A valid water FluidProperties UserObject must be provided in water_fp");

  // Set the number of phases and components, and their indexes
  _num_phases = 2;
  _num_components = 2;
  _gas_phase_number = 1 - _aqueous_phase_number;
  _gas_fluid_component = 1 - _aqueous_fluid_component;

  // Check that _aqueous_phase_number is <= total number of phases
  if (_aqueous_phase_number >= _num_phases)
    paramError("liquid_phase_number",
               "This value is larger than the possible number of phases ",
               _num_phases);

  // Check that _aqueous_fluid_component is <= total number of fluid components
  if (_aqueous_fluid_component >= _num_components)
    paramError("liquid_fluid_component",
               "This value is larger than the possible number of fluid components",
               _num_components);
}
コード例 #2
0
ComputeInterfaceStress::ComputeInterfaceStress(const InputParameters & parameters)
  : Material(parameters),
    _nvar(coupledComponents("v")),
    _grad_v(_nvar),
    _op_range(getParam<std::vector<Real>>("op_range")),
    _stress(getParam<std::vector<Real>>("stress")),
    _planar_stress(
        declareProperty<RankTwoTensor>(getParam<MaterialPropertyName>("planar_stress_name")))
{
  if (_stress.size() == 1)
    _stress.assign(_nvar, _stress[0]);
  if (_stress.size() != _nvar)
    paramError("stress", "Supply either one single stress or one per order parameter");

  if (_op_range.size() == 1)
    _op_range.assign(_nvar, _op_range[0]);
  if (_op_range.size() != _nvar)
    paramError("op_range", "Supply either one single op_range or one per order parameter");

  for (MooseIndex(_grad_v) i = 0; i < _nvar; ++i)
  {
    _grad_v[i] = &coupledGradient("v", i);
    _stress[i] /= _op_range[i];
  }
}
コード例 #3
0
TwoPhaseFluidProperties::TwoPhaseFluidProperties(const InputParameters & parameters)
  : FluidProperties(parameters),

    _liquid_name(isParamValid("fp_liquid") ? getParam<UserObjectName>("fp_liquid")
                                           : UserObjectName(name() + ":liquid")),
    _vapor_name(isParamValid("fp_vapor") ? getParam<UserObjectName>("fp_vapor")
                                         : UserObjectName(name() + ":vapor"))
{
  // If the single-phase fluid properties user object names are not provided, it
  // is implied that these objects will be created by a derived class. In this
  // case, we need to check that these user objects do not already exist.
  if (!isParamValid("fp_liquid"))
    if (_fe_problem.hasUserObject(_liquid_name))
      paramError("fp_liquid",
                 "The two-phase fluid properties object '" + name() + "' is ",
                 "trying to create a single-phase fluid properties object with ",
                 "name '",
                 _liquid_name,
                 "', but a single-phase fluid properties ",
                 "object with this name already exists.");
  if (!isParamValid("fp_vapor"))
    if (_fe_problem.hasUserObject(_vapor_name))
      paramError("fp_vapor",
                 "The two-phase fluid properties object '" + name() + "' is ",
                 "trying to create a single-phase fluid properties object with ",
                 "name '",
                 _vapor_name,
                 "', but a single-phase fluid properties ",
                 "object with this name already exists.");
}
コード例 #4
0
GlobalDisplacementAux::GlobalDisplacementAux(const InputParameters & parameters)
  : AuxKernel(parameters),
    _scalar_global_strain(coupledScalarValue("scalar_global_strain")),
    _component(getParam<unsigned int>("component")),
    _output_global_disp(getParam<bool>("output_global_displacement")),
    _pst(getUserObject<GlobalStrainUserObjectInterface>("global_strain_uo")),
    _periodic_dir(_pst.getPeriodicDirections()),
    _dim(_mesh.dimension()),
    _ndisp(coupledComponents("displacements")),
    _disp(_ndisp)
{
  if (!isNodal())
    paramError("variable", "GlobalDisplacementAux must be used on a nodal auxiliary variable");

  if (_component >= _dim)
    paramError("component",
               "The component ",
               _component,
               " does not exist for ",
               _dim,
               " dimensional problems");

  for (unsigned int i = 0; i < _ndisp; ++i)
    _disp[i] = &coupledValue("displacements", i);
}
コード例 #5
0
ファイル: Kernel.C プロジェクト: radioactivekate/moose
Kernel::Kernel(const InputParameters & parameters)
  : KernelBase(parameters),
    MooseVariableInterface<Real>(this, false),
    _var(*mooseVariable()),
    _test(_var.phi()),
    _grad_test(_var.gradPhi()),
    _phi(_assembly.phi(_var)),
    _grad_phi(_assembly.gradPhi(_var)),
    _u(_is_implicit ? _var.sln() : _var.slnOld()),
    _grad_u(_is_implicit ? _var.gradSln() : _var.gradSlnOld()),
    _u_dot(_var.uDot()),
    _du_dot_du(_var.duDotDu())
{
  addMooseVariableDependency(mooseVariable());
  _save_in.resize(_save_in_strings.size());
  _diag_save_in.resize(_diag_save_in_strings.size());

  for (unsigned int i = 0; i < _save_in_strings.size(); i++)
  {
    MooseVariable * var = &_subproblem.getStandardVariable(_tid, _save_in_strings[i]);

    if (_fe_problem.getNonlinearSystemBase().hasVariable(_save_in_strings[i]))
      paramError("save_in", "cannot use solution variable as save-in variable");

    if (var->feType() != _var.feType())
      paramError(
          "save_in",
          "saved-in auxiliary variable is incompatible with the object's nonlinear variable: ",
          moose::internal::incompatVarMsg(*var, _var));

    _save_in[i] = var;
    var->sys().addVariableToZeroOnResidual(_save_in_strings[i]);
    addMooseVariableDependency(var);
  }

  _has_save_in = _save_in.size() > 0;

  for (unsigned int i = 0; i < _diag_save_in_strings.size(); i++)
  {
    MooseVariable * var = &_subproblem.getStandardVariable(_tid, _diag_save_in_strings[i]);

    if (_fe_problem.getNonlinearSystemBase().hasVariable(_diag_save_in_strings[i]))
      paramError("diag_save_in", "cannot use solution variable as diag save-in variable");

    if (var->feType() != _var.feType())
      paramError(
          "diag_save_in",
          "saved-in auxiliary variable is incompatible with the object's nonlinear variable: ",
          moose::internal::incompatVarMsg(*var, _var));

    _diag_save_in[i] = var;
    var->sys().addVariableToZeroOnJacobian(_diag_save_in_strings[i]);
    addMooseVariableDependency(var);
  }

  _has_diag_save_in = _diag_save_in.size() > 0;
}
コード例 #6
0
ファイル: ADIntegratedBC.C プロジェクト: amjokisaari/moose
ADIntegratedBCTempl<T, compute_stage>::ADIntegratedBCTempl(const InputParameters & parameters)
  : IntegratedBCBase(parameters),
    MooseVariableInterface<T>(this,
                              false,
                              "variable",
                              Moose::VarKindType::VAR_NONLINEAR,
                              std::is_same<T, Real>::value ? Moose::VarFieldType::VAR_FIELD_STANDARD
                                                           : Moose::VarFieldType::VAR_FIELD_VECTOR),
    _var(*this->mooseVariable()),
    _normals(_assembly.adNormals<compute_stage>()),
    _ad_q_points(_assembly.adQPointsFace<compute_stage>()),
    _test(_var.phiFace()),
    _grad_test(_var.template adGradPhiFace<compute_stage>()),
    _u(_var.template adSln<compute_stage>()),
    _grad_u(_var.template adGradSln<compute_stage>()),
    _ad_JxW(_assembly.adJxWFace<compute_stage>())
{
  addMooseVariableDependency(this->mooseVariable());

  _save_in.resize(_save_in_strings.size());
  _diag_save_in.resize(_diag_save_in_strings.size());

  for (unsigned int i = 0; i < _save_in_strings.size(); i++)
  {
    MooseVariable * var = &_subproblem.getStandardVariable(_tid, _save_in_strings[i]);

    if (var->feType() != _var.feType())
      paramError(
          "save_in",
          "saved-in auxiliary variable is incompatible with the object's nonlinear variable: ",
          moose::internal::incompatVarMsg(*var, _var));
    _save_in[i] = var;
    var->sys().addVariableToZeroOnResidual(_save_in_strings[i]);
    addMooseVariableDependency(var);
  }

  _has_save_in = _save_in.size() > 0;

  for (unsigned int i = 0; i < _diag_save_in_strings.size(); i++)
  {
    MooseVariable * var = &_subproblem.getStandardVariable(_tid, _diag_save_in_strings[i]);

    if (var->feType() != _var.feType())
      paramError(
          "diag_save_in",
          "saved-in auxiliary variable is incompatible with the object's nonlinear variable: ",
          moose::internal::incompatVarMsg(*var, _var));

    _diag_save_in[i] = var;
    var->sys().addVariableToZeroOnJacobian(_diag_save_in_strings[i]);
    addMooseVariableDependency(var);
  }

  _has_diag_save_in = _diag_save_in.size() > 0;
}
コード例 #7
0
ファイル: IntegratedBC.C プロジェクト: aashiquear/moose
IntegratedBC::IntegratedBC(const InputParameters & parameters)
  : IntegratedBCBase(parameters),
    MooseVariableInterface<Real>(this,
                                 false,
                                 "variable",
                                 Moose::VarKindType::VAR_NONLINEAR,
                                 Moose::VarFieldType::VAR_FIELD_STANDARD),
    _var(*mooseVariable()),
    _normals(_var.normals()),
    _phi(_assembly.phiFace(_var)),
    _grad_phi(_assembly.gradPhiFace(_var)),
    _test(_var.phiFace()),
    _grad_test(_var.gradPhiFace()),
    _u(_is_implicit ? _var.sln() : _var.slnOld()),
    _grad_u(_is_implicit ? _var.gradSln() : _var.gradSlnOld())
{
  addMooseVariableDependency(mooseVariable());

  _save_in.resize(_save_in_strings.size());
  _diag_save_in.resize(_diag_save_in_strings.size());

  for (unsigned int i = 0; i < _save_in_strings.size(); i++)
  {
    MooseVariable * var = &_subproblem.getStandardVariable(_tid, _save_in_strings[i]);

    if (var->feType() != _var.feType())
      paramError(
          "save_in",
          "saved-in auxiliary variable is incompatible with the object's nonlinear variable: ",
          moose::internal::incompatVarMsg(*var, _var));
    _save_in[i] = var;
    var->sys().addVariableToZeroOnResidual(_save_in_strings[i]);
    addMooseVariableDependency(var);
  }

  _has_save_in = _save_in.size() > 0;

  for (unsigned int i = 0; i < _diag_save_in_strings.size(); i++)
  {
    MooseVariable * var = &_subproblem.getStandardVariable(_tid, _diag_save_in_strings[i]);

    if (var->feType() != _var.feType())
      paramError(
          "diag_save_in",
          "saved-in auxiliary variable is incompatible with the object's nonlinear variable: ",
          moose::internal::incompatVarMsg(*var, _var));

    _diag_save_in[i] = var;
    var->sys().addVariableToZeroOnJacobian(_diag_save_in_strings[i]);
    addMooseVariableDependency(var);
  }

  _has_diag_save_in = _diag_save_in.size() > 0;
}
コード例 #8
0
ファイル: NodalBC.C プロジェクト: FHilty/moose
NodalBC::NodalBC(const InputParameters & parameters)
  : NodalBCBase(parameters),
    MooseVariableInterface<Real>(this,
                                 true,
                                 "variable",
                                 Moose::VarKindType::VAR_NONLINEAR,
                                 Moose::VarFieldType::VAR_FIELD_STANDARD),
    _var(*mooseVariable()),
    _current_node(_var.node()),
    _u(_var.dofValues())
{
  addMooseVariableDependency(mooseVariable());

  _save_in.resize(_save_in_strings.size());
  _diag_save_in.resize(_diag_save_in_strings.size());

  for (unsigned int i = 0; i < _save_in_strings.size(); i++)
  {
    MooseVariable * var = &_subproblem.getStandardVariable(_tid, _save_in_strings[i]);

    if (var->feType() != _var.feType())
      paramError(
          "save_in",
          "saved-in auxiliary variable is incompatible with the object's nonlinear variable: ",
          moose::internal::incompatVarMsg(*var, _var));

    _save_in[i] = var;
    var->sys().addVariableToZeroOnResidual(_save_in_strings[i]);
    addMooseVariableDependency(var);
  }

  _has_save_in = _save_in.size() > 0;

  for (unsigned int i = 0; i < _diag_save_in_strings.size(); i++)
  {
    MooseVariable * var = &_subproblem.getStandardVariable(_tid, _diag_save_in_strings[i]);

    if (var->feType() != _var.feType())
      paramError(
          "diag_save_in",
          "saved-in auxiliary variable is incompatible with the object's nonlinear variable: ",
          moose::internal::incompatVarMsg(*var, _var));

    _diag_save_in[i] = var;
    var->sys().addVariableToZeroOnJacobian(_diag_save_in_strings[i]);
    addMooseVariableDependency(var);
  }

  _has_diag_save_in = _diag_save_in.size() > 0;
}
コード例 #9
0
PorousFlowNearestQp::PorousFlowNearestQp(const InputParameters & parameters)
  : PorousFlowMaterial(parameters),
    _nearest_qp(declareProperty<unsigned>("PorousFlow_nearestqp_nodal"))
{
  if (getParam<bool>("nodal_material") == false)
    paramError("nodal_material", "This must be a nodal material!");
}
コード例 #10
0
void
PolycrystalUserObjectBase::assignOpsToGrains()
{
  mooseAssert(_is_master, "This routine should only be called on the master rank");

  Moose::perf_log.push("assignOpsToGrains()", "PolycrystalICTools");

  // Use a simple backtracking coloring algorithm
  if (_coloring_algorithm == "bt")
  {
    paramInfo("coloring_algorithm",
              "The backtracking algorithm has exponential complexity. If you are using very few "
              "order parameters, or you have several hundred grains or more, you should use one of "
              "the PETSc coloring algorithms such as \"jp\".");

    if (!colorGraph(0))
      paramError("op_num",
                 "Unable to find a valid grain to op coloring, Make sure you have created enough "
                 "variables to hold a valid polycrystal initial condition (no grains represented "
                 "by the same variable should be allowed to touch, ~8 for 2D, ~25 for 3D)?");
  }
  else // PETSc Coloring algorithms
  {
#ifdef LIBMESH_HAVE_PETSC
    const std::string & ca_str = _coloring_algorithm;
    Real * am_data = _adjacency_matrix->get_values().data();

    try
    {
      Moose::PetscSupport::colorAdjacencyMatrix(
          am_data, _feature_count, _vars.size(), _grain_to_op, ca_str.c_str());
    }
    catch (std::runtime_error & e)
    {
      paramError("op_num",
                 "Unable to find a valid grain to op coloring, Make sure you have created enough "
                 "variables to hold a valid polycrystal initial condition (no grains represented "
                 "by the same variable should be allowed to touch, ~8 for 2D, ~25 for 3D)?");
    }
#else
    mooseError("Selected coloring algorithm requires PETSc");
#endif
  }

  Moose::perf_log.pop("assignOpsToGrains()", "PolycrystalICTools");
}
コード例 #11
0
PorousFlowHeatEnergy::PorousFlowHeatEnergy(const InputParameters & parameters)
  : ElementIntegralPostprocessor(parameters),
    _dictator(getUserObject<PorousFlowDictator>("PorousFlowDictator")),
    _num_phases(_dictator.numPhases()),
    _fluid_present(_num_phases > 0),
    _include_porous_skeleton(getParam<bool>("include_porous_skeleton")),
    _phase_index(getParam<std::vector<unsigned int>>("phase")),
    _porosity(getMaterialProperty<Real>("PorousFlow_porosity_nodal")),
    _rock_energy_nodal(getMaterialProperty<Real>("PorousFlow_matrix_internal_energy_nodal")),
    _fluid_density(_fluid_present ? &getMaterialProperty<std::vector<Real>>(
                                        "PorousFlow_fluid_phase_density_nodal")
                                  : nullptr),
    _fluid_saturation_nodal(
        _fluid_present ? &getMaterialProperty<std::vector<Real>>("PorousFlow_saturation_nodal")
                       : nullptr),
    _energy_nodal(_fluid_present ? &getMaterialProperty<std::vector<Real>>(
                                       "PorousFlow_fluid_phase_internal_energy_nodal")
                                 : nullptr),
    _var(getParam<unsigned>("kernel_variable_number") < _dictator.numVariables()
             ? _dictator.getCoupledStandardMooseVars()[getParam<unsigned>("kernel_variable_number")]
             : nullptr)
{
  if (!_phase_index.empty())
  {
    // Check that the phase indices entered are not greater than the number of phases
    const unsigned int max_phase_num = *std::max_element(_phase_index.begin(), _phase_index.end());
    if (max_phase_num > _num_phases - 1)
      paramError("phase",
                 "The Dictator proclaims that the phase index ",
                 max_phase_num,
                 " is greater than the largest phase index possible, which is ",
                 _num_phases - 1);
  }

  // Check that kernel_variable_number is OK
  if (getParam<unsigned>("kernel_variable_number") >= _dictator.numVariables())
    paramError("kernel_variable_number",
               "The Dictator pronounces that the number of PorousFlow variables is ",
               _dictator.numVariables(),
               ", however you have used ",
               getParam<unsigned>("kernel_variable_number"),
               ". This is an error");
}
コード例 #12
0
void
BimodalInverseSuperellipsoidsIC::initialSetup()
{
  if (_size_variation_type == 2 && _size_variation > 0.0)
    paramError("size_variation",
               "If size_variation > 0.0, you must pass in a size_variation_type in "
               "BimodalInverseSuperellipsoidsIC");

  BimodalSuperellipsoidsIC::initialSetup();
}
コード例 #13
0
MultiAppNearestNodeTransfer::MultiAppNearestNodeTransfer(const InputParameters & parameters)
  : MultiAppFieldTransfer(parameters),
    _fixed_meshes(getParam<bool>("fixed_meshes")),
    _node_map(declareRestartableData<std::map<dof_id_type, Node *>>("node_map")),
    _distance_map(declareRestartableData<std::map<dof_id_type, Real>>("distance_map")),
    _neighbors_cached(declareRestartableData<bool>("neighbors_cached", false)),
    _cached_froms(declareRestartableData<std::vector<std::vector<unsigned int>>>("cached_froms")),
    _cached_dof_ids(
        declareRestartableData<std::vector<std::vector<dof_id_type>>>("cached_dof_ids")),
    _cached_from_inds(
        declareRestartableData<std::map<dof_id_type, unsigned int>>("cached_from_ids")),
    _cached_qp_inds(declareRestartableData<std::map<dof_id_type, unsigned int>>("cached_qp_inds"))
{
  if (_to_var_names.size() != 1)
    paramError("variable", " Support single to-variable only");

  if (_from_var_names.size() != 1)
    paramError("source_variable", " Support single from-variable only");
}
コード例 #14
0
ファイル: AdvectionBC.C プロジェクト: idaholab/moose
AdvectionBC::AdvectionBC(const InputParameters & parameters)
  : IntegratedBC(parameters), _dim(_mesh.dimension()), _outflow(getParam<bool>("outflow"))
{
  // check if # components matches mesh's dim
  if (_dim != coupledComponents("velocity_vector"))
    paramError("velocity_vector",
               "Number of components of velocity_vector must match mesh dimension");

  _velocity.resize(_dim);
  for (unsigned int j = 0; j < _dim; ++j)
    _velocity[j] = &coupledValue("velocity_vector", j);
}
コード例 #15
0
ファイル: ACGrGrMulti.C プロジェクト: huangh-inl/moose
ACGrGrMulti::ACGrGrMulti(const InputParameters & parameters)
  : ACGrGrBase(parameters),
    _gamma_names(getParam<std::vector<MaterialPropertyName>>("gamma_names")),
    _num_j(_gamma_names.size()),
    _prop_gammas(_num_j)
{
  // check passed in parameter vectors
  if (_num_j != coupledComponents("v"))
    paramError("gamma_names",
               "Need to pass in as many gamma_names as coupled variables in v in ACGrGrMulti");

  for (unsigned int n = 0; n < _num_j; ++n)
    _prop_gammas[n] = &getMaterialPropertyByName<Real>(_gamma_names[n]);
}
コード例 #16
0
NodalEqualValueConstraint::NodalEqualValueConstraint(const InputParameters & parameters)
  : NodalScalarKernel(parameters)
{
  if (_node_ids.size() != 2)
    paramError("boundary", "invalid number of nodes: want 2, got ", _node_ids.size());

  unsigned int n = coupledComponents("var");
  _value.resize(n);
  _val_number.resize(n);
  for (unsigned int k = 0; k < n; k++)
  {
    _value[k] = &coupledValue("var", k);
    _val_number[k] = coupled("var", k);
  }
}
コード例 #17
0
ファイル: SmoothCircleBaseIC.C プロジェクト: aashiquear/moose
SmoothCircleBaseIC::SmoothCircleBaseIC(const InputParameters & parameters)
  : InitialCondition(parameters),
    _mesh(_fe_problem.mesh()),
    _invalue(parameters.get<Real>("invalue")),
    _outvalue(parameters.get<Real>("outvalue")),
    _int_width(parameters.get<Real>("int_width")),
    _3D_spheres(parameters.get<bool>("3D_spheres")),
    _zero_gradient(parameters.get<bool>("zero_gradient")),
    _num_dim(_3D_spheres ? 3 : 2),
    _profile(getParam<MooseEnum>("profile").getEnum<ProfileType>())
{
  _random.seed(_tid, getParam<unsigned int>("rand_seed"));

  if (_int_width <= 0.0 && _profile == ProfileType::TANH)
    paramError("int_width",
               "Interface width has to be strictly positive for the hyperbolic tangent profile");
}
コード例 #18
0
void
MultiAppCopyTransfer::transfer(FEProblemBase & to_problem, FEProblemBase & from_problem)
{
  // Populate the to/from variables needed to perform the transfer
  MooseVariableFE & to_var = to_problem.getVariable(0, _to_var_name);
  MeshBase & to_mesh = to_problem.mesh().getMesh();

  MooseVariableFE & from_var = from_problem.getVariable(0, _from_var_name);
  MeshBase & from_mesh = from_problem.mesh().getMesh();

  // Check integrity
  if (to_var.feType() != from_var.feType())
    paramError("variable",
               "'variable' and 'source_variable' must be the same type (order and family): ",
               libMesh::Utility::enum_to_string<FEFamily>(to_var.feType().family),
               moose::internal::incompatVarMsg(to_var, from_var));

  if ((to_mesh.n_nodes() != from_mesh.n_nodes()) || (to_mesh.n_elem() != from_mesh.n_elem()))
    mooseError("The meshes must be identical to utilize MultiAppCopyTransfer.");

  // Transfer node dofs
  MeshBase::const_node_iterator node_it = to_mesh.local_nodes_begin();
  MeshBase::const_node_iterator node_end = to_mesh.local_nodes_end();
  for (; node_it != node_end; ++node_it)
    transferDofObject(*node_it, from_mesh.node_ptr((*node_it)->id()), to_var, from_var);

  // Transfer elem dofs
  MeshBase::const_element_iterator elem_it = to_mesh.local_elements_begin();
  MeshBase::const_element_iterator elem_end = to_mesh.local_elements_end();
  Elem * to_elem;
  Elem * from_elem;
  for (; elem_it != elem_end; ++elem_it)
  {
    to_elem = *elem_it;
    from_elem = from_mesh.elem_ptr(to_elem->id());
    mooseAssert(to_elem->type() == from_elem->type(), "The elements must be the same type.");
    transferDofObject(to_elem, from_elem, to_var, from_var);
  }

  to_var.sys().solution().close();
  to_var.sys().update();
}
コード例 #19
0
PorousFlowVolumetricStrain::PorousFlowVolumetricStrain(const InputParameters & parameters)
  : PorousFlowMaterialVectorBase(parameters),
    _consistent(getParam<bool>("consistent_with_displaced_mesh")),
    _ndisp(coupledComponents("displacements")),
    _disp(3),
    _disp_var_num(3),
    _grad_disp(3),
    _grad_disp_old(3),

    _vol_strain_rate_qp(declareProperty<Real>("PorousFlow_volumetric_strain_rate_qp")),
    _dvol_strain_rate_qp_dvar(
        declareProperty<std::vector<RealGradient>>("dPorousFlow_volumetric_strain_rate_qp_dvar")),
    _vol_total_strain_qp(declareProperty<Real>("PorousFlow_total_volumetric_strain_qp")),
    _dvol_total_strain_qp_dvar(
        declareProperty<std::vector<RealGradient>>("dPorousFlow_total_volumetric_strain_qp_dvar"))
{
  if (_ndisp != _mesh.dimension())
    paramError("displacements", "The number of variables supplied must match the mesh dimension.");

  // fetch coupled variables and gradients (as stateful properties if necessary)
  for (unsigned int i = 0; i < _ndisp; ++i)
  {
    _disp[i] = &coupledValue("displacements", i);
    _disp_var_num[i] = coupled("displacements", i);
    _grad_disp[i] = &coupledGradient("displacements", i);
    _grad_disp_old[i] = &coupledGradientOld("displacements", i);
  }

  // set unused dimensions to zero
  for (unsigned i = _ndisp; i < 3; ++i)
  {
    _disp[i] = &_zero;
    _disp_var_num[i] = 0;
    while (_dictator.isPorousFlowVariable(_disp_var_num[i]))
      _disp_var_num[i]++; // increment until disp_var_num[i] is not a porflow var
    _grad_disp[i] = &_grad_zero;
    _grad_disp_old[i] = &_grad_zero;
  }
  if (_nodal_material == true)
    mooseError("PorousFlowVolumetricStrain classes are only defined for at_nodes = false");
}
コード例 #20
0
ファイル: NodalKernel.C プロジェクト: aashiquear/moose
NodalKernel::NodalKernel(const InputParameters & parameters)
  : MooseObject(parameters),
    BlockRestrictable(this),
    BoundaryRestrictable(this, true), // true for applying to nodesets
    SetupInterface(this),
    FunctionInterface(this),
    UserObjectInterface(this),
    TransientInterface(this),
    PostprocessorInterface(this),
    GeometricSearchInterface(this),
    Restartable(this, "BCs"),
    MeshChangedInterface(parameters),
    RandomInterface(parameters,
                    *parameters.getCheckedPointerParam<FEProblemBase *>("_fe_problem_base"),
                    parameters.get<THREAD_ID>("_tid"),
                    true),
    CoupleableMooseVariableDependencyIntermediateInterface(this, true),
    MooseVariableInterface<Real>(this,
                                 true,
                                 "variable",
                                 Moose::VarKindType::VAR_NONLINEAR,
                                 Moose::VarFieldType::VAR_FIELD_STANDARD),
    TaggingInterface(this),
    _subproblem(*getCheckedPointerParam<SubProblem *>("_subproblem")),
    _fe_problem(*getCheckedPointerParam<FEProblemBase *>("_fe_problem_base")),
    _sys(*getCheckedPointerParam<SystemBase *>("_sys")),
    _tid(parameters.get<THREAD_ID>("_tid")),
    _assembly(_subproblem.assembly(_tid)),
    _var(*mooseVariable()),
    _mesh(_subproblem.mesh()),
    _current_node(_var.node()),
    _u(_var.dofValues()),
    _save_in_strings(parameters.get<std::vector<AuxVariableName>>("save_in")),
    _diag_save_in_strings(parameters.get<std::vector<AuxVariableName>>("diag_save_in"))

{
  _save_in.resize(_save_in_strings.size());
  _diag_save_in.resize(_diag_save_in_strings.size());

  for (unsigned int i = 0; i < _save_in_strings.size(); i++)
  {
    MooseVariable * var = &_subproblem.getStandardVariable(_tid, _save_in_strings[i]);

    if (var->feType() != _var.feType())
      paramError(
          "save_in",
          "saved-in auxiliary variable is incompatible with the object's nonlinear variable: ",
          moose::internal::incompatVarMsg(*var, _var));

    _save_in[i] = var;
    var->sys().addVariableToZeroOnResidual(_save_in_strings[i]);
    addMooseVariableDependency(var);
  }

  _has_save_in = _save_in.size() > 0;

  for (unsigned int i = 0; i < _diag_save_in_strings.size(); i++)
  {
    MooseVariable * var = &_subproblem.getStandardVariable(_tid, _diag_save_in_strings[i]);

    if (var->feType() != _var.feType())
      paramError(
          "diag_save_in",
          "saved-in auxiliary variable is incompatible with the object's nonlinear variable: ",
          moose::internal::incompatVarMsg(*var, _var));

    _diag_save_in[i] = var;
    var->sys().addVariableToZeroOnJacobian(_diag_save_in_strings[i]);
    addMooseVariableDependency(var);
  }

  _has_diag_save_in = _diag_save_in.size() > 0;
}