예제 #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] );
}
예제 #2
0
void moveSurface( const MESH& mesh,
                  const FIELD& velocity,
                  typename base::cut::SurfaceMeshBinder<MESH>::SurfaceMesh &surfaceMesh,
                  const double dt, 
                  const double factor,
                  const typename MESH::Node::VecDim &centroid )
{
    typedef typename base::cut::SurfaceMeshBinder<MESH>::SurfaceMesh SurfaceMesh;
    typedef typename base::Vector<MESH::Node::dim>::Type             VecDim;
    
    // go through all elements of the surface mesh
    typename SurfaceMesh::ElementPtrIter eIter = surfaceMesh.elementsBegin();
    typename SurfaceMesh::ElementPtrIter eEnd  = surfaceMesh.elementsEnd();
    for ( ; eIter != eEnd; ++eIter )
    {
        const std::size_t elemID = (*eIter) -> getDomainID();
            
        const typename MESH::Element*  geomElem  = mesh.elementPtr( elemID );
        const typename FIELD::Element* velocElem = velocity.elementPtr( elemID );

        typename SurfaceMesh::Element::ParamIter   pIter = (*eIter) -> parametricBegin();
        typename SurfaceMesh::Element::ParamIter   pEnd  = (*eIter) -> parametricEnd();
        typename SurfaceMesh::Element::NodePtrIter nIter = (*eIter) -> nodesBegin();
        for ( ; pIter != pEnd; ++pIter, ++nIter ) {

            // evaluate time step times velocity at parameter coordinate
            const VecDim du = dt * 
                base::post::evaluateFieldHistory<0>( geomElem, velocElem, *pIter );

            // get old location
            VecDim x;
            (*nIter) -> getX( &(x[0]) );
            
            // add value to nodal coordinate
            //const VecDim xNew = x + du;
            const VecDim xNew = centroid + factor * (x-centroid) + du;
            
            (*nIter) -> setX( &(xNew[0]) );
        }
    }

    return;
}