本文整理汇总了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, ¶m, &cur, &matched);
if (matched) goto next_param;
}
result = fcs_common_set_parameter(handle, continue_on_errors, ¶m, &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;
}