FSIOperator::solidBchandlerPtr_Type BCh_solid (FSIOperator& _oper)
{

    if (! _oper.isSolid() )
    {
        return FSIOperator::solidBchandlerPtr_Type();
    }

    // Boundary conditions for the solid displacement
    debugStream ( 10000 ) << "Boundary condition for the solid\n";
    FSIOperator::solidBchandlerPtr_Type BCh_solid ( new FSIOperator::solidBchandler_Type );

    BCFunctionBase bcf (fZero);


    BCh_solid->addBC ("Top",       3, Essential, Full, bcf,  3);
    BCh_solid->addBC ("Base",      2, Essential, Full, bcf,  3);
    //BCh_solid->addBC("EdgesIn",    20, EssentialVertices, Full, bcf,  3);

    std::vector<ID> zComp (1);
    zComp[0] = 3;
    //     debugStream(10000) << "SP harmonic extension\n";

    if (_oper.data().method() == "steklovPoincare")
    {
        //         steklovPoincare *SPOper = dynamic_cast<steklovPoincare *>(&_oper);
        //         SPOper->setSolidInterfaceDisp((LifeV::Vector&) _oper.displacement());

        //         BCh_solid->addBC("Interface", 1, Essential, Full,
        //                          *SPOper->bcvSolidInterfaceDisp(), 3);
    }
    else if (_oper.data().method() == "exactJacobian")
    {
        FSIExactJacobian*  EJOper = dynamic_cast<FSIExactJacobian*> (&_oper);
        EJOper->setFluidLoadToStructure (_oper.sigmaSolidRepeated() );

        BCh_solid->addBC ("Interface", SOLIDINTERFACE, Natural,   Full,
                          *EJOper->bcvFluidLoadToStructure(), 3);
    }
    else if (_oper.data().method() == "fixedPoint")
    {
        FSIFixedPoint* FPOper = dynamic_cast<FSIFixedPoint*> (&_oper);

        FPOper->setFluidLoadToStructure (_oper.sigmaSolidRepeated() );

        BCh_solid->addBC ("Interface", FLUIDINTERFACE, Natural, Full,
                          *FPOper->bcvFluidLoadToStructure(), 3);
    }

    return BCh_solid;
}
FSIOperator::fluidBchandlerPtr_Type BCh_fluidLin (FSIOperator& _oper)
{
    if (! _oper.isFluid() )
    {
        return FSIOperator::fluidBchandlerPtr_Type();
    }

    // Boundary conditions for the fluid velocity
    debugStream ( 10000 ) << "Boundary condition for the linearized fluid\n";
    FSIOperator::fluidBchandlerPtr_Type BCh_fluidLin ( new FSIOperator::fluidBchandler_Type );

    BCFunctionBase bcf (fZero);
    BCFunctionBase in_flow (u2);

#ifdef FLUX
    BCh_fluidLin->addBC ("InFlow",   2,       Flux, Normal, bcf,     3);
#else
    //BCh_fluidLin->addBC("InFlow",  2,  Natural,   Full, bcf,     3);
#endif

    BCh_fluidLin->addBC ("outFlow",  3,    Natural, Full, bcf,     3);
    //BCh_fluidLin->addBC("Edges",   20,  EssentialVertices, Full, bcf,     3);//this condition must be equal to the one

    //BCh_fluidLin->addBC("ainterface",  1,  Essential,   Full, bcf,     3);


    if (_oper.data().method() == "steklovPoincare")
    {
        //             steklovPoincare *SPOper = dynamic_cast<steklovPoincare *>(&_oper);
        //             SPOper->setDerHarmonicExtensionVelToFluid(_oper.dw());
        //             BCh_fluidLin->addBC("Wall"     , 1, Essential  , Full,
        //                                 *SPOper->bcvDerHarmonicExtensionVelToFluid(), 3);
    }
    if (_oper.data().method() == "exactJacobian")
    {
        FSIExactJacobian* EJOper = dynamic_cast<FSIExactJacobian*> (&_oper);
        EJOper->setDerHarmonicExtensionVelToFluid (_oper.derVeloFluidMesh() );
        BCh_fluidLin->addBC ("Interface", FLUIDINTERFACE, Essential  , Full,
                             *_oper.bcvDerHarmonicExtensionVelToFluid(), 3);
    }

    return BCh_fluidLin;
}
FSIOperator::fluidBchandlerPtr_Type BCh_fluid (FSIOperator& _oper)
{
    // Boundary conditions for the fluid velocity
    debugStream ( 10000 ) << "Boundary condition for the fluid\n";

    if (! _oper.isFluid() )
    {
        return FSIOperator::fluidBchandlerPtr_Type();
    }

    FSIOperator::fluidBchandlerPtr_Type BCh_fluid ( new FSIOperator::fluidBchandler_Type );

    BCFunctionBase bcf           (fZero);
    BCFunctionBase in_flow  (u2);
    //    BCFunctionBase in_flow_flux  (PhysFlux);
    BCFunctionBase out_flow      (fZero);


#ifdef FLUX
    BCh_fluid->addBC ("InFlow" ,   2,  Flux,  Normal, in_flow, 3);
#else
    BCh_fluid->addBC ("InFlow" , 2,  Natural,   Full, in_flow, 3);
#endif

    BCh_fluid->addBC ("OutFlow",   3,  Natural,   Full, out_flow, 3);
    //BCh_fluid->addBC("EdgesIn",  20, EssentialVertices, Full, bcf,  3);




    //    BCh_fluid->showMe();

    _oper.setStructureToFluid (_oper.veloFluidMesh() );
    // _oper.setHarmonicExtensionVelToFluid(_oper.veloFluidMesh());

    if (_oper.data().algorithm() == "RobinNeumann")
    {
        // _oper.setAlphafbcf(alpha); // if alpha is bcFunction define in ud_function.cpp

        //        assert(false);
        _oper.setSolidLoadToStructure ( _oper.minusSigmaFluidRepeated() );
        _oper.setStructureToFluidParameters();

        BCh_fluid->addBC ("Interface",   FLUIDINTERFACE,  Robin, Full,
                          *_oper.bcvStructureToFluid(),  3);
        BCh_fluid->addBC ("Interface",   FLUIDINTERFACE,  Natural, Full,
                          *_oper.bcvSolidLoadToStructure(), 3);
    }
    else
    {
        BCh_fluid->addBC ("Interface",   FLUIDINTERFACE,  Essential, Full,
                          *_oper.bcvStructureToFluid(),  3);
    }
    return BCh_fluid;
}
FSIOperator::fluidBchandlerPtr_Type BCh_harmonicExtension (FSIOperator& _oper)
{

    //     debugStream(10000) << "SP harmonic extension\n";
    //     fixedPoint *FPOper = dynamic_cast<fixedPoint *>(&_oper);

    //     FPOper->setStructureDispToHarmonicExtension(_oper.lambdaFluid());

    if (! _oper.isFluid() )
    {
        return FSIOperator::fluidBchandlerPtr_Type();
    }

    //    FPOper->bcvStructureDispToHarmonicExtension()->showMe(true,std::cout);

    // Boundary condition for the mesh
    debugStream ( 10000 ) << "Boundary condition for the harmonic extension\n";

    BCFunctionBase bcf (fZero);

    FSISolver::fluidBchandlerPtr_Type BCh_he (new FSIOperator::fluidBchandler_Type );



    BCh_he->addBC ("Edges", INOUTEDGE, Essential, Full, bcf,   3);
    BCh_he->addBC ("Edges", INEDGE, Essential, Full, bcf,   3);
    BCh_he->addBC ("Base",  INLET,     Essential, Full, bcf,   3);

    // BCh_he->addBC("Top",         3, Essential, Full, bcf,   3);
    // BCh_he->addBC("Base",        2, Essential, Full, bcf,   3);


    if (_oper.data().method() == "steklovPoincare")
    {
        //         debugStream(10000) << "SP harmonic extension\n";
        //         steklovPoincare *SPOper = dynamic_cast<steklovPoincare *>(&_oper);
        //         SPOper->setFluidInterfaceDisp((LifeV::Vector&) _oper.lambdaFluidRepeated());
        //         BCh_he->addBC("Interface", 1, Essential, Full,
        //                       *SPOper->bcvFluidInterfaceDisp(), 3);
    }
    else if (_oper.data().method() == "exactJacobian")
    {
        debugStream (10000) << "EJ harmonic extension\n";
        FSIExactJacobian* EJOper = dynamic_cast<FSIExactJacobian*> (&_oper);
        EJOper->setStructureDispToHarmonicExtension (_oper.lambdaFluidRepeated() );
        BCh_he->addBC ("Interface", FLUIDINTERFACE, Essential, Full,
                       *EJOper->bcvStructureDispToHarmonicExtension(), 3);
    }
    else if (_oper.data().method() == "fixedPoint")
    {
        debugStream (10000) << "FP harmonic extension\n";
        FSIFixedPoint* FPOper = dynamic_cast<FSIFixedPoint*> (&_oper);

        FPOper->setStructureDispToHarmonicExtension (_oper.lambdaFluidRepeated() );
        BCh_he->addBC ("Interface", FLUIDINTERFACE, Essential, Full,
                       *FPOper->bcvStructureDispToHarmonicExtension(), 3);
    }



    return BCh_he;
}