ComputeAxisymmetric1DIncrementalStrain::ComputeAxisymmetric1DIncrementalStrain( const InputParameters & parameters) : Compute1DIncrementalStrain(parameters), _disp_old_0(coupledValueOld("displacements", 0)), _subblock_id_provider(isParamValid("subblock_index_provider") ? &getUserObject<SubblockIndexProvider>("subblock_index_provider") : nullptr), _has_out_of_plane_strain(isParamValid("out_of_plane_strain")), _out_of_plane_strain(_has_out_of_plane_strain ? coupledValue("out_of_plane_strain") : _zero), _out_of_plane_strain_old(_has_out_of_plane_strain ? coupledValueOld("out_of_plane_strain") : _zero), _has_scalar_out_of_plane_strain(isParamValid("scalar_out_of_plane_strain")), _nscalar_strains( _has_scalar_out_of_plane_strain ? coupledScalarComponents("scalar_out_of_plane_strain") : 0) { if (_has_out_of_plane_strain && _has_scalar_out_of_plane_strain) mooseError("Must define only one of out_of_plane_strain or scalar_out_of_plane_strain"); if (!_has_out_of_plane_strain && !_has_scalar_out_of_plane_strain) mooseError("Must define either out_of_plane_strain or scalar_out_of_plane_strain"); // in case when the provided scalar_out_of_plane_strain is not a coupled // scalar variable, still set _nscalar_strains = 1 but return its default value 0 if (coupledScalarComponents("scalar_out_of_plane_strain") == 0) _nscalar_strains = 1; if (_has_scalar_out_of_plane_strain) { _scalar_out_of_plane_strain.resize(_nscalar_strains); _scalar_out_of_plane_strain_old.resize(_nscalar_strains); for (unsigned int i = 0; i < _nscalar_strains; ++i) { _scalar_out_of_plane_strain[i] = &coupledScalarValue("scalar_out_of_plane_strain", i); _scalar_out_of_plane_strain_old[i] = &coupledScalarValueOld("scalar_out_of_plane_strain", i); } } }
ParsedODEKernel::ParsedODEKernel(const InputParameters & parameters) : ODEKernel(parameters), FunctionParserUtils(parameters), _function(getParam<std::string>("function")), _nargs(coupledScalarComponents("args")), _args(_nargs), _arg_names(_nargs), _func_dFdarg(_nargs), _number_of_nl_variables(_sys.nVariables()), _arg_index(_number_of_nl_variables, -1) { // build variables argument (start with variable the kernel is operating on) std::string variables = _var.name(); // add additional coupled variables for (unsigned int i = 0; i < _nargs; ++i) { _arg_names[i] = getScalarVar("args", i)->name(); variables += "," + _arg_names[i]; _args[i] = &coupledScalarValue("args", i); // populate number -> arg index lookup table skipping aux variables unsigned int number = coupledScalar("args", i); if (number < _number_of_nl_variables) _arg_index[number] = i; } // base function object _func_F = ADFunctionPtr(new ADFunction()); // set FParser interneal feature flags setParserFeatureFlags(_func_F); // add the constant expressions addFParserConstants(_func_F, getParam<std::vector<std::string>>("constant_names"), getParam<std::vector<std::string>>("constant_expressions")); // parse function if (_func_F->Parse(_function, variables) >= 0) mooseError("Invalid function\n", _function, "\nin ParsedODEKernel ", name(), ".\n", _func_F->ErrorMsg()); // on-diagonal derivative _func_dFdu = ADFunctionPtr(new ADFunction(*_func_F)); if (_func_dFdu->AutoDiff(_var.name()) != -1) mooseError("Failed to take first derivative w.r.t. ", _var.name()); // off-diagonal derivatives for (unsigned int i = 0; i < _nargs; ++i) { _func_dFdarg[i] = ADFunctionPtr(new ADFunction(*_func_F)); if (_func_dFdarg[i]->AutoDiff(_arg_names[i]) != -1) mooseError("Failed to take first derivative w.r.t. ", _arg_names[i]); } // optimize if (!_disable_fpoptimizer) { _func_F->Optimize(); _func_dFdu->Optimize(); for (unsigned int i = 0; i < _nargs; ++i) _func_dFdarg[i]->Optimize(); } // just-in-time compile if (_enable_jit) { _func_F->JITCompile(); _func_dFdu->JITCompile(); for (unsigned int i = 0; i < _nargs; ++i) _func_dFdarg[i]->JITCompile(); } // reserve storage for parameter passing buffer _func_params.resize(_nargs + 1); }