void DofManager :: giveUnknownVector(FloatArray &answer, const IntArray &dofIDArry, ValueModeType mode, TimeStep *tStep, bool padding) { answer.resize( dofIDArry.giveSize() ); if ( dofIDArry.giveSize() == 0 ) return; int k = 0; for ( auto &dofid: dofIDArry ) { auto pos = this->findDofWithDofId( ( DofIDItem ) dofid ); if ( pos == this->end() ) { if ( padding ) { answer.at(++k) = 0.; continue; } else { continue; } } answer.at(++k) = (*pos)->giveUnknown(mode, tStep); } answer.resizeWithValues(k); // Transform to global c.s. FloatMatrix L2G; if ( this->computeL2GTransformation(L2G, dofIDArry) ) { answer.rotatedWith(L2G, 'n'); } }
int PetscSparseMtrx :: assemble(const IntArray &rloc, const IntArray &cloc, const FloatMatrix &mat) { #ifdef __PARALLEL_MODE if ( emodel->isParallel() ) { // translate eq numbers IntArray grloc( rloc.giveSize() ), gcloc( cloc.giveSize() ); emodel->givePetscContext(this->di, ut)->giveN2Gmap()->map2New(grloc, rloc, 0); emodel->givePetscContext(this->di, ut)->giveN2Gmap()->map2New(gcloc, cloc, 0); MatSetValues(this->mtrx, grloc.giveSize(), grloc.givePointer(), gcloc.giveSize(), gcloc.givePointer(), mat.givePointer(), ADD_VALUES); } else { #endif int i, rsize = rloc.giveSize(), csize = cloc.giveSize(); IntArray grloc(rsize), gcloc(csize); for ( i = 1; i <= rsize; i++ ) { grloc.at(i) = rloc.at(i) - 1; } for ( i = 1; i <= csize; i++ ) { gcloc.at(i) = cloc.at(i) - 1; } MatSetValues(this->mtrx, rsize, grloc.givePointer(), csize, gcloc.givePointer(), mat.givePointer(), ADD_VALUES); #ifdef __PARALLEL_MODE } #endif // increment version this->version++; this->newValues = true; return 1; }
void SolutionbasedShapeFunction :: giveValueAtPoint(FloatArray &answer, const FloatArray &coords, IntArray &dofIDs, EngngModel &myEngngModel) { answer.resize( dofIDs.giveSize() ); FloatArray closest, lcoords, values; Element *elementAtCoords = myEngngModel.giveDomain(1)->giveSpatialLocalizer()->giveElementClosestToPoint(lcoords, closest, coords, 1); if ( elementAtCoords == NULL ) { OOFEM_WARNING("Cannot find element closest to point"); coords.pY(); return; } IntArray eldofids; elementAtCoords->giveElementDofIDMask(eldofids); elementAtCoords->computeField(VM_Total, thisTimestep, lcoords, values); for ( int i = 1; i <= dofIDs.giveSize(); i++ ) { for ( int j = 1; j <= eldofids.giveSize(); j++ ) { if ( dofIDs.at(i) == eldofids.at(j) ) { answer.at(i) = values.at(j); break; } } } }
void SolutionbasedShapeFunction :: giveValueAtPoint(FloatArray &answer, const FloatArray &coords, IntArray &dofIDs, EngngModel &myEngngModel) { answer.resize( dofIDs.giveSize() ); FloatArray closest, lcoords, values; Element *elementAtCoords = myEngngModel.giveDomain(1)->giveSpatialLocalizer()->giveElementClosestToPoint(lcoords, closest, coords, 1); if ( elementAtCoords == NULL ) { OOFEM_WARNING("Cannot find element closest to point"); coords.pY(); } EIPrimaryUnknownMapperInterface *em = dynamic_cast< EIPrimaryUnknownMapperInterface * >( elementAtCoords->giveInterface(EIPrimaryUnknownMapperInterfaceType) ); IntArray eldofids; em->EIPrimaryUnknownMI_givePrimaryUnknownVectorDofID(eldofids); em->EIPrimaryUnknownMI_computePrimaryUnknownVectorAtLocal(VM_Total, thisTimestep, lcoords, values); for ( int i = 1; i <= dofIDs.giveSize(); i++ ) { for ( int j = 1; j <= eldofids.giveSize(); j++ ) { if ( dofIDs.at(i) == eldofids.at(j) ) { answer.at(i) = values.at(j); break; } } } }
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 VTKXMLExportModule :: makeFullForm(FloatArray &answer, const FloatArray &reducedForm, InternalStateValueType type, const IntArray &redIndx) { answer.resize(9); answer.zero(); if ( type == ISVT_TENSOR_S3 ) { for (int i = 1; i <= redIndx.giveSize(); i++) { if (redIndx.at(i) > 0) { answer.at(redToFull.at(i)) = reducedForm.at(redIndx.at(i)); } } } else if ( type == ISVT_TENSOR_S3E ) { for (int i = 1; i <= redIndx.giveSize(); i++) { if (redIndx.at(i) > 3) { answer.at(redToFull.at(i)) = reducedForm.at(i)*0.5; } else if (redIndx.at(i) > 0) { answer.at(redToFull.at(i)) = reducedForm.at(i); } } } // Symmetrize answer.at(4) = answer.at(2); answer.at(7) = answer.at(3); answer.at(8) = answer.at(6); }
void Node2NodeContact :: giveLocationArray(IntArray &answer, const UnknownNumberingScheme &s) { // should return location array for the master and the slave node // TODO this whole thing should be rewritten answer.resize(6); answer.zero(); //TODO should use a proper unknownnumberingscheme IntArray dofIdArray = {D_u, D_v, D_w}; // master node for ( int i = 1; i <= dofIdArray.giveSize(); i++ ) { if ( this->masterNode->hasDofID( (DofIDItem)dofIdArray.at(i) ) ) { // add corresponding number Dof *dof= this->masterNode->giveDofWithID( (DofIDItem)dofIdArray.at(i) ); answer.at(i) = s.giveDofEquationNumber( dof ); } } // slave node for ( int i = 1; i <= dofIdArray.giveSize(); i++ ) { if ( this->slaveNode->hasDofID( (DofIDItem)dofIdArray.at(i) ) ) { // add corresponding number Dof *dof= this->slaveNode->giveDofWithID( (DofIDItem)dofIdArray.at(i) ); answer.at(3 + i) = s.giveDofEquationNumber( dof ); } } }
void DynCompCol :: checkSizeTowards(const IntArray &rloc, const IntArray &cloc) { int i, maxid = 0; int rsize = rloc.giveSize(); int csize = cloc.giveSize(); // adjust the size of receiver for ( i = 0; i < rsize; i++ ) { maxid = max( maxid, rloc(i) ); } for ( i = 0; i < csize; i++ ) { maxid = max( maxid, cloc(i) ); } this->growTo(maxid); #ifndef DynCompCol_USE_STL_SETS IntArray rowsToAdd( rloc.giveSize() ); int ii, j, jj; for ( i = 0; i < csize; i++ ) { if ( ( ii = cloc(i) ) ) { for ( j = 0; j < rsize; j++ ) { if ( ( jj = rloc(j) ) ) { insertRowInColumn(ii - 1, jj - 1); } } } } #endif }
void SolutionbasedShapeFunction :: setLoads(EngngModel *myEngngModel, int d) { DynamicInputRecord ir; FloatArray gradP; gradP.resize( this->giveDomain()->giveNumberOfSpatialDimensions() ); gradP.zero(); gradP.at(d) = 1.0; ir.setRecordKeywordField("deadweight", 1); ir.setField(gradP, _IFT_Load_components); ir.setField(1, _IFT_GeneralBoundaryCondition_timeFunct); int bcID = myEngngModel->giveDomain(1)->giveNumberOfBoundaryConditions() + 1; GeneralBoundaryCondition *myBodyLoad; myBodyLoad = classFactory.createBoundaryCondition( "deadweight", bcID, myEngngModel->giveDomain(1) ); myBodyLoad->initializeFrom(& ir); myEngngModel->giveDomain(1)->setBoundaryCondition(bcID, myBodyLoad); for ( int i = 1; i <= myEngngModel->giveDomain(1)->giveNumberOfElements(); i++ ) { IntArray *blArray; blArray = myEngngModel->giveDomain(1)->giveElement(i)->giveBodyLoadArray(); blArray->resizeWithValues(blArray->giveSize() + 1); blArray->at( blArray->giveSize() ) = bcID; } }
void Tr2Shell7 :: giveBoundaryLocationArray(IntArray &locationArray, const IntArray &bNodes, const UnknownNumberingScheme &s, IntArray *dofIdArray) { IntArray localloc; // not a nice solution here, trying to deduce if Boundary is egde or surface if (bNodes.giveSize() == 3) { // should be edge //detect edge number if (bNodes.at(1)==1 && bNodes.at(2)==2 && bNodes.at(3)==4) { // edge #1 giveEdgeDofMapping(localloc, 1); } else if (bNodes.at(1)==2 && bNodes.at(2)==3 && bNodes.at(3)==5) { // edge #2 giveEdgeDofMapping(localloc, 2); } else if (bNodes.at(1)==3 && bNodes.at(2)==1 && bNodes.at(3)==6) { // edge #3 giveEdgeDofMapping(localloc, 3); } else { OOFEM_ERROR ("wrong edge number detected"); } } else if (bNodes.giveSize() == 6) { // should be surface this->giveSurfaceDofMapping(localloc, 1); } else { OOFEM_ERROR ("boundary not supported/detected"); } IntArray eloc, dofID; this->giveLocationArray(eloc, s, &dofID); locationArray.resize(localloc.giveSize()); dofIdArray->resize(localloc.giveSize()); for (int i=1; i<=localloc.giveSize(); i++) { locationArray.at(i)=eloc.at(localloc.at(i)); dofIdArray->at(i) = dofID.at(localloc.at(i)); } }
void SimpleCrossSection :: giveReducedCharacteristicVector(FloatArray &answer, GaussPoint *gp, const FloatArray &charVector3d) // // returns reduced stressVector or strainVector from full 3d vector reduced // to vector required by gp->giveStressStrainMode() // { MaterialMode mode = gp->giveMaterialMode(); StructuralMaterial *mat = static_cast< StructuralMaterial * >( gp->giveElement()->giveMaterial() ); IntArray indx; int size = charVector3d.giveSize(); int i, j; if ( ( mode == _3dShell ) || ( mode == _3dBeam ) || ( mode == _2dPlate ) || ( mode == _2dBeam ) ) { if ( size != 12 ) { OOFEM_ERROR("SimpleCrossSection :: giveReducedCharacteristicVector - charVector3d size mismatch"); } mat->giveStressStrainMask( indx, ReducedForm, gp->giveMaterialMode() ); answer.resize( indx.giveSize() ); answer.zero(); for ( i = 1; i <= indx.giveSize(); i++ ) { if ( ( j = indx.at(i) ) ) { answer.at(i) = charVector3d.at(j); } } return; } else if ( mode == _3dBeam ) { if ( size != 6 ) { OOFEM_ERROR("SimpleCrossSection :: giveReducedCharacteristicVector - charVector3d size mismatch"); } answer = charVector3d; return; } else if ( mode == _PlaneStressRot ) { if ( size != 7 ) { OOFEM_ERROR("SimpleCrossSection :: giveReducedCharacteristicVector - charVector3d size mismatch"); } mat->giveStressStrainMask( indx, ReducedForm, gp->giveMaterialMode() ); answer.resize( indx.giveSize() ); answer.zero(); for ( i = 1; i <= indx.giveSize(); i++ ) { if ( ( j = indx.at(i) ) ) { answer.at(i) = charVector3d.at(j); } } return; } else { StructuralCrossSection :: giveReducedCharacteristicVector(answer, gp, charVector3d); return; } }
void NonLinearDynamic :: timesMtrx(FloatArray &vec, FloatArray &answer, CharType type, Domain *domain, TimeStep *tStep) { int nelem = domain->giveNumberOfElements(); //int neq = this->giveNumberOfDomainEquations(EID_MomentumBalance); int jj, kk, n; FloatMatrix charMtrx; IntArray loc; Element *element; EModelDefaultEquationNumbering en; answer.resize( this->giveNumberOfDomainEquations(domain->giveNumber(), en) ); answer.zero(); for ( int i = 1; i <= nelem; i++ ) { element = domain->giveElement(i); #ifdef __PARALLEL_MODE // Skip remote elements (these are used as mirrors of remote elements on other domains // when nonlocal constitutive models are used. They introduction is necessary to // allow local averaging on domains without fine grain communication between domains). if ( element->giveParallelMode() == Element_remote ) { continue; } #endif element->giveLocationArray(loc, EID_MomentumBalance, en); element->giveCharacteristicMatrix(charMtrx, type, tStep); // // assemble it manually // #ifdef DEBUG if ( ( n = loc.giveSize() ) != charMtrx.giveNumberOfRows() ) { _error("solveYourselfAt : dimension mismatch"); } #endif n = loc.giveSize(); for ( int j = 1; j <= n; j++ ) { jj = loc.at(j); if ( jj ) { for ( int k = 1; k <= n; k++ ) { kk = loc.at(k); if ( kk ) { answer.at(jj) += charMtrx.at(j, k) * vec.at(kk); } } } } } #ifdef __PARALLEL_MODE this->updateSharedDofManagers(answer, MassExchangeTag); #endif }
const IntArray &Set :: giveNodeList() { // Lazy evaluation, we compute the unique set of nodes if needed (and store it). if ( this->totalNodes.giveSize() == 0 ) { IntArray afflictedNodes( this->domain->giveNumberOfDofManagers() ); afflictedNodes.zero(); for ( int ielem = 1; ielem <= this->elements.giveSize(); ++ielem ) { Element *e = this->domain->giveElement( this->elements.at(ielem) ); for ( int inode = 1; inode <= e->giveNumberOfNodes(); ++inode ) { afflictedNodes.at( e->giveNode(inode)->giveNumber() ) = 1; } } /* boundary entities are obsolete, use edges and/or surfaces instead */ IntArray bNodes; for ( int ibnd = 1; ibnd <= this->elementBoundaries.giveSize() / 2; ++ibnd ) { Element *e = this->domain->giveElement( this->elementBoundaries.at(ibnd * 2 - 1) ); int boundary = this->elementBoundaries.at(ibnd * 2); FEInterpolation *fei = e->giveInterpolation(); fei->boundaryGiveNodes(bNodes, boundary); for ( int inode = 1; inode <= bNodes.giveSize(); ++inode ) { afflictedNodes.at( e->giveNode( bNodes.at(inode) )->giveNumber() ) = 1; } } IntArray eNodes; for ( int iedge = 1; iedge <= this->elementEdges.giveSize() / 2; ++iedge ) { Element *e = this->domain->giveElement( this->elementEdges.at(iedge * 2 - 1) ); int edge = this->elementEdges.at(iedge * 2); FEInterpolation *fei = e->giveInterpolation(); fei->boundaryEdgeGiveNodes(eNodes, edge); for ( int inode = 1; inode <= eNodes.giveSize(); ++inode ) { afflictedNodes.at( e->giveNode( eNodes.at(inode) )->giveNumber() ) = 1; } } for ( int isurf = 1; isurf <= this->elementSurfaces.giveSize() / 2; ++isurf ) { Element *e = this->domain->giveElement( this->elementSurfaces.at(isurf * 2 - 1) ); int surf = this->elementSurfaces.at(isurf * 2); FEInterpolation *fei = e->giveInterpolation(); fei->boundarySurfaceGiveNodes(eNodes, surf); for ( int inode = 1; inode <= eNodes.giveSize(); ++inode ) { afflictedNodes.at( e->giveNode( eNodes.at(inode) )->giveNumber() ) = 1; } } for ( int inode = 1; inode <= this->nodes.giveSize(); ++inode ) { afflictedNodes.at( this->nodes.at(inode) ) = 1; } totalNodes.findNonzeros(afflictedNodes); } return this->totalNodes; }
void PrescribedMean :: computeDomainSize() { if (domainSize > 0.0) return; if (elementEdges) { IntArray setList = ((GeneralBoundaryCondition *)this)->giveDomain()->giveSet(set)->giveBoundaryList(); elements.resize(setList.giveSize() / 2); sides.resize(setList.giveSize() / 2); for (int i=1; i<=setList.giveSize(); i=i+2) { elements.at(i/2+1) = setList.at(i); sides.at(i/2+1) = setList.at(i+1); } } else { IntArray setList = ((GeneralBoundaryCondition *)this)->giveDomain()->giveSet(set)->giveElementList(); elements = setList; } domainSize = 0.0; for ( int i=1; i<=elements.giveSize(); i++ ) { int elementID = elements.at(i); Element *thisElement = this->giveDomain()->giveElement(elementID); FEInterpolation *interpolator = thisElement->giveInterpolation(DofIDItem(dofid)); IntegrationRule *iRule; if (elementEdges) { iRule = interpolator->giveBoundaryIntegrationRule(3, sides.at(i)); } else { iRule = interpolator->giveIntegrationRule(3); } for ( GaussPoint * gp: * iRule ) { FloatArray lcoords = gp->giveNaturalCoordinates(); double detJ; if (elementEdges) { detJ = fabs ( interpolator->boundaryGiveTransformationJacobian(sides.at(i), lcoords, FEIElementGeometryWrapper(thisElement)) ); } else { detJ = fabs ( interpolator->giveTransformationJacobian(lcoords, FEIElementGeometryWrapper(thisElement)) ); } domainSize = domainSize + detJ*gp->giveWeight(); } delete iRule; } printf("%f\n", domainSize); }
IRResultType StationaryTransportProblem :: initializeFrom(InputRecord *ir) { const char *__proc = "initializeFrom"; // Required by IR_GIVE_FIELD macro IRResultType result; // Required by IR_GIVE_FIELD macro EngngModel :: initializeFrom(ir); int val = SMT_Skyline; IR_GIVE_OPTIONAL_FIELD(ir, val, _IFT_EngngModel_smtype); this->sparseMtrxType = ( SparseMtrxType ) val; ///@todo Combine this option with structural problems, where it is possible to keep the secant tangent elastic tangent (or generally, the initial tangent) etc. One option should fit all common needs here. this->keepTangent = ir->hasField(_IFT_StationaryTransportProblem_keepTangent); // read field export flag IntArray exportFields; exportFields.resize(0); IR_GIVE_OPTIONAL_FIELD(ir, exportFields, _IFT_StationaryTransportProblem_exportfields); if ( exportFields.giveSize() ) { IntArray mask(1); FieldManager *fm = this->giveContext()->giveFieldManager(); for ( int i = 1; i <= exportFields.giveSize(); i++ ) { if ( exportFields.at(i) == FT_Temperature ) { mask.at(1) = T_f; #ifdef FIELDMANAGER_USE_SHARED_PTR //std::tr1::shared_ptr<Field> _temperatureField = make_shared<MaskedPrimaryField>(FT_Temperature, this->UnknownsField, mask); std::tr1::shared_ptr<Field> _temperatureField (new MaskedPrimaryField(FT_Temperature, this->UnknownsField, mask)); fm->registerField(_temperatureField, ( FieldType ) exportFields.at(i)); #else MaskedPrimaryField *_temperatureField = new MaskedPrimaryField(FT_Temperature, this->UnknownsField, mask); fm->registerField(_temperatureField, ( FieldType ) exportFields.at(i), true); #endif } else if ( exportFields.at(i) == FT_HumidityConcentration ) { mask.at(1) = C_1; #ifdef FIELDMANAGER_USE_SHARED_PTR //std::tr1::shared_ptr<Field> _temperatureField = make_shared<MaskedPrimaryField>(FT_Temperature, this->UnknownsField, mask); std::tr1::shared_ptr<Field> _concentrationField (new MaskedPrimaryField(FT_HumidityConcentration, this->UnknownsField, mask)); fm->registerField(_concentrationField, ( FieldType ) exportFields.at(i)); #else MaskedPrimaryField *_concentrationField = new MaskedPrimaryField(FT_HumidityConcentration, this->UnknownsField, mask); fm->registerField(_concentrationField, ( FieldType ) exportFields.at(i), true); #endif } } } if( UnknownsField == NULL ){ // can exist from nonstationary transport problem UnknownsField = new PrimaryField(this, 1, FT_TransportProblemUnknowns, EID_ConservationEquation, 0); } return IRRT_OK; }
// see https://github.com/woodem/woo/blob/master/pkg/dem/FlowAnalysis.cpp // and https://woodem.org/user/flow-analysis.html for explanation about the interpolation routine int UniformGridField::evaluateAt(FloatArray &answer, const FloatArray &coords, ValueModeType mode, TimeStep *tStep){ // scalar value answer.resize(1); double& ret(answer[0]); ret=0; // find cell containing coords, and coords within the cell IntArray ijk; FloatArray normXyz; this->xyz2ijk(coords,ijk,normXyz); // 3D interpolation if(ijk.giveSize()==3){ const int& i(ijk[0]); const int& j(ijk[1]); const int& k(ijk[2]); int I(i+1), J(j+1), K(k+1); const double& x(normXyz[0]); const double& y(normXyz[1]); const double& z(normXyz[2]); double X(1-x), Y(1-y), Z(1-z); double weights[]={ X*Y*Z,x*Y*Z,x*y*Z,X*y*Z, X*Y*z,x*Y*z,x*y*z,X*y*z }; int pts[][3]={ {i,j,k},{I,j,k},{I,J,k},{i,J,k}, {i,j,K},{I,j,K},{I,J,K},{i,J,K} }; assert(abs(weights[0]+weights[1]+weights[2]+weights[3]+weights[4]+weights[5]+weights[6]+weights[7]-1) < 1e-5); for(int p=0; p<8; p++){ // std::cerr<<p<<": at "<<coords[0]<<","<<coords[1]<<","<<coords[2]<<", ijk "<<i<<","<<j<<","<<k<<" normXYZ "<<x<<","<<y<<","<<z<<std::endl; ret+=weights[p]*this->nodeValue3d(pts[p][0],pts[p][1],pts[p][2]); } } // 2D interpolation else if (ijk.giveSize()==2){ const int& i(ijk[0]); const int& j(ijk[1]); int I(i+1); int J(j+1); const double& x(normXyz[0]); const double y(normXyz[1]); double X(1-x); double Y(1-y); double weights[]={X*Y,x*Y,X*y,x*y}; // TODO: check int pts[][2]={{i,j},{I,j},{i,J},{I,J}}; // TODO: check assert(abs(weights[0]+weights[1]+weights[2]+weights[3]-1)<1e-5); for(int p=0; p<4; p++){ // std::cerr<<p<<": at "<<coords[0]<<","<<coords[1]<<" ij "<<i<<","<<j<<" normXY "<<x<<","<<y<<std::endl; ret+=weights[p]*this->nodeValue2d(pts[p][0],pts[p][1]); } } // any other is unsupported else { OOFEM_ERROR((std::string("UniformGridField::evaluateAt: erroneous dimension of input coordinates (")+std::to_string(coords.giveSize())+", must be 2 or 3).").c_str()); return 1; } return 0; // OK }
void ParmetisLoadBalancer :: addSharedDofmanPartitions(int _locnum, IntArray _partitions) { int i, s = _partitions.giveSize(); for ( i = 1; i <= s; i++ ) { dofManPartitions [ _locnum - 1 ].insertOnce( _partitions.at(i) ); } }
IRResultType Beam3d :: initializeFrom(InputRecord *ir) { IRResultType result; // Required by IR_GIVE_FIELD macro if ( ir->hasField(_IFT_Beam3d_refnode) ) { IR_GIVE_FIELD(ir, referenceNode, _IFT_Beam3d_refnode); if ( referenceNode == 0 ) { OOFEM_WARNING("wrong reference node specified. Using default orientation."); } } else if ( ir->hasField(_IFT_Beam3d_refangle) ) { IR_GIVE_FIELD(ir, referenceAngle, _IFT_Beam3d_refangle); usingAngle = true; } else { OOFEM_ERROR("reference node or reference angle not set") } if ( ir->hasField(_IFT_Beam3d_dofstocondense) ) { IntArray val; IR_GIVE_FIELD(ir, val, _IFT_Beam3d_dofstocondense); if ( val.giveSize() >= 12 ) { OOFEM_WARNING("wrong input data for condensed dofs"); return IRRT_BAD_FORMAT; } dofsToCondense = new IntArray(val); } else { dofsToCondense = NULL; } return StructuralElement :: initializeFrom(ir); }
void InteractionPFEMParticle :: givePrescribedUnknownVector(FloatArray &answer, const IntArray &dofIDArry, ValueModeType mode, TimeStep *stepN) { answer.resize( dofIDArry.giveSize() ); FloatArray velocities; FluidStructureProblem *fsiProblem = this->giveFluidStructureMasterProblem(); if (fsiProblem) { StructuralEngngModel *structuralProblem = this->giveStructuralProblem(); if ( structuralProblem ) { int j = 1; if (fsiProblem->giveIterationNumber() < 1) { for (int dofid: dofIDArry ) { answer.at(j++) = this->giveDofWithID( dofid )->giveBcValue(mode, stepN); } } else { DofManager *dman = structuralProblem->giveDomain(1)->giveDofManager(coupledNode); //dman->giveUnknownVectorOfType(velocities, VelocityVector, VM_Velocity, stepN); //dman->giveUnknownVector(velocities, dofIDArry, VM_Velocity, stepN); dman->giveCompleteUnknownVector(velocities, VM_Velocity, stepN); for ( int dofid: dofIDArry) { answer.at(dofid) = velocities.at( dofid ); } } } } // Transform to global c.s. FloatMatrix L2G; if (this->computeL2GTransformation(L2G, dofIDArry)) { answer.rotatedWith(L2G, 'n'); } }
void Structural2DElement :: giveEdgeDofMapping(IntArray &answer, int iEdge) const { /* * provides dof mapping of local edge dofs (only nonzero are taken into account) * to global element dofs */ IntArray eNodes; static_cast< FEInterpolation2d* > ( this->giveInterpolation() )->computeLocalEdgeMapping(eNodes, iEdge); answer.resize( eNodes.giveSize() * 2 ); for ( int i = 1; i <= eNodes.giveSize(); i++ ) { answer.at(i * 2 - 1) = eNodes.at(i) * 2 - 1; answer.at(i * 2) = eNodes.at(i) * 2; } }
int Line :: computeNumberOfIntersectionPoints(Element *element) { int numIntersec = 0; const double relTol = 1.0e-6; const double LineLength = giveLength(); const double absTol = relTol*std::max(LineLength, XfemTolerances::giveCharacteristicElementLength() ); const int numEdges = element->giveInterpolation()->giveNumberOfEdges(); for ( int edgeIndex = 1; edgeIndex <= numEdges; edgeIndex++ ) { IntArray bNodes; element->giveInterpolation()->boundaryGiveNodes(bNodes, edgeIndex); const int nsLoc = bNodes.at(1); const int neLoc = bNodes.at( bNodes.giveSize() ); const FloatArray &xS = *(element->giveNode(nsLoc)->giveCoordinates() ); const FloatArray &xE = *(element->giveNode(neLoc)->giveCoordinates() ); const double dist = BasicGeometry :: computeLineDistance(xS, xE, mVertices[0], mVertices[1]); if(dist < absTol) { numIntersec++; } } return numIntersec; }
void DynCompCol :: checkSizeTowards(IntArray &loc) { int i, maxid = 0; int size = loc.giveSize(); // adjust the size of receiver for ( i = 0; i < size; i++ ) { maxid = max( maxid, loc(i) ); } this->growTo(maxid); #ifndef DynCompCol_USE_STL_SETS int ii, j, jj; for ( i = 0; i < size; i++ ) { if ( ( ii = loc(i) ) ) { for ( j = 0; j < size; j++ ) { if ( ( jj = loc(j) ) ) { this->insertRowInColumn(ii - 1, jj - 1); } } } } #endif }
void MMAShapeFunctProjection :: __init(Domain *dold, IntArray &varTypes, FloatArray &coords, int region, TimeStep *tStep) //(Domain* dold, IntArray& varTypes, GaussPoint* gp, TimeStep* tStep) { int nvar = varTypes.giveSize(); // check time stemp if ( stateCounter == tStep->giveSolutionStateCounter() ) { return; } // Project Gauss point components to nodes on old mesh if ( this->smootherList.giveSize() != nvar ) { this->smootherList.clear(); this->smootherList.growTo(nvar); for ( int ivar = 1; ivar <= nvar; ivar++ ) { this->smootherList.put( ivar, new NodalAveragingRecoveryModel(dold) ); } } this->intVarTypes = varTypes; for ( int ivar = 1; ivar <= nvar; ivar++ ) { this->smootherList.at(ivar)->recoverValues( ( InternalStateType ) varTypes.at(ivar), tStep ); } // remember time stemp stateCounter = tStep->giveSolutionStateCounter(); this->domain = dold; }
void SolutionbasedShapeFunction :: copyDofManagersToSurfaceData(modeStruct *mode, IntArray nodeList, bool isPlus, bool isMinus, bool isZeroBoundary) { for ( int i = 1; i <= nodeList.giveSize(); i++ ) { FloatArray values; DofManager *dman = mode->myEngngModel->giveDomain(1)->giveDofManager( nodeList.at(i) ); computeBaseFunctionValueAt(values, * dman->giveCoordinates(), this->dofs, * mode->myEngngModel); for ( int j = 1; j <= this->dofs.giveSize(); j++ ) { SurfaceDataStruct *surfaceData = new(SurfaceDataStruct); Dof *d = dman->giveDofWithID( dofs.at(j) ); surfaceData->DofID = ( DofIDItem ) this->dofs.at(j); surfaceData->DofMan = dman; surfaceData->isPlus = isPlus; surfaceData->isMinus = isMinus; surfaceData->isZeroBoundary = isZeroBoundary; surfaceData->isFree = d->giveBcId() == 0; surfaceData->value = values.at(j); mode->SurfaceData.push_back(surfaceData); } } }
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 DynCompCol :: assemble(const IntArray &loc, const FloatMatrix &mat) { int i, j, ii, jj, dim; # ifdef DEBUG dim = mat.giveNumberOfRows(); if ( dim != loc.giveSize() ) { OOFEM_ERROR("dimension of 'k' and 'loc' mismatch"); } # endif dim = mat.giveNumberOfRows(); for ( j = 1; j <= dim; j++ ) { jj = loc.at(j); if ( jj ) { for ( i = 1; i <= dim; i++ ) { ii = loc.at(i); if ( ii ) { this->at(ii, jj) += mat.at(i, j); } } } } // increment version this->version++; return 1; }
void RowColumn :: checkSizeTowards(const IntArray &loc) // If loc points to a coefficient which out of the receiver's range, // enlarges the receiver. { int n, i, j, c, first = start; n = loc.giveSize(); if ( !n ) { OOFEM_ERROR("0-size location array"); } // get first non-zero coefficient in loc for ( i = 1; i <= n; i++ ) { if ( ( first = loc.at(i) ) ) { break; } } // get min coefficient in loc for ( j = i + 1; j <= n; j++ ) { if ( ( c = loc.at(j) ) ) { first = min(c, first); } } // enlarge the receiver if necessary if ( first < start && first ) { this->growTo(first); } }
void FloatArray :: beSubArrayOf(const FloatArray &src, const IntArray &indx) // // returns subVector from receiver // subVector size will be indx max val size // and on i-th position of subVector will be this->at(indx->at(i)) // { int i, ii, n, isize; n = indx.giveSize(); #ifdef DEBUG if ( src.size != n ) { OOFEM_ERROR("FloatArray :: beSubArrayOf - size mismatch"); } #endif for ( isize = 0, i = 1; i <= n; i++ ) { if ( indx.at(i) > isize ) { isize = indx.at(i); } } this->resize(isize); for ( i = 1; i <= n; i++ ) { ii = indx.at(i); if ( ii > 0 ) { this->at(ii) = src.at(i); } } }
void DofManager :: mergePartitionList(IntArray &_p) { // more optimized version can be made requiring sorted partition list of receiver int size = _p.giveSize(); for ( int i = 1; i <= size; i++ ) { partitions.insertOnce( _p.at(i) ); } }
int Structural2DElement :: computeNumberOfDofs() { ///@todo move one hiearchy up and generalize IntArray dofIdMask; this->giveDofManDofIDMask(-1, dofIdMask); // ok for standard elements return this->giveInterpolation()->giveNumberOfNodes() * dofIdMask.giveSize(); }