void ContactDefinition :: createContactDofs() { // Creates new dofs due associated with the contact (Lagrange multipliers) and appends them to the dof managers // Creates new dofs due associated with the contact (Lagrange multipliers) and appends them to the dof managers //TODO This is a bit ugly, find a better solution than asking the contact el if ( int numDofs = this->giveNumberOfConstraintEqToAdd() ) { // get an array with dof ids' to append to IntArray dofIdArray(numDofs), dofMans; for ( int i = 1; i <= numDofs; i++ ) { dofIdArray.at(i) = this->cMan->giveDomain()->giveNextFreeDofID(); } for ( ContactElement *cEl : this->masterElementList ) { cEl->giveDofManagersToAppendTo(dofMans); if ( dofMans.giveSize() ) { // if the contact element adds extra dofs, store them. Maybe just store in cDef? cEl->setDofIdArray(dofIdArray); } for ( int i = 1; i <= dofMans.giveSize(); i++ ) { DofManager *dMan = this->cMan->giveDomain()->giveDofManager(dofMans.at(i)); for ( auto &dofid: dofIdArray ) { if ( !dMan->hasDofID( ( DofIDItem ) ( dofid ) ) ) { dMan->appendDof( new MasterDof( dMan, ( DofIDItem ) dofid ) ); } } } } } }
void EnrichmentItem :: createEnrichedDofs() { // Creates new dofs due to the enrichment and appends them to the dof managers int nrDofMan = this->giveDomain()->giveNumberOfDofManagers(); IntArray EnrDofIdArray; mEIDofIdArray.clear(); //int bcIndex = -1; int icIndex = -1; // Create new dofs for ( int i = 1; i <= nrDofMan; i++ ) { DofManager *dMan = this->giveDomain()->giveDofManager(i); if ( isDofManEnriched(* dMan) ) { //printf("dofMan %i is enriched \n", dMan->giveNumber()); computeEnrichedDofManDofIdArray(EnrDofIdArray, * dMan); // Collect boundary condition ID of existing dofs IntArray bcIndexArray; for ( Dof *dof: *dMan ) { bcIndexArray.followedBy(dof->giveBcId()); } bool foundBC = false; IntArray nonZeroBC; if ( !bcIndexArray.containsOnlyZeroes() ) { // BC is found on dofs foundBC = true; nonZeroBC.findNonzeros(bcIndexArray); } int iDof(1); for ( auto &dofid: EnrDofIdArray ) { if ( !dMan->hasDofID( ( DofIDItem ) ( dofid ) ) ) { if ( mInheritBoundaryConditions || mInheritOrderedBoundaryConditions ) { if ( foundBC ) { // Append dof with BC if ( mInheritOrderedBoundaryConditions ) { ///TODO: add choise of inheriting only specific BC. // Assume order type of new dofs are the same as original dMan->appendDof( new MasterDof(dMan, bcIndexArray.at(iDof), icIndex, ( DofIDItem ) dofid) ); } else { // Append enriched dofs with same BC dMan->appendDof( new MasterDof(dMan, bcIndexArray.at(nonZeroBC.at(1)), icIndex, ( DofIDItem ) dofid) ); } } else { // No BC found, append enriched dof without BC dMan->appendDof( new MasterDof(dMan, ( DofIDItem ) dofid) ); } } else { // Append enriched dof without BC dMan->appendDof( new MasterDof(dMan, ( DofIDItem ) dofid) ); } } iDof++; } } } // Remove old dofs int poolStart = giveStartOfDofIdPool(); int poolEnd = giveEndOfDofIdPool(); for ( int i = 1; i <= nrDofMan; i++ ) { DofManager *dMan = this->giveDomain()->giveDofManager(i); computeEnrichedDofManDofIdArray(EnrDofIdArray, * dMan); std :: vector< DofIDItem >dofsToRemove; for ( Dof *dof: *dMan ) { DofIDItem dofID = dof->giveDofID(); if ( dofID >= DofIDItem(poolStart) && dofID <= DofIDItem(poolEnd) ) { bool dofIsInIdArray = false; for ( int k = 1; k <= EnrDofIdArray.giveSize(); k++ ) { if ( dofID == DofIDItem( EnrDofIdArray.at(k) ) ) { dofIsInIdArray = true; break; } } if ( !dofIsInIdArray ) { dofsToRemove.push_back(dofID); } if(mEIDofIdArray.findFirstIndexOf(dofID) == 0 && dofIsInIdArray) { mEIDofIdArray.followedBy(dofID); } } } for ( size_t j = 0; j < dofsToRemove.size(); j++ ) { dMan->removeDof(dofsToRemove [ j ]); } } }