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


C++ FCS::set_parameter方法代码示例

本文整理汇总了C++中FCS::set_parameter方法的典型用法代码示例。如果您正苦于以下问题:C++ FCS::set_parameter方法的具体用法?C++ FCS::set_parameter怎么用?C++ FCS::set_parameter使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在FCS的用法示例。


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

示例1: fcs_set_parameters

/**
 * set the parameters of the FCS solver based on a parameter string
 */
FCSResult fcs_set_parameters(FCS handle, const char *parameters, fcs_bool continue_on_errors)
{
  const char *fnc_name = "fcs_set_parameters";

  CHECK_HANDLE_RETURN_RESULT(handle, fnc_name);

  FCSResult result = FCS_RESULT_SUCCESS;

  char *cur;
  char *params, *param;
  fcs_int params_strlen, matched;

  params_strlen = strlen(parameters) + 1;
  params = malloc(params_strlen * sizeof(char));
  strncpy(params, parameters, params_strlen);

  cur = params;

  while (cur)
  {
    param = cur;

    cur = strchr(cur, ',');

    if (cur)
    {
      *cur = 0;
      ++cur;
    }

/*    printf("param: %s\n", param);
    printf("cur: %s\n", cur);*/

    FCS_PARSE_IF_PARAM_THEN_FUNC1_GOTO_NEXT("box_a",                   set_box_a,           FCS_PARSE_SEQ(fcs_float, 3));
    FCS_PARSE_IF_PARAM_THEN_FUNC1_GOTO_NEXT("box_b",                   set_box_b,           FCS_PARSE_SEQ(fcs_float, 3));
    FCS_PARSE_IF_PARAM_THEN_FUNC1_GOTO_NEXT("box_c",                   set_box_c,           FCS_PARSE_SEQ(fcs_float, 3));
    FCS_PARSE_IF_PARAM_THEN_FUNC1_GOTO_NEXT("offset",                  set_box_origin,      FCS_PARSE_SEQ(fcs_float, 3));
    FCS_PARSE_IF_PARAM_THEN_FUNC1_GOTO_NEXT("periodicity",             set_periodicity,     FCS_PARSE_SEQ(fcs_int, 3));
    FCS_PARSE_IF_PARAM_THEN_FUNC1_GOTO_NEXT("near_field_flag",         set_near_field_flag, FCS_PARSE_VAL(fcs_int));
    FCS_PARSE_IF_PARAM_THEN_FUNC1_GOTO_NEXT("total_particles",         set_total_particles, FCS_PARSE_VAL(fcs_int));
    FCS_PARSE_IF_PARAM_THEN_FUNC1_GOTO_NEXT("r_cut",                   set_r_cut,           FCS_PARSE_VAL(fcs_float));
    FCS_PARSE_IF_PARAM_THEN_FUNC1_GOTO_NEXT("require_virial",          set_compute_virial,  FCS_PARSE_VAL(fcs_int));
    FCS_PARSE_IF_PARAM_THEN_FUNC2_GOTO_NEXT("",                        set_tolerance,       FCS_PARSE_VAL(fcs_int),                                     FCS_PARSE_VAL(fcs_float));
    FCS_PARSE_IF_PARAM_THEN_FUNC2_GOTO_NEXT("tolerance_energy",        set_tolerance,       FCS_PARSE_CONST(fcs_int, FCS_TOLERANCE_TYPE_ENERGY),        FCS_PARSE_VAL(fcs_float));
    FCS_PARSE_IF_PARAM_THEN_FUNC2_GOTO_NEXT("tolerance_energy_rel",    set_tolerance,       FCS_PARSE_CONST(fcs_int, FCS_TOLERANCE_TYPE_ENERGY_REL),    FCS_PARSE_VAL(fcs_float));
    FCS_PARSE_IF_PARAM_THEN_FUNC2_GOTO_NEXT("tolerance_potential",     set_tolerance,       FCS_PARSE_CONST(fcs_int, FCS_TOLERANCE_TYPE_POTENTIAL),     FCS_PARSE_VAL(fcs_float));
    FCS_PARSE_IF_PARAM_THEN_FUNC2_GOTO_NEXT("tolerance_potential_rel", set_tolerance,       FCS_PARSE_CONST(fcs_int, FCS_TOLERANCE_TYPE_POTENTIAL_REL), FCS_PARSE_VAL(fcs_float));
    FCS_PARSE_IF_PARAM_THEN_FUNC2_GOTO_NEXT("tolerance_field",         set_tolerance,       FCS_PARSE_CONST(fcs_int, FCS_TOLERANCE_TYPE_FIELD),         FCS_PARSE_VAL(fcs_float));
    FCS_PARSE_IF_PARAM_THEN_FUNC2_GOTO_NEXT("tolerance_field_rel",     set_tolerance,       FCS_PARSE_CONST(fcs_int, FCS_TOLERANCE_TYPE_FIELD_REL),     FCS_PARSE_VAL(fcs_float));

    if (handle->set_parameter)
    {
      result = handle->set_parameter(handle, continue_on_errors, &param, &cur, &matched);
      if (matched) goto next_param;
    }

    result = fcs_common_set_parameter(handle, continue_on_errors, &param, &cur, &matched);
    if (matched) goto next_param;

    if (result == FCS_RESULT_SUCCESS)
      result = fcs_result_create(FCS_ERROR_WRONG_ARGUMENT, fnc_name, "interface (parser): error in parameter string at '%s'!", param); 

    if (FCS_IS_FALSE(continue_on_errors)) break;

next_param:
    ;
  }

  free(params);

  return result;
}
开发者ID:fweik,项目名称:scafacos,代码行数:75,代码来源:FCSInterface.c


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