Example #1
0
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;
}
Example #2
0
int
RCM2Material :: giveIntVarCompFullIndx(IntArray &answer, InternalStateType type, MaterialMode mmode)
{
    if ( type == IST_CrackedFlag ) {
        answer.resize(1);
        answer.at(1) = 1;
        return 1;
    } else if ( type ==  IST_CrackDirs ) {
        answer.resize(9);
        for ( int i = 1; i <= 9; i++ ) {
            answer.at(i) = i;
        }

        return 1;
    } else if ( type == IST_CrackStatuses ) {
        answer.resize(3);
        for ( int i = 1; i <= 3; i++ ) {
            answer.at(i) = i;
        }

        return 1;
    } else {
        return StructuralMaterial :: giveIntVarCompFullIndx(answer, type, mmode);
    }
}
Example #3
0
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);
        }
    }
}
Example #4
0
void
RCM2Material :: updateActiveCrackMap(GaussPoint *gp, const IntArray *activatedCracks)
//
//
// updates mapping matrix of active cracks
//
{
    int i, indx = 1;
    RCM2MaterialStatus *status = ( RCM2MaterialStatus * ) this->giveStatus(gp);
    IntArray crackMap;
    status->giveCrackMap(crackMap);

    //if (crackMap == NULL) _error ("updateActiveCrackMap: NULL pointer encountered");

    for ( i = 1; i <= 3; i++ ) {
        if ( status->isCrackActive(i) ) {
            crackMap.at(i) = indx++;
        } else if ( activatedCracks ) {
            if ( ( activatedCracks->at(i) != 0 ) ) {
                crackMap.at(i) = indx++;
            }
        } else {
            crackMap.at(i) = 0;
        }
    }

    // store modified map into status
    status->letCrackMapBe(crackMap);
}
Example #5
0
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;
}
Example #6
0
void
RCM2Material :: checkIfClosedCracks(GaussPoint *gp, FloatArray &crackStrainVector,
                                    IntArray &crackMap)
//
// Check if crack closing occurs
// if yes updates crackStrainVector and gp-status accordingly
//
{
    RCM2MaterialStatus *status = ( RCM2MaterialStatus * ) this->giveStatus(gp);
    int i, isClosing = 0;

    for ( i = 1; i <= 3; i++ ) {
        if ( crackMap.at(i) ) {
            if ( crackStrainVector.at(i) < 0. ) {
                // crack closing occur
                crackStrainVector.at(i) = 0.;
                crackMap.at(i) = 0;
                // status->giveTempCrackStatus()->at(i) = pscm_CLOSED;
                isClosing = 1;
            }
        }
    }

    status->letCrackMapBe(crackMap);
    if ( isClosing ) {
        this->updateActiveCrackMap(gp);
    }

    status->giveCrackMap(crackMap); // update crack Map
}
void
VTKXMLExportModule :: giveElementCell(IntArray &answer, Element *elem, int cell)
{
    Element_Geometry_Type elemGT = elem->giveGeometryType();
    int nelemNodes;

    if ( ( elemGT == EGT_point ) ||
        ( elemGT == EGT_line_1 ) || ( elemGT == EGT_line_2 ) ||
        ( elemGT == EGT_triangle_1 ) || ( elemGT == EGT_triangle_2 ) ||
        ( elemGT == EGT_tetra_1 ) || ( elemGT == EGT_tetra_2 ) ||
        ( elemGT == EGT_quad_1 ) || ( elemGT == EGT_quad_2 ) ||
        ( elemGT == EGT_hexa_1 ) ) {
        nelemNodes = elem->giveNumberOfNodes();
        answer.resize(nelemNodes);
        for ( int i = 1; i <= nelemNodes; i++ ) {
            answer.at(i) = elem->giveNode(i)->giveNumber() ;
        }
    } else if ( elemGT == EGT_hexa_2 ) {
        int HexaQuadNodeMapping [] = {
            5, 8, 7, 6, 1, 4, 3, 2, 16, 15, 14, 13, 12, 11, 10, 9, 17, 20, 19, 18
        };
        nelemNodes = elem->giveNumberOfNodes();
        answer.resize(nelemNodes);
        for ( int i = 1; i <= nelemNodes; i++ ) {
            answer.at(i) = elem->giveNode(HexaQuadNodeMapping [ i - 1 ])->giveNumber() ;
        }
    } else {
        OOFEM_ERROR("VTKXMLExportModule: unsupported element geometry type");
    }
}
Example #8
0
int SymCompCol :: assemble(const IntArray &rloc, const IntArray &cloc, const FloatMatrix &mat)
{
    int i, j, ii, jj, dim1, dim2;

    // this->checkSizeTowards(rloc, cloc);

    dim1 = mat.giveNumberOfRows();
    dim2 = mat.giveNumberOfColumns();
    for ( i = 1; i <= dim1; i++ ) {
        ii = rloc.at(i);
        if ( ii ) {
            for ( j = 1; j <= dim2; j++ ) {
                jj = cloc.at(j);
                if ( jj && ( ii >= jj ) ) {
                    this->at(ii, jj) += mat.at(i, j);
                }
            }
        }
    }

    // increment version
    this->version++;

    return 1;
}
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
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) );    
    }
}    
Example #11
0
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;
            }
        }
    }
}
Example #12
0
void
FEI3dTrQuad :: computeLocalEdgeMapping(IntArray &edgeNodes, int iedge)
{
    int aNode = 0, bNode = 0, cNode = 0;
    edgeNodes.resize(3);

    if ( iedge == 1 ) { // edge between nodes 1 2
        aNode = 1;
        bNode = 2;
        cNode = 4;
    } else if ( iedge == 2 ) { // edge between nodes 2 3
        aNode = 2;
        bNode = 3;
        cNode = 5;
    } else if ( iedge == 3 ) { // edge between nodes 2 3
        aNode = 3;
        bNode = 1;
        cNode = 6;
    } else {
        OOFEM_ERROR("Wrong edge number (%d)", iedge);
    }

    edgeNodes.at(1) = aNode;
    edgeNodes.at(2) = bNode;
    edgeNodes.at(3) = cNode;
}
int
FluidDynamicMaterial :: giveIntVarCompFullIndx(IntArray &answer, InternalStateType type, MaterialMode mmode)
{
    if ( type == IST_DeviatoricStress ) {
        if ( mmode == _2dFlow ) {
            answer.setValues(3, 1, 2, 3);
            return 1;
        } else if ( mmode == _2dAxiFlow ) {
            answer.setValues(4, 1, 2, 3, 6);
            return 1;
        } else if ( mmode == _3dFlow ) {
            answer.resize(6);
            for ( int i = 1; i <= 6; i++ ) answer.at(i) = i;
            return 1;
        } else {
            OOFEM_ERROR ("FluidDynamicMaterial :: giveIntVarCompFullIndx: material mode not supported");
            return 0;
        }
    } else if ( type == IST_Viscosity ) {
        answer.resize(1); answer.at(1) = 1;
        return 1;
    }  else {
        return Material :: giveIntVarCompFullIndx(answer, type, mmode);
    }
}
void
TrPlanestressRotAllman :: computeEgdeNMatrixAt(FloatMatrix &answer, int iedge, GaussPoint *gp)
{
    FloatArray lxy[6];
    const FloatArray *lxyptr[]= {lxy, lxy+1, lxy+2, lxy+3, lxy+4, lxy+5};
    FloatArray l, n;
    IntArray en;
    FEI2dTrQuad qi (1,2);

    this->computeLocalCoordinates(lxy); // get ready for tranformation into 3d
    qi.edgeEvalN( n, iedge, *gp->giveCoordinates(), FEIVertexListGeometryWrapper(6, lxyptr) );
    qi.computeLocalEdgeMapping (en, iedge); // get edge mapping
    this->interp.edgeEvalN( l, iedge, *gp->giveCoordinates(), FEIElementGeometryWrapper(this) );
    answer.resize(3,6);

    answer.at(1, 1) = answer.at(2,2) = n.at(1) + n.at(3)/2.0;
    answer.at(1, 4) = answer.at(2,5) = n.at(2) + n.at(3)/2.0;
    answer.at(1, 3) = n.at(3)*(lxy[en.at(2)-1].at(2)-lxy[en.at(1)-1].at(2))/8.0;
    answer.at(1, 6) = -answer.at(1, 3);
    answer.at(2, 3) = n.at(3)*(lxy[en.at(2)-1].at(1)-lxy[en.at(1)-1].at(1))/8.0;
    answer.at(2, 6) = -answer.at(2, 3);
    answer.at(3, 3) = l.at(1);
    answer.at(3, 6) = l.at(2);

}
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;
            }
        }
    }
}
Example #16
0
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;
}
Example #17
0
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);
        }
    }
}
Example #18
0
void
QTrPlaneStrain :: SPRNodalRecoveryMI_giveSPRAssemblyPoints(IntArray &pap)
{
    pap.resize(3);
    pap.at(1) = this->giveNode(1)->giveNumber();
    pap.at(2) = this->giveNode(2)->giveNumber();
    pap.at(3) = this->giveNode(3)->giveNumber();
}
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;
    }
}
Example #20
0
void
PetscNatural2LocalOrdering :: map2Old(IntArray &answer, const IntArray &src, int baseOffset)
{
    int i, n = src.giveSize();
    answer.resize(n);
    for ( i = 1; i <= n; i++ ) {
        answer.at(i) = giveOldEq( src.at(i) ) - baseOffset;
    }
}
Example #21
0
void
LTRSpace :: SPRNodalRecoveryMI_giveSPRAssemblyPoints(IntArray &pap)
{
    pap.resize(4);
    pap.at(1) = this->giveNode(1)->giveNumber();
    pap.at(2) = this->giveNode(2)->giveNumber();
    pap.at(3) = this->giveNode(3)->giveNumber();
    pap.at(4) = this->giveNode(4)->giveNumber();
}
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
}
Example #23
0
File: set.C Project: Micket/oofem
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
TrPlanestressRotAllman :: giveEdgeDofMapping(IntArray &answer, int iEdge) const
{
    /*
     * provides dof mapping of local edge dofs (only nonzero are taken into account)
     * to global element dofs
     */

    answer.resize(6);
    if ( iEdge == 1 ) { // edge between nodes 1,2
        answer.at(1) = 1;
        answer.at(2) = 2;
        answer.at(3) = 3;
        answer.at(4) = 4;
        answer.at(5) = 5;
        answer.at(6) = 6;
    } else if ( iEdge == 2 ) { // edge between nodes 2 3
        answer.at(1) = 4;
        answer.at(2) = 5;
        answer.at(3) = 6;
        answer.at(4) = 7;
        answer.at(5) = 8;
        answer.at(6) = 9;
    } else if ( iEdge == 3 ) { // edge between nodes 3 1
        answer.at(1) = 7;
        answer.at(2) = 8;
        answer.at(3) = 9;
        answer.at(4) = 1;
        answer.at(5) = 2;
        answer.at(6) = 3;
    } else {
        _error("giveEdgeDofMapping: wrong edge number");
    }
}
Example #25
0
int
ProblemCommunicator :: quickSortPartition( IntArray &map, int l, int r, int ( ProblemCommunicator :: *cmp ) (int, int) )
{
    int i = l - 1, j = r;
    int v = map.at(r);
    int swap;

    for ( ; ; ) {
        while ( ( ( this->*cmp )(map.at(++i), v) ) < 0 ) {
            ;
        }

        while ( ( ( this->*cmp )( v, map.at(--j) ) ) < 0 ) {
            if ( j == l ) {
                break;
            }
        }

        if ( i >= j ) {
            break;
        }

        swap = map.at(i);
        map.at(i) = map.at(j);
        map.at(j) = swap;
    }

    swap = map.at(i);
    map.at(i) = map.at(r);
    map.at(r) = swap;
    return i;
}
Example #26
0
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);

}
Example #27
0
void
FEI3dHexaQuad :: computeGlobalSurfaceMapping(IntArray &surfNodes, IntArray &elemNodes, int iSurf)
{
    IntArray nodes;
    surfNodes.resize(8);

    computeLocalSurfaceMapping(nodes, iSurf);

    for ( int i = 1; i <= 8; i++ ) {
        surfNodes.at(i) = elemNodes.at( nodes.at(i) );
    }
}
Example #28
0
void
RCM2Material :: giveNormalElasticStiffnessMatrix(FloatMatrix &answer,
                                                 MatResponseForm form, MatResponseMode rMode,
                                                 GaussPoint *gp, TimeStep *atTime,
                                                 const FloatMatrix &dir)
//
// return Elastic Stiffness matrix for normal Stresses
// taking into account the directions of normal stresses
// (not supported now)
//
{
    StructuralMaterial *lMat = static_cast< StructuralMaterial * >( this->giveLinearElasticMaterial() );
    FloatMatrix de, fullAnswer(3, 3);
    IntArray mask;
    int i, j, sd;

    lMat->giveCharacteristicMatrix(de, FullForm, rMode, gp, atTime);
    // copy first 3x3 submatrix to answer
    for ( i = 1; i <= 3; i++ ) {
        for ( j = 1; j <= 3; j++ ) {
            fullAnswer.at(i, j) = de.at(i, j);
        }
    }

    if ( form == FullForm ) { // 3x3 full form required
        answer = fullAnswer;
    } else {
        // reduced form for only
        // nonzero normal stresses
        //
        // first find spatial dimension of problem
        sd = 0;
        for ( i = 1; i <= 3; i++ ) {
            if ( ( this->giveStressStrainComponentIndOf(FullForm, gp->giveMaterialMode(), i) ) ) {
                sd++;
            }
        }

        answer.resize(sd, sd);
        answer.zero();

        // copy fullAnswer to reduced one
        this->giveStressStrainMask( mask, FullForm, gp->giveMaterialMode() );
        for ( i = 1; i <= 3; i++ ) {
            for ( j = 1; j <= 3; j++ ) {
                if ( mask.at(i) && mask.at(j) ) {
                    answer.at( mask.at(i), mask.at(j) ) = fullAnswer.at(i, j);
                }
            }
        }
        return;
    }
}
Example #29
0
int Skyline :: assemble(const IntArray &loc, const FloatMatrix &mat)
{
    // Assembles the elemental matrix 'mat' to the receiver, using 'loc' as a
    // location array. The values in ke corresponding to a zero coefficient
    // in loc are not assembled.

    // int ielem,i,j,ac,ac1,ac2,ndofe;
    // Domain* domain = eModel->giveDomain();
    int i, j, ac, ac1, ac2, ndofe;

    /*
     * int nelem = domain -> giveNumberOfElements ();
     * for ( ielem = 1; ielem <= nelem ; ielem++ ) {
     * domain -> giveElement(ielem) -> giveLocationArray (loc);
     * eModel->giveElementCharacteristicMatrix(mat, ielem, type, tStep );
     */

#  ifdef DEBUG
    int dim = mat.giveNumberOfRows();
    if ( dim != loc.giveSize() ) {
        OOFEM_ERROR("Skyline::assemble : dimension of 'mat' and 'loc' mismatch");
    }

#  endif

    ndofe = mat.giveNumberOfRows();

    for ( i = 1; i <= ndofe; i++ ) {
        ac1 = loc.at(i);
        if ( ac1 == 0 ) {
            continue;
        }

        for ( j = 1; j <= ndofe; j++ ) {
            ac2 = loc.at(j);
            if ( ac2 == 0 ) {
                continue;
            }

            if ( ac1 > ac2 ) {
                continue;
            }

            ac = adr->at(ac2) + ac2 - ac1;
            mtrx [ ac ] += mat.at(i, j);
        }
    }

    // increment vesion
    this->version++;
    return 1;
}
Example #30
0
void
QTRSpace :: giveDofManDofIDMask(int inode, EquationID ut, IntArray &answer) const
// returns DofId mask array for inode element node.
// DofId mask array determines the dof ordering requsted from node.
// DofId mask array contains the DofID constants (defined in cltypes.h)
// describing physical meaning of particular DOFs.
{
    answer.resize(3);

    answer.at(1) = D_u;
    answer.at(2) = D_v;
    answer.at(3) = D_w;
}