void list_DeleteWithElement(LIST List, void (*ElementDelete)(POINTER)) /************************************************************** INPUT: A list and a delete function for the elements. RETURNS: Nothing. EFFECT: The list and all its elements are deleted. The function needs time O(n*d), where <n> is the length of the list and <d> is the time for the delete function. ***************************************************************/ { LIST Scan; while (!list_Empty(List)) { Scan = list_Cdr(List); ElementDelete(list_Car(List)); list_Free(List); List = Scan; } }
NAT list_DeleteWithElementCount(LIST List, void (*ElementDelete)(POINTER)) /************************************************************** INPUT: A List and a delete function for the elements. RETURNS: The number of deleted elements. EFFECT: The List and all its elements are deleted. The function needs time O(n*d), where <n> is the length of the list and <d> is the time for the delete function. ***************************************************************/ { int Result; LIST Scan; Result = 0; while (!list_Empty(List)) { Scan = list_Cdr(List); ElementDelete(list_Car(List)); list_Free(List); List = Scan; Result++; } return Result; }
std::pair<int, int> NuTo::Structure::InterfaceElementsCreate(int rElementGroupId, int rInterfaceInterpolationType, int rFibreInterpolationType) { // find element group boost::ptr_map<int, GroupBase>::iterator itGroupElements = mGroupMap.find(rElementGroupId); if (itGroupElements == mGroupMap.end()) throw Exception(__PRETTY_FUNCTION__, "Group with the given identifier does not exist."); if (itGroupElements->second->GetType() != NuTo::eGroupId::Elements) throw Exception(__PRETTY_FUNCTION__, "Group is not an element group."); // gets member ids from an element group. The element group must only contain truss elements auto elementIds = GroupGetMemberIds(rElementGroupId); int groupElementsInterface = GroupCreate(NuTo::eGroupId::Elements); int groupElementsFibre = GroupCreate(NuTo::eGroupId::Elements); // loop over elements in element group for (int elementId : elementIds) { auto nodeIds = ElementGetNodes(elementId); assert((nodeIds.size() == 2 or nodeIds.size() == 3) and "Only implemented for the 4 node and 6 node interface element"); std::vector<int> nodeIdsFibre(nodeIds.size()); std::vector<int> nodeIdsMatrix(nodeIds.size()); // loop over nodes of element for (unsigned int k = 0; k < nodeIds.size(); ++k) { Eigen::VectorXd nodeCoordinates; NodeGetCoordinates(nodeIds[k], nodeCoordinates); int groupNodes = GroupCreate(NuTo::eGroupId::Nodes); GroupAddNodeRadiusRange(groupNodes, nodeCoordinates, 0.0, 1e-6); // create an additional node at the same position if it has not been created already if (GroupGetNumMembers(groupNodes) > 1) { assert(GroupGetNumMembers(groupNodes) == 2 and "This group should have exactly two members. Check what went wrong!"); auto groupNodeMemberIds = GroupGetMemberIds(groupNodes); if (groupNodeMemberIds[0] == nodeIds[k]) { nodeIdsFibre[k] = groupNodeMemberIds[1]; } else { nodeIdsFibre[k] = groupNodeMemberIds[0]; } } else { std::set<NuTo::Node::eDof> dofs; dofs.insert(NuTo::Node::eDof::COORDINATES); dofs.insert(NuTo::Node::eDof::DISPLACEMENTS); nodeIdsFibre[k] = NodeCreate(nodeCoordinates, dofs); } nodeIdsMatrix[k] = nodeIds[k]; } // create interface element std::vector<int> nodeIndicesInterface(2 * nodeIds.size()); for (unsigned int iIndex = 0; iIndex < nodeIds.size(); ++iIndex) { nodeIndicesInterface[iIndex] = nodeIdsMatrix[iIndex]; nodeIndicesInterface[nodeIndicesInterface.size() - iIndex - 1] = nodeIdsFibre[iIndex]; } int newElementInterface = ElementCreate(rInterfaceInterpolationType, nodeIndicesInterface); GroupAddElement(groupElementsInterface, newElementInterface); // create new truss element with duplicated nodes int newElementFibre = ElementCreate(rFibreInterpolationType, nodeIdsFibre); GroupAddElement(groupElementsFibre, newElementFibre); // delete old element ElementDelete(elementId); } return std::make_pair(groupElementsFibre, groupElementsInterface); }