예제 #1
0
파일: Exporter.hpp 프로젝트: nuraiman/lifev
void Exporter<MeshType>::exportPID( boost::shared_ptr<MeshType> mesh, boost::shared_ptr<Epetra_Comm> comm )
{
    // TODO: use FESpace M_spacemap for generality
    const ReferenceFE* refFEPtr;

    // Need a factory!!!!
    // @todo Need a factory!
    switch ( MeshType::S_geoDimensions )
    {
    case 3:
        refFEPtr = &feTetraP0;
        break;
    case 2:
        refFEPtr = &feTriaP0;
        break;
    case 1:
        refFEPtr = &feSegP0;
        break;
    default:
        ERROR_MSG ( "Dimension not supported " );
    }

    // Useless quadrature rule
    const QuadratureRule & dummyQR = quadRuleDummy;

    feSpacePtr_Type PID_FESpacePtr( new feSpace_Type( mesh, *refFEPtr, dummyQR, dummyQR, 1, comm ) );

    vectorPtr_Type PIDData ( new vector_Type ( PID_FESpacePtr->map() ) );

    for ( UInt iElem( 0 ); iElem < mesh->numElements(); ++iElem )
    {
        const ID globalElem = mesh->element(iElem).id();
        (*PIDData)[ globalElem ] = comm->MyPID();
    }

    addVariable( exporterData_Type::ScalarField,
                 "PID",
                 PID_FESpacePtr,
                 PIDData,
                 0,
                 exporterData_Type::SteadyRegime,
                 exporterData_Type::Cell );
}
예제 #2
0
void Exporter<MeshType>::exportPID ( meshPtr_Type& mesh, commPtr_Type& comm, bool const binaryFormat )
{
    // TODO: use FESpace M_spacemap for generality
    const ReferenceFE* refFEPtr;

    // Need a factory!!!!
    // @todo Need a factory!
    switch ( MeshType::S_geoDimensions )
    {
        case 3:
            refFEPtr = &feTetraP0;
            break;
        case 2:
            refFEPtr = &feTriaP0;
            break;
        case 1:
            refFEPtr = &feSegP0;
            break;
        default:
            ERROR_MSG ( "Dimension not supported " );
    }

    // Useless quadrature rule
    const QuadratureRule& dummyQR = quadRuleDummy;

    feSpacePtr_Type PID_FESpacePtr ( new feSpace_Type ( mesh, *refFEPtr, dummyQR, dummyQR, 1, comm ) );

    vectorPtr_Type PIDData ( new vector_Type ( PID_FESpacePtr->map() ) );
    *PIDData = 0.;

    std::string name;

    if ( binaryFormat )
    {
        name = "PIDbinary";
        for ( UInt iElem ( 0 ); iElem < mesh->numElements(); ++iElem )
        {
            const ID globalElem = mesh->element (iElem).id();
            Int PIDValue = 1;
            PIDValue <<= comm->MyPID();
            PIDData->sumIntoGlobalValues ( globalElem, PIDValue );
        }
        PIDData->globalAssemble();
    }
    else
    {
        name = "PID";
        for ( UInt iElem ( 0 ); iElem < mesh->numElements(); ++iElem )
        {
            const ID globalElem = mesh->element (iElem).id();
            (*PIDData) [ globalElem ] = comm->MyPID();
        }
    }

    addVariable ( exporterData_Type::ScalarField,
                  name,
                  PID_FESpacePtr,
                  PIDData,
                  0,
                  exporterData_Type::SteadyRegime,
                  exporterData_Type::Cell );
}