Exemple #1
0
void QuadratureRule::setPoints(const std::vector<QuadraturePoint>& pts)
{
    M_pt.clear();
    M_pt.resize(pts.size());
    for (UInt i(0); i<pts.size(); ++i)
    {
        M_pt[i]=QuadraturePoint(pts[i],M_dimension);
    }

    M_nbQuadPt=pts.size();
}
Exemple #2
0
void QuadratureRule::setDimensionShape(const UInt& newDim, const ReferenceShapes& newShape)
{
    ASSERT(newDim >= shapeDimension(newShape)," Impossible shape-dimension combinaison ");
    M_dimension = newDim;
    M_shape = newShape;

    // Change also the dimension of the points if they are already set!
    for (UInt i(0); i<M_pt.size(); ++i)
    {
        M_pt[i] = QuadraturePoint(M_pt[i],newDim);
    }
}
Exemple #3
0
void QuadratureRule::setPoints(const std::vector<GeoVector>& coordinates, const std::vector<Real>& weights)
{
    ASSERT(coordinates.size()==weights.size(),"Non matching length of the arguments");

    M_pt.clear();
    M_pt.resize(coordinates.size());
    for (UInt i(0); i<M_pt.size(); ++i)
    {
        M_pt[i]=QuadraturePoint(coordinates[i],weights[i],M_dimension);
    }

    M_nbQuadPt=M_pt.size();
}
void
LevelSetBDQRAdapter<FESpaceType, VectorType>::
update (UInt elementID, UInt localFaceID)
{
    // They are ordered so that the "mapping" in
    // QuadratureBoundary is right.

    std::vector<UInt> myLID (3);

    if (localFaceID == 0)
    {
        myLID[0] = 0;
        myLID[1] = 1;
        myLID[2] = 2;
    }
    else if (localFaceID == 1)
    {
        myLID[0] = 0;
        myLID[1] = 1;
        myLID[2] = 3;
    }
    else if (localFaceID == 2)
    {
        myLID[0] = 3;
        myLID[1] = 1;
        myLID[2] = 2;
    }
    else
    {
        myLID[0] = 0;
        myLID[1] = 3;
        myLID[2] = 2;
    }

    // Compute the global IDs
    std::vector<UInt> myGID (3);

    for (UInt i (0); i < 3; ++i)
    {
        myGID[i] = M_lsFESpace->dof().localToGlobalMap (elementID, myLID[i]);
    }

    // Check the level set values
    std::vector<UInt> localPositive;
    std::vector<UInt> localNegative;
    std::vector<Real> localPositiveValue;
    std::vector<Real> localNegativeValue;

    for (UInt i (0); i < 3; ++i)
    {
        if (M_lsValue[myGID[i]] >= 0)
        {
            localPositive.push_back (i);
            localPositiveValue.push_back (M_lsValue[myGID[i]]);
        }
        else
        {
            localNegative.push_back (i);
            localNegativeValue.push_back (M_lsValue[myGID[i]]);
        }
    }

    // Check if the element is actually cut by the interface.
    if (localPositive.empty() || localNegative.empty() )
    {
        M_isAdaptedElement = false;
        *M_adaptedQrBd =  M_qrBd;
    }
    else
    {

        M_isAdaptedElement = true;

        std::vector<std::vector<Real> >refCoor (3, std::vector<Real> (2) );
        refCoor[0][0] = 0.0;
        refCoor[0][1] = 0.0;
        refCoor[1][0] = 1.0;
        refCoor[1][1] = 0.0;
        refCoor[2][0] = 0.0;
        refCoor[2][1] = 1.0;

        QuadratureRule qrRef ("none", TRIANGLE, 3, 0, 0);

        // Disinguish the two cases
        if (localPositive.size() == 1)
        {
            // Do nothing
        }
        else
        {
            // Exchange positive and negative values
            localPositive.swap (localNegative);
            localPositiveValue.swap (localNegativeValue);
        }


        // Two negative case
        Real lambda1 = -localPositiveValue[0] / (localNegativeValue[0] - localPositiveValue[0]);

        std::vector < Real > I1 (2);
        I1[0] = refCoor[localPositive[0]][0] + lambda1 * (refCoor[localNegative[0]][0] - refCoor[localPositive[0]][0]);
        I1[1] = refCoor[localPositive[0]][1] + lambda1 * (refCoor[localNegative[0]][1] - refCoor[localPositive[0]][1]);

        Real lambda2 = -localPositiveValue[0] / (localNegativeValue[1] - localPositiveValue[0]);

        std::vector < Real > I2 (2);
        I2[0] = refCoor[localPositive[0]][0] + lambda2 * (refCoor[localNegative[1]][0] - refCoor[localPositive[0]][0]);
        I2[1] = refCoor[localPositive[0]][1] + lambda2 * (refCoor[localNegative[1]][1] - refCoor[localPositive[0]][1]);

        // First triangle
        {
            std::vector<Real> P0 (2);
            P0[0] = refCoor[localPositive[0]][0];
            P0[1] = refCoor[localPositive[0]][1];

            std::vector<Real> v1 (2);
            v1[0] = I1[0] - refCoor[localPositive[0]][0];
            v1[1] = I1[1] - refCoor[localPositive[0]][1];

            std::vector<Real> v2 (2);
            v2[0] = I2[0] - refCoor[localPositive[0]][0];
            v2[1] = I2[1] - refCoor[localPositive[0]][1];

            Real wRel (std::abs (v1[0]*v2[1] - v1[1]*v2[0]) );

            for (UInt iq (0); iq < M_qrBd.qr (0).nbQuadPt(); ++iq)
            {
                Real x (P0[0] + M_qrBd.qr (0).quadPointCoor (iq, 0) *v1[0] + M_qrBd.qr (0).quadPointCoor (iq, 1) *v2[0]);
                Real y (P0[1] + M_qrBd.qr (0).quadPointCoor (iq, 0) *v1[1] + M_qrBd.qr (0).quadPointCoor (iq, 1) *v2[1]);

                qrRef.addPoint (QuadraturePoint (x, y, M_qrBd.qr (0).weight (iq) *wRel) );
            }
        }

        // Second triangle
        {
            std::vector<Real> P0 (2);
            P0[0] = refCoor[localNegative[0]][0];
            P0[1] = refCoor[localNegative[0]][1];

            std::vector<Real> v1 (2);
            v1[0] = I1[0] - refCoor[localNegative[0]][0];
            v1[1] = I1[1] - refCoor[localNegative[0]][1];

            std::vector<Real> v2 (2);
            v2[0] = I2[0] - refCoor[localNegative[0]][0];
            v2[1] = I2[1] - refCoor[localNegative[0]][1];

            Real wRel (std::abs (v1[0]*v2[1] - v1[1]*v2[0]) );

            for (UInt iq (0); iq < M_qrBd.qr (0).nbQuadPt(); ++iq)
            {
                Real x (P0[0] + M_qrBd.qr (0).quadPointCoor (iq, 0) *v1[0] + M_qrBd.qr (0).quadPointCoor (iq, 1) *v2[0]);
                Real y (P0[1] + M_qrBd.qr (0).quadPointCoor (iq, 0) *v1[1] + M_qrBd.qr (0).quadPointCoor (iq, 1) *v2[1]);

                qrRef.addPoint (QuadraturePoint (x, y, M_qrBd.qr (0).weight (iq) *wRel) );
            }
        }

        // Third triangle
        {
            std::vector<Real> P0 (2);
            P0[0] = refCoor[localNegative[0]][0];
            P0[1] = refCoor[localNegative[0]][1];

            std::vector<Real> v1 (2);
            v1[0] = I2[0] - refCoor[localNegative[0]][0];
            v1[1] = I2[1] - refCoor[localNegative[0]][1];

            std::vector<Real> v2 (2);
            v2[0] = refCoor[localNegative[1]][0] - refCoor[localNegative[0]][0];
            v2[1] = refCoor[localNegative[1]][1] - refCoor[localNegative[0]][1];

            Real wRel (std::abs (v1[0]*v2[1] - v1[1]*v2[0]) );

            for (UInt iq (0); iq < M_qrBd.qr (0).nbQuadPt(); ++iq)
            {
                Real x (P0[0] + M_qrBd.qr (0).quadPointCoor (iq, 0) *v1[0] + M_qrBd.qr (0).quadPointCoor (iq, 1) *v2[0]);
                Real y (P0[1] + M_qrBd.qr (0).quadPointCoor (iq, 0) *v1[1] + M_qrBd.qr (0).quadPointCoor (iq, 1) *v2[1]);

                qrRef.addPoint (QuadraturePoint (x, y, M_qrBd.qr (0).weight (iq) *wRel) );
            }
        }

        // Call the make tretra
        M_adaptedQrBd.reset (new QuadratureBoundary (buildTetraBDQR (qrRef) ) );
    }
}