void EnrichmentItem :: computeEnrichedDofManDofIdArray(IntArray &oDofIdArray, DofManager &iDMan) { // Gives an array containing the dofId's that // are candidates for enrichment. At the moment, // regular dofs are considered as candidates. In // the future, we may also consider enriching // enriched dofs from other enrichment items. const IntArray *enrichesDofsWithIdArray = this->giveEnrichesDofsWithIdArray(); // Number of candidates for enrichment int numEnrCand = enrichesDofsWithIdArray->giveSize(); // Number of active enrichment functions int numEnrFunc = this->giveNumDofManEnrichments(iDMan); // Go through the list of dofs that the EI supports // and compare with the available dofs in the dofMan. int count = 0; for ( int i = 1; i <= numEnrFunc; i++ ) { for ( int j = 1; j <= numEnrCand; j++ ) { if ( iDMan.hasDofID( ( DofIDItem ) enrichesDofsWithIdArray->at(j) ) ) { count++; } } } oDofIdArray.resize(count); for ( int i = 1; i <= count; i++ ) { oDofIdArray.at(i) = this->giveStartOfDofIdPool() + i - 1; } }
IntArray XfemManager :: giveEnrichedDofIDs(const DofManager &iDMan) const { IntArray dofIdArray; for(int id : mXFEMPotentialDofIDs) { if(iDMan.hasDofID( DofIDItem(id) )) { dofIdArray.followedBy(id); } } return dofIdArray; }
void StructuralInterfaceElementPhF :: computeLocationArrayOfDofIDs( const IntArray &dofIdArray, IntArray &answer ) { // Routine to compute the local ordering array an element given a dofid array. answer.resize( 0 ); int k = 0; for(int i = 1; i <= this->giveNumberOfDofManagers(); i++) { DofManager *dMan = this->giveDofManager( i ); for(int j = 1; j <= dofIdArray.giveSize( ); j++) { if(dMan->hasDofID( (DofIDItem) dofIdArray.at( j ) )) { // hack answer.followedBy( k + j ); } } k += dMan->giveNumberOfDofs( ); } }
void PhaseFieldElement :: computeLocationArrayOfDofIDs( const IntArray &dofIdArray, IntArray &answer ) { // Routine to extract compute the location array an element given an dofid array. answer.clear(); NLStructuralElement *el = this->giveElement(); int k = 0; for ( int i = 1; i <= el->giveNumberOfDofManagers(); i++ ) { DofManager *dMan = el->giveDofManager( i ); for ( int j = 1; j <= dofIdArray.giveSize( ); j++ ) { if ( dMan->hasDofID( (DofIDItem) dofIdArray.at( j ) ) ) { Dof *d = dMan->giveDofWithID( dofIdArray.at( j ) ); answer.followedBy( k + d->giveNumber( ) ); } } k += dMan->giveNumberOfDofs( ); } }
void CoupledFieldsElement :: computeLocationArrayOfDofIDs(const IntArray &dofIdArray, IntArray &answer) { // Routine to extract compute the location array an element given an dofid array. answer.resize(0); int k = 0; for ( int i = 1; i <= numberOfDofMans; i++ ) { DofManager *dMan = this->giveDofManager(i); for (int j = 1; j <= dofIdArray.giveSize(); j++ ) { if ( dMan->hasDofID( (DofIDItem) dofIdArray.at(j) ) ) { Dof *d = dMan->giveDofWithID( dofIdArray.at(j) ); answer.followedBy( k + d->giveNumber() ); //answer.followedBy( k + j ); } } k += dMan->giveNumberOfDofs( ); } }
void CoupledFieldsElement :: computeVectorOfDofIDs(const IntArray &dofIdArray, ValueModeType valueMode, TimeStep *stepN, FloatArray &answer) { // Routine to extract the solution vector for an element given an dofid array. // Size will be numberOfDofs and if a certain dofId does not exist a zero is used as value. answer.resize( numberOfDofMans * dofIdArray.giveSize() ); // equal number of nodes for all fields answer.zero(); int k = 1; for ( int i = 1; i <= numberOfDofMans; i++ ) { DofManager *dMan = this->giveDofManager(i); for (int j = 1; j <= dofIdArray.giveSize(); j++ ) { if ( dMan->hasDofID( (DofIDItem) dofIdArray.at(j) ) ) { Dof *d = dMan->giveDofWithID( dofIdArray.at(j) ); answer.at(k) = d->giveUnknown(valueMode, stepN); } k++; } } }
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 ]); } } }