Beispiel #1
0
void
assembleMatrix ( MatrixEpetra<Real>& globalMatrix,
                 MatrixElemental&            localMatrix,
                 const CurrentFE&    currentFE,
                 const DofType&      dof,
                 Int                 iblock,
                 Int                 jblock,
                 Int                 iOffset,
                 Int                 jOffset)

{
    return assembleMatrix ( globalMatrix, localMatrix, currentFE, currentFE, dof, dof,
                            iblock, jblock, iOffset, jOffset);
}
Beispiel #2
0
void
assembleMatrix ( MatrixEpetra<Real>& globalMatrix,
                 UInt const&         elementID1,
                 UInt const&         elementID2,
                 LocalMatrixType&    localMatrix,
                 const CurrentFE&    currentFE1,
                 const CurrentFE&    currentFE2,
                 const DofType1&     dof1,
                 const DofType2&     dof2,
                 Int                 iOffset,
                 Int                 jOffset)

{
    assembleMatrix (globalMatrix, elementID1, elementID2, localMatrix, currentFE1.nbFEDof(), currentFE2.nbFEDof(),
                    dof1, dof2, iOffset, jOffset);

}
Beispiel #3
0
void
ADRAssembler< mesh_type, matrix_type, vector_type>::
addDiffusion (matrix_ptrType matrix, const Real& coefficient, const UInt& offsetLeft, const UInt& offsetUp)
{
    // Check that the fespace is set
    ASSERT (M_fespace != 0, "No FE space for assembling the diffusion!");

    M_diffusionAssemblyChrono.start();

    // Some constants
    const UInt nbElements (M_fespace->mesh()->numElements() );
    const UInt fieldDim (M_fespace->fieldDim() );
    const UInt nbTotalDof (M_fespace->dof().numTotalDof() );

    // Loop over the elements
    for (UInt iterElement (0); iterElement < nbElements; ++iterElement)
    {
        // Update the diffusion current FE
        M_diffCFE->update ( M_fespace->mesh()->element (iterElement), UPDATE_DPHI | UPDATE_WDET );

        // Clean the local matrix
        M_localDiff->zero();

        // local stiffness
        AssemblyElemental::stiffness (*M_localDiff, *M_diffCFE, coefficient, fieldDim);

        // Assembly
        for (UInt iFieldDim (0); iFieldDim < fieldDim; ++iFieldDim)
        {
            assembleMatrix ( *matrix,
                             *M_localDiff,
                             *M_diffCFE,
                             *M_diffCFE,
                             M_fespace->dof(),
                             M_fespace->dof(),
                             iFieldDim, iFieldDim,
                             iFieldDim * nbTotalDof + offsetLeft, iFieldDim * nbTotalDof + offsetUp );
        }
    }

    M_diffusionAssemblyChrono.stop();
}
Beispiel #4
0
void
assembleMatrix ( MatrixEpetra<Real>& globalMatrix,
                 MatrixElemental&            localMatrix,
                 const CurrentFE&    currentFE1,
                 const CurrentFE&    currentFE2,
                 const DofType1&     dof1,
                 const DofType2&     dof2,
                 Int                 iblock,
                 Int                 jblock,
                 Int                 iOffset,
                 Int                 jOffset )

{
    MatrixElemental::matrix_view localView = localMatrix.block ( iblock, jblock );

    UInt elementID1 = currentFE1.currentLocalId();
    UInt elementID2 = currentFE2.currentLocalId();

    assembleMatrix ( globalMatrix, elementID1, elementID2, localView,
                     currentFE1, currentFE2, dof1,  dof2, iOffset, jOffset );

    return;

}
Beispiel #5
0
void
assembleMatrix ( MatrixEpetra<Real>&   globalMatrix,
                 const UInt&           elementID,
                 MatrixElemental&              localMatrix,
                 const UInt&           feNbDof,
                 const DofType&        dof,
                 Int                   iblock,
                 Int                   jblock,
                 Int                   iOffset,
                 Int                   jOffset)

{

    MatrixElemental::matrix_view localView = localMatrix.block ( iblock, jblock );

    assembleMatrix ( globalMatrix,
                     elementID,
                     elementID,
                     localView,
                     feNbDof,
                     feNbDof,
                     dof,
                     dof, iOffset, jOffset);
}
Beispiel #6
0
void
ADRAssembler< mesh_type, matrix_type, vector_type>::
addAdvection (matrix_ptrType matrix, const vector_type& beta, const UInt& offsetLeft, const UInt& offsetUp)
{
    // Beta has to be repeated!
    if (beta.mapType() == Unique)
    {
        addAdvection (matrix, vector_type (beta, Repeated), offsetLeft, offsetUp);
        return;
    }

    // Check that the fespace is set
    ASSERT (M_fespace != 0, "No FE space for assembling the advection!");
    ASSERT (M_betaFESpace != 0, "No FE space (beta) for assembling the advection!");

    M_advectionAssemblyChrono.start();


    // Some constants
    const UInt nbElements (M_fespace->mesh()->numElements() );
    const UInt fieldDim (M_fespace->fieldDim() );
    const UInt betaFieldDim (M_betaFESpace->fieldDim() );
    const UInt nbTotalDof (M_fespace->dof().numTotalDof() );
    const UInt nbQuadPt (M_advCFE->nbQuadPt() );

    // Temporaries
    //Real localValue(0);
    std::vector< std::vector< Real > > localBetaValue (nbQuadPt, std::vector<Real> ( betaFieldDim, 0.0 ) );

    // Loop over the elements
    for (UInt iterElement (0); iterElement < nbElements; ++iterElement)
    {
        // Update the advection current FEs
        M_advCFE->update ( M_fespace->mesh()->element (iterElement), UPDATE_PHI | UPDATE_DPHI | UPDATE_WDET );
        M_advBetaCFE->update (M_fespace->mesh()->element (iterElement), UPDATE_PHI );

        // Clean the local matrix
        M_localAdv->zero();

        // Interpolate beta in the quadrature points
        AssemblyElemental::interpolate (localBetaValue, *M_advBetaCFE, betaFieldDim, M_betaFESpace->dof(), iterElement, beta);

        // Assemble the advection
        AssemblyElemental::advection (*M_localAdv, *M_advCFE, 1.0, localBetaValue, fieldDim);


        // Assembly
        for (UInt iFieldDim (0); iFieldDim < fieldDim; ++iFieldDim)
        {
            assembleMatrix ( *matrix,
                             *M_localAdv,
                             *M_advCFE,
                             *M_advCFE,
                             M_fespace->dof(),
                             M_fespace->dof(),
                             iFieldDim, iFieldDim,
                             iFieldDim * nbTotalDof + offsetLeft, iFieldDim * nbTotalDof + offsetUp );
        }
    }

    M_advectionAssemblyChrono.stop();
}
void NeoHookeanMaterialNonLinear<Mesh>::updateNonLinearJacobianTerms ( matrixPtr_Type&       jacobian,
                                                                       const vector_Type&    disp,
                                                                       const dataPtr_Type&   dataMaterial,
                                                                       const mapMarkerVolumesPtr_Type mapsMarkerVolumes,
                                                                       const displayerPtr_Type&  displayer )
{
    displayer->leaderPrint ("   Non-Linear S-  updating non linear terms in the Jacobian Matrix (Neo-Hookean)");

    UInt totalDof = this->M_FESpace->dof().numTotalDof();
    VectorElemental dk_loc (this->M_FESpace->fe().nbFEDof(), nDimensions);

    vector_Type dRep (disp, Repeated);

    //! Number of displacement components
    UInt nc = nDimensions;

    //! Nonlinear part of jacobian
    //! loop on volumes: assembling source term

    mapIterator_Type it;

    for ( it = (*mapsMarkerVolumes).begin(); it != (*mapsMarkerVolumes).end(); it++ )
    {

        //Given the marker pointed by the iterator, let's extract the material parameters
        UInt marker = it->first;

        Real mu     = dataMaterial->mu (marker);
        Real bulk   = dataMaterial->bulk (marker);

        for ( UInt j (0); j < it->second.size(); j++ )
        {
            this->M_FESpace->fe().updateFirstDerivQuadPt ( * (it->second[j]) );

            UInt eleID = this->M_FESpace->fe().currentLocalId();

            for ( UInt iNode = 0; iNode < ( UInt ) this->M_FESpace->fe().nbFEDof(); iNode++ )
            {
                UInt  iloc = this->M_FESpace->fe().patternFirst ( iNode );

                for ( UInt iComp = 0; iComp < nDimensions; ++iComp )
                {
                    UInt ig = this->M_FESpace->dof().localToGlobalMap ( eleID, iloc ) + iComp * this->M_FESpace->dim() + this->M_offset;
                    dk_loc[iloc + iComp * this->M_FESpace->fe().nbFEDof()] = dRep[ig];
                }
            }

            this->M_elmatK->zero();

            //! Computes F, Cof(F), J = det(F), Tr(C)
            computeKinematicsVariables ( dk_loc );

            //! Stiffness for non-linear terms of the Neo-Hookean model
            /*!
              The results of the integrals are stored at each step into elmatK, until to build K matrix of the bilinear form
            */

            //! VOLUMETRIC PART
            //! 1. Stiffness matrix: int { 1/2 * bulk * ( 2 - 1/J + 1/J^2 ) * ( CofF : \nabla \delta ) (CofF : \nabla v) }
            AssemblyElementalStructure::stiff_Jac_Pvol_1term ( 0.5 * bulk, (*M_CofFk), (*M_Jack),
                                                               *this->M_elmatK, this->M_FESpace->fe() );

            //! 2. Stiffness matrix: int { 1/2 * bulk * ( 1/J- 1 - log(J)/J^2 ) * ( CofF [\nabla \delta]^t CofF ) : \nabla v }
            AssemblyElementalStructure::stiff_Jac_Pvol_2term ( 0.5 * bulk, (*M_CofFk), (*M_Jack),
                                                               *this->M_elmatK, this->M_FESpace->fe() );

            //! ISOCHORIC PART
            //! 1. Stiffness matrix : int { -2/3 * mu * J^(-5/3) *( CofF : \nabla \delta ) ( F : \nabla \v ) }
            AssemblyElementalStructure::stiff_Jac_P1iso_NH_1term ( (-2.0 / 3.0) * mu, (*M_CofFk), (*M_Fk), (*M_Jack),
                                                                   *this->M_elmatK, this->M_FESpace->fe() );

            //! 2. Stiffness matrix : int { 2/9 * mu * ( Ic_iso / J^2 )( CofF : \nabla \delta ) ( CofF : \nabla \v ) }
            AssemblyElementalStructure::stiff_Jac_P1iso_NH_2term ( (2.0 / 9.0) * mu, (*M_CofFk), (*M_Jack), (*M_trCisok),
                                                                   *this->M_elmatK, this->M_FESpace->fe() );

            //! 3. Stiffness matrix : int { mu * J^(-2/3) (\nabla \delta : \nabla \v)}
            AssemblyElementalStructure::stiff_Jac_P1iso_NH_3term ( mu, (*M_Jack), *this->M_elmatK, this->M_FESpace->fe() );

            //! 4. Stiffness matrix : int { -2/3 * mu * J^(-5/3) ( F : \nabla \delta ) ( CofF : \nabla \v ) }
            AssemblyElementalStructure::stiff_Jac_P1iso_NH_4term ( (-2.0 / 3.0) * mu, (*M_CofFk), (*M_Fk), (*M_Jack),
                                                                   *this->M_elmatK, this->M_FESpace->fe() );

            //! 5. Stiffness matrix : int { 1/3 * mu * J^(-2) * Ic_iso * (CofF [\nabla \delta]^t CofF ) : \nabla \v }
            AssemblyElementalStructure::stiff_Jac_P1iso_NH_5term ( (1.0 / 3.0) * mu, (*M_CofFk), (*M_Jack), (*M_trCisok),
                                                                   *this->M_elmatK, this->M_FESpace->fe() );

            //! assembling
            for ( UInt ic = 0; ic < nc; ++ic )
            {
                for ( UInt jc = 0; jc < nc; jc++ )
                {
                    assembleMatrix ( *jacobian,
                                     *this->M_elmatK,
                                     this->M_FESpace->fe(),
                                     this->M_FESpace->dof(),
                                     ic, jc,
                                     this->M_offset +  ic * totalDof, this->M_offset +  jc * totalDof );
                }
            }
        }
    }
}
void VenantKirchhoffMaterialLinear<Mesh>::computeLinearStiff(dataPtr_Type& dataMaterial,
                                                             const mapMarkerVolumesPtr_Type mapsMarkerVolumes)
{
    //  std::cout<<"compute LinearStiff Matrix start\n";

    UInt totalDof = this->M_FESpace->dof().numTotalDof();
    // Number of displacement components
    UInt nc = nDimensions;

    //Compute the linear part of the Stiffness Matrix.
    //In the case of Linear Material it is the Stiffness Matrix.
    //In the case of NonLinear Materials it must be added of the non linear part.

    mapIterator_Type it;

    for( it = (*mapsMarkerVolumes).begin(); it != (*mapsMarkerVolumes).end(); it++ )
    {

        //Given the marker pointed by the iterator, let's extract the material parameters
        UInt marker = it->first;

        Real mu = dataMaterial->mu(marker);
        Real lambda = dataMaterial->lambda(marker);

        //Given the parameters I loop over the volumes with that marker
        for ( UInt j(0); j < it->second.size(); j++ )
        {
            this->M_FESpace->fe().updateFirstDerivQuadPt( *(it->second[j]) );

            this->M_elmatK->zero();

            //These methods are implemented in AssemblyElemental.cpp
            //They have been kept in AssemblyElemental in order to avoid repetitions
            stiff_strain( 2*mu, *this->M_elmatK, this->M_FESpace->fe() );// here in the previous version was 1. (instead of 2.)
            stiff_div   ( lambda, *this->M_elmatK, this->M_FESpace->fe() );// here in the previous version was 0.5 (instead of 1.)

            //this->M_elmatK->showMe();

            // assembling
            for ( UInt ic = 0; ic < nc; ic++ )
            {
                for ( UInt jc = 0; jc < nc; jc++ )
                {
                    assembleMatrix( *this->M_linearStiff,
                                    *this->M_elmatK,
                                    this->M_FESpace->fe(),
                                    this->M_FESpace->fe(),
                                    this->M_FESpace->dof(),
                                    this->M_FESpace->dof(),
                                    ic,  jc,
                                    this->M_offset +ic*totalDof, this->M_offset + jc*totalDof );

                }
            }


        }

    }

    this->M_linearStiff->globalAssemble();

    //Initialization of the pointer M_stiff to what is pointed by M_linearStiff
    this->M_stiff = this->M_linearStiff;
    //   std::cout<<"compute LinearStiff Matrix end\n";
    this->M_jacobian = this->M_linearStiff;
}