LCOV - code coverage report
Current view: top level - src/actions - CohesiveZoneActionBase.C (source / functions) Hit Total Coverage
Test: idaholab/moose solid_mechanics: f45d79 Lines: 67 69 97.1 %
Date: 2025-07-25 05:00:39 Functions: 5 5 100.0 %
Legend: Lines: hit not hit

          Line data    Source code
       1             : //* This file is part of the MOOSE framework
       2             : //* https://mooseframework.inl.gov
       3             : //*
       4             : //* All rights reserved, see COPYRIGHT for full restrictions
       5             : //* https://github.com/idaholab/moose/blob/master/COPYRIGHT
       6             : //*
       7             : //* Licensed under LGPL 2.1, please see LICENSE for details
       8             : //* https://www.gnu.org/licenses/lgpl-2.1.html
       9             : 
      10             : #include "CohesiveZoneActionBase.h"
      11             : #include "CommonCohesiveZoneAction.h"
      12             : #include "ActionWarehouse.h"
      13             : #include "AddAuxVariableAction.h"
      14             : #include "MooseEnum.h"
      15             : #include "MooseApp.h"
      16             : #include "InputParameterWarehouse.h"
      17             : 
      18             : // map vector name shortcuts to tensor material property names
      19             : const std::map<std::string, std::string>
      20             :     CohesiveZoneActionBase::_real_vector_cartesian_component_table = {
      21             :         {"traction", "traction_global"},
      22             :         {"jump", "displacement_jump_global"},
      23             :         {"pk1_traction", "PK1traction"}};
      24             : 
      25             : // map aux variable name prefixes to CZM vector scalar options and list of permitted tensor name
      26             : // shortcuts
      27             : const std::map<std::string, std::pair<std::string, std::vector<std::string>>>
      28             :     CohesiveZoneActionBase::_vector_direction_table = {
      29             :         {"normal", {"Normal", {"traction", "jump"}}},
      30             :         {"tangent", {"Tangent", {"traction", "jump"}}}};
      31             : 
      32             : const std::vector<char> CohesiveZoneActionBase::_component_table = {'x', 'y', 'z'};
      33             : 
      34             : InputParameters
      35         384 : CohesiveZoneActionBase::validParams()
      36             : {
      37         384 :   InputParameters params = Action::validParams();
      38         384 :   params.addClassDescription("Action to create an instance of the cohesive zone model kernel for "
      39             :                              "each displacement component");
      40         768 :   params.addRequiredParam<std::vector<VariableName>>(
      41             :       "displacements", "The nonlinear displacement variables for the problem");
      42         768 :   MooseEnum strainType("SMALL FINITE", "SMALL");
      43         768 :   params.addParam<MooseEnum>("strain", strainType, "Strain formulation");
      44             : 
      45             :   // Advanced
      46         768 :   params.addParam<bool>("use_automatic_differentiation",
      47         768 :                         false,
      48             :                         "Whether to use automatic differentiation to compute the Jacobian");
      49         768 :   params.addParam<std::string>("base_name", "Material property base name");
      50         768 :   params.addParam<std::vector<AuxVariableName>>(
      51             :       "save_in_master", {}, "The displacement residuals on the  master side");
      52         768 :   params.addParam<std::vector<AuxVariableName>>(
      53             :       "diag_save_in_master",
      54             :       {},
      55             :       "The displacement diagonal preconditioner terms on the  master side");
      56         768 :   params.addParam<std::vector<AuxVariableName>>(
      57             :       "save_in_slave", {}, "The displacement residuals on the  slave side");
      58         768 :   params.addParam<std::vector<AuxVariableName>>(
      59             :       "diag_save_in_slave",
      60             :       {},
      61             :       "The displacement diagonal preconditioner terms on the  slave side");
      62         768 :   params.addParamNamesToGroup("save_in_master diag_save_in_master save_in_slave diag_save_in_slave",
      63             :                               "Advanced");
      64         768 :   params.addParam<bool>("verbose", false, "Display extra information.");
      65             : 
      66             :   // Output
      67         768 :   params.addParam<MultiMooseEnum>("generate_output",
      68         768 :                                   CohesiveZoneActionBase::outputPropertiesType(),
      69             :                                   "Add scalar quantity output for stress and/or strain");
      70         768 :   params.addParam<MultiMooseEnum>(
      71             :       "material_output_order",
      72         768 :       CohesiveZoneActionBase::materialOutputOrders(),
      73             :       "Specifies the order of the FE shape function to use for this variable.");
      74         768 :   params.addParam<MultiMooseEnum>(
      75             :       "material_output_family",
      76         768 :       CohesiveZoneActionBase::materialOutputFamilies(),
      77             :       "Specifies the family of FE shape functions to use for this variable.");
      78         768 :   params.addParamNamesToGroup("generate_output material_output_order material_output_family",
      79             :                               "Output");
      80         768 :   params.addParam<MultiMooseEnum>("additional_generate_output",
      81         768 :                                   CohesiveZoneActionBase::outputPropertiesType(),
      82             :                                   "Add scalar quantity output for stress and/or strain (will be "
      83             :                                   "appended to the list in `generate_output`)");
      84         768 :   params.addParam<MultiMooseEnum>(
      85             :       "additional_material_output_order",
      86         768 :       CohesiveZoneActionBase::materialOutputOrders(),
      87             :       "Specifies the order of the FE shape function to use for this variable.");
      88             : 
      89         768 :   params.addParam<MultiMooseEnum>(
      90             :       "additional_material_output_family",
      91         768 :       CohesiveZoneActionBase::materialOutputFamilies(),
      92             :       "Specifies the family of FE shape functions to use for this variable.");
      93             : 
      94         768 :   params.addParamNamesToGroup("additional_generate_output additional_material_output_order "
      95             :                               "additional_material_output_family",
      96             :                               "Output");
      97         384 :   return params;
      98         384 : }
      99             : 
     100         206 : CohesiveZoneActionBase::CohesiveZoneActionBase(const InputParameters & params) : Action(params)
     101             : {
     102             :   // FIXME: suggest to use action of action to add this to avoid changing the input parameters in
     103             :   // the warehouse.
     104         206 :   const auto & parameters = _app.getInputParameterWarehouse().getInputParameters();
     105         206 :   InputParameters & pars(*(parameters.find(uniqueActionName())->second.get()));
     106             : 
     107             :   // check if a container block with common parameters is found
     108         206 :   auto action = _awh.getActions<CommonCohesiveZoneAction>();
     109         206 :   if (action.size() == 1)
     110         206 :     pars.applyParameters(action[0]->parameters());
     111             : 
     112             :   // append additional_generate_output to generate_output
     113         412 :   if (isParamValid("additional_generate_output"))
     114             :   {
     115          48 :     MultiMooseEnum generate_output = getParam<MultiMooseEnum>("generate_output");
     116             :     MultiMooseEnum additional_generate_output =
     117          48 :         getParam<MultiMooseEnum>("additional_generate_output");
     118             : 
     119          48 :     MultiMooseEnum material_output_order = getParam<MultiMooseEnum>("material_output_order");
     120             :     MultiMooseEnum additional_material_output_order =
     121          48 :         getParam<MultiMooseEnum>("additional_material_output_order");
     122             : 
     123          48 :     MultiMooseEnum material_output_family = getParam<MultiMooseEnum>("material_output_family");
     124             :     MultiMooseEnum additional_material_output_family =
     125          72 :         getParam<MultiMooseEnum>("additional_material_output_family");
     126             : 
     127          96 :     for (auto & output : additional_generate_output)
     128         144 :       generate_output.setAdditionalValue(output);
     129          24 :     for (auto & order : additional_material_output_order)
     130           0 :       material_output_order.setAdditionalValue(order);
     131          24 :     for (auto & family : additional_material_output_family)
     132           0 :       material_output_family.setAdditionalValue(family);
     133             : 
     134          24 :     pars.set<MultiMooseEnum>("generate_output") = generate_output;
     135          24 :     pars.set<MultiMooseEnum>("material_output_order") = material_output_order;
     136          24 :     pars.set<MultiMooseEnum>("material_output_family") = material_output_family;
     137          24 :   }
     138         206 : }
     139             : 
     140             : MultiMooseEnum
     141         768 : CohesiveZoneActionBase::outputPropertiesType()
     142             : {
     143         768 :   std::string options = "";
     144        3072 :   for (auto & vc : _real_vector_cartesian_component_table)
     145        9216 :     for (unsigned int a = 0; a < 3; ++a)
     146       19968 :       options += (options == "" ? "" : " ") + vc.first + '_' + _component_table[a];
     147             : 
     148        2304 :   for (auto & vi : _vector_direction_table)
     149        4608 :     for (auto & t : vi.second.second)
     150        9216 :       options += " " + vi.first + "_" + t;
     151             : 
     152        1536 :   return MultiMooseEnum(options, "", true);
     153             : }
     154             : 
     155             : MultiMooseEnum
     156         768 : CohesiveZoneActionBase::materialOutputOrders()
     157             : {
     158         768 :   auto orders = AddAuxVariableAction::getAuxVariableOrders().getRawNames();
     159             : 
     160        1536 :   return MultiMooseEnum(orders);
     161             : }
     162             : 
     163             : MultiMooseEnum
     164         768 : CohesiveZoneActionBase::materialOutputFamilies()
     165             : {
     166        1536 :   return MultiMooseEnum("MONOMIAL");
     167             : }

Generated by: LCOV version 1.14