GenericFunctionMaterial::GenericFunctionMaterial(const InputParameters & parameters) : Material(parameters), _prop_names(getParam<std::vector<std::string> >("prop_names")), _prop_values(getParam<std::vector<FunctionName> >("prop_values")), _enable_stateful(getParam<bool>("enable_stateful")) { unsigned int num_names = _prop_names.size(); unsigned int num_values = _prop_values.size(); if (num_names != num_values) mooseError("Number of prop_names much match the number of prop_values for a GenericFunctionMaterial!"); _num_props = num_names; _properties.resize(num_names); if (_enable_stateful) { _properties_old.resize(num_names); _properties_older.resize(num_names); } _functions.resize(num_names); for (unsigned int i=0; i<_num_props; i++) { _properties[i] = &declareProperty<Real>(_prop_names[i]); if (_enable_stateful) { _properties_old[i] = &declarePropertyOld<Real>(_prop_names[i]); _properties_older[i] = &declarePropertyOlder<Real>(_prop_names[i]); } _functions[i] = &getFunctionByName(_prop_values[i]); } }
LinearCombinationFunction::LinearCombinationFunction(const InputParameters & parameters) : Function(parameters), FunctionInterface(this), _w(getParam<std::vector<Real>>("w")) { const std::vector<FunctionName> & names = getParam<std::vector<FunctionName>>("functions"); const unsigned int len = names.size(); if (len != _w.size()) mooseError( "LinearCombinationFunction: The number of functions must equal the number of w values"); _f.resize(len); for (unsigned i = 0; i < len; ++i) { if (name() == names[i]) mooseError("A LinearCombinationFunction must not reference itself"); Function * const f = &getFunctionByName(names[i]); if (!f) mooseError("LinearCombinationFunction: The function ", names[i], " (referenced by ", name(), ") cannot be found"); _f[i] = f; } }
LineFunctionSampler::LineFunctionSampler(const InputParameters & parameters) : GeneralVectorPostprocessor(parameters), SamplerBase(parameters, this, _communicator), _start_point(getParam<Point>("start_point")), _end_point(getParam<Point>("end_point")), _num_points(getParam<unsigned int>("num_points")), _function_names(getParam<std::vector<FunctionName> >("functions")), _num_funcs(_function_names.size()), _functions(_num_funcs), _values(_num_funcs) { // Get the Functions for (unsigned int i=0; i<_num_funcs; i++) _functions[i] = &getFunctionByName(_function_names[i]); // Unfortunately, std::vector<FunctionName> can't be cast to std::vector<std::string>... std::vector<std::string> function_name_strings(_num_funcs); for (unsigned int i=0; i<_num_funcs; i++) function_name_strings[i] = _function_names[i]; // Initialize the datastructions in SamplerBase SamplerBase::setupVariables(function_name_strings); // Generate points along the line LineValueSampler::generatePointsAndIDs(_start_point, _end_point, _num_points, _points, _ids); }
ComputeStressBase::ComputeStressBase(const InputParameters & parameters) : DerivativeMaterialInterface<Material>(parameters), _base_name(isParamValid("base_name") ? getParam<std::string>("base_name") + "_" : "" ), _mechanical_strain(getMaterialPropertyByName<RankTwoTensor>(_base_name + "mechanical_strain")), _stress(declareProperty<RankTwoTensor>(_base_name + "stress")), _elastic_strain(declareProperty<RankTwoTensor>(_base_name + "elastic_strain")), _elasticity_tensor(getMaterialPropertyByName<ElasticityTensorR4>(_base_name + "elasticity_tensor")), _extra_stress(getDefaultMaterialProperty<RankTwoTensor>(_base_name + "extra_stress")), _Jacobian_mult(declareProperty<ElasticityTensorR4>(_base_name + "Jacobian_mult")), _store_stress_old(getParam<bool>("store_stress_old")) { //Declares old stress and older stress if the parameter _store_stress_old is true. This parameter can be set from the input file using any of the child classes of ComputeStressBase. if (_store_stress_old) { declarePropertyOld<RankTwoTensor>(_base_name + "stress"); declarePropertyOlder<RankTwoTensor>(_base_name + "stress"); } const std::vector<FunctionName> & fcn_names(getParam<std::vector<FunctionName> >("initial_stress")); const unsigned num = fcn_names.size(); if (!(num == 0 || num == 3*3)) mooseError("Either zero or " << 3*3 << " initial stress functions must be provided to TensorMechanicsMaterial. You supplied " << num << "\n"); _initial_stress.resize(num); for (unsigned i = 0 ; i < num ; ++i) _initial_stress[i] = &getFunctionByName(fcn_names[i]); }
TensorMechanicsMaterial::TensorMechanicsMaterial(const std::string & name, InputParameters parameters) : Material(name, parameters), _grad_disp_x(coupledGradient("disp_x")), _grad_disp_y(coupledGradient("disp_y")), _grad_disp_z(_mesh.dimension() == 3 ? coupledGradient("disp_z") : _grad_zero), _grad_disp_x_old(_fe_problem.isTransient() ? coupledGradientOld("disp_x") : _grad_zero), _grad_disp_y_old(_fe_problem.isTransient() ? coupledGradientOld("disp_y") : _grad_zero), _grad_disp_z_old(_fe_problem.isTransient() && _mesh.dimension() == 3 ? coupledGradientOld("disp_z") : _grad_zero), _stress(declareProperty<RankTwoTensor>("stress")), _total_strain(declareProperty<RankTwoTensor>("total_strain")), _elastic_strain(declareProperty<RankTwoTensor>("elastic_strain")), _elasticity_tensor(declareProperty<ElasticityTensorR4>("elasticity_tensor")), _Jacobian_mult(declareProperty<ElasticityTensorR4>("Jacobian_mult")), // _d_stress_dT(declareProperty<RankTwoTensor>("d_stress_dT")), _euler_angle_1(getParam<Real>("euler_angle_1")), _euler_angle_2(getParam<Real>("euler_angle_2")), _euler_angle_3(getParam<Real>("euler_angle_3")), _Cijkl_vector(getParam<std::vector<Real> >("C_ijkl")), _Cijkl(), _Euler_angles(_euler_angle_1, _euler_angle_2, _euler_angle_3), _has_T(isCoupled("temperature")), _T(_has_T ? &coupledValue("temperature") : NULL), _fill_method((RankFourTensor::FillMethod)(int)getParam<MooseEnum>("fill_method")) { _Cijkl.fillFromInputVector(_Cijkl_vector, _fill_method); const std::vector<FunctionName> & fcn_names( getParam<std::vector<FunctionName> >("initial_stress") ); const unsigned num = fcn_names.size(); if (!(num == 0 || num == 3*3)) mooseError("Either zero or " << 3*3 << " initial stress functions must be provided to TensorMechanicsMaterial. You supplied " << num << "\n"); _initial_stress.resize(num); for (unsigned i = 0 ; i < num ; ++i) _initial_stress[i] = &getFunctionByName(fcn_names[i]); }
CompositeFunction::CompositeFunction(const InputParameters & parameters) : Function(parameters), FunctionInterface(this), _scale_factor(getParam<Real>("scale_factor")) { const std::vector<FunctionName> & names = getParam<std::vector<FunctionName>>("functions"); const unsigned int len = names.size(); if (len == 0) mooseError("A composite function must reference at least one other function"); _f.resize(len); for (unsigned i = 0; i < len; ++i) { if (name() == names[i]) mooseError("A composite function must not reference itself"); Function * const f = &getFunctionByName(names[i]); if (!f) { std::string msg("Error in composite function "); msg += name(); msg += ". Function "; msg += names[i]; msg += " referenced but not found."; mooseError(msg); } _f[i] = f; } }
ImageProcessing::ImageProcessing(const InputParameters & parameters) : Material(parameters), _func(getParam<FunctionName>("function")) { _function.resize(1); _function[ 0 ] = &getFunctionByName(_func); idFile = fopen("idfile.txt", "w"); fputs("", idFile); fclose(idFile); }
FunctionScalarAux::FunctionScalarAux(const InputParameters & parameters) : AuxScalarKernel(parameters) { std::vector<FunctionName> funcs = getParam<std::vector<FunctionName>>("function"); if (funcs.size() != _var.order()) mooseError("number of functions is not equal to the number of scalar variable components"); for (const auto & func : funcs) _functions.push_back(&getFunctionByName(func)); }
FunctionScalarIC::FunctionScalarIC(const InputParameters & parameters) : ScalarInitialCondition(parameters), _ncomp(_var.order()) { std::vector<FunctionName> funcs = getParam<std::vector<FunctionName> >("function"); if (funcs.size() != _ncomp) mooseError("number of functions must be equal to the scalar variable order"); for (unsigned int i = 0; i < funcs.size(); ++i) _func.push_back(&getFunctionByName(funcs[i])); }
TensorMechanicsMaterial::TensorMechanicsMaterial(const InputParameters & parameters) : Material(parameters), _grad_disp_x(coupledGradient("disp_x")), _grad_disp_y(coupledGradient("disp_y")), _grad_disp_z(_mesh.dimension() == 3 ? coupledGradient("disp_z") : _grad_zero), _grad_disp_x_old(_fe_problem.isTransient() ? coupledGradientOld("disp_x") : _grad_zero), _grad_disp_y_old(_fe_problem.isTransient() ? coupledGradientOld("disp_y") : _grad_zero), _grad_disp_z_old(_fe_problem.isTransient() && _mesh.dimension() == 3 ? coupledGradientOld("disp_z") : _grad_zero), _base_name(isParamValid("base_name") ? getParam<std::string>("base_name") + "_" : ""), _stress(declareProperty<RankTwoTensor>(_base_name + "stress")), _total_strain(declareProperty<RankTwoTensor>(_base_name + "total_strain")), _elastic_strain(declareProperty<RankTwoTensor>(_base_name + "elastic_strain")), _elasticity_tensor_name(_base_name + "elasticity_tensor"), _elasticity_tensor(declareProperty<RankFourTensor>(_elasticity_tensor_name)), _Jacobian_mult(declareProperty<RankFourTensor>(_base_name + "Jacobian_mult")), _Euler_angles(getParam<Real>("euler_angle_1"), getParam<Real>("euler_angle_2"), getParam<Real>("euler_angle_3")), _Cijkl(getParam<std::vector<Real>>("C_ijkl"), (RankFourTensor::FillMethod)(int)getParam<MooseEnum>("fill_method")), _prefactor_function(isParamValid("elasticity_tensor_prefactor") ? &getFunction("elasticity_tensor_prefactor") : NULL) { mooseDeprecated("EigenStrainBaseMaterial is deprecated. Please use the TensorMechanics " "plug-and-play system instead: " "http://mooseframework.org/wiki/PhysicsModules/TensorMechanics/" "PlugAndPlayMechanicsApproach/"); const std::vector<FunctionName> & fcn_names( getParam<std::vector<FunctionName>>("initial_stress")); const unsigned num = fcn_names.size(); if (!(num == 0 || num == 3 * 3)) mooseError( "Either zero or ", 3 * 3, " initial stress functions must be provided to TensorMechanicsMaterial. You supplied ", num, "\n"); _initial_stress.resize(num); for (unsigned i = 0; i < num; ++i) _initial_stress[i] = &getFunctionByName(fcn_names[i]); }
Real EelEnergy::computeQpResidual() { // Compute convective part of the energy equation: RealVectorValue _conv; _conv(0) = _rhouA_x[_qp] * ( _u[_qp] + _pressure[_qp]*_area[_qp] ) / _rhoA[_qp]; _conv(1) = _rhouA_y[_qp] * ( _u[_qp] + _pressure[_qp]*_area[_qp] ) / _rhoA[_qp]; _conv(2) = _rhouA_z[_qp] * ( _u[_qp] + _pressure[_qp]*_area[_qp] ) / _rhoA[_qp]; // Gravity work: RealVectorValue _vector_vel(_rhouA_x[_qp]/_rhoA[_qp], _rhouA_y[_qp]/_rhoA[_qp], _rhouA_z[_qp]/_rhoA[_qp]); Real _gravity_work = _rhoA[_qp]*_gravity*_vector_vel; // Wall heat tranfer (WHT): Real rho = _rhoA[_qp] / _area[_qp]; Real Hw_val = isParamValid("Hw_fn_name") ? getFunctionByName(_Hw_fn_name).value(_t, _q_point[_qp]) : _Hw; Real Tw_val = isParamValid("Tw_fn_name") ? getFunctionByName(_Tw_fn_name).value(_t, _q_point[_qp]) : _Tw; Real WHT = Hw_val * _aw * ( _eos.temperature_from_p_rho(_pressure[_qp], rho) - Tw_val ); // Returns the residual return -_conv * _grad_test[_i][_qp] + (WHT+_gravity_work)*_test[_i][_qp]; }
void initExtensions() { mGlxFuncs.glXJoinSwapGroupNV = (PFNGLXJOINSWAPGROUPNVPROC) (getFunctionByName("glXJoinSwapGroupNV")); mGlxFuncs.glXBindSwapBarrierNV = (PFNGLXBINDSWAPBARRIERNVPROC) (getFunctionByName("glXBindSwapBarrierNV")); mGlxFuncs.glXQuerySwapGroupNV = (PFNGLXQUERYSWAPGROUPNVPROC) (getFunctionByName("glXQuerySwapGroupNV")); mGlxFuncs.glXQueryMaxSwapGroupsNV = (PFNGLXQUERYMAXSWAPGROUPSNVPROC) (getFunctionByName("glXQueryMaxSwapGroupsNV")); mGlxFuncs.glXQueryFrameCountNV = (PFNGLXQUERYFRAMECOUNTNVPROC) (getFunctionByName("glXQueryFrameCountNV")); mGlxFuncs.glXResetFrameCountNV = (PFNGLXRESETFRAMECOUNTNVPROC) (getFunctionByName("glXResetFrameCountNV")); }
//----------------------------------------------------------------------------- Function* Program::createFunction(const String& name, const String& desc, const Function::FunctionType functionType) { Function* shaderFunction; shaderFunction = getFunctionByName(name); if (shaderFunction != NULL) { OGRE_EXCEPT( Exception::ERR_INVALIDPARAMS, "Function " + name + " already declared in program.", "Program::createFunction" ); } shaderFunction = OGRE_NEW Function(name, desc, functionType); mFunctions.push_back(shaderFunction); return shaderFunction; }
// DEPRECATED CONSTRUCTOR ComputeStressBase::ComputeStressBase(const std::string & deprecated_name, InputParameters parameters) : DerivativeMaterialInterface<Material>(deprecated_name, parameters), _base_name(isParamValid("base_name") ? getParam<std::string>("base_name") + "_" : "" ), _total_strain(getMaterialPropertyByName<RankTwoTensor>(_base_name + "total_strain")), _stress(declareProperty<RankTwoTensor>(_base_name + "stress")), _elastic_strain(declareProperty<RankTwoTensor>(_base_name + "elastic_strain")), _elasticity_tensor(getMaterialPropertyByName<ElasticityTensorR4>(_base_name + "elasticity_tensor")), _extra_stress(getDefaultMaterialProperty<RankTwoTensor>(_base_name + "extra_stress")), _Jacobian_mult(declareProperty<ElasticityTensorR4>(_base_name + "Jacobian_mult")) { const std::vector<FunctionName> & fcn_names(getParam<std::vector<FunctionName> >("initial_stress")); const unsigned num = fcn_names.size(); if (!(num == 0 || num == 3*3)) mooseError("Either zero or " << 3*3 << " initial stress functions must be provided to TensorMechanicsMaterial. You supplied " << num << "\n"); _initial_stress.resize(num); for (unsigned i = 0 ; i < num ; ++i) _initial_stress[i] = &getFunctionByName(fcn_names[i]); }
ComputeEigenstrainFromInitialStress::ComputeEigenstrainFromInitialStress( const InputParameters & parameters) : ComputeEigenstrainBase(parameters), _base_name(isParamValid("base_name") ? getParam<std::string>("base_name") + "_" : ""), _elasticity_tensor(getMaterialPropertyByName<RankFourTensor>(_base_name + "elasticity_tensor")), _eigenstrain_old(getMaterialPropertyOld<RankTwoTensor>(_eigenstrain_name)) { const std::vector<FunctionName> & fcn_names( getParam<std::vector<FunctionName>>("initial_stress")); const unsigned num = fcn_names.size(); if (num != LIBMESH_DIM * LIBMESH_DIM) mooseError("ComputeEigenstrainFromInitialStress: ", LIBMESH_DIM * LIBMESH_DIM, " initial stress functions must be provided. You supplied ", num, "\n"); _initial_stress_fcn.resize(num); for (unsigned i = 0; i < num; ++i) _initial_stress_fcn[i] = &getFunctionByName(fcn_names[i]); }
IsotropicTempDepHardening::IsotropicTempDepHardening(const InputParameters & parameters) : IsotropicPlasticity(parameters), _hardening_functions_names(getParam<std::vector<FunctionName>>("hardening_functions")), _hf_temperatures(getParam<std::vector<Real>>("temperatures")) { const unsigned int len = _hardening_functions_names.size(); if (len < 2) mooseError("At least two stress-strain curves must be provided in hardening_functions"); _hardening_functions.resize(len); const unsigned int len_temps = _hf_temperatures.size(); if (len != len_temps) mooseError("The vector of hardening function temperatures must have the same length as the " "vector of temperature dependent hardening functions."); // Check that the temperatures are strictly increasing for (unsigned int i = 1; i < len_temps; ++i) { if (_hf_temperatures[i] <= _hf_temperatures[i - 1]) mooseError("The temperature dependent hardening functions and corresponding temperatures " "should be listed in order of increasing temperature."); } std::vector<Real> yield_stress_vec; for (unsigned int i = 0; i < len; ++i) { PiecewiseLinear * const f = dynamic_cast<PiecewiseLinear *>(&getFunctionByName(_hardening_functions_names[i])); if (!f) mooseError("Function ", _hardening_functions_names[i], " not found in ", name()); _hardening_functions[i] = f; yield_stress_vec.push_back(f->value(0.0, Point())); } _interp_yield_stress = MooseSharedPointer<LinearInterpolation>( new LinearInterpolation(_hf_temperatures, yield_stress_vec)); }
TensorMechanicsMaterial::TensorMechanicsMaterial(const std::string & name, InputParameters parameters) : Material(name, parameters), _grad_disp_x(coupledGradient("disp_x")), _grad_disp_y(coupledGradient("disp_y")), _grad_disp_z(_mesh.dimension() == 3 ? coupledGradient("disp_z") : _grad_zero), _grad_disp_x_old(_fe_problem.isTransient() ? coupledGradientOld("disp_x") : _grad_zero), _grad_disp_y_old(_fe_problem.isTransient() ? coupledGradientOld("disp_y") : _grad_zero), _grad_disp_z_old(_fe_problem.isTransient() && _mesh.dimension() == 3 ? coupledGradientOld("disp_z") : _grad_zero), _base_name(isParamValid("base_name") ? getParam<std::string>("base_name") + "_" : "" ), _stress(declareProperty<RankTwoTensor>(_base_name + "stress")), _total_strain(declareProperty<RankTwoTensor>(_base_name + "total_strain")), _elastic_strain(declareProperty<RankTwoTensor>(_base_name + "elastic_strain")), _elasticity_tensor_name(_base_name + "elasticity_tensor"), _elasticity_tensor(declareProperty<ElasticityTensorR4>(_elasticity_tensor_name)), _Jacobian_mult(declareProperty<ElasticityTensorR4>(_base_name + "Jacobian_mult")), _Euler_angles(getParam<Real>("euler_angle_1"), getParam<Real>("euler_angle_2"), getParam<Real>("euler_angle_3")), _Cijkl(getParam<std::vector<Real> >("C_ijkl"), (RankFourTensor::FillMethod)(int)getParam<MooseEnum>("fill_method")), _prefactor_function(isParamValid("elasticity_tensor_prefactor") ? &getFunction("elasticity_tensor_prefactor") : NULL) { const std::vector<FunctionName> & fcn_names(getParam<std::vector<FunctionName> >("initial_stress")); const unsigned num = fcn_names.size(); if (!(num == 0 || num == 3*3)) mooseError("Either zero or " << 3*3 << " initial stress functions must be provided to TensorMechanicsMaterial. You supplied " << num << "\n"); _initial_stress.resize(num); for (unsigned i = 0 ; i < num ; ++i) _initial_stress[i] = &getFunctionByName(fcn_names[i]); }
void ExtensionLoaderWGL::registerExtensions() { if(!mExtensionsRegistered) { vrj::opengl::ExtensionLoader::registerExtensions(); mWglFuncs->wglJoinSwapGroupNV = (PFNWGLJOINSWAPGROUPNVPROC) getFunctionByName("wglJoinSwapGroupNV"); mWglFuncs->wglBindSwapBarrierNV = (PFNWGLBINDSWAPBARRIERNVPROC) getFunctionByName("wglBindSwapBarrierNV"); mWglFuncs->wglQuerySwapGroupNV = (PFNWGLQUERYSWAPGROUPNVPROC) getFunctionByName("wglQuerySwapGroupNV"); mWglFuncs->wglQueryMaxSwapGroupsNV = (PFNWGLQUERYMAXSWAPGROUPSNVPROC) getFunctionByName("wglQueryMaxSwapGroupsNV"); mWglFuncs->wglQueryFrameCountNV = (PFNWGLQUERYFRAMECOUNTNVPROC) getFunctionByName("wglQueryFrameCountNV"); mWglFuncs->wglResetFrameCountNV = (PFNWGLRESETFRAMECOUNTNVPROC) getFunctionByName("wglResetFrameCountNV"); mWglFuncs->wglCreateContextAttribsARB = (PFNWGLCREATECONTEXTATTRIBSARBPROC) getFunctionByName("wglCreateContextAttribsARB"); mExtensionsRegistered = true; } }
void ExtensionLoaderGLX::registerExtensions() { if ( ! mExtensionsRegistered ) { vrj::opengl::ExtensionLoader::registerExtensions(); mGlxFuncs->glXJoinSwapGroupNV = (PFNGLXJOINSWAPGROUPNVPROC) getFunctionByName("glXJoinSwapGroupNV"); mGlxFuncs->glXBindSwapBarrierNV = (PFNGLXBINDSWAPBARRIERNVPROC) getFunctionByName("glXBindSwapBarrierNV"); mGlxFuncs->glXQuerySwapGroupNV = (PFNGLXQUERYSWAPGROUPNVPROC) getFunctionByName("glXQuerySwapGroupNV"); mGlxFuncs->glXQueryMaxSwapGroupsNV = (PFNGLXQUERYMAXSWAPGROUPSNVPROC) getFunctionByName("glXQueryMaxSwapGroupsNV"); mGlxFuncs->glXQueryFrameCountNV = (PFNGLXQUERYFRAMECOUNTNVPROC) getFunctionByName("glXQueryFrameCountNV"); mGlxFuncs->glXResetFrameCountNV = (PFNGLXRESETFRAMECOUNTNVPROC) getFunctionByName("glXResetFrameCountNV"); mGlxFuncs->glXCreateContextAttribsARB = (PFNGLXCREATECONTEXTATTRIBSARBPROC) getFunctionByName("glXCreateContextAttribsARB"); mExtensionsRegistered = true; } }