function[Data, nb_nodes]=updateInterface(Mesh, Data, body_tag, nodes, operation) % updateInterface: Updates the interface properties % INPUT: % Mesh: Structure containing all the mesh parameters % Data: Structure containing all the data parameters % body_tag: Tag of the body to be updated % nodes: Nodes to be added or removed from the potential contact interface % operation: Specifies whether nodes should be added (add) or removed (dump) % OUTPUT: % Data: Updated data structure with interface properties % nb_nodes: Number of nodes added or removed % Retrieve initial interface connectivity matrix iIc=Data.body{body_tag}.initial_interface_connect; % Retrieve initial set of nodes iIn=Data.body{body_tag}.initial_nodes; % Retrieve current set of nodes In=Data.body{body_tag}.interface_nodes; % Update interface connectivity matrix switch operation case 'dump' new_nodes=setdiff(In, nodes); indx=all(ismember(iIc,new_nodes),2); new_interface_connect=iIc(indx,:); case 'add' new_nodes=union(In, nodes); indx=all(ismember(iIc,new_nodes),2); new_interface_connect=iIc(indx,:); end % Update active set of nodes active_set=ismember(iIn, new_nodes); % Update interface degrees of freedom new_interface_dof=Mesh.Dof_set(:,new_nodes); new_interface_dof=new_interface_dof(:); % Update body properties Data.body{body_tag}.interface_nodes=new_nodes(:); Data.body{body_tag}.active_set=active_set; Data.body{body_tag}.interface_dof=new_interface_dof; Data.body{body_tag}.interface_connect=new_interface_connect; % Update mapping of degrees of freedom [Data]=mapGlobal2Local(Data); % Change in the number of nodes nb_nodes=length(new_nodes)-length(In); end