void NuTo::Structure::InterpolationTypeAdd(int rInterpolationTypeId, NuTo::Node::eDof rDofType, NuTo::Interpolation::eTypeOrder rTypeOrder, const Eigen::VectorXi& rDegree, const std::vector<Eigen::VectorXd>& rKnots, const Eigen::MatrixXd& rWeights) { InterpolationType* interpolationType = InterpolationTypeGet(rInterpolationTypeId); interpolationType->AddDofInterpolation(rDofType, rTypeOrder, rDegree, rKnots, rWeights); eIntegrationType integrationTypeEnum = interpolationType->GetStandardIntegrationType(); const IntegrationTypeBase& integrationType = *this->GetPtrIntegrationType(integrationTypeEnum); interpolationType->ClearCache(); // update all elements // disable show time bool showTime = GetShowTime(); SetShowTime(false); int elementGroupId = GroupCreate("Elements"); GroupAddElementFromType(elementGroupId, rInterpolationTypeId); for (int elementId : GroupGetMemberIds(elementGroupId)) { ElementBase* element = ElementGetElementPtr(elementId); element->SetIntegrationType(integrationType); } GroupDelete(elementGroupId); UpdateDofStatus(); SetShowTime(showTime); }
void NuTo::Structure::InterpolationTypeAdd( int rInterpolationTypeId, NuTo::Node::eDof rDofType, NuTo::Interpolation::eTypeOrder rTypeOrder = Interpolation::eTypeOrder::EQUIDISTANT1) { InterpolationType& interpolationType = *InterpolationTypeGet(rInterpolationTypeId); interpolationType.AddDofInterpolation(rDofType, rTypeOrder); eIntegrationType integrationTypeEnum = interpolationType.GetStandardIntegrationType(); const IntegrationTypeBase& integrationType = *this->GetPtrIntegrationType(integrationTypeEnum); interpolationType.ClearCache(); // update all elements // disable show time bool showTime = GetShowTime(); SetShowTime(false); int elementGroupId = GroupCreate(eGroupId::Elements); GroupAddElementFromType(elementGroupId, rInterpolationTypeId); for (int elementId : GroupGetMemberIds(elementGroupId)) { ElementBase* element = ElementGetElementPtr(elementId); element->SetIntegrationType(integrationType); } GroupDelete(elementGroupId); UpdateDofStatus(); SetShowTime(showTime); }
static void BuildWindowGroup(EWin ** ewins, int num, int gid) { int i; Group *group; Mode_groups.current = group = GroupCreate(gid); for (i = 0; i < num; i++) AddEwinToGroup(ewins[i], group); }
Bool GetActorPair1(Obj *con, Obj *actor, int i, /* RESULTS */ Obj **counter_actor) { ObjList *members, *p, *counter_group; if (ISA(N("group"), I(con, i))) { members = GroupMembers(&TsNA, I(con, i)); if (ObjListIn(actor, members)) { counter_group = NULL; for (p = members; p; p = p->next) { if (p->obj == actor) continue; counter_group = ObjListCreate(p->obj, counter_group); } *counter_actor = GroupCreate(&TsNA, counter_group); ObjListFree(counter_group); ObjListFree(members); return(1); } ObjListFree(members); } return(0); }
int NuTo::Structure::ElementsCreate(int rInterpolationTypeId, const Eigen::MatrixXi& rNodeNumbers) { std::vector<int> newElementIds; // go through the elements for (int iNode = 0; iNode < rNodeNumbers.cols(); ++iNode) { auto column = rNodeNumbers.col(iNode); std::vector<int> incidence(column.data(), column.data() + column.size()); int newElementId = ElementCreate(rInterpolationTypeId, incidence); newElementIds.push_back(newElementId); } bool showTime = mShowTime; mShowTime = false; // create element group containing the new elements int newElementGroup = GroupCreate(eGroupId::Elements); for (int newElementId : newElementIds) GroupAddElement(newElementGroup, newElementId); mShowTime = showTime; return newElementGroup; }
void NuTo::Structure::InterpolationTypeSetIntegrationType(int rInterpolationTypeId, IntegrationTypeBase* rIntegrationType) { InterpolationType* interpolationType = InterpolationTypeGet(rInterpolationTypeId); interpolationType->ClearCache(); // update all elements // disable show time bool showTime = GetShowTime(); SetShowTime(false); int elementGroupId = GroupCreate("Elements"); GroupAddElementFromType(elementGroupId, rInterpolationTypeId); for (int elementId : GroupGetMemberIds(elementGroupId)) { ElementBase* element = ElementGetElementPtr(elementId); element->SetIntegrationType(*rIntegrationType); } GroupDelete(elementGroupId); SetShowTime(showTime); }
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); }
int NuTo::Structure::BoundaryElementsCreate(int rElementGroupId, int rNodeGroupId, NodeBase* rControlNode) { Timer timer(__FUNCTION__, GetShowTime(), GetLogger()); // find groups 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."); boost::ptr_map<int, GroupBase>::iterator itGroupBoundaryNodes = mGroupMap.find(rNodeGroupId); if (itGroupBoundaryNodes == mGroupMap.end()) throw Exception(__PRETTY_FUNCTION__, "Group with the given identifier does not exist."); if (itGroupBoundaryNodes->second->GetType() != NuTo::eGroupId::Nodes) throw Exception(__PRETTY_FUNCTION__, "Group is not a node group."); Group<ElementBase>& elementGroup = *(itGroupElements->second->AsGroupElement()); Group<NodeBase>& nodeGroup = *(itGroupBoundaryNodes->second->AsGroupNode()); // since the search is done via the id's, the surface nodes are ptr, so make another set with the node ptrs std::set<const NodeBase*> nodePtrSet; for (auto itNode : nodeGroup) { nodePtrSet.insert(itNode.second); } std::vector<int> newBoundaryElementIds; // loop over all elements for (auto itElement : elementGroup) { ElementBase* elementPtr = itElement.second; const InterpolationType& interpolationType = elementPtr->GetInterpolationType(); // std::cout << typeid(*elementPtr).name() << "\n"; // std::cout << typeid(ContinuumElement<1>).name() << std::endl; if (typeid(*elementPtr) != typeid(ContinuumElement<1>) && typeid(*elementPtr) != typeid(ContinuumElement<2>) && typeid(*elementPtr) != typeid(ContinuumElement<3>)) throw Exception(__PRETTY_FUNCTION__, "Element is not a ContinuumElement."); // loop over all surfaces for (int iSurface = 0; iSurface < interpolationType.GetNumSurfaces(); ++iSurface) { bool elementSurfaceNodesMatchBoundaryNodes = true; Eigen::VectorXi surfaceNodeIndices = interpolationType.GetSurfaceNodeIndices(iSurface); int numSurfaceNodes = surfaceNodeIndices.rows(); std::vector<const NodeBase*> surfaceNodes(numSurfaceNodes); for (int iSurfaceNode = 0; iSurfaceNode < numSurfaceNodes; ++iSurfaceNode) { surfaceNodes[iSurfaceNode] = elementPtr->GetNode(surfaceNodeIndices(iSurfaceNode, 0)); } // check, if all surface nodes are in the node group for (auto& surfaceNode : surfaceNodes) { if (nodePtrSet.find(surfaceNode) == nodePtrSet.end()) { // this surface has at least one node that is not in the list, continue elementSurfaceNodesMatchBoundaryNodes = false; break; } } if (not elementSurfaceNodesMatchBoundaryNodes) continue; int surfaceId = iSurface; int elementId = GetUnusedId(mElementMap); ElementBase* boundaryElement = nullptr; ConstitutiveBase& constitutiveLaw = elementPtr->GetConstitutiveLaw(0); switch (elementPtr->GetLocalDimension()) { case 1: { const auto& integrationType = *GetPtrIntegrationType(eIntegrationType::IntegrationType0DBoundary); auto& element = dynamic_cast<ContinuumElement<1>&>(*elementPtr); if (rControlNode == nullptr) boundaryElement = new ContinuumBoundaryElement<1>(element, integrationType, surfaceId); else boundaryElement = new ContinuumBoundaryElementConstrainedControlNode<1>(element, integrationType, surfaceId, rControlNode); break; } case 2: { eIntegrationType integrationTypeEnum; // check for 2D types switch (interpolationType.GetStandardIntegrationType()) { case eIntegrationType::IntegrationType2D3NGauss1Ip: case eIntegrationType::IntegrationType2D4NGauss1Ip: integrationTypeEnum = eIntegrationType::IntegrationType1D2NGauss1Ip; break; case eIntegrationType::IntegrationType2D3NGauss3Ip: case eIntegrationType::IntegrationType2D4NGauss4Ip: integrationTypeEnum = eIntegrationType::IntegrationType1D2NGauss2Ip; break; case eIntegrationType::IntegrationType2D3NGauss6Ip: case eIntegrationType::IntegrationType2D4NGauss9Ip: integrationTypeEnum = eIntegrationType::IntegrationType1D2NGauss3Ip; break; case eIntegrationType::IntegrationType2D3NGauss12Ip: integrationTypeEnum = eIntegrationType::IntegrationType1D2NGauss5Ip; break; case eIntegrationType::IntegrationType2D4NLobatto9Ip: integrationTypeEnum = eIntegrationType::IntegrationType1D2NLobatto3Ip; break; case eIntegrationType::IntegrationType2D4NLobatto16Ip: integrationTypeEnum = eIntegrationType::IntegrationType1D2NLobatto4Ip; break; case eIntegrationType::IntegrationType2D4NLobatto25Ip: integrationTypeEnum = eIntegrationType::IntegrationType1D2NLobatto5Ip; break; default: throw Exception(__PRETTY_FUNCTION__, "Could not automatically determine integration type of the boundary element."); } const auto& integrationType = *GetPtrIntegrationType(integrationTypeEnum); auto& element = dynamic_cast<ContinuumElement<2>&>(*elementPtr); if (rControlNode == nullptr) boundaryElement = new ContinuumBoundaryElement<2>(element, integrationType, surfaceId); else boundaryElement = new ContinuumBoundaryElementConstrainedControlNode<2>(element, integrationType, surfaceId, rControlNode); break; } case 3: { eIntegrationType integrationTypeEnum; // check for 3D types switch (interpolationType.GetStandardIntegrationType()) { case eIntegrationType::IntegrationType3D4NGauss1Ip: integrationTypeEnum = eIntegrationType::IntegrationType2D3NGauss1Ip; break; case eIntegrationType::IntegrationType3D4NGauss4Ip: integrationTypeEnum = eIntegrationType::IntegrationType2D3NGauss3Ip; break; case eIntegrationType::IntegrationType3D8NGauss1Ip: integrationTypeEnum = eIntegrationType::IntegrationType2D4NGauss1Ip; break; case eIntegrationType::IntegrationType3D8NGauss2x2x2Ip: integrationTypeEnum = eIntegrationType::IntegrationType2D4NGauss4Ip; break; case eIntegrationType::IntegrationType3D8NLobatto3x3x3Ip: integrationTypeEnum = eIntegrationType::IntegrationType2D4NLobatto9Ip; break; case eIntegrationType::IntegrationType3D8NLobatto4x4x4Ip: integrationTypeEnum = eIntegrationType::IntegrationType2D4NLobatto16Ip; break; case eIntegrationType::IntegrationType3D8NLobatto5x5x5Ip: integrationTypeEnum = eIntegrationType::IntegrationType2D4NLobatto16Ip; break; default: throw Exception(__PRETTY_FUNCTION__, "Could not automatically determine integration type of the boundary element."); } const auto& integrationType = *GetPtrIntegrationType(integrationTypeEnum); auto& element = dynamic_cast<ContinuumElement<3>&>(*elementPtr); if (rControlNode == nullptr) boundaryElement = new ContinuumBoundaryElement<3>(element, integrationType, surfaceId); else boundaryElement = new ContinuumBoundaryElementConstrainedControlNode<3>(element, integrationType, surfaceId, rControlNode); break; } default: throw Exception(__PRETTY_FUNCTION__, "Boundary element for Continuum element with dimension " + std::to_string(elementPtr->GetLocalDimension()) + "not implemented"); } mElementMap.insert(elementId, boundaryElement); newBoundaryElementIds.push_back(elementId); boundaryElement->SetConstitutiveLaw(constitutiveLaw); } } int boundaryElementGroup = GroupCreate(eGroupId::Elements); for (int boundaryElementId : newBoundaryElementIds) GroupAddElement(boundaryElementGroup, boundaryElementId); return boundaryElementGroup; }