void StaggeredSolver :: giveTotalLocationArray(IntArray &condensedLocationArray, const UnknownNumberingScheme &s, Domain *d) { IntArray nodalArray, ids, locationArray; locationArray.clear(); for ( auto &dman : d->giveDofManagers() ) { dman->giveCompleteLocationArray(nodalArray, s); locationArray.followedBy(nodalArray); } for ( auto &elem : d->giveElements() ) { for ( int i = 1; i <= elem->giveNumberOfInternalDofManagers(); i++ ) { elem->giveInternalDofManDofIDMask(i, ids); elem->giveInternalDofManager(i)->giveLocationArray(ids, nodalArray, s); locationArray.followedBy(nodalArray); } } IntArray nonZeroMask; nonZeroMask.findNonzeros(locationArray); condensedLocationArray.resize(nonZeroMask.giveSize()); for ( int i = 1; i <= nonZeroMask.giveSize(); i++ ) { condensedLocationArray.at(i) = locationArray.at( nonZeroMask.at(i) ); } }
void Set :: computeIntArray(IntArray& answer, const IntArray& specified, std::list< Range > ranges) { // Find the max value; int maxIndex = specified.giveSize() == 0 ? 0 : specified.maximum(); for (std::list< Range >::iterator it = ranges.begin(); it != ranges.end(); ++it) { if ( it->giveEnd() > maxIndex ) maxIndex = it->giveEnd(); } IntArray afflictedNodes(maxIndex); afflictedNodes.zero(); for (int i = 1; i <= specified.giveSize(); ++i) { afflictedNodes.at(specified.at(i)) = 1; } for (std::list< Range >::iterator it = ranges.begin(); it != ranges.end(); ++it) { for (int i = it->giveStart(); i <= it->giveEnd(); ++i) { afflictedNodes.at(i) = 1; } } answer.findNonzeros(afflictedNodes); }
void Set :: computeIntArray(IntArray &answer, const IntArray &specified, std :: list< Range >ranges) { // Find the max value; int maxIndex = specified.giveSize() == 0 ? 0 : specified.maximum(); for ( auto &range: ranges ) { if ( range.giveEnd() > maxIndex ) { maxIndex = range.giveEnd(); } } IntArray afflictedNodes(maxIndex); afflictedNodes.zero(); for ( int i = 1; i <= specified.giveSize(); ++i ) { afflictedNodes.at( specified.at(i) ) = 1; } for ( auto &range: ranges ) { for ( int i = range.giveStart(); i <= range.giveEnd(); ++i ) { afflictedNodes.at(i) = 1; } } answer.findNonzeros(afflictedNodes); }
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 ]); } } }