当前位置: 首页>>代码示例>>C++>>正文


C++ coupledComponents函数代码示例

本文整理汇总了C++中coupledComponents函数的典型用法代码示例。如果您正苦于以下问题:C++ coupledComponents函数的具体用法?C++ coupledComponents怎么用?C++ coupledComponents使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。


在下文中一共展示了coupledComponents函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。

示例1: _names

BubbleBase::BubbleBase(const InputParameters & parameters)
  :Kernel(parameters),
  _names(getParam<std::vector<VariableName> >("coupled_conc")),
  _this_var(getParam<NonlinearVariableName>("variable")),
  _atoms(getParam<std::vector<Real> >("coupled_atoms")),
  _widths(getParam<std::vector<Real> >("coupled_widths"))
{
	_G = coupledComponents("coupled_conc");
  if ( _G != coupledComponents("coupled_rad") )
    mooseError("From BubbleBase: The number of coupled concentrations does not match coupled radii.");
  if ( _G != _atoms.size() )
    mooseError("From BubbleBase: The number of coupled concentrations does not match atom sizes list.");

  for ( unsigned int i=0; i<_G; ++i )
  {
    _c.push_back( &coupledValue("coupled_conc", i) );
    _r.push_back( &coupledValue("coupled_rad", i) );
  }

  // Determine which group current kernel acts on
  _g = -1;
  for ( unsigned int i=0; i<_G; ++i )
  {
    if ( _names[i].compare(_this_var) == 0 )
    {
      _g = i;
      break;
    }
  }
  if (_g == -1)
    mooseError("From BubbleBase: Variable not found in coupled_conc list. Check the list.");

  mooseDoOnce( displayBubbleInfo() );
}
开发者ID:tophmatthews,项目名称:buck,代码行数:34,代码来源:BubbleBase.C

示例2: ElementVectorPostprocessor

SphericalAverage::SphericalAverage(const InputParameters & parameters)
  : ElementVectorPostprocessor(parameters),
    _nbins(getParam<unsigned int>("bin_number")),
    _radius(getParam<Real>("radius")),
    _deltaR(_radius / _nbins),
    _nvals(coupledComponents("variable")),
    _values(_nvals),
    _empty_bin_value(getParam<Real>("empty_bin_value")),
    _bin_center(declareVector("radius")),
    _counts(_nbins),
    _average(_nvals)
{
  if (coupledComponents("variable") != 1)
    mooseError("SphericalAverage works on exactly one coupled variable");

  // Note: We associate the local variable "i" with nbins and "j" with nvals throughout.

  // couple variables initialize vectors
  for (auto j = beginIndex(_average); j < _nvals; ++j)
  {
    _values[j] = &coupledValue("variable", j);
    _average[j] = &declareVector(getVar("variable", j)->name());
  }

  // initialize the bin center value vector
  _bin_center.resize(_nbins);
  for (auto i = beginIndex(_counts); i < _nbins; ++i)
    _bin_center[i] = (i + 0.5) * _deltaR;
}
开发者ID:zachmprince,项目名称:moose,代码行数:29,代码来源:SphericalAverage.C

示例3: AuxKernel

AqueousEquilibriumRxnAux::AqueousEquilibriumRxnAux(const InputParameters & parameters)
  : AuxKernel(parameters),
    _log_k(coupledValue("log_k")),
    _sto_v(getParam<std::vector<Real>>("sto_v")),
    _gamma_eq(coupledValue("gamma"))
{
  const unsigned int n = coupledComponents("v");

  // Check that the correct number of stoichiometric coefficients have been provided
  if (_sto_v.size() != n)
    mooseError("The number of stoichiometric coefficients in sto_v is not equal to the number of "
               "coupled species in ",
               _name);

  // Check that the correct number of activity coefficients have been provided (if applicable)
  if (isCoupled("gamma_v"))
    if (coupledComponents("gamma_v") != n)
      mooseError("The number of activity coefficients in gamma_v is not equal to the number of "
                 "coupled species in ",
                 _name);

  _vals.resize(n);
  _gamma_v.resize(n);

  for (unsigned int i = 0; i < n; ++i)
  {
    _vals[i] = &coupledValue("v", i);
    // If gamma_v has been supplied, use those values, but if not, use the default value
    _gamma_v[i] = (isCoupled("gamma_v") ? &coupledValue("gamma_v", i) : &coupledValue("gamma_v"));
  }
}
开发者ID:radioactivekate,项目名称:moose,代码行数:31,代码来源:AqueousEquilibriumRxnAux.C

示例4: Kernel

OptionallyVectorCoupledForce::OptionallyVectorCoupledForce(const InputParameters & parameters)
  : Kernel(parameters)
{
  _v_var.resize(coupledComponents("v"));
  _v.resize(coupledComponents("v"));
  for (unsigned int j = 0; j < coupledComponents("v"); ++j)
  {
    _v_var[j] = coupled("v", j);
    _v[j] = &coupledValue("v", j);
  }
}
开发者ID:FHilty,项目名称:moose,代码行数:11,代码来源:OptionallyVectorCoupledForce.C

示例5: Material

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];
  }
}
开发者ID:jwpeterson,项目名称:moose,代码行数:25,代码来源:ComputeInterfaceStress.C

示例6: ElementUserObject

GlobalStrainUserObject::GlobalStrainUserObject(const InputParameters & parameters)
  : ElementUserObject(parameters),
    _base_name(isParamValid("base_name") ? getParam<std::string>("base_name") + "_" : ""),
    _Cijkl(getMaterialProperty<RankFourTensor>(_base_name + "elasticity_tensor")),
    _stress(getMaterialProperty<RankTwoTensor>(_base_name + "stress")),
    _dim(_mesh.dimension()),
    _ndisp(coupledComponents("displacements")),
    _disp_var(_ndisp),
    _periodic_dir()
{
  for (unsigned int i = 0; i < _ndisp; ++i)
    _disp_var[i] = coupled("displacements", i);

  for (unsigned int dir = 0; dir < _dim; ++dir)
  {
    _periodic_dir(dir) = _mesh.isTranslatedPeriodic(_disp_var[0], dir);

    for (unsigned int i = 1; i < _ndisp; ++i)
      if (_mesh.isTranslatedPeriodic(_disp_var[i], dir) != _periodic_dir(dir))
        mooseError("All the displacement components in a particular direction should have same "
                   "periodicity.");
  }

  if (isParamValid("applied_stress_tensor"))
    _applied_stress_tensor.fillFromInputVector(
        getParam<std::vector<Real>>("applied_stress_tensor"));
  else
    _applied_stress_tensor.zero();
}
开发者ID:huangh-inl,项目名称:moose,代码行数:29,代码来源:GlobalStrainUserObject.C

示例7: TensorMechanicsMaterial

CosseratLinearElasticMaterial::CosseratLinearElasticMaterial(const InputParameters & parameters) :
    TensorMechanicsMaterial(parameters),
    _curvature(declareProperty<RankTwoTensor>("curvature")),
    _stress_couple(declareProperty<RankTwoTensor>("couple_stress")),
    _elastic_flexural_rigidity_tensor(declareProperty<RankFourTensor>("elastic_flexural_rigidity_tensor")),
    _Jacobian_mult_couple(declareProperty<RankFourTensor>("couple_Jacobian_mult")),
    _Bijkl_vector(getParam<std::vector<Real> >("B_ijkl")),
    _Bijkl(),
    _T(coupledValue("T")),
    _thermal_expansion_coeff(getParam<Real>("thermal_expansion_coeff")),
    _T0(getParam<Real>("T0")),
    _applied_strain_vector(getParam<std::vector<Real> >("applied_strain_vector")),
    _nrots(coupledComponents("Cosserat_rotations")),
    _wc(_nrots),
    _grad_wc(_nrots),
    _fill_method_bending(getParam<MooseEnum>("fill_method_bending"))
{
    if (_nrots != 3)
        mooseError("CosseratLinearElasticMaterial: This Material is only defined for 3-dimensional simulations so 3 Cosserat rotation variables are needed");
    for (unsigned i = 0; i < _nrots; ++i)
    {
        _wc[i] = &coupledValue("Cosserat_rotations", i);
        _grad_wc[i] = &coupledGradient("Cosserat_rotations", i);
    }

    //Initialize applied strain tensor from input vector
    if (_applied_strain_vector.size() == 6)
        _applied_strain_tensor.fillFromInputVector(_applied_strain_vector);
    else
        _applied_strain_tensor.zero();

    _Bijkl.fillFromInputVector(_Bijkl_vector, (RankFourTensor::FillMethod)(int)_fill_method_bending);
}
开发者ID:permcody,项目名称:moose,代码行数:33,代码来源:CosseratLinearElasticMaterial.C

示例8: GeneralUserObject

RichardsPorepressureNames::RichardsPorepressureNames(const std::string & name, InputParameters parameters) :
  GeneralUserObject(name, parameters),
  Coupleable(parameters, false),
  ZeroInterface(parameters),
  _num_p(coupledComponents("porepressure_vars")),
  _the_names(std::string())

{
  unsigned int max_moose_var_num_seen(0);

  _moose_var_num.resize(_num_p);
  _moose_var_value.resize(_num_p);
  _moose_var_value_old.resize(_num_p);
  _moose_grad_var.resize(_num_p);
  _moose_raw_var.resize(_num_p);
  for (unsigned int i=0 ; i<_num_p; ++i)
    {
      _moose_var_num[i] = coupled("porepressure_vars", i);
      max_moose_var_num_seen = (max_moose_var_num_seen > _moose_var_num[i] ? max_moose_var_num_seen : _moose_var_num[i]);
      _moose_var_value[i] = &coupledValue("porepressure_vars", i); // coupledValue returns a reference (an alias) to a VariableValue, and the & turns it into a pointer
      _moose_var_value_old[i] = (_is_transient ? &coupledValueOld("porepressure_vars", i) : &_zero);
      _moose_grad_var[i] = &coupledGradient("porepressure_vars", i);
      _moose_raw_var[i] = getVar("porepressure_vars", i);
      _the_names += getVar("porepressure_vars", i)->name() + " ";
    }
  _the_names.erase(_the_names.end() - 1, _the_names.end()); // remove trailing space

  _pressure_var_num.resize(max_moose_var_num_seen + 1);
  for (unsigned int i=0 ; i<max_moose_var_num_seen+1 ; ++i)
    _pressure_var_num[i] = _num_p; // NOTE: indicates that i is not a porepressure variable
  for (unsigned int i=0 ; i<_num_p; ++i)
    _pressure_var_num[_moose_var_num[i]] = i;
}
开发者ID:IoannisSt,项目名称:moose,代码行数:33,代码来源:RichardsPorepressureNames.C

示例9: _force_x

ExternalForceDensityMaterial::ExternalForceDensityMaterial(const InputParameters & parameters)
  : DerivativeMaterialInterface<Material>(parameters),
    _force_x(getFunction("force_x")),
    _force_y(getFunction("force_y")),
    _force_z(getFunction("force_z")),
    _c(coupledValue("c")),
    _c_name(getVar("c", 0)->name()),
    _k(getParam<Real>("k")),
    _op_num(coupledComponents(
        "etas")),   // determine number of grains from the number of names passed in.
    _vals(_op_num), // Size variable arrays
    _vals_name(_op_num),
    _dF(declareProperty<std::vector<RealGradient>>("force_density_ext")),
    _dFdc(declarePropertyDerivative<std::vector<RealGradient>>("force_density_ext", _c_name)),
    _dFdeta(_op_num)
{
  // Loop through grains and load coupled variables into the arrays
  for (unsigned int i = 0; i < _op_num; ++i)
  {
    _vals[i] = &coupledValue("etas", i);
    _vals_name[i] = getVar("etas", i)->name();
    _dFdeta[i] =
        &declarePropertyDerivative<std::vector<RealGradient>>("force_density_ext", _vals_name[i]);
  }
}
开发者ID:radioactivekate,项目名称:moose,代码行数:25,代码来源:ExternalForceDensityMaterial.C

示例10: ComputeEigenstrain

ComputeVariableEigenstrain::ComputeVariableEigenstrain(const InputParameters & parameters) :
    ComputeEigenstrain(parameters),
    _num_args(coupledComponents("args")),
    _dprefactor(_num_args),
    _d2prefactor(_num_args),
    _delastic_strain(_num_args),
    _d2elastic_strain(_num_args)
{
  // fetch prerequisite derivatives and build elastic_strain derivatives and cross-derivatives
  for (unsigned int i = 0; i < _num_args; ++i)
  {
    const VariableName & iname = getVar("args", i)->name();
    _dprefactor[i] = &getMaterialPropertyDerivative<Real>("prefactor", iname);
    _delastic_strain[i] = &declarePropertyDerivative<RankTwoTensor>(_base_name + "elastic_strain", iname);

    _d2prefactor[i].resize(_num_args);
    _d2elastic_strain[i].resize(_num_args);

    for (unsigned int j = i; j < _num_args; ++j)
    {
      const VariableName & jname = getVar("args", j)->name();
      _d2prefactor[i][j] = &getMaterialPropertyDerivative<Real>("prefactor", iname, jname);
      _d2elastic_strain[i][j] = &declarePropertyDerivative<RankTwoTensor>(_base_name + "elastic_strain", iname, jname);
    }
  }
}
开发者ID:AhmedAly83,项目名称:moose,代码行数:26,代码来源:ComputeVariableEigenstrain.C

示例11: ElementUserObject

NucleationLocationUserObject::NucleationLocationUserObject(const InputParameters & parameters) :
    ElementUserObject(parameters),
    _mesh(_subproblem.mesh()),
    //_coupled_probability(coupledValue("coupled_aux")),
    _n_coupled_aux(getParam<int>("n_coupled_aux")),
    _dwell_time(getParam<Real>("dwell_time")),
    _num_orientations(getParam<int>("num_orientations")),
    _boundary_width(getParam<Real>("boundary_width")),
    _random_seed(getParam<int>("random_seed")),
    // _counter(0),
    //make restartable
    _counter(declareRestartableData<int>("counter", 0)),
    _phase_gen_index(std::numeric_limits<unsigned int>::max()),
    // _nuclei(0),
    //make restartable
    _nuclei(declareRestartableData<std::vector<Nucleus> >("nuclei")),
    //_old_nucleus_list_size(0),
    //make restartable
    _old_nucleus_list_size(declareRestartableData<unsigned int>("old_nucleus_list_size", 0)),
    _has_new_nucleus(false),
    _master_random(-1000),
    _slave_random(-100)
{
    if(_n_coupled_aux != coupledComponents("coupled_aux_vars"))
    mooseError("Please specify the correct # of coupled probabilities (NucleationLocationUserObject).");

  _coupled_probability.resize(_n_coupled_aux);

  for(unsigned int i=0; i<_n_coupled_aux; i++)
    _coupled_probability[i] = &coupledValue("coupled_aux_vars", i);
}
开发者ID:UMThorntonGroup,项目名称:Hyrax,代码行数:31,代码来源:NucleationLocationUserObject.C

示例12: GeneralUserObject

PorousFlowDictator::PorousFlowDictator(const InputParameters & parameters)
  : GeneralUserObject(parameters),
    Coupleable(this, false),
    _num_variables(coupledComponents("porous_flow_vars")),
    _num_phases(getParam<unsigned int>("number_fluid_phases")),
    _num_components(getParam<unsigned int>("number_fluid_components"))
{
  _moose_var_num.resize(_num_variables);
  for (unsigned int i = 0; i < _num_variables; ++i)
    _moose_var_num[i] = coupled("porous_flow_vars", i);

  _pf_var_num.assign(_fe_problem.getNonlinearSystemBase().nVariables(),
                     _num_variables); // Note: the _num_variables assignment indicates that "this is
                                      // not a PorousFlow variable"
  for (unsigned int i = 0; i < _num_variables; ++i)
    if (_moose_var_num[i] < _pf_var_num.size())
      _pf_var_num[_moose_var_num[i]] = i;
    else
      // should not couple AuxVariables to the Dictator (Jacobian entries are not calculated for
      // them)
      mooseError("PorousFlowDictator: AuxVariables variables must not be coupled into the Dictator "
                 "for this is against specification #1984.  Variable number ",
                 i,
                 " is an AuxVariable.");
}
开发者ID:zachmprince,项目名称:moose,代码行数:25,代码来源:PorousFlowDictator.C

示例13: _dictator_UO

PorousFlowMassFraction::PorousFlowMassFraction(const InputParameters & parameters) :
    DerivativeMaterialInterface<Material>(parameters),

    _dictator_UO(getUserObject<PorousFlowDictator>("PorousFlowDictator_UO")),
    _num_phases(_dictator_UO.numPhases()),
    _num_components(_dictator_UO.numComponents()),

    _mass_frac(declareProperty<std::vector<std::vector<Real> > >("PorousFlow_mass_frac")),
    _mass_frac_old(declarePropertyOld<std::vector<std::vector<Real> > >("PorousFlow_mass_frac")),
    _grad_mass_frac(declareProperty<std::vector<std::vector<RealGradient> > >("PorousFlow_grad_mass_frac")),
    _dmass_frac_dvar(declareProperty<std::vector<std::vector<std::vector<Real> > > >("dPorousFlow_mass_frac_dvar")),

    _yaqi_hacky(false),

    _num_passed_mf_vars(coupledComponents("mass_fraction_vars"))
{
  if (_num_phases < 1 || _num_components < 1)
    mooseError("PorousFlowMassFraction: The Dictator proclaims that the number of phases is " << _num_phases << " and the number of components is " << _num_components << ", and stipulates that you should not use PorousFlowMassFraction in this case");
  if (_num_passed_mf_vars != _num_phases*(_num_components - 1))
    mooseError("PorousFlowMassFraction: The number of mass_fraction_vars is " << _num_passed_mf_vars << " which must be equal to the Dictator's num_phases (" << _num_phases << ") multiplied by num_components-1 (" << _num_components - 1 << ")");

  _mf_vars_num.resize(_num_passed_mf_vars);
  _mf_vars.resize(_num_passed_mf_vars);
  _grad_mf_vars.resize(_num_passed_mf_vars);
  for (unsigned i = 0; i < _num_passed_mf_vars; ++i)
  {
    _mf_vars_num[i] = coupled("mass_fraction_vars", i);
    _mf_vars[i] = &coupledNodalValue("mass_fraction_vars", i);
    _grad_mf_vars[i] = &coupledGradient("mass_fraction_vars", i);
  }
}
开发者ID:Biyss,项目名称:moose,代码行数:31,代码来源:PorousFlowMassFraction.C

示例14: AuxKernel

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);
}
开发者ID:aashiquear,项目名称:moose,代码行数:25,代码来源:GlobalDisplacementAux.C

示例15: _h_names

SwitchingFunctionConstraintLagrange::SwitchingFunctionConstraintLagrange(const std::string & name, InputParameters parameters) :
    DerivativeMaterialInterface<Kernel>(name, parameters),
    _h_names(getParam<std::vector<std::string> >("h_names")),
    _num_h(_h_names.size()),
    _h(_num_h),
    _dh(_num_h),
    _number_of_nl_variables(_fe_problem.getNonlinearSystem().nVariables()),
    _j_eta(_number_of_nl_variables, -1),
    _epsilon(getParam<Real>("epsilon"))
{
  // parameter check. We need exactly one eta per h
  if (_num_h != coupledComponents("etas"))
    mooseError("Need to pass in as many h_names as etas in SwitchingFunctionConstraintLagrange kernel " << name);

  // fetch switching functions (for the residual) and h derivatives (for the Jacobian)
  for (unsigned int i = 0; i < _num_h; ++i)
  {
    _h[i] = &getMaterialProperty<Real>(_h_names[i]);
    _dh[i] = &getMaterialPropertyDerivative<Real>(_h_names[i], getVar("etas", i)->name());

    // generate the lookup table from j_var -> eta index
    unsigned int num = coupled("etas", i);
    if (num < _number_of_nl_variables)
      _j_eta[num] = i;
  }
}
开发者ID:ChaliZhg,项目名称:moose,代码行数:26,代码来源:SwitchingFunctionConstraintLagrange.C


注:本文中的coupledComponents函数示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。