Line data Source code
1 : //* This file is part of the MOOSE framework 2 : //* https://www.mooseframework.org 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 192 : CohesiveZoneActionBase::validParams() 36 : { 37 192 : InputParameters params = Action::validParams(); 38 192 : params.addClassDescription("Action to create an instance of the cohesive zone model kernel for " 39 : "each displacement component"); 40 384 : params.addRequiredParam<std::vector<VariableName>>( 41 : "displacements", "The nonlinear displacement variables for the problem"); 42 384 : MooseEnum strainType("SMALL FINITE", "SMALL"); 43 384 : params.addParam<MooseEnum>("strain", strainType, "Strain formulation"); 44 : 45 : // Advanced 46 384 : params.addParam<bool>("use_automatic_differentiation", 47 384 : false, 48 : "Whether to use automatic differentiation to compute the Jacobian"); 49 384 : params.addParam<std::string>("base_name", "Material property base name"); 50 384 : params.addParam<std::vector<AuxVariableName>>( 51 : "save_in_master", {}, "The displacement residuals on the master side"); 52 384 : params.addParam<std::vector<AuxVariableName>>( 53 : "diag_save_in_master", 54 : {}, 55 : "The displacement diagonal preconditioner terms on the master side"); 56 384 : params.addParam<std::vector<AuxVariableName>>( 57 : "save_in_slave", {}, "The displacement residuals on the slave side"); 58 384 : params.addParam<std::vector<AuxVariableName>>( 59 : "diag_save_in_slave", 60 : {}, 61 : "The displacement diagonal preconditioner terms on the slave side"); 62 384 : params.addParamNamesToGroup("save_in_master diag_save_in_master save_in_slave diag_save_in_slave", 63 : "Advanced"); 64 384 : params.addParam<bool>("verbose", false, "Display extra information."); 65 : 66 : // Output 67 384 : params.addParam<MultiMooseEnum>("generate_output", 68 384 : CohesiveZoneActionBase::outputPropertiesType(), 69 : "Add scalar quantity output for stress and/or strain"); 70 384 : params.addParam<MultiMooseEnum>( 71 : "material_output_order", 72 384 : CohesiveZoneActionBase::materialOutputOrders(), 73 : "Specifies the order of the FE shape function to use for this variable."); 74 384 : params.addParam<MultiMooseEnum>( 75 : "material_output_family", 76 384 : CohesiveZoneActionBase::materialOutputFamilies(), 77 : "Specifies the family of FE shape functions to use for this variable."); 78 384 : params.addParamNamesToGroup("generate_output material_output_order material_output_family", 79 : "Output"); 80 384 : params.addParam<MultiMooseEnum>("additional_generate_output", 81 384 : CohesiveZoneActionBase::outputPropertiesType(), 82 : "Add scalar quantity output for stress and/or strain (will be " 83 : "appended to the list in `generate_output`)"); 84 384 : params.addParam<MultiMooseEnum>( 85 : "additional_material_output_order", 86 384 : CohesiveZoneActionBase::materialOutputOrders(), 87 : "Specifies the order of the FE shape function to use for this variable."); 88 : 89 384 : params.addParam<MultiMooseEnum>( 90 : "additional_material_output_family", 91 384 : CohesiveZoneActionBase::materialOutputFamilies(), 92 : "Specifies the family of FE shape functions to use for this variable."); 93 : 94 384 : params.addParamNamesToGroup("additional_generate_output additional_material_output_order " 95 : "additional_material_output_family", 96 : "Output"); 97 192 : return params; 98 192 : } 99 : 100 103 : 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 103 : const auto & parameters = _app.getInputParameterWarehouse().getInputParameters(); 105 103 : InputParameters & pars(*(parameters.find(uniqueActionName())->second.get())); 106 : 107 : // check if a container block with common parameters is found 108 103 : auto action = _awh.getActions<CommonCohesiveZoneAction>(); 109 103 : if (action.size() == 1) 110 103 : pars.applyParameters(action[0]->parameters()); 111 : 112 : // append additional_generate_output to generate_output 113 206 : if (isParamValid("additional_generate_output")) 114 : { 115 24 : MultiMooseEnum generate_output = getParam<MultiMooseEnum>("generate_output"); 116 : MultiMooseEnum additional_generate_output = 117 24 : getParam<MultiMooseEnum>("additional_generate_output"); 118 : 119 24 : MultiMooseEnum material_output_order = getParam<MultiMooseEnum>("material_output_order"); 120 : MultiMooseEnum additional_material_output_order = 121 24 : getParam<MultiMooseEnum>("additional_material_output_order"); 122 : 123 24 : MultiMooseEnum material_output_family = getParam<MultiMooseEnum>("material_output_family"); 124 : MultiMooseEnum additional_material_output_family = 125 36 : getParam<MultiMooseEnum>("additional_material_output_family"); 126 : 127 48 : for (auto & output : additional_generate_output) 128 72 : generate_output.push_back(output); 129 12 : for (auto & order : additional_material_output_order) 130 0 : material_output_order.push_back(order); 131 12 : for (auto & family : additional_material_output_family) 132 0 : material_output_family.push_back(family); 133 : 134 12 : pars.set<MultiMooseEnum>("generate_output") = generate_output; 135 12 : pars.set<MultiMooseEnum>("material_output_order") = material_output_order; 136 12 : pars.set<MultiMooseEnum>("material_output_family") = material_output_family; 137 12 : } 138 103 : } 139 : 140 : MultiMooseEnum 141 384 : CohesiveZoneActionBase::outputPropertiesType() 142 : { 143 384 : std::string options = ""; 144 1536 : for (auto & vc : _real_vector_cartesian_component_table) 145 4608 : for (unsigned int a = 0; a < 3; ++a) 146 9984 : options += (options == "" ? "" : " ") + vc.first + '_' + _component_table[a]; 147 : 148 1152 : for (auto & vi : _vector_direction_table) 149 2304 : for (auto & t : vi.second.second) 150 4608 : options += " " + vi.first + "_" + t; 151 : 152 768 : return MultiMooseEnum(options, "", true); 153 : } 154 : 155 : MultiMooseEnum 156 384 : CohesiveZoneActionBase::materialOutputOrders() 157 : { 158 384 : auto orders = AddAuxVariableAction::getAuxVariableOrders().getRawNames(); 159 : 160 768 : return MultiMooseEnum(orders); 161 : } 162 : 163 : MultiMooseEnum 164 384 : CohesiveZoneActionBase::materialOutputFamilies() 165 : { 166 768 : return MultiMooseEnum("MONOMIAL"); 167 : }