Ejemplo n.º 1
0
bool RHSTests::testTrivialRHS()
{

    bool success = true;
    double tol = 1e-14;

    int rank = _mesh->Comm()->MyPID();

    Teuchos::RCP<ElementType> elemType = _mesh->getElement(0)->elementType();

    vector< Teuchos::RCP< Element > > elemsInPartitionOfType = _mesh->elementsOfType(rank, elemType);
    FieldContainer<double> physicalCellNodes = _mesh->physicalCellNodes(elemType);

    int numCells = elemsInPartitionOfType.size();
    int numTestDofs = elemType->testOrderPtr->totalDofs();

    // determine cellIDs
    vector<GlobalIndexType> cellIDs = _mesh->globalDofAssignment()->cellIDsOfElementType(rank, elemType);

    if (numCells > 0)
    {
        // prepare basisCache and cellIDs
        BasisCachePtr basisCache = Teuchos::rcp(new BasisCache(elemType,_mesh));
        bool createSideCacheToo = true;
        basisCache->setPhysicalCellNodes(physicalCellNodes,cellIDs,createSideCacheToo);

        FieldContainer<double> rhsExpected(numCells,numTestDofs);

        FunctionPtr zero = Function::constant(0.0);
        RHSPtr rhs = RHS::rhs();
        FunctionPtr f = zero;
        rhs->addTerm( f * _v ); // obviously, with f = 0 adding this term is not necessary!
        rhs->integrateAgainstStandardBasis(rhsExpected, elemType->testOrderPtr, basisCache);

        for (int i = 0; i<numCells; i++)
        {
            for (int j = 0; j<numTestDofs; j++)
            {
                if (abs(rhsExpected(i,j))>tol)
                {
                    success = false;
                }
            }
        }
    }

    return allSuccess(success);
}