static int Cmiss_field_group_destroy_all_elements(Cmiss_field_group_id group, void *dummy_void) { USE_PARAMETER(dummy_void); int return_code = 0; if (group) { Cmiss_field_module_id field_module = Cmiss_field_get_field_module(Cmiss_field_group_base_cast(group)); for (int i = 1; i <= 3; i++) { Cmiss_mesh_id master_mesh = Cmiss_field_module_find_mesh_by_dimension(field_module, /*dimension*/i); Cmiss_field_element_group_id element_group = Cmiss_field_group_get_element_group(group, master_mesh); Cmiss_mesh_destroy(&master_mesh); if (element_group) { Cmiss_mesh_group_id mesh_group = Cmiss_field_element_group_get_mesh(element_group); Cmiss_mesh_destroy_all_elements(Cmiss_mesh_group_base_cast(mesh_group)); Cmiss_mesh_group_destroy(&mesh_group); Cmiss_field_element_group_destroy(&element_group); } } Cmiss_field_module_destroy(&field_module); return_code = 1; } return return_code; }
static void Element_tool_interactive_event_handler(void *device_id, struct Interactive_event *event,void *element_tool_void, struct Graphics_buffer *graphics_buffer) /******************************************************************************* LAST MODIFIED 18 November 2005 DESCRIPTION : Input handler for input from devices. <device_id> is a unique address enabling the editor to handle input from more than one device at a time. The <event> describes the type of event, button numbers and key modifiers, and the volume of space affected by the interaction. Main events are button press, movement and release. ==============================================================================*/ { enum Interactive_event_type event_type; FE_value time, xi[MAXIMUM_ELEMENT_XI_DIMENSIONS]; int clear_selection, element_dimension, i, input_modifier, number_of_xi_points, shift_pressed; int number_in_xi[MAXIMUM_ELEMENT_XI_DIMENSIONS]; struct FE_element *picked_element; struct FE_element_shape *element_shape; struct Element_tool *element_tool; struct Interaction_volume *interaction_volume,*temp_interaction_volume; struct LIST(Scene_picked_object) *scene_picked_object_list; struct Scene *scene; struct Cmiss_rendition *rendition = NULL; FE_value_triple *xi_points; ENTER(Element_tool_interactive_event_handler); if (device_id&&event&&(element_tool= (struct Element_tool *)element_tool_void)) { Cmiss_region_begin_hierarchical_change(element_tool->region); interaction_volume=Interactive_event_get_interaction_volume(event); scene=Interactive_event_get_scene(event); if (scene != 0) { event_type=Interactive_event_get_type(event); input_modifier=Interactive_event_get_input_modifier(event); shift_pressed=(INTERACTIVE_EVENT_MODIFIER_SHIFT & input_modifier); switch (event_type) { case INTERACTIVE_EVENT_BUTTON_PRESS: { /* interaction only works with first mouse button */ if (1==Interactive_event_get_button_number(event)) { scene_picked_object_list= Scene_pick_objects(scene,interaction_volume,graphics_buffer); if (scene_picked_object_list != 0) { element_tool->picked_element_was_unselected=1; if (0 != (picked_element=Scene_picked_object_list_get_nearest_element( scene_picked_object_list,(struct Cmiss_region *)NULL, element_tool->select_elements_enabled, element_tool->select_faces_enabled, element_tool->select_lines_enabled, (struct Scene_picked_object **)NULL, &rendition, (struct Cmiss_graphic **)NULL))) { /* Open command_field of picked_element in browser */ if (element_tool->command_field) { if (element_tool->time_keeper) { time = Time_keeper_get_time(element_tool->time_keeper); } else { time = 0; } /* since we don't really have fields constant over an element, evaluate at its centre */ element_dimension = get_FE_element_dimension(picked_element); for (i = 0; i < element_dimension; i++) { number_in_xi[i] = 1; } get_FE_element_shape(picked_element, &element_shape); if (FE_element_shape_get_xi_points_cell_centres( element_shape, number_in_xi, &number_of_xi_points, &xi_points)) { /*???debug*/printf("element_tool: xi ="); for (i = 0; i < element_dimension; i++) { xi[i] = xi_points[0][i]; /*???debug*/printf(" %g",xi[i]); } /*???debug*/printf("\n"); Cmiss_field_module_id field_module = Cmiss_field_get_field_module(element_tool->command_field); Cmiss_field_cache_id field_cache = Cmiss_field_module_create_cache(field_module); Cmiss_field_cache_set_time(field_cache, time); Cmiss_field_cache_set_mesh_location(field_cache, picked_element, element_dimension, xi); char *command_string = Cmiss_field_evaluate_string(element_tool->command_field, field_cache); if (command_string) { Execute_command_execute_string(element_tool->execute_command, command_string); DEALLOCATE(command_string); } Cmiss_field_cache_destroy(&field_cache); Cmiss_field_module_destroy(&field_module); DEALLOCATE(xi_points); } } Cmiss_field_group_id group = Cmiss_rendition_get_selection_group(rendition); if (group) { Cmiss_region_id temp_region = Cmiss_rendition_get_region(rendition); Cmiss_field_module_id field_module = Cmiss_region_get_field_module(temp_region); int dimension = Cmiss_element_get_dimension(picked_element); Cmiss_mesh_id master_mesh = Cmiss_field_module_find_mesh_by_dimension(field_module, dimension); Cmiss_field_element_group_id element_group = Cmiss_field_group_get_element_group(group, master_mesh); Cmiss_mesh_destroy(&master_mesh); if (element_group) { Cmiss_mesh_group_id mesh_group = Cmiss_field_element_group_get_mesh(element_group); element_tool->picked_element_was_unselected = !Cmiss_mesh_contains_element(Cmiss_mesh_group_base_cast(mesh_group), picked_element); Cmiss_mesh_group_destroy(&mesh_group); Cmiss_field_element_group_destroy(&element_group); } Cmiss_field_group_destroy(&group); Cmiss_field_module_destroy(&field_module); } } REACCESS(FE_element)(&(element_tool->last_picked_element), picked_element); /*(if ((clear_selection = !shift_pressed) &&((!picked_element)|| (element_tool->picked_element_was_unselected)))*/ clear_selection = !shift_pressed; if (clear_selection) { if (element_tool->region) { Cmiss_rendition *root_rendition = Cmiss_region_get_rendition_internal(element_tool->region); Cmiss_field_group_id root_group = Cmiss_rendition_get_selection_group(root_rendition); if (root_group) { Cmiss_field_group_clear_region_tree_element(root_group); Cmiss_field_group_destroy(&root_group); } Cmiss_rendition_destroy(&root_rendition); } } if (picked_element) { REACCESS(Cmiss_rendition)(&(element_tool->rendition), rendition); Cmiss_region *sub_region = NULL; Cmiss_field_group_id sub_group = NULL; Cmiss_mesh_group_id mesh_group = 0; if (element_tool->rendition) { sub_region = Cmiss_rendition_get_region(element_tool->rendition); sub_group = Cmiss_rendition_get_or_create_selection_group(element_tool->rendition); if (sub_group) { int dimension = Cmiss_element_get_dimension(picked_element); Cmiss_field_module_id field_module = Cmiss_region_get_field_module(sub_region); Cmiss_mesh_id temp_mesh = Cmiss_field_module_find_mesh_by_dimension(field_module, dimension); Cmiss_field_element_group_id element_group = Cmiss_field_group_get_element_group(sub_group, temp_mesh); if (!element_group) element_group = Cmiss_field_group_create_element_group(sub_group, temp_mesh); mesh_group = Cmiss_field_element_group_get_mesh(element_group); Cmiss_field_element_group_destroy(&element_group); Cmiss_mesh_destroy(&temp_mesh); Cmiss_field_module_destroy(&field_module); } } if (mesh_group) { Cmiss_mesh_group_add_element(mesh_group, picked_element); Cmiss_mesh_group_destroy(&mesh_group); } if (sub_group) { Cmiss_field_group_destroy(&sub_group); } } DESTROY(LIST(Scene_picked_object))(&(scene_picked_object_list)); } element_tool->motion_detected=0; REACCESS(Interaction_volume)( &(element_tool->last_interaction_volume),interaction_volume); } } break; case INTERACTIVE_EVENT_MOTION_NOTIFY: case INTERACTIVE_EVENT_BUTTON_RELEASE: { if (element_tool->last_interaction_volume&& ((INTERACTIVE_EVENT_MOTION_NOTIFY==event_type) || (1==Interactive_event_get_button_number(event)))) { if (INTERACTIVE_EVENT_MOTION_NOTIFY==event_type) { element_tool->motion_detected=1; } if (element_tool->last_picked_element) { /* unselect last_picked_element if not just added */ if ((INTERACTIVE_EVENT_BUTTON_RELEASE==event_type)&& shift_pressed&&(!(element_tool->picked_element_was_unselected))) { struct LIST(FE_element) *temp_element_list = CREATE(LIST(FE_element))(); ADD_OBJECT_TO_LIST(FE_element)(element_tool->last_picked_element, temp_element_list); Cmiss_rendition_remove_selection_from_element_list_of_dimension(element_tool->rendition, temp_element_list, Cmiss_element_get_dimension(element_tool->last_picked_element)); DESTROY(LIST(FE_element))(&temp_element_list); } } else if (element_tool->motion_detected) { /* rubber band select */ temp_interaction_volume= create_Interaction_volume_bounding_box( element_tool->last_interaction_volume,interaction_volume); if (temp_interaction_volume != 0) { if (INTERACTIVE_EVENT_MOTION_NOTIFY==event_type) { if (!element_tool->rubber_band) { /* create rubber_band object and put in scene */ element_tool->rubber_band=CREATE(GT_object)( "element_tool_rubber_band",g_POLYLINE, element_tool->rubber_band_material); ACCESS(GT_object)(element_tool->rubber_band); } Interaction_volume_make_polyline_extents( temp_interaction_volume,element_tool->rubber_band); } else { #if defined (USE_SCENE_OBJECT) Scene_remove_graphics_object(scene,element_tool->rubber_band); #endif DEACCESS(GT_object)(&(element_tool->rubber_band)); } if (INTERACTIVE_EVENT_BUTTON_RELEASE==event_type) { scene_picked_object_list= Scene_pick_objects(scene,temp_interaction_volume, graphics_buffer); if (scene_picked_object_list != 0) { Region_element_map *element_map = (Region_element_map *)Scene_picked_object_list_get_picked_region_sorted_elements( scene_picked_object_list, element_tool->select_elements_enabled, element_tool->select_faces_enabled, element_tool->select_lines_enabled); if (element_map) { Cmiss_region *sub_region = NULL; Cmiss_field_group_id sub_group = NULL; Cmiss_rendition *region_rendition = NULL; Cmiss_mesh_group_id mesh_group[MAXIMUM_ELEMENT_XI_DIMENSIONS]; int iter = 0; for (iter = 0; iter < MAXIMUM_ELEMENT_XI_DIMENSIONS; iter++) { mesh_group[iter] = 0; } Region_element_map::iterator pos; for (pos = element_map->begin(); pos != element_map->end(); ++pos) { if (pos->first != sub_region) { if (sub_group) { Cmiss_field_group_destroy(&sub_group); } for (iter = 0; iter < MAXIMUM_ELEMENT_XI_DIMENSIONS; iter++) { if (mesh_group[iter]) { Cmiss_mesh_group_destroy(&(mesh_group[iter])); } } if (region_rendition) { Cmiss_rendition_destroy(®ion_rendition); } sub_region = pos->first; if (sub_region) { region_rendition= Cmiss_region_get_rendition_internal(sub_region); sub_group = Cmiss_rendition_get_or_create_selection_group(region_rendition); } } if (sub_region && sub_group) { Cmiss_field_module_id field_module = Cmiss_region_get_field_module(sub_region); int dimension = Cmiss_element_get_dimension(pos->second); if (dimension <= MAXIMUM_ELEMENT_XI_DIMENSIONS) { if (!mesh_group[dimension - 1]) { Cmiss_mesh_id temp_mesh = Cmiss_field_module_find_mesh_by_dimension(field_module, dimension); Cmiss_field_element_group_id element_group = Cmiss_field_group_get_element_group(sub_group, temp_mesh); if (!element_group) { element_group = Cmiss_field_group_create_element_group(sub_group, temp_mesh); } mesh_group[dimension - 1] = Cmiss_field_element_group_get_mesh(element_group); Cmiss_field_element_group_destroy(&element_group); Cmiss_mesh_destroy(&temp_mesh); } Cmiss_mesh_group_add_element(mesh_group[dimension - 1], pos->second); } Cmiss_field_module_destroy(&field_module); } } if (sub_group) { Cmiss_field_group_destroy(&sub_group); } for (iter = 0; iter < MAXIMUM_ELEMENT_XI_DIMENSIONS; iter++) { if (mesh_group[iter]) { Cmiss_mesh_group_destroy(&(mesh_group[iter])); } } if (region_rendition) { Cmiss_rendition_destroy(®ion_rendition); } delete element_map; } DESTROY(LIST(Scene_picked_object))( &(scene_picked_object_list)); } } DESTROY(Interaction_volume)(&temp_interaction_volume); } } if (INTERACTIVE_EVENT_BUTTON_RELEASE==event_type) { Element_tool_reset((void *)element_tool); } } } break; default: { display_message(ERROR_MESSAGE, "Element_tool_interactive_event_handler. Unknown event type"); } break; }
int define_Computed_field_type_compose(struct Parse_state *state, void *field_modify_void, void *computed_field_compose_package_void) /******************************************************************************* LAST MODIFIED : 24 August 2006 DESCRIPTION : Converts <field> into type COMPUTED_FIELD_COMPOSE (if it is not already) and allows its contents to be modified. ==============================================================================*/ { int return_code; Computed_field_compose_package *computed_field_compose_package; Computed_field_modify_data *field_modify; struct Option_table *find_option_table, *option_table, *out_of_bounds_option_table; struct Set_Computed_field_conditional_data set_calculate_values_field_data, set_find_element_xi_field_data, set_texture_coordinates_field_data; ENTER(define_Computed_field_type_compose); if (state && (field_modify=(Computed_field_modify_data *)field_modify_void) && (computed_field_compose_package = (Computed_field_compose_package *) computed_field_compose_package_void)) { return_code = 1; Cmiss_mesh_id mesh = 0; char *search_group_name = 0; Cmiss_field_id calculate_values_field = 0; Cmiss_field_id find_element_xi_field = 0; Cmiss_field_id texture_coordinates_field = 0; char find_nearest_flag = 0; char find_exact_flag = 0; char use_point_five_when_out_of_bounds_flag = 0; char fail_when_out_of_bounds_flag = 0; int use_point_five_when_out_of_bounds = 0; int element_dimension = 0; /* Maintain the existing behaviour as the default */ int find_nearest = 0; /* get valid parameters for composite field */ if (field_modify->get_field()) { Computed_field_compose* compose_core = dynamic_cast<Computed_field_compose*>(field_modify->get_field()->core); if (compose_core) { return_code = compose_core->get_type( &calculate_values_field, &find_element_xi_field, &texture_coordinates_field, &mesh, &find_nearest, &use_point_five_when_out_of_bounds); if (mesh) { Cmiss_mesh_access(mesh); element_dimension = Cmiss_mesh_get_dimension(mesh); } } } if (return_code) { /* must access objects for set functions */ if (calculate_values_field) { ACCESS(Computed_field)(calculate_values_field); } if (find_element_xi_field) { ACCESS(Computed_field)(find_element_xi_field); } if (texture_coordinates_field) { ACCESS(Computed_field)(texture_coordinates_field); } option_table = CREATE(Option_table)(); Option_table_add_help(option_table, "The value of a compose field is found by evaluating the <texture_coordinates_field>, " "then searching for matching values of the <find_element_xi_field> in the elements of " "the <mesh> (alternatively specified by <group> and <element_dimension>) and then " "finally evaluating the <calculate_values_field> at this found location. You can " "specify the outcome if the matching values cannot be found in the mesh with " "<use_point_five_when_out_of_bounds> or <fail_when_out_of_bounds>. See examples " "a/resample_texture or a/create_slices where the compose field is used to find the " "equivalent coordinate in another element to evaluate a texture."); /* calculate_values_field */ set_calculate_values_field_data.computed_field_manager = field_modify->get_field_manager(); set_calculate_values_field_data.conditional_function = Computed_field_has_numerical_components; set_calculate_values_field_data.conditional_function_user_data = (void *)NULL; Option_table_add_entry(option_table, "calculate_values_field", &calculate_values_field, &set_calculate_values_field_data, set_Computed_field_conditional); Option_table_add_int_positive_entry(option_table,"element_dimension", &element_dimension); /* find_element_xi_field */ set_find_element_xi_field_data.computed_field_manager = field_modify->get_field_manager(); set_find_element_xi_field_data.conditional_function = Computed_field_has_numerical_components; set_find_element_xi_field_data.conditional_function_user_data = (void *)NULL; Option_table_add_entry(option_table, "find_element_xi_field", &find_element_xi_field, &set_find_element_xi_field_data, set_Computed_field_conditional); find_option_table=CREATE(Option_table)(); Option_table_add_char_flag_entry(find_option_table,"find_nearest", &find_nearest_flag); Option_table_add_char_flag_entry(find_option_table,"find_exact", &find_exact_flag); Option_table_add_suboption_table(option_table, find_option_table); /* group */ Option_table_add_string_entry(option_table, "group", &search_group_name, " GROUP_NAME"); // mesh Option_table_add_mesh_entry(option_table, "mesh", field_modify->get_region(), &mesh); /* texture_coordinates_field */ set_texture_coordinates_field_data.computed_field_manager = field_modify->get_field_manager(); set_texture_coordinates_field_data.conditional_function = Computed_field_has_numerical_components; set_texture_coordinates_field_data.conditional_function_user_data = (void *)NULL; Option_table_add_entry(option_table, "texture_coordinates_field", &texture_coordinates_field, &set_texture_coordinates_field_data, set_Computed_field_conditional); out_of_bounds_option_table=CREATE(Option_table)(); /* use_point_five_when_out_of_bounds */ Option_table_add_char_flag_entry(out_of_bounds_option_table, "use_point_five_when_out_of_bounds", &use_point_five_when_out_of_bounds_flag); Option_table_add_char_flag_entry(out_of_bounds_option_table, "fail_when_out_of_bounds", &fail_when_out_of_bounds_flag); Option_table_add_suboption_table(option_table, out_of_bounds_option_table); return_code = Option_table_multi_parse(option_table, state); if (return_code && !mesh) { mesh = Cmiss_field_module_find_mesh_by_dimension( field_modify->get_field_module(), element_dimension); if (search_group_name) { Cmiss_field_id group_field = Cmiss_field_module_find_field_by_name(field_modify->get_field_module(), search_group_name); Cmiss_field_group_id group = Cmiss_field_cast_group(group_field); Cmiss_field_element_group_id element_group = Cmiss_field_group_get_element_group(group, mesh); Cmiss_mesh_destroy(&mesh); mesh = Cmiss_mesh_group_base_cast(Cmiss_field_element_group_get_mesh(element_group)); Cmiss_field_element_group_destroy(&element_group); Cmiss_field_group_destroy(&group); Cmiss_field_destroy(&group_field); } } if (return_code && !mesh) { display_message(ERROR_MESSAGE, "You must specify a mesh (or element_dimension and optional group)."); return_code = 0; } if (return_code) { if (find_nearest_flag && find_exact_flag) { display_message(ERROR_MESSAGE, "Specify only one of find_nearest and find_exact"); return_code = 0; } if (find_nearest_flag) { find_nearest = 1; } else if (find_exact_flag) { find_nearest = 0; } if (use_point_five_when_out_of_bounds_flag && fail_when_out_of_bounds_flag) { display_message(ERROR_MESSAGE, "Specify only one of use_point_five_when_out_of_bounds " "and fail_when_out_of_bounds"); return_code = 0; } if (use_point_five_when_out_of_bounds_flag) { use_point_five_when_out_of_bounds = 1; } else if (fail_when_out_of_bounds_flag) { use_point_five_when_out_of_bounds = 0; } } if (return_code) { return_code = field_modify->update_field_and_deaccess( Computed_field_create_compose(field_modify->get_field_module(), texture_coordinates_field, find_element_xi_field, calculate_values_field, mesh, find_nearest, use_point_five_when_out_of_bounds)); } if (!return_code) { if ((!state->current_token) || (strcmp(PARSER_HELP_STRING, state->current_token)&& strcmp(PARSER_RECURSIVE_HELP_STRING, state->current_token))) { /* error */ display_message(ERROR_MESSAGE, "define_Computed_field_type_compose. Failed"); } } Cmiss_mesh_destroy(&mesh); if (calculate_values_field) { DEACCESS(Computed_field)(&calculate_values_field); } if (find_element_xi_field) { DEACCESS(Computed_field)(&find_element_xi_field); } if (search_group_name) { DEALLOCATE(search_group_name); } if (texture_coordinates_field) { DEACCESS(Computed_field)(&texture_coordinates_field); } DESTROY(Option_table)(&option_table); } } else { display_message(ERROR_MESSAGE, "define_Computed_field_type_compose. Invalid argument(s)"); return_code = 0; } LEAVE; return (return_code); } /* define_Computed_field_type_compose */
void StrainMeasures::embedStrainOnElements(std::string fieldname, std::vector<std::string>& strain) { const unsigned int num_strains = numberOfModelFrames_; double times[1024]; for (unsigned int j = 0; j < num_strains; j++) { times[j] = static_cast<double>(j) / (num_strains - 1.0); } Cmiss_time_sequence_id time_sequence = Cmiss_field_module_get_matching_time_sequence(field_module, num_strains, times); Cmiss_field_module_begin_change(field_module); //Create Node template Cmiss_nodeset_id nodeset = Cmiss_field_module_find_nodeset_by_name(field_module, "cmiss_nodes"); Cmiss_node_template_id nodeTemplate = Cmiss_nodeset_create_node_template(nodeset); //Create the field Cmiss_field_id strainField = Cmiss_field_module_create_field(field_module, fieldname.c_str(), "finite number_of_components 1 component_names value"); if (!strainField) { std::cout << "Unable to create field " << fieldname << std::endl; return; } Cmiss_node_template_define_field(nodeTemplate, strainField); Cmiss_node_template_define_time_sequence(nodeTemplate, strainField, time_sequence); //Create Element template Cmiss_mesh_id mesh = Cmiss_field_module_find_mesh_by_dimension(field_module, 3); Cmiss_element_template_id element_template = Cmiss_mesh_create_element_template(mesh); Cmiss_element_template_set_shape_type(element_template, CMISS_ELEMENT_SHAPE_CUBE); Cmiss_element_template_set_number_of_nodes(element_template, 1); Cmiss_element_basis_id constant_basis = Cmiss_field_module_create_element_basis(field_module, 3, CMISS_BASIS_FUNCTION_CONSTANT); const int local_node_index = 1; Cmiss_element_template_define_field_simple_nodal(element_template, strainField, -1, constant_basis, 1, &local_node_index); Cmiss_element_basis_destroy(&constant_basis); //Map strains to elements std::map<int, int> elemStrainMap; //Cmiss element no is mapped to strain array number //APLAX elemStrainMap[3] = elemStrainMap[10] = 1; //Array id base 0 elemStrainMap[15] = elemStrainMap[22] = 18; //Average of strain ids 2 and 8 elemStrainMap[27] = elemStrainMap[34] = 12; elemStrainMap[39] = elemStrainMap[46] = 17; elemStrainMap[40] = elemStrainMap[45] = 17; elemStrainMap[28] = elemStrainMap[33] = 10; elemStrainMap[16] = elemStrainMap[21] = 19; //Average of strain ids 11 and 5 elemStrainMap[4] = elemStrainMap[9] = 4; //TCH elemStrainMap[11] = elemStrainMap[12] = 2; //Array id base 0 elemStrainMap[23] = elemStrainMap[24] = 20; //Average of strain ids 3 and 9 elemStrainMap[35] = elemStrainMap[36] = 8; elemStrainMap[47] = elemStrainMap[48] = 16; elemStrainMap[41] = elemStrainMap[42] = 16; elemStrainMap[17] = elemStrainMap[18] = 11; elemStrainMap[29] = elemStrainMap[30] = 21; //Average of strain ids 12 and 6 elemStrainMap[5] = elemStrainMap[6] = 5; //FCH elemStrainMap[1] = elemStrainMap[2] = 3; //Array id base 0 elemStrainMap[13] = elemStrainMap[14] = 22; //Average of 10 and 4 elemStrainMap[25] = elemStrainMap[26] = 4; elemStrainMap[37] = elemStrainMap[38] = 23; //Average of strains 14 and 15 elemStrainMap[43] = elemStrainMap[44] = 24; //Average of strains 16 and 13 elemStrainMap[31] = elemStrainMap[32] = 6; elemStrainMap[19] = elemStrainMap[20] = 25; //Average of strains 7 and 1 elemStrainMap[7] = elemStrainMap[8] = 0; std::vector<std::string> allStrain = strain; //Add the additional strains 18 - 23 std::string s2 = strain[1]; std::string s8 = strain[7]; std::string s11 = strain[10]; std::string s5 = strain[5]; std::string s9 = strain[8]; std::string s3 = strain[2]; std::string s12 = strain[11]; std::string s6 = strain[6]; std::string s10 = strain[9]; std::string s4 = strain[3]; std::string s14 = strain[13]; std::string s15 = strain[14]; std::string s16 = strain[15]; std::string s13 = strain[12]; std::string s1 = strain[0]; std::string s7 = strain[6]; std::vector<std::string> compute; compute.push_back(s2); compute.push_back(s8); compute.push_back(s11); compute.push_back(s5); compute.push_back(s9); compute.push_back(s3); compute.push_back(s12); compute.push_back(s6); compute.push_back(s10); compute.push_back(s4); compute.push_back(s14); compute.push_back(s15); compute.push_back(s16); compute.push_back(s13); compute.push_back(s7); compute.push_back(s1); for (int cptc = 0; cptc < 16; cptc += 2) { std::vector<std::string> strain1; std::vector<std::string> strain2; std::ostringstream ss; boost::split(strain1, compute[cptc], boost::is_any_of(",")); boost::split(strain2, compute[cptc + 1], boost::is_any_of(",")); for (unsigned int j = 0; j < num_strains - 1; j++) { double value1 = atof(strain1[j].c_str()); double value2 = atof(strain2[j].c_str()); ss << (value1 + value2) * 0.5 << ","; } ss << "0.0"; allStrain.push_back(ss.str()); } for (unsigned int i = 0; i < num_elements; i++) { Cmiss_node_id temporaryNode = Cmiss_nodeset_create_node(nodeset, extraNodeStartID++, nodeTemplate); Cmiss_element_template_set_node(element_template, 1, temporaryNode); //Link node with the element Cmiss_element_merge(elements[i], element_template); Cmiss_field_cache_set_node(fieldCache, temporaryNode); std::vector<std::string> strains; boost::split(strains, allStrain[elemStrainMap[i + 1]], boost::is_any_of(",")); for (unsigned int j = 0; j < num_strains; j++) { double value = atof(strains[j].c_str()); double time = times[j]; Cmiss_field_cache_set_time(fieldCache, time); Cmiss_field_assign_real(strainField,fieldCache,1,&value); } Cmiss_node_destroy(&temporaryNode); } Cmiss_field_module_end_change(field_module); Cmiss_field_destroy(&strainField); Cmiss_element_template_destroy(&element_template); Cmiss_node_template_destroy(&nodeTemplate); Cmiss_nodeset_destroy(&nodeset); //Calling the following leads to the error ERROR: DESTROY(FE_time_sequence). Positive access_count //Cmiss_time_sequence_destroy(&time_sequence); }