Exemple #1
0
std::pair<double,double> probe( const MESH& mesh, const DISP& displacement,
                                const PRESS& pressure )
{
    // pick an element
    const std::size_t numElements = std::distance( mesh.elementsBegin(), mesh.elementsEnd() );
    const std::size_t elemNum = (numElements +
                                 static_cast<std::size_t>(std::sqrt(numElements)) ) / 2;

    // geometry
    const typename MESH::Element* geomEp = mesh.elementPtr( elemNum );
    const typename base::Vector<MESH::Element::dim>::Type xi =
        base::constantVector<MESH::Element::dim>( 0. );

    const typename base::Geometry<typename MESH::Element>::result_type x =
        base::Geometry<typename MESH::Element>()( geomEp, xi );

    // displacement
    const typename DISP::Element* dispEp = displacement.elementPtr( elemNum );
    const typename base::Vector<DISP::DegreeOfFreedom::size>::Type uh =
        base::post::evaluateField( geomEp, dispEp, xi );
    
    // pressure
    const typename PRESS::Element* pressEp = pressure.elementPtr( elemNum );
    const typename base::Vector<PRESS::DegreeOfFreedom::size>::Type ph =
        base::post::evaluateField( geomEp, pressEp, xi );

    return std::make_pair( uh[1], ph[0] );
}
Exemple #2
0
        double errorComputation( const QUADRATURE& quadrature,
                                 const MESH&       mesh,
                                 const FIELD&      field,
                                 const typename
                                 base::post::ErrorNorm<
                                     typename MESH::Element,
                                     typename FIELD::Element,
                                     ORDER>::Reference& refSol )
        {
            typedef ErrorNorm<typename MESH::Element,typename FIELD::Element,
                              ORDER> Error;
            Error error( refSol );

            // compute for every element the error
            typename MESH::ElementPtrConstIter  elemIter  = mesh.elementsBegin();
            typename MESH::ElementPtrConstIter  elemLast  = mesh.elementsEnd();

            double errorSquared = 0.;
    
            for ( ; elemIter != elemLast; ++elemIter ) {

                // work around to get the ID of the field elements
                const std::size_t fieldElemID = detail_::getID( *elemIter );

                // get corresponding field element
                typename FIELD::Element* fieldElem =
                    field.elementPtr( fieldElemID );

                // Construct a field element pointer tuple 
                base::asmb::FieldElementPointerTuple<
                    typename MESH::Element*,
                    typename FIELD::Element*> fept( *elemIter, fieldElem );

                // apply quadrature
                quadrature.apply( error, fept, errorSquared );
            }
            
            // return the square root of the sum of the squares
            return  std::sqrt( errorSquared );
        }