void CriticalPoint::TraceMaxLineFromSaddle(SadPoint& sadP, size_t& maxP, IntArray& pathArray) { /* TraceMaxLineFromSaddle : from a saddle point, find a path to a max point * maxP : sadP.maxPoints* * pathArray : sadP.maxPath* */ CoordArray& vCoord = *(Global::p_coord); size_t nextVID = maxP; pathArray.clear(); pathArray.push_back(sadP.getId()); double lensum = 0; while( ((m_vtx)[nextVID])->getType() != Global::MAXPOINT) { pathArray.push_back(nextVID); double len = (vCoord[pathArray[pathArray.size() - 2]] - vCoord[pathArray[pathArray.size() - 1]]).abs(); lensum += len; if (lensum < Global::maxLineLength) { nextVID = FindMaxEigenValueFromVertexNeigh(nextVID); } else return; } pathArray.push_back(nextVID); maxP = nextVID; }
/* * Returns array storing nonlocal dependency * (in terms of global element numbers) for given element */ void NonlocalMaterialWTP :: giveElementNonlocalDepArry(IntArray &answer, Domain *d, int num) { std :: set< int >relems; std :: set< int > :: const_iterator relemsIter; Element *ielem = d->giveElement(num); if ( ielem->giveMaterial()->giveInterface(NonlocalMaterialExtensionInterfaceType) ) { relems.clear(); // loop over element IRules and their IPs to retrieve remote (nonlocal) elements // store their global numbers in the relems set (to avoid redundancy) // and then keep them in nonlocTables array. ielem->ipEvaluator(this, & NonlocalMaterialWTP :: giveNonlocalDepArryElementPlugin, relems); // convert relems set into an int array // and store it answer.resize( relems.size() ); int _i = 1; for ( int relem: relems ) { answer.at(_i++) = relem; } } else { answer.clear(); } }
void PrescribedGradientBCWeak :: giveTractionLocationArray(IntArray &rows, const UnknownNumberingScheme &s) { OOFEM_ERROR("Not implemented.") #if 0 rows.clear(); // Loop over traction elements for ( size_t tracElInd = 0; tracElInd < mpTractionElements.size(); tracElInd++ ) { IntArray tracElRows, trac_loc_r; const TractionElement &tEl = * ( mpTractionElements [ tracElInd ] ); for ( int tracNodeInd : tEl.mTractionNodeInd ) { Node *tNode = mpTractionNodes [ tracNodeInd ]; tNode->giveLocationArray(giveTracDofIDs(), trac_loc_r, s); tracElRows.followedBy(trac_loc_r); } rows.followedBy(tracElRows); } if ( mpDisplacementLock != NULL ) { IntArray dispLock_r; mpDisplacementLock->giveLocationArray(giveDispLockDofIDs(), dispLock_r, s); rows.followedBy(dispLock_r); } #endif }
void DofManager :: giveLocationArray(const IntArray &dofIDArry, IntArray &locationArray, const UnknownNumberingScheme &s) const { if ( !hasSlaveDofs ) { int size; // prevents some size problem when connecting different elements with // different number of dofs size = dofIDArry.giveSize(); locationArray.resize(size); for ( int i = 1; i <= size; i++ ) { auto pos = this->findDofWithDofId( ( DofIDItem ) dofIDArry.at(i) ); if ( pos == this->end() ) { OOFEM_ERROR("incompatible dof (%d) requested", dofIDArry.at(i)); } locationArray.at(i) = s.giveDofEquationNumber( *pos ); } } else { IntArray mstrEqNmbrs; locationArray.clear(); for ( int dofid: dofIDArry ) { auto pos = this->findDofWithDofId( ( DofIDItem ) dofid ); if ( pos == this->end() ) { OOFEM_ERROR("incompatible dof (%d) requested", dofid); } (*pos)->giveEquationNumbers(mstrEqNmbrs, s); locationArray.followedBy(mstrEqNmbrs); } } }
int EIPrimaryUnknownMapper :: mapAndUpdate(FloatArray &answer, ValueModeType mode, Domain *oldd, Domain *newd, TimeStep *tStep) { int inode, nd_nnodes = newd->giveNumberOfDofManagers(); int nsize = newd->giveEngngModel()->giveNumberOfDomainEquations( newd->giveNumber(), EModelDefaultEquationNumbering() ); FloatArray unknownValues; IntArray dofidMask, locationArray; IntArray reglist; #ifdef OOFEM_MAPPING_CHECK_REGIONS ConnectivityTable *conTable = newd->giveConnectivityTable(); const IntArray *nodeConnectivity; #endif answer.resize(nsize); answer.zero(); for ( inode = 1; inode <= nd_nnodes; inode++ ) { DofManager *node = newd->giveNode(inode); /* HUHU CHEATING */ #ifdef __PARALLEL_MODE if ( ( node->giveParallelMode() == DofManager_null ) || ( node->giveParallelMode() == DofManager_remote ) ) { continue; } #endif #ifdef OOFEM_MAPPING_CHECK_REGIONS // build up region list for node nodeConnectivity = conTable->giveDofManConnectivityArray(inode); reglist.resize( nodeConnectivity->giveSize() ); reglist.clear(); for ( int indx = 1; indx <= nodeConnectivity->giveSize(); indx++ ) { reglist.insertSortedOnce( newd->giveElement( nodeConnectivity->at(indx) )->giveRegionNumber() ); } #endif ///@todo Shouldn't we pass a primary field or something to this function? if ( this->evaluateAt(unknownValues, dofidMask, mode, oldd, * node->giveCoordinates(), reglist, tStep) ) { ///@todo This doesn't respect local coordinate systems in nodes. Supporting that would require major reworking. for ( int ii = 1; ii <= dofidMask.giveSize(); ii++ ) { // exclude slaves; they are determined from masters auto it = node->findDofWithDofId((DofIDItem)dofidMask.at(ii)); if ( it != node->end() ) { Dof *dof = *it; if ( dof->isPrimaryDof() ) { int eq = dof->giveEquationNumber(EModelDefaultEquationNumbering()); answer.at( eq ) += unknownValues.at(ii); } } } } else { OOFEM_ERROR("evaluateAt service failed for node %d", inode); } } return 1; }
static void UpdateIndexes( IntArray& indexes ) { IntArray t_indexes; for( int i = 0; i < ( int )indexes.size(); i++ ) { if( indexes[i] != -1 ) t_indexes.push_back( indexes[i] ); } indexes.clear(); std::copy( t_indexes.begin(), t_indexes.end(), std::back_inserter( indexes ) ); }
void SolutionbasedShapeFunction :: splitBoundaryNodeIDs(modeStruct &mode, Element &e, IntArray &bnodes, IntArray &pList, IntArray &mList, IntArray &zList, FloatMatrix &nodeValues) { pList.clear(); mList.clear(); zList.clear(); for ( int j = 1; j <= bnodes.giveSize(); j++ ) { DofManager *dman = e.giveDofManager( bnodes.at(j) ); bool isZero = false; bool isPlus = false; bool isMinus = false; whichBoundary(* dman->giveCoordinates(), isPlus, isMinus, isZero); if ( isZero ) { zList.insertSorted(j); } else if ( isPlus ) { pList.insertSorted(j); } else if ( isMinus ) { mList.insertSorted(j); } // Find global DofManager and fetch nodal values for ( size_t k = 0; k < mode.SurfaceData.size(); k++ ) { if ( mode.SurfaceData.at(k)->DofMan == dman ) { int IndexOfDofIDItem = 0; for ( int l = 1; l <= dofs.giveSize(); l++ ) { if ( dofs.at(l) == mode.SurfaceData.at(k)->DofID ) { IndexOfDofIDItem = l; break; } } nodeValues.at(IndexOfDofIDItem, j) = mode.SurfaceData.at(k)->value; } } } }
void testAccess() { const IntArray a = {1, 2, 3}; assert(a[0] == 1); assert(a[1] == 2); assert(a[2] == 3); assert(a.at(0) == 1); assert(a.at(1) == 2); assert(a.at(2) == 3); IntArray b; b.assign({7, 7, 7, 7, 7}); assert(b[4] == 7); assert(b.at(4) == 7); b.assign(a.begin(), a.end()); assert(b == a); b.clear(); assert(b.size() == 0); }
bool DofManager :: giveMasterDofMans(IntArray &masters) { IntArray _dof_masters; bool answer = false; masters.clear(); for ( Dof *dof: *this ) { if ( !dof->isPrimaryDof() ) { answer = true; dof->giveMasterDofManArray(_dof_masters); for ( int j = 1; j <= _dof_masters.giveSize(); j++ ) { masters.insertSortedOnce(_dof_masters.at(j), 2); } } } return answer; }
void DofManager :: giveMasterDofIDArray(const IntArray &dofIDArry, IntArray &masterDofIDs) const { if ( !hasSlaveDofs ) { masterDofIDs = dofIDArry; } else { IntArray temp; masterDofIDs.clear(); for ( int dofid: dofIDArry ) { auto pos = this->findDofWithDofId( ( DofIDItem ) dofid ); if ( pos == this->end() ) { OOFEM_ERROR("incompatible dof (%d) requested", dofid); } (*pos)->giveDofIDs(temp); masterDofIDs.followedBy(temp); } } }
void ActiveDof :: giveDofIDs(IntArray &masterDofIDs) { if ( this->isPrimaryDof() ) { masterDofIDs.resize(1); masterDofIDs.at(1) = this->giveDofID(); return; } IntArray mstrDofIDs; int countOfMasterDofs = this->giveNumberOfMasterDofs(); masterDofIDs.preallocate(countOfMasterDofs); masterDofIDs.clear(); for ( int i = 1; i <= countOfMasterDofs; i++ ) { this->giveMasterDof(i)->giveDofIDs(mstrDofIDs); masterDofIDs.followedBy(mstrDofIDs); } }
void ActiveDof :: giveEquationNumbers(IntArray &masterEqNumbers, const UnknownNumberingScheme &s) { if ( this->isPrimaryDof() ) { masterEqNumbers.resize(1); masterEqNumbers.at(1) = this->giveEquationNumber(s); return; } IntArray mstrEqNmbrs; int countOfMasterDofs = this->giveNumberOfMasterDofs(); masterEqNumbers.preallocate(countOfMasterDofs); masterEqNumbers.clear(); for ( int i = 1; i <= countOfMasterDofs; i++ ) { this->giveMasterDof(i)->giveEquationNumbers(mstrEqNmbrs, s); masterEqNumbers.followedBy(mstrEqNmbrs); } }
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( ); } }
int TrabBoneNL3D :: giveLocalNonlocalStiffnessContribution(GaussPoint *gp, IntArray &loc, const UnknownNumberingScheme &s, FloatArray &lcontrib, TimeStep *tStep) { TrabBoneNL3DStatus *nlStatus = static_cast< TrabBoneNL3DStatus * >( this->giveStatus(gp) ); StructuralElement *elem = static_cast< StructuralElement * >( gp->giveElement() ); int nrows, nsize; double sum, nlKappa, dDamFunc, dam, tempDam; FloatArray localNu; FloatMatrix b; this->computeCumPlastStrain(nlKappa, gp, tStep); dam = nlStatus->giveDam(); tempDam = nlStatus->giveTempDam(); if ( ( tempDam - dam ) > 0.0 ) { elem->giveLocationArray(loc, s); localNu = nlStatus->giveTempEffectiveStress(); elem->giveLocationArray(loc, EModelDefaultEquationNumbering() ); elem->computeBmatrixAt(gp, b); dDamFunc = expDam * critDam * exp(-expDam * nlKappa); nrows = b.giveNumberOfColumns(); nsize = localNu.giveSize(); lcontrib.resize(nrows); for ( int i = 1; i <= nrows; i++ ) { sum = 0.0; for ( int j = 1; j <= nsize; j++ ) { sum += b.at(j, i) * localNu.at(j); } lcontrib.at(i) = mParam * dDamFunc * sum; } return 1; } else { loc.clear(); return 0; } }
void EnrichmentItem :: givePotentialEIDofIdArray(IntArray &answer) const { answer.clear(); for ( int i = this->giveStartOfDofIdPool(); i <= this->giveEndOfDofIdPool(); i++ ) { answer.followedBy(i); } }
void MMALeastSquareProjection :: __init(Domain *dold, IntArray &type, FloatArray &coords, Set &elemSet, TimeStep *tStep, bool iCohesiveZoneGP) //(Domain* dold, IntArray& varTypes, GaussPoint* gp, TimeStep* tStep) { GaussPoint *sourceIp; Element *sourceElement; SpatialLocalizer *sl = dold->giveSpatialLocalizer(); IntegrationRule *iRule; IntArray patchList; this->patchDomain = dold; // find the closest IP on old mesh sourceElement = sl->giveElementContainingPoint(coords, elemSet); if ( !sourceElement ) { OOFEM_ERROR("no suitable source element found"); } // determine the type of patch Element_Geometry_Type egt = sourceElement->giveGeometryType(); if ( egt == EGT_line_1 ) { this->patchType = MMALSPPatchType_1dq; } else if ( ( egt == EGT_triangle_1 ) || ( egt == EGT_quad_1 ) ) { this->patchType = MMALSPPatchType_2dq; } else { OOFEM_ERROR("unsupported material mode"); } /* Determine the state of closest point. * Only IP in the neighbourhood with same state can be used * to interpolate the values. */ FloatArray dam; int state = 0; if ( this->stateFilter ) { iRule = sourceElement->giveDefaultIntegrationRulePtr(); for ( GaussPoint *gp: *iRule ) { sourceElement->giveIPValue(dam, gp, IST_PrincipalDamageTensor, tStep); if ( dam.computeNorm() > 1.e-3 ) { state = 1; // damaged } } } // from source neighbours the patch will be constructed Element *element; IntArray neighborList; patchList.resize(1); patchList.at(1) = sourceElement->giveNumber(); int minNumberOfPoints = this->giveNumberOfUnknownPolynomialCoefficients(this->patchType); int actualNumberOfPoints = sourceElement->giveDefaultIntegrationRulePtr()->giveNumberOfIntegrationPoints(); int nite = 0; int elemFlag; // check if number of IP in patchList is sufficient // some recursion control would be appropriate while ( ( actualNumberOfPoints < minNumberOfPoints ) && ( nite <= 2 ) ) { //if not, construct the neighborhood dold->giveConnectivityTable()->giveElementNeighbourList(neighborList, patchList); // count number of available points patchList.clear(); actualNumberOfPoints = 0; for ( int i = 1; i <= neighborList.giveSize(); i++ ) { if ( this->stateFilter ) { element = patchDomain->giveElement( neighborList.at(i) ); // exclude elements in different regions if ( !elemSet.hasElement( element->giveNumber() ) ) { continue; } iRule = element->giveDefaultIntegrationRulePtr(); elemFlag = 0; for ( GaussPoint *gp: *iRule ) { element->giveIPValue(dam, gp, IST_PrincipalDamageTensor, tStep); if ( state && ( dam.computeNorm() > 1.e-3 ) ) { actualNumberOfPoints++; elemFlag = 1; } else if ( ( state == 0 ) && ( dam.computeNorm() < 1.e-3 ) ) { actualNumberOfPoints++; elemFlag = 1; } } if ( elemFlag ) { // include this element with corresponding state in neighbor search. patchList.followedBy(neighborList.at(i), 10); } } else { // if (! yhis->stateFilter) element = patchDomain->giveElement( neighborList.at(i) ); // exclude elements in different regions if ( !elemSet.hasElement( element->giveNumber() ) ) { continue; } actualNumberOfPoints += element->giveDefaultIntegrationRulePtr()->giveNumberOfIntegrationPoints(); patchList.followedBy(neighborList.at(i), 10); } } // end loop over neighbor list nite++; } if ( nite > 2 ) { // not enough points -> take closest point projection patchGPList.clear(); sourceIp = sl->giveClosestIP(coords, elemSet); patchGPList.push_front(sourceIp); //fprintf(stderr, "MMALeastSquareProjection: too many neighbor search iterations\n"); //exit (1); return; } #ifdef MMALSP_ONLY_CLOSEST_POINTS // select only the nval closest IP points GaussPoint **gpList = ( GaussPoint ** ) malloc(sizeof( GaussPoint * ) * actualNumberOfPoints); FloatArray dist(actualNumberOfPoints), srcgpcoords; int npoints = 0; // check allocation of gpList if ( gpList == NULL ) { OOFEM_FATAL("memory allocation error"); } for ( int ielem = 1; ielem <= patchList.giveSize(); ielem++ ) { element = patchDomain->giveElement( patchList.at(ielem) ); iRule = element->giveDefaultIntegrationRulePtr(); for ( GaussPoint *srcgp: *iRule ) { if ( element->computeGlobalCoordinates( srcgpcoords, * ( srcgp->giveNaturalCoordinates() ) ) ) { element->giveIPValue(dam, srcgp, IST_PrincipalDamageTensor, tStep); if ( this->stateFilter ) { // consider only points with same state if ( ( ( state == 1 ) && ( norm(dam) > 1.e-3 ) ) || ( ( ( state == 0 ) && norm(dam) < 1.e-3 ) ) ) { npoints++; dist.at(npoints) = coords.distance(srcgpcoords); gpList [ npoints - 1 ] = srcgp; } } else { // take all points into account npoints++; dist.at(npoints) = coords.distance(srcgpcoords); gpList [ npoints - 1 ] = srcgp; } } else { OOFEM_ERROR("computeGlobalCoordinates failed"); } } } if ( npoints != actualNumberOfPoints ) { OOFEM_ERROR("internal error"); } //minNumberOfPoints = min (actualNumberOfPoints, minNumberOfPoints+2); patchGPList.clear(); // now find the minNumberOfPoints with smallest distance // from point of interest double swap, minDist; int minDistIndx = 0; // loop over all points for ( int i = 1; i <= minNumberOfPoints; i++ ) { minDist = dist.at(i); minDistIndx = i; // search for point with i-th smallest distance for ( j = i + 1; j <= actualNumberOfPoints; j++ ) { if ( dist.at(j) < minDist ) { minDist = dist.at(j); minDistIndx = j; } } // remember this ip patchGPList.push_front(gpList [ minDistIndx - 1 ]); swap = dist.at(i); dist.at(i) = dist.at(minDistIndx); dist.at(minDistIndx) = swap; srcgp = gpList [ i - 1 ]; gpList [ i - 1 ] = gpList [ minDistIndx - 1 ]; gpList [ minDistIndx - 1 ] = srcgp; } if ( patchGPList.size() != minNumberOfPoints ) { OOFEM_ERROR("internal error 2"); exit(1); } free(gpList); #else // take all neighbors patchGPList.clear(); for ( int ielem = 1; ielem <= patchList.giveSize(); ielem++ ) { element = patchDomain->giveElement( patchList.at(ielem) ); iRule = element->giveDefaultIntegrationRulePtr(); for ( GaussPoint *gp: *iRule ) { patchGPList.push_front( gp ); } } #endif }
//-------------------------------------------------------------------------------------------------- /// //-------------------------------------------------------------------------------------------------- TEST(ArrayTest, BasicIntArray) { // IntArray IntArray iA; iA.resize(3); ASSERT_EQ(3u, iA.size()); iA[0] = 99; iA[1] = 10; iA[2] = 3; ASSERT_EQ(99, iA[0]); ASSERT_EQ(10, iA[1]); ASSERT_EQ(3, iA[2]); iA.clear(); ASSERT_EQ(0u, iA.size()); int* data = new int[3]; data[0] = 1; data[1] = 2; data[2] = 99; IntArray* ai = new IntArray(data, 3); ASSERT_EQ(3u, ai->size()); ASSERT_EQ(1, (*ai)[0]); ASSERT_EQ(2, (*ai)[1]); ASSERT_EQ(99, (*ai)[2]); data[2] = 3; ASSERT_EQ(99, (*ai)[2]); IntArray i2(*ai); delete ai; ai = NULL; ASSERT_EQ(3u, i2.size()); ASSERT_EQ(1, i2[0]); ASSERT_EQ(2, i2[1]); ASSERT_EQ(99, i2[2]); IntArray i3(2); i3[0] = 10; i3[1] = 20; ASSERT_EQ(2u, i3.size()); ASSERT_EQ(10, i3[0]); ASSERT_EQ(20, i3[1]); int* p = i3.ptr(); ASSERT_EQ(10, p[0]); ASSERT_EQ(20, p[1]); const IntArray* pi = &i3; const int* cp = pi->ptr(); ASSERT_EQ(10, cp[0]); ASSERT_EQ(20, cp[1]); const IntArray& ci = i3; ASSERT_EQ(10, ci[0]); ASSERT_EQ(20, ci[1]); }
void SPRNodalRecoveryModel :: initPatch(IntArray &patchElems, IntArray &dofManToDetermine, IntArray &pap, int papNumber, Set &elementSet) { int nelem, ndofman, ielem, count, patchElements, i, j, includes, npap, ipap; const IntArray *papDofManConnectivity = domain->giveConnectivityTable()->giveDofManConnectivityArray(papNumber); std :: list< int >dofManToDetermineList; std :: list< int > :: iterator dofManToDetermineListIter; SPRNodalRecoveryModelInterface *interface; IntArray toDetermine, toDetermine2, elemPap, papInv; Element *element; IntArray regionelements = elementSet.giveElementList(); // looop over elements sharing dofManager with papNumber and // determine those in region in ireg // nelem = papDofManConnectivity->giveSize(); count = 0; for ( ielem = 1; ielem <= nelem; ielem++ ) { if ( domain->giveElement( papDofManConnectivity->at(ielem) )->giveParallelMode() != Element_local ) { continue; } if ( elementSet.hasElement(papDofManConnectivity->at(ielem)) ) { count++; } } patchElems.resize(count); patchElements = 0; for ( int i = 1; i <= nelem; i++ ) { ielem = regionelements.at(i); if ( domain->giveElement( papDofManConnectivity->at(ielem) )->giveParallelMode() != Element_local ) { continue; } if ( elementSet.hasElement(papDofManConnectivity->at(ielem)) ) { patchElems.at(++patchElements) = papDofManConnectivity->at(ielem); } } // Invert the pap array for faster access later ndofman = this->domain->giveNumberOfDofManagers(); papInv.resize(ndofman); papInv.zero(); for ( int i = 1; i <= pap.giveSize(); ++i ) { papInv.at( pap.at(i) ) = 1; } // determine dofManagers which values will be determined by this patch // first add those required by elements participating in patch dofManToDetermine.clear(); for ( ielem = 1; ielem <= patchElements; ielem++ ) { element = domain->giveElement( patchElems.at(ielem) ); if ( element->giveParallelMode() != Element_local ) { continue; } if ( ( interface = static_cast< SPRNodalRecoveryModelInterface * >( element->giveInterface(SPRNodalRecoveryModelInterfaceType) ) ) ) { // add element reported dofMans for pap dofMan interface->SPRNodalRecoveryMI_giveDofMansDeterminedByPatch(toDetermine, papNumber); for ( i = 1; i <= toDetermine.giveSize(); i++ ) { includes = 0; // test if INCLUDED for ( int dman: dofManToDetermineList ) { if ( dman == toDetermine.at(i) ) { includes = 1; } } if ( !includes ) { dofManToDetermineList.push_back( toDetermine.at(i) ); } // determine those dofManagers which are not reported by elements, // but their values shoud be determined from this patch // Example include pap DofMans with connectivity 1 interface->SPRNodalRecoveryMI_giveSPRAssemblyPoints(elemPap); npap = elemPap.giveSize(); for ( ipap = 1; ipap <= npap; ipap++ ) { // test if element reported SPRAssembly point is not global assembly point // then determine this point from this patch if ( papInv.at( elemPap.at(ipap) ) == 0 ) { includes = 0; // test if INCLUDED for ( int dman: dofManToDetermineList ) { if ( dman == elemPap.at(ipap) ) { includes = 1; } } if ( !includes ) { dofManToDetermineList.push_back( elemPap.at(ipap) ); } // add also all dofManagers which are reported by element for this Assembly node interface->SPRNodalRecoveryMI_giveDofMansDeterminedByPatch( toDetermine2, elemPap.at(ipap) ); for ( j = 1; j <= toDetermine2.giveSize(); j++ ) { includes = 0; // test if INCLUDED for ( int dman: dofManToDetermineList ) { if ( dman == toDetermine2.at(j) ) { includes = 1; } } if ( !includes ) { dofManToDetermineList.push_back( toDetermine2.at(j) ); } } } } } } } // end loop over patch elements // transform set to dofManToDetermine array count = (int)dofManToDetermineList.size(); dofManToDetermine.resize(count); count = 0; for ( int dman: dofManToDetermineList ) { dofManToDetermine.at(++count) = dman; } }
void MatlabExportModule :: doOutputReactionForces(TimeStep *tStep, FILE *FID) { int domainIndex = 1; Domain *domain = emodel->giveDomain( domainIndex ); FloatArray reactions; IntArray dofManMap, dofidMap, eqnMap; #ifdef __SM_MODULE StructuralEngngModel *strEngMod = dynamic_cast< StructuralEngngModel * >(emodel); if ( strEngMod ) { strEngMod->buildReactionTable(dofManMap, dofidMap, eqnMap, tStep, domainIndex); strEngMod->computeReaction(reactions, tStep, 1); } else #endif { OOFEM_ERROR("Cannot export reaction forces - only implemented for structural problems."); } // Set the nodes and elements to export based on sets if ( this->reactionForcesNodeSet > 0 ) { Set *set = domain->giveSet( this->reactionForcesNodeSet ); reactionForcesDofManList = set->giveNodeList(); } int numDofManToExport = this->reactionForcesDofManList.giveSize(); if ( numDofManToExport == 0 ) { // No dofMan's given - export every dMan with reaction forces for (int i = 1; i <= domain->giveNumberOfDofManagers(); i++) { if ( dofManMap.contains(i) ) { this->reactionForcesDofManList.followedBy(i); } } numDofManToExport = this->reactionForcesDofManList.giveSize(); } // Output header fprintf( FID, "\n %%%% Export of reaction forces \n\n" ); // Output the dofMan numbers that are exported fprintf( FID, "\tReactionForces.DofManNumbers = [" ); for ( int i = 1; i <= numDofManToExport; i++ ) { fprintf( FID, "%i ", this->reactionForcesDofManList.at(i) ); } fprintf( FID, "];\n" ); // Define the reaction forces as a cell object fprintf( FID, "\tReactionForces.ReactionForces = cell(%i,1); \n", numDofManToExport ); fprintf( FID, "\tReactionForces.DofIDs = cell(%i,1); \n", numDofManToExport ); // Output the reaction forces for each dofMan. If a certain dof is not prescribed zero is exported. IntArray dofIDs; for ( int i = 1; i <= numDofManToExport; i++ ) { int dManNum = this->reactionForcesDofManList.at(i); fprintf(FID, "\tReactionForces.ReactionForces{%i} = [", i); if ( dofManMap.contains( dManNum ) ) { DofManager *dofMan = domain->giveDofManager( dManNum ); dofIDs.clear(); for ( Dof *dof: *dofMan ) { int num = dof->giveEquationNumber( EModelDefaultPrescribedEquationNumbering() ); int pos = eqnMap.findFirstIndexOf( num ); dofIDs.followedBy(dof->giveDofID()); if ( pos > 0 ) { fprintf(FID, "%e ", reactions.at(pos)); } else { fprintf( FID, "%e ", 0.0 ); // if not prescibed output zero } } } fprintf(FID, "];\n"); // Output dof ID's fprintf( FID, "\tReactionForces.DofIDs{%i} = [", i); if ( dofManMap.contains( dManNum ) ) { for ( int id: dofIDs ) { fprintf( FID, "%i ", id ); } } fprintf(FID, "];\n"); } }
int Network::Dinic() { int maxflow = 0; int u,v,e,ee,f; IntArray q; _E.resize(_E.size()+1); _E.back().v = _s; while (true) { for (u = 0;u < _V.size();u++) _V[u].l = -1; _V[_s].l = f = 0; _V[_s].o = _V[_s].e; q.clear(); q.push_back(_s); while (f < (int)q.size()) { u = q[f++]; for (e = _V[u].e;e != -1;e = _E[e].n) { v = _E[e].v; if (_V[v].l == -1 && _E[e].c > 0) { _V[v].o = _V[v].e; _V[v].l = _V[u].l+1; q.push_back(v); } } } if (_V[_t].l == -1) break; q.clear(); q.push_back(_E.size()-1); while (!q.empty()) { u = _E[q.back()].v; if (u == _t) { for (f = INT_MAX,e = 1;e < (int)q.size();e++) if (_E[q[e]].c < f) f = _E[q[e]].c,u = e; for (e = 1;e < q.size();e++) { _E[q[e]].c -= f; _E[q[e]^1].c += f; } maxflow += f; q.resize(u); } else { for (e = _V[u].o;e != -1;e = _E[e].n) { if (_V[_E[e].v].l < 0 || _E[e].c < 1) continue; if (_V[_E[e].v].l == _V[u].l+1) break; } if ((_V[u].o = e) != -1) q.push_back(e); else { q.pop_back(); _V[u].l = -1; } } } } return maxflow; }
void KDTree<T>::nodeSizes( IntArray &sizes ) const { sizes.clear(); _root->nodeSizes( sizes, 0 ); }