예제 #1
0
static void p2_test_semi2(void)
{
	struct PC_vertex_ll * r1 = createRect(2,2,4,4);
	struct PC_vertex_ll * r2 = createRectCW(4,3,2,2);
	
	enum PC_op_t op = PC_op_union;
	bool result = PC_phase_one(r1, r2); 
	
	
	
	LT_REQUIRE(polySize(r1) == 6); 
	LT_REQUIRE(polySize(r2) == 6);
	
	PC_phase_two(r1, r2, op);
	

	LT_ASSERT(_I(r1, 0)->flag == FLG_NONE);
	LT_ASSERT(_I(r1, 1)->flag == FLG_NONE);
	LT_ASSERT(_I(r1, 2)->flag == FLG_EN);
	LT_ASSERT(_I(r1, 3)->flag == FLG_EX);
	LT_ASSERT(_I(r1, 4)->flag == FLG_EX);
	LT_ASSERT(_I(r1, 5)->flag == FLG_NONE);
	
	LT_ASSERT(_I(r2, 0)->flag == FLG_NONE);
	LT_ASSERT(_I(r2, 1)->flag == FLG_EX);
	LT_ASSERT(_I(r2, 2)->flag == FLG_EX);
	LT_ASSERT(_I(r2, 3)->flag == FLG_NONE);
	LT_ASSERT(_I(r2, 4)->flag == FLG_NONE);
	LT_ASSERT(_I(r2, 5)->flag == FLG_EN);
	
	
	// Test couple creation
	LT_ASSERT(_I(r1, 0)->couple == NULL);
	LT_ASSERT(_I(r1, 1)->couple == NULL);
	LT_ASSERT(_I(r1, 2)->couple == NULL);
	LT_ASSERT(_I(r1, 3)->couple == _I(r1, 4));
	LT_ASSERT(_I(r1, 4)->couple == _I(r1, 3));
	LT_ASSERT(_I(r1, 5)->couple == NULL);
	
	LT_ASSERT(_I(r2, 0)->couple == NULL);
	LT_ASSERT(_I(r2, 1)->couple == _I(r2, 2));
	LT_ASSERT(_I(r2, 2)->couple == _I(r2, 1));
	LT_ASSERT(_I(r2, 3)->couple == NULL);
	LT_ASSERT(_I(r2, 4)->couple == NULL);
	LT_ASSERT(_I(r2, 5)->couple == NULL);
    
    
    PC_free_verticies(r1);
    PC_free_verticies(r2);
}
예제 #2
0
static void p2_test_onelarger2(void)
{
	// Square centered on 2,2
	struct PC_vertex_ll * r1 = createRect(2,2,4,4);
	
	// Square centered on 3,4
	struct PC_vertex_ll * r2 = createRect(3,3,6,6);
	
	enum PC_op_t op = PC_op_union;
	bool result = PC_phase_one(r1, r2); 
	
	
	LT_REQUIRE(polySize(r1) == 4); 
	LT_REQUIRE(polySize(r2) == 6);
	
	PC_phase_two(r1, r2, op);
	
	LT_ASSERT(_I(r1, 0)->flag == FLG_NONE);
	LT_ASSERT(_I(r1, 1)->flag == FLG_EN);
	LT_ASSERT(_I(r1, 2)->flag == FLG_NONE);
	LT_ASSERT(_I(r1, 3)->flag == FLG_EX);
	
	LT_ASSERT(_I(r2, 0)->flag == FLG_NONE);
	LT_ASSERT(_I(r2, 1)->flag == FLG_EX);
	LT_ASSERT(_I(r2, 2)->flag == FLG_NONE);
	LT_ASSERT(_I(r2, 3)->flag == FLG_NONE);
	LT_ASSERT(_I(r2, 4)->flag == FLG_NONE);
	LT_ASSERT(_I(r2, 5)->flag == FLG_EN);
	
	LT_ASSERT(no_couples(r1));
	LT_ASSERT(no_couples(r2));
    
    
    PC_free_verticies(r1);
    PC_free_verticies(r2);
}
void Foam::RBFInterpolation::calcB() const
{
    // Determine inverse of boundary connectivity matrix
    label polySize(4);

    if (!polynomials_)
    {
        polySize = 0;
    }

    // Fill Nb x Nb matrix
    simpleMatrix<scalar> A(controlPoints_.size()+polySize);

    const label nControlPoints = controlPoints_.size();
    for (label i = 0; i < nControlPoints; i++)
    {
        scalarField weights = RBF_->weights(controlPoints_, controlPoints_[i]);

        for (label col = 0; col < nControlPoints; col++)
        {
            A[i][col] = weights[col];
        }
    }

    if (polynomials_)
    {
        for
        (
            label row = nControlPoints;
            row < nControlPoints + 1;
            row++
        )
        {
            for (label col = 0; col < nControlPoints; col++)
            {
                A[col][row] = 1.0;
                A[row][col] = 1.0;
            }
        }

        // Fill in X components of polynomial part of matrix
        for
        (
            label row = nControlPoints + 1;
            row < nControlPoints + 2;
            row++
        )
        {
            for (label col = 0; col < nControlPoints; col++)
            {
                A[col][row] = controlPoints_[col].x();
                A[row][col] = controlPoints_[col].x();
            }
        }

        // Fill in Y components of polynomial part of matrix
        for
        (
            label row = nControlPoints + 2;
            row < nControlPoints + 3;
            row++
        )
        {
            for (label col = 0; col < nControlPoints; col++)
            {
                A[col][row] = controlPoints_[col].y();
                A[row][col] = controlPoints_[col].y();
            }
        }
        // Fill in Z components of polynomial part of matrix
        for
        (
            label row = nControlPoints + 3;
            row < nControlPoints + 4;
            row++
        )
        {
            for (label col = 0; col < nControlPoints; col++)
            {
                A[col][row] = controlPoints_[col].z();
                A[row][col] = controlPoints_[col].z();
            }
        }

        // Fill 4x4 zero part of matrix
        for
        (
            label row = nControlPoints;
            row < nControlPoints + 4;
            row++
        )
        {
            for
            (
                label col = nControlPoints;
                col < nControlPoints + 4;
                col++
            )
            {
                A[row][col] = 0.0;
            }
        }
    }

    // HJ and FB (05 Jan 2009)
    // Collect ALL control points from ALL CPUs
    // Create an identical inverse for all CPUs

    Info<< "Inverting RBF motion matrix" << endl;

    BPtr_ = new scalarSquareMatrix(A.LUinvert());
}