Beispiel #1
0
Var Interpreter::make_Callable( Vec<Var> lst, Var self ) {
    // remove doubles
    for( int i = 0; i < lst.size(); ++i )
        for( int j = i + 1; j < lst.size(); ++j )
            if ( lst[ i ].expr() == lst[ j ].expr() )
                lst.remove_unordered( j-- );

    //
    Expr surdef_list_data = cst( SI32( lst.size() ) );
    for( int i = 0; i < lst.size(); ++i )
        surdef_list_data = concat( surdef_list_data, pointer_on( lst[ i ].expr() ) );
    Var surdef_list( &type_SurdefList, surdef_list_data );

    //
    Var self_type = type_of( self ); // returns void if self is not defined

    // -> Callable[ surdef_list, self_type, parm_type ]
    Var *parms[ 3 ];
    parms[ 0 ] = &surdef_list;
    parms[ 1 ] = &self_type;
    parms[ 2 ] = &void_var;

    Var *callable_type = type_for( class_info( class_Callable ), parms );
    return Var( callable_type, self ? pointer_on( self.expr() ) : cst() ).add_ref( 0, self );
}
Beispiel #2
0
static inline void assemble(boost::shared_ptr<Mesh<Simplex<Dim>>>& mesh, double* vec) {
    boost::timer time;
    auto Vh = FunctionSpace<Mesh<Simplex<Dim>>, bases<Lagrange<Order, Type>>>::New(_mesh = mesh);
    vec[2] = time.elapsed();
    vec[1] = Vh->nDof();
    Environment::logMemoryUsage( "Assemble Laplacian Memory Usage: FunctionSpace" );
    time.restart();
    auto v = Vh->element();
    auto f = backend()->newVector(Vh);
    auto l = form1(_test = Vh, _vector = f);
    l = integrate(_range = elements(mesh), _expr = id(v));

    vec[4] = time.elapsed();
    Environment::logMemoryUsage( "Assemble Laplacian Memory Usage: Form1" );
    time.restart();
    auto u = Vh->element();
    auto A = backend()->newMatrix(Vh, Vh);
    vec[5] = time.elapsed();
    Environment::logMemoryUsage( "Assemble Laplacian Memory Usage: Matrix" );
    time.restart();
    auto a = form2(_trial = Vh, _test = Vh, _matrix = A);
    a = integrate(_range = elements(mesh), _expr = inner(gradt(u),grad(v)));
    a += on(_range = markedfaces(mesh, "Dirichlet"), _rhs = l, _element = u, _expr = cst(0.0));
    vec[3] = time.elapsed();
    auto mem = Environment::logMemoryUsage( "Assemble Laplacian Memory Usage: form2" );
    v[6] = mem.memory_usage/1e9;
    LOG(INFO) << "v[6] = " << v[6];
    cleanup();
}
 void setCstDensity(double d, std::string const& marker = "" )
 {
     std::string markerUsed = ( marker.empty() )? self_type::defaultMaterialName() : marker;
     M_cstDensity[markerUsed]=d;
     this->updateDensity( cst(d),marker);
     this->updateCinematicViscosity( marker );
 }
Beispiel #4
0
Expr Inst::_smp_slice( int nout, int beg, int end ) {
    if ( beg == 0 and end == size_in_bits( nout ) )
        return Expr( this, nout );
    if ( beg == end )
        return cst();
    return Expr();
}
Beispiel #5
0
GlobalVariables::GlobalVariables() {
    #define DECL_BT( T ) class_##T = new Class;
    #include "DeclBaseClass.h"
    #include "DeclParmClass.h"
    #undef DECL_BT

    #define DECL_BT( T ) type_##T = new Type_<T>( class_##T ); class_##T->types << type_##T; type_##T->aryth = true; type_##T->_len = 8 * sizeof( T ); type_##T->_ali = 8 * sizeof( T ); type_##T->_pod = 1;
    #include "DeclArytTypes.h"
    #undef DECL_BT

    #define DECL_BT( T ) type_##T = new Type( class_##T ); class_##T->types << type_##T;
    #define DONT_WANT_DeclArytTypes_h
    #include "DeclBaseClass.h"
    #undef DONT_WANT_DeclArytTypes_h
    #undef DECL_BT

    type_Type      ->_len = 64; type_Type      ->_ali = 32; type_Type      ->_pod = 1;
    type_Void      ->_len =  0; type_Void      ->_ali =  1; type_Void      ->_pod = 1;
    type_Error     ->_len =  0; type_Error     ->_ali =  1; type_Error     ->_pod = 1;
    type_Def       ->_len = 64; type_Def       ->_ali = 32; type_Def       ->_pod = 1;
    type_Class     ->_len = 64; type_Class     ->_ali = 32; type_Class     ->_pod = 1;
    type_SurdefList->_len = 64; type_SurdefList->_ali = 32; type_SurdefList->_pod = 1;
    type_Varargs   ->_len = 64; type_Varargs   ->_ali = 32; type_Varargs   ->_pod = 1;
    type_Bool      ->_len =  1; type_Bool      ->_ali = 1;

    type_ST  = sizeof( void * ) == 8 ? type_SI64 : type_SI32;
    ptr_size = 8 * sizeof( void * );

    main_parsing_context = 0;
    ip_snapshot = 0;
    pc = 0;

    main_scope[ "void" ] = Variable{ room( cst( type_Void, 0, 0 ) ) };
}
Beispiel #6
0
int main() {
    Expr tcs[] = { cst( 0 ), cst( 1 ) };
    PA( tcs[ 0 ] );
    PA( tcs[ 1 ] );
    PA( cst( 0 ) );
    PA( cst( 1 ) );

    PA( slice( cst( SI64( 0x01234567 ) ), 8, 32 ) );

    Expr gfe = cst( SI64( 0x656667 ) );
    PRINT( gfe );
    PRINT( gfe.cst_data() );
    PRINT( gfe.cst_data( 8 ) );

    Expr pgfe = pointer_on( gfe );
    PRINT( pgfe );
    PRINT( pgfe.vat_data() );
    PRINT( pgfe.vat_data( 8 ) );

    PRINT( slice( gfe, 8, 32 ) );
    PRINT( slice( gfe, 8, 32 ).cst_data() );
    PRINT( slice( gfe, 8, 32 ).cst_data( 8 ) );

    PRINT( pointer_on( slice( gfe, 8, 32 ) ) );
    PRINT( pointer_on( slice( gfe, 8, 32 ) ).vat_data() );

    PRINT( add( arch->bt_ptr(), pointer_on( gfe ), cst( 1l ) ) );
    PRINT( val_at( add( arch->bt_ptr(), pointer_on( gfe ), cst( 1l ) ), 16 ) );

//    Expr sa = syscall( cst( 6 ), 2, tcs, 32 ).ret;
//    Expr sb = syscall( cst( 6 ), 2, tcs, 32 ).ret;
//    PA( sa );
//    PA( sb );

//    Expr pa = pointer_on( tcs[ 0 ], 64 );
//    Expr pb = pointer_on( tcs[ 0 ], 64 );
//    PA( pa );
//    PA( pb );

//    PA( add( bt_SI32, cst( 10 ), cst( 20 ) ) );

//    PA( rand( 64 ) );

//    PA( slice( cst( SI64( 0x176548 ) ), 8, 32 ) );

//    Expr struct_expr = concat( cst( 0x17 ), rand( 32 ) );
//    PA( struct_expr );
//    PA( slice( struct_expr,  0, 16 ) );
//    PA( slice( struct_expr,  0, 32 ) );
//    PA( slice( struct_expr, 32, 64 ) );
//    PA( slice( struct_expr, 32, 63 ) );

//    PA( val_at( pointer_on( cst( 0x32 ), 64 ), 32 ) );
//    PA( pointer_on( val_at( cst( 0x32 ), 32 ), 32 ) );
}
std::shared_ptr<nokkhum::Camera> CameraFactory::getCamera(std::shared_ptr<nokkhum::CameraAttribute> cameraAttribute) {
    LOG(INFO) << "Build camera name: " << cameraAttribute->getName() << " url: " << cameraAttribute->getVideoUri();

    CameraStartTimer cst(100000); //100 s
    cst.start();

    std::shared_ptr<nokkhum::Camera> camera = std::make_shared<nokkhum::CvIpCamera> (cameraAttribute->getWidth(), cameraAttribute->getHeight(),
            cameraAttribute->getFps(), cameraAttribute->getVideoUri(), cameraAttribute->getUsername(),
            cameraAttribute->getPassword());

    cst.stop();
    //LOG(INFO) << "return camera";
    return camera;
}
void
PreconditionerBlockMS<space_type>::initAMS( void )
    {
        M_grad  = Grad( _domainSpace=M_Qh, _imageSpace=M_Vh);

        // This preconditioner is linked to that backend : the backend will
        // automatically use the preconditioner.
        auto prec = preconditioner(_pc=pcTypeConvertStrToEnum(soption(M_prefix_11+".pc-type")),
                                   _backend=backend(_name=M_prefix_11),
                                   _prefix=M_prefix_11,
                                   _matrix=M_11
                                  );
        prec->setMatrix(M_11);
        prec->attachAuxiliarySparseMatrix("G",M_grad.matPtr());
        if(boption(M_prefix_11+".useEdge"))
        {
            LOG(INFO) << "[ AMS ] : using SetConstantEdgeVector \n";
            ozz.on(_range=elements(M_Vh->mesh()),_expr=vec(cst(1),cst(0),cst(0)));
            zoz.on(_range=elements(M_Vh->mesh()),_expr=vec(cst(0),cst(1),cst(0)));
            zzo.on(_range=elements(M_Vh->mesh()),_expr=vec(cst(0),cst(0),cst(1)));
            *M_ozz = ozz; M_ozz->close();
            *M_zoz = zoz; M_zoz->close();
            *M_zzo = zzo; M_zzo->close();

            prec->attachAuxiliaryVector("Px",M_ozz);
            prec->attachAuxiliaryVector("Py",M_zoz);
            prec->attachAuxiliaryVector("Pz",M_zzo);
        }
        else
        {
            LOG(INFO) << "[ AMS ] : using SetCoordinates \n";
            X.on(_range=elements(M_Vh->mesh()),_expr=Px());
            Y.on(_range=elements(M_Vh->mesh()),_expr=Py());
            Z.on(_range=elements(M_Vh->mesh()),_expr=Pz());
            *M_X = X; M_X->close();
            *M_Y = Y; M_Y->close();
            *M_Z = Z; M_Z->close();
            prec->attachAuxiliaryVector("X",M_X);
            prec->attachAuxiliaryVector("Y",M_Y);
            prec->attachAuxiliaryVector("Z",M_Z);
        }
    }
Beispiel #9
0
/** Copy contents of another Wflograph.
 *  @param original is a weighted flograph to be copied to this object
 */
void Wflograph::copyFrom(const Wflograph& original) {
        if (N != original.n() || maxEdge < original.m()) {
                resize(original.n(), original.m()); 
        } else {
                reset();
        } 
        N = original.n();
        for (edge e = original.first(); e != 0; e = original.next(e)) {
                edge ee = join(original.left(e),original.right(e));
                cpy(ee) = original.cpy(e); cst(ee) = original.cst(e);
                flo(ee) = original.flo(e);
        }
        setSrcSnk(original.src(),original.snk());
        sortAdjLists();
}
Beispiel #10
0
Var *Interpreter::_make_varargs_type( const Vec<Var> &uv_args, const Vec<Var> &nv_args, const Vec<int> &nv_name, int off ) {
    // class VarargsItemEnd
    if ( off >= uv_args.size() + nv_args.size() )
        return &type_VarargsItemEnd;

    // class VarargsItemBeg[ data_type, data_name, next_type ]
    Var data_type = type_of( off >= uv_args.size() ? nv_args[ off - uv_args.size() ] : uv_args[ off ] );
    Var data_name( &type_SI32, cst( off >= uv_args.size() ? nv_name[ off - uv_args.size() ] : -1 ) );

    Var *parms[ 3 ];
    parms[ 0 ] = &data_type;
    parms[ 1 ] = &data_name;
    parms[ 2 ] = _make_varargs_type( uv_args, nv_args, nv_name, off + 1 );
    return type_for( class_info( class_VarargsItemBeg ), parms );
}
Beispiel #11
0
Var Interpreter::make_varargs_var( const Vec<Var> &uv_args, const Vec<Var> &nv_args, const Vec<int> &nv_name ) {
    Var *type = _make_varargs_type( uv_args, nv_args, nv_name, 0 );

    Expr data = cst();
    for( int i = 0; i < uv_args.size(); ++i )
        data = concat( data, pointer_on( uv_args[ i ].expr() ) );
    for( int i = 0; i < nv_args.size(); ++i )
        data = concat( data, pointer_on( nv_args[ i ].expr() ) );

    Var res( type, data );
    for( int i = 0, off = 0; i < uv_args.size(); off += bt_ST->size_in_bits(), ++i )
        res.add_ref( off, uv_args[ i ] );
    for( int i = 0, off = 0; i < nv_args.size(); off += bt_ST->size_in_bits(), ++i )
        res.add_ref( off, nv_args[ i ] );
    return res;
}
TEST(ChangeSalariedTransactionTest, PayrollTest) {
	int empid = 10;
	AddHourlyEmployee ht(empid, "Test11", "Home10", 50.00);
	ht.Execute();

	ChangeSalariedTransaction cst(empid, 1000.00);
	cst.Execute();

	Employee *e = ((DatabaseProxy *)getInstance())->GetEmployee(empid);
	EXPECT_TRUE(e != 0);

	SalariedClassification* ms = dynamic_cast<SalariedClassification*>(e->GetPaymentClassification());
	EXPECT_TRUE(ms != 0);

	EXPECT_TRUE(ms->GetSalary() == 1000.00);
}
Beispiel #13
0
Expr Ast_Def::_parse_in( ParsingContext &context ) const {
    std::set<String> res;
    if ( context.parent ) {
        std::set<String> avail;
        avail.insert( name );
        get_potentially_needed_ext_vars( res, avail );
    }

    //
    Def *c = new Def( this );

    //
    SI64 ptr = SI64( ST( c ) );
    Expr out = room( cst( ip->type_Def, 64, &ptr ) );
    out->flags |= Inst::SURDEF;
    if ( stat )
        out->flags |= Inst::STATIC;
    return context.reg_var( name, out, true );
}
Beispiel #14
0
void Interpreter::import( String filename ) {
    if ( already_imported( filename ) )
        return;

    // -> source data
    ReadFile r( filename.c_str() );
    if ( not r )
        return disp_error( "Impossible to open " + filename );

    // -> lexical data
    Lexer l( error_list );
    l.parse( r.data, filename.c_str() );
    if ( error_list )
        return;

    // -> binary stream
    IrWriter t( error_list );
    t.parse( l.root() );
    if ( error_list )
        return;

    // -> make a new SourceFile
    ST bin_size = t.size_of_binary_data();
    Vec<PI8> data( Size(), sizeof( SI32 ) + bin_size + sizeof( SI32 ) + filename.size() + 1 );
    reinterpret_cast<SI32 &>( data[ 0 ] ) = bin_size;
    t.copy_binary_data_to( data.ptr() + sizeof( SI32 ) );
    reinterpret_cast<SI32 &>( data[ sizeof( int ) + bin_size ] ) = filename.size();
    memcpy( data.ptr() + sizeof( SI32 ) + bin_size + sizeof( SI32 ), filename.c_str(), filename.size() + 1 );

    const Expr &sf = *sourcefiles.push_back( pointer_on( cst( data.ptr(), 0, 8 * data.size() ) ) );

    // -> virtual machine
    if ( not main_scope )
        main_scope = new Scope( 0 );
    main_scope->parse( sf, sf_info( sf )->tok_data );
}
Beispiel #15
0
Expr Ast_Class::_parse_in( ParsingContext &context ) const {
    std::set<String> res;
    if ( context.parent ) {
        std::set<String> avail;
        avail.insert( name );
        get_potentially_needed_ext_vars( res, avail );
    }

    //
    Class *c = 0;
    #define DECL_BT( T ) if ( name == #T ) { c = ip->class_##T; c->ast_item = this; }
    #include "../Ssa/DeclBaseClass.h"
    #include "../Ssa/DeclParmClass.h"
    #undef DECL_BT
    if ( not c )
        c = new Class( this );

    //
    SI64 ptr = SI64( ST( c ) );
    Expr val = cst( ip->type_Class, 64, &ptr );
    Expr out = room( val );
    out->flags |= Inst::SURDEF;
    return context.reg_var( name, out, true );
}
 void initFromMesh( mesh_ptrtype const& mesh, bool useExtendedDofTable )
 {
     super_type::initFromMesh(mesh,useExtendedDofTable);
     M_fieldDensity = this->dynamicViscositySpace()->elementPtr( cst( this->cstDensity() ) );
     M_fieldCinematicViscosity = this->dynamicViscositySpace()->elementPtr( cst( this->cstCinematicViscosity() ) );
 }
Beispiel #17
0
int
PreconditionerAS<space_type,coef_space_type>::applyInverse ( const vector_type& X /*R*/, vector_type& Y /*W*/) const
{
    /*
     * We solve Here P_v w = r
     * With P_v^-1 = diag(P_m)^-1 (=A)
     *              + P (\bar L + g \bar Q) P^t (=B)
     *              + C (L^-1) C^T (=C)
     */

    U = X;
    U.close();

    // solve equ (12)
    if ( this->type() == AS )
    {
        tic();

        *M_r = U;
        M_r->close();

        // step A : diag(Pm)^-1*r
        A->pointwiseDivide(*M_r,*M_diagPm);
        A->close();
        // s = P^t r
        M_Pt->multVector(M_r,M_s);

        // Impose boundary conditions on M_s
#if 1
        M_qh3_elt = *M_s;
        M_qh3_elt.close();
#if FEELPP_DIM == 3
        M_qh3_elt.on( _range=boundaryfaces( M_Qh3->mesh() ), _expr=vec(cst(0.), cst(0.), cst(0.)) );
#else
        M_qh3_elt.on( _range=boundaryfaces( M_Qh3->mesh() ), _expr=vec(cst(0.), cst(0.)) );
#endif
        *M_s = M_qh3_elt;
        M_s->close();
#endif
#if 1
        // Subvectors for M_s (per component) need to be updated
        M_s1 = M_s->createSubVector(M_Qh3_indices[0], true);
        M_s2 = M_s->createSubVector(M_Qh3_indices[1], true);
#if FEELPP_DIM == 3
        M_s3 = M_s->createSubVector(M_Qh3_indices[2], true);
#endif
#else 
        // s = [ s1, s2, s3 ]
        M_s->updateSubVector(M_s1, M_Qh3_indices[0]);
        M_s->updateSubVector(M_s2, M_Qh3_indices[1]);
#if FEELPP_DIM == 3
        M_s->updateSubVector(M_s3, M_Qh3_indices[2]);
#endif
#endif
        M_s->close();
        /*
         * hat(L) + g Q is a (Qh,Qh) matrix
         * [[ hat(L) + g Q, 0  ,     0   ],    [ y1 ]    [ s1 ]
         * [   0,   hat(L) + g Q,    0   ], *  [ y2 ] =  [ s2 ]
         * [   0,     0   , hat(L) + g Q ]]    [ y3 ]    [ s3 ]
         */
        M_lgqOp->applyInverse(M_s1,M_y1);
        M_lgqOp->applyInverse(M_s2,M_y2);
#if FEELPP_DIM == 3
        M_lgqOp->applyInverse(M_s3,M_y3);
#endif

        // y = [ y1, y2, y3 ]
        M_y->updateSubVector(M_y1, M_Qh3_indices[0]);
        M_y->updateSubVector(M_y2, M_Qh3_indices[1]);
#if FEELPP_DIM == 3
        M_y->updateSubVector(M_y3, M_Qh3_indices[2]);
#endif
        M_y->close();
        // step B : P*y
        M_P->multVector(M_y,B);

        // Impose boundary conditions on B = Py
#if 1
        M_vh_elt = *B;
        M_vh_elt.close();
#if FEELPP_DIM == 3
        M_vh_elt.on( _range=boundaryfaces( M_Qh3->mesh() ), _expr=vec(cst(0.), cst(0.), cst(0.)) );
#else
        M_vh_elt.on( _range=boundaryfaces( M_Qh3->mesh() ), _expr=vec(cst(0.), cst(0.)) );
#endif
        *B = M_vh_elt;
        B->close();
#endif
        // t = C^t r
        M_Ct->multVector(M_r,M_t);

        // Impose boundary conditions on M_t
#if 1
        M_qh_elt = *M_t;
        M_qh_elt.close();
        M_qh_elt.on( _range=boundaryfaces( M_Qh3->mesh() ), _expr=cst(0.) );
        *M_t = M_qh_elt;
        M_t->close();
#endif

        // 14.b : hat(L) z = t
        M_lOp->applyInverse(M_t,M_z);
        M_z->close();

        // step C : M_C z
        M_C->multVector(M_z,C);
        C->scale(1./M_g);

        // Impose boundary conditions on C = Cz
#if 1
        M_vh_elt = *C;
        M_vh_elt.close();
#if FEELPP_DIM == 3
        M_vh_elt.on( _range=boundaryfaces( M_Qh3->mesh() ), _expr=vec(cst(0.), cst(0.), cst(0.)) );
#else
        M_vh_elt.on( _range=boundaryfaces( M_Qh3->mesh() ), _expr=vec(cst(0.), cst(0.)) );
#endif
        *C = M_vh_elt;
        C->close();
#endif
        //if(M_g != 1.0)
        A->add(*C);
        A->add(*B);

        C->close();
        B->close();
        A->close();

        toc("assemble preconditioner AS",FLAGS_v>0);
        *M_uout = *A; // 15 : w = A + B + C
    }
    else if( this->type() == SIMPLE )
    {
        SimpleOp->applyInverse(X, Y);
        *M_uout = Y;
    }
    else
    {
        Y=U;
        *M_uout = Y;
    }
    M_uout->close();

    tic();
    Y=*M_uout;
    Y.close();
    toc("PreconditionerAS::applyInverse", FLAGS_v>0 );

    return 0;
}
Beispiel #18
0
    void assembleDivergence();

    void assembleGradient();

    void assembleSchurApp( double mu, double rho, double alpha = 0 );

#if 0
    BOOST_PARAMETER_MEMBER_FUNCTION( ( sparse_matrix_ptrtype ),
                                     update,
                                     tag,
                                     ( required
                                       ( matrix,*( boost::is_convertible<mpl::_,boost::shared_ptr<MatrixSparse> > ) )
                                       ( bc, *) )
                                     ( optional
                                       ( diffusion,*( boost::is_convertible<mpl::_,ExprBase> ), cst(M_mu) )
                                       ( density,*( boost::is_convertible<mpl::_,ExprBase> ), cst(M_rho) )
                                       ( convection,*( boost::is_convertible<mpl::_,ExprBase> ), zero<Dim>() )
                                       ( tn,  *( std::is_arithmetic<mpl::_> ), 0. )
                                       ( tn1,  *( std::is_arithmetic<mpl::_> ), 0. )
                                     ) )
    {
        this->setDiffusion( diffusion );
        this->setDensity( diffusion );
        this->setConvection( convection);
        this->setBC( bc );
        this->setTimes( std::pair<double,double>( tn1, tn) )
        this->update( matrix );
    }
#endif
CSonTime& CSonTime::operator =(LPCTSTR mstr)
{
	CSonTime cst(mstr);
	operator=(cst);
	return *this;
}
void run()
{

    Environment::changeRepository( boost::format( "/testsuite/feeldiscr/%1%/P%2%/" )
                                   % Environment::about().appName()
                                   % OrderPoly );


    /* change parameters below */
    const int nDim = 2;
    const int nOrderPoly = OrderPoly;
    const int nOrderGeo = 1;

    //------------------------------------------------------------------------------//

    typedef Mesh< Simplex<nDim, 1,nDim> > mesh_type;
    typedef Mesh< Simplex<nDim, 1,nDim> > mesh_bis_type;

    double meshSize = option("hsize").as<double>();
    double meshSizeBis = option("hsize-bis").as<double>();

    // mesh
    GeoTool::Node x1( 0,0 );
    GeoTool::Node x2( 4,1 );
    GeoTool::Rectangle Omega( meshSize,"Omega",x1,x2 );
    Omega.setMarker( _type="line",_name="Entree",_marker4=true );
    Omega.setMarker( _type="line",_name="Sortie",_marker2=true );
    Omega.setMarker( _type="line",_name="Paroi",_marker1=true,_marker3=true );
    Omega.setMarker( _type="surface",_name="Fluid",_markerAll=true );
    auto mesh = Omega.createMesh(_mesh=new mesh_type,_name="omega_"+ mesh_type::shape_type::name() );
    LOG(INFO) << "created mesh\n";

    GeoTool::Rectangle OmegaBis( meshSizeBis,"Omega",x1,x2 );
    OmegaBis.setMarker( _type="line",_name="Entree",_marker4=true );
    OmegaBis.setMarker( _type="line",_name="Sortie",_marker2=true );
    OmegaBis.setMarker( _type="line",_name="Paroi",_marker1=true,_marker3=true );
    OmegaBis.setMarker( _type="surface",_name="Fluid",_markerAll=true );
    auto meshBis = OmegaBis.createMesh(_mesh=new mesh_bis_type,_name="omegaBis_"+ mesh_type::shape_type::name() );

    //auto meshBis= mesh->createP1mesh();
    LOG(INFO) << "created meshBis\n";

    typedef Lagrange<nOrderPoly,Scalar,Continuous,PointSetFekete> basis_type;
    typedef FunctionSpace<mesh_type, bases<basis_type> > space_type;

    auto Xh = space_type::New( mesh );
    auto u = Xh->element();
    auto v = Xh->element();
    auto u2 = Xh->element();
    LOG(INFO) << "created space and elements\n";

    auto mybackend = backend();

    //--------------------------------------------------------------//

    auto A = mybackend->newMatrix( Xh, Xh );
    auto F = mybackend->newVector( Xh );
    auto pi = cst( M_PI );
    auto u_exact = cos( pi*Px() )*sin( pi*Py() );
    auto dudx = -pi*sin( pi*Px() )*sin( pi*Py() );
    auto dudy = pi*cos( pi*Px() )*cos( pi*Py() );
    auto grad_u_uexact = vec( dudx,dudy );
    auto lap = -2*pi*pi*cos( pi*Px() )*sin( pi*Py() );
    //auto lap = -pi*pi*cos(pi*Px())*sin(pi*Py())
    //    -pi*pi*cos(pi*Px())*sin(pi*Py());
    LOG(INFO) << "created exact data and matrix/vector\n";

    auto f = -lap;//cst(1.);
    double gammabc=10;

    // assemblage
    form2( Xh, Xh, A, _init=true ) =
        integrate( elements( mesh ), //_Q<15>(),
                   + gradt( u )*trans( grad( v ) ) );

    form2( Xh, Xh, A ) +=
        integrate( boundaryfaces( mesh ),
                   - gradt( u )*N()*id( v )
                   + gammabc*idt( u )*id( v )/hFace() );

    form1( Xh, F, _init=true ) =
        integrate( elements( mesh ), // _Q<10>(),
                   trans( f )*id( v ) );

    form1( Xh, F ) +=
        integrate( boundaryfaces( mesh ),
                   + gammabc*u_exact*id( v )/hFace() );

    LOG(INFO) << "A,F assembled\n";

    //form2( Xh, Xh, A ) +=
    //    on( boundaryfaces(mesh) , u, F, u_exact );

    // solve system
    mybackend->solve( A,u,F );
    LOG(INFO) << "A u = F solved\n";
    //--------------------------------------------------------------//

    auto a2 = form2( _test=Xh, _trial=Xh );
    auto f2 = form1( _test=Xh );
    LOG(INFO) << "created form2 a2 and form1 F2\n";

    // assemblage

    a2 = integrate( elements( meshBis ),
                    + gradt( u2 )*trans( grad( v ) ),
                    _Q<10>() );
    LOG(INFO) << "a2 grad.grad term\n";
    a2 += integrate( boundaryfaces( meshBis ),
                     - gradt( u2 )*N()*id( v )
                     + gammabc*idt( u2 )*id( v )/hFace(),
                     _Q<10>() );
    LOG(INFO) << "a2 weak dirichlet terms\n";

    f2 = integrate( elements( meshBis ),
                    trans( f )*id( v ),
                    _Q<10>() );
    LOG(INFO) << "f2 source term\n";
    f2 += integrate( boundaryfaces( meshBis ),
                     + gammabc*u_exact*id( v )/hFace(),
                     _Q<10>() );
    LOG(INFO) << "f2 dirichlet terms\n";

    LOG(INFO) << "a2,f2 assembled\n";

    //form2( Xh, Xh, A2 ) +=
    //     on( boundaryfaces(mesh) , u2, F2, u_exact );



#if 0

    for ( size_type i = 0 ; i< F->size() ; ++i )
    {
        auto errOnF = std::abs( ( *F )( i )-( *F2 )( i ) );

        if ( errOnF > 1e-8 )
            std::cout << "\nerrOnF : " << errOnF;
    }

    std::cout << "\nFin errOnF !!!!\n";
#endif

    // solve system
    a2.solve( _rhs=f2, _solution=u2 );


    auto diff = std::sqrt( integrate( elements( mesh ), ( idv( u )-idv( u2 ) )*( idv( u )-idv( u2 ) ) ).evaluate()( 0,0 ) );
#if 0
    auto int1 = integrate( elements( mesh ), abs( idv( u ) ) ).evaluate()( 0,0 );
    auto int2 = integrate( elements( mesh ), abs( idv( u2 ) ) ).evaluate()( 0,0 );

    std::cout << "\nThe diff : " << diff
              << " int1 :" << int1
              << " int2 :" << int2
              << "\n";
#endif
#if USE_BOOST_TEST
    BOOST_CHECK_SMALL( diff,1e-2 );
#endif


    //--------------------------------------------------------------//

    if ( option("exporter.export").as<bool>() )
    {
        // export
        auto ex = exporter( _mesh=mesh );
        ex->add( "u", u );
        ex->add( "ubis", u2 );
        ex->save();
    }
}
Beispiel #21
0
Expr GlobalVariables::void_var() {
    return room( cst( type_Void, 0, 0 ) );
}
Beispiel #22
0
    ( optional
      ( quad,   *, typename vf::detail::integrate_type<Args>::_quad_type() )
      ( geomap, *, GeomapStrategyType::GEOMAP_OPT )
      ( quad1,   *, typename vf::detail::integrate_type<Args>::_quad1_type() )
      ( use_tbb,   ( bool ), false )
      ( use_harts,   ( bool ), false )
      ( grainsize,   ( int ), 100 )
      ( partitioner,   *, "auto" )
      ( verbose,   ( bool ), false )
      ( parallel,   *( boost::is_integral<mpl::_> ), 1 )
      ( worldcomm,       (WorldComm), Environment::worldComm() )
    )
)
{
    double meas = integrate( _range=range, _expr=cst(1.0), _quad=quad, _quad1=quad1, _geomap=geomap,
                             _use_tbb=use_tbb, _use_harts=use_harts, _grainsize=grainsize,
                             _partitioner=partitioner, _verbose=verbose ).evaluate( parallel,worldcomm )( 0, 0 );
    DLOG(INFO) << "[mean] nelements = " << nelements(range) << "\n";
    DLOG(INFO) << "[mean] measure = " << meas << "\n";
    CHECK( math::abs(meas) > 1e-13 ) << "Invalid domain measure : " << meas << ", domain range: " << nelements( range ) << "\n";
    auto eint = integrate( _range=range, _expr=expr, _quad=quad, _geomap=geomap,
                           _quad1=quad1, _use_tbb=use_tbb, _use_harts=use_harts, _grainsize=grainsize,
                           _partitioner=partitioner, _verbose=verbose ).evaluate( parallel,worldcomm );
    DLOG(INFO) << "[mean] integral = " << eint << "\n";
    DLOG(INFO) << "[mean] mean = " << eint/meas << "\n";
    return eint/meas;
}

}
#endif // FEELPP_VF_MEAN_HPP
Beispiel #23
0
void
NavierStokes::run()
{
    this->init();

    auto U = Xh->element( "(u,p)" );
    auto V = Xh->element( "(u,q)" );
    auto u = U.element<0>( "u" );
    auto v = V.element<0>( "u" );
    auto p = U.element<1>( "p" );
    auto q = V.element<1>( "p" );
#if defined( FEELPP_USE_LM )
    auto lambda = U.element<2>();
    auto nu = V.element<2>();
#endif
    //# endmarker4 #

    LOG(INFO) << "[dof]         number of dof: " << Xh->nDof() << "\n";
    LOG(INFO) << "[dof]    number of dof/proc: " << Xh->nLocalDof() << "\n";
    LOG(INFO) << "[dof]      number of dof(U): " << Xh->functionSpace<0>()->nDof()  << "\n";
    LOG(INFO) << "[dof] number of dof/proc(U): " << Xh->functionSpace<0>()->nLocalDof()  << "\n";
    LOG(INFO) << "[dof]      number of dof(P): " << Xh->functionSpace<1>()->nDof()  << "\n";
    LOG(INFO) << "[dof] number of dof/proc(P): " << Xh->functionSpace<1>()->nLocalDof()  << "\n";

    LOG(INFO) << "Data Summary:\n";
    LOG(INFO) << "   hsize = " << meshSize << "\n";
    LOG(INFO) << "  export = " << this->vm().count( "export" ) << "\n";
    LOG(INFO) << "      mu = " << mu << "\n";
    LOG(INFO) << " bccoeff = " << penalbc << "\n";




    //# marker5 #
    auto deft = gradt( u )+trans(gradt(u));
    auto def = grad( v )+trans(grad(v));
    //# endmarker5 #

    //# marker6 #
    // total stress tensor (trial)
    auto SigmaNt = -idt( p )*N()+mu*deft*N();

    // total stress tensor (test)
    auto SigmaN = -id( p )*N()+mu*def*N();
    //# endmarker6 #

    auto F = M_backend->newVector( Xh );
    auto D =  M_backend->newMatrix( Xh, Xh );

    // right hand side
    auto ns_rhs = form1( _test=Xh, _vector=F );


    LOG(INFO) << "[navier-stokes] vector local assembly done\n";

    // construction of the BDF
    auto bdfns=bdf(_space=Xh);

    /*
     * Construction of the left hand side
     */

    auto navierstokes = form2( _test=Xh, _trial=Xh, _matrix=D );
    mpi::timer chrono;
    navierstokes += integrate( elements( mesh ), mu*inner( deft,def )+ trans(idt( u ))*id( v )*bdfns->polyDerivCoefficient( 0 ) );
    LOG(INFO) << "mu*inner(deft,def)+(bdf(u),v): " << chrono.elapsed() << "\n";
    chrono.restart();
    navierstokes +=integrate( elements( mesh ), - div( v )*idt( p ) + divt( u )*id( q ) );
    LOG(INFO) << "(u,p): " << chrono.elapsed() << "\n";
    chrono.restart();
#if defined( FEELPP_USE_LM )
    navierstokes +=integrate( elements( mesh ), id( q )*idt( lambda ) + idt( p )*id( nu ) );
    LOG(INFO) << "(lambda,p): " << chrono.elapsed() << "\n";
    chrono.restart();
#endif

    std::for_each( inflow_conditions.begin(), inflow_conditions.end(),
                   [&]( BoundaryCondition const&  bc )
                   {
                       // right hand side
                       ns_rhs += integrate( markedfaces( mesh, bc.marker() ), inner( idf(&bc,BoundaryCondition::operator()),-SigmaN+penalbc*id( v )/hFace() ) );

                       navierstokes +=integrate( boundaryfaces( mesh ), -inner( SigmaNt,id( v ) ) );
                       navierstokes +=integrate( boundaryfaces( mesh ), -inner( SigmaN,idt( u ) ) );
                       navierstokes +=integrate( boundaryfaces( mesh ), +penalbc*inner( idt( u ),id( v ) )/hFace() );
                   });
    std::for_each( wall_conditions.begin(), wall_conditions.end(),
                   [&]( BoundaryCondition const&  bc )
                   {
                       navierstokes +=integrate( boundaryfaces( mesh ), -inner( SigmaNt,id( v ) ) );
                       navierstokes +=integrate( boundaryfaces( mesh ), -inner( SigmaN,idt( u ) ) );
                       navierstokes +=integrate( boundaryfaces( mesh ), +penalbc*inner( idt( u ),id( v ) )/hFace() );
                   });
    std::for_each( outflow_conditions.begin(), outflow_conditions.end(),
                   [&]( BoundaryCondition const&  bc )
                   {
                       ns_rhs += integrate( markedfaces( mesh, bc.marker() ), inner( idf(&bc,BoundaryCondition::operator()),N() ) );
                   });

    LOG(INFO) << "bc: " << chrono.elapsed() << "\n";
    chrono.restart();

    u = vf::project( _space=Xh->functionSpace<0>(), _expr=cst(0.) );
    p = vf::project( _space=Xh->functionSpace<1>(), _expr=cst(0.) );

    M_bdf->initialize( U );

    for( bdfns->start(); bdfns->isFinished(); bdfns->next() )
    {
        // add time dependent terms
        auto bdf_poly = bdfns->polyDeriv();
        form1( _test=Xh, _vector=Ft ) =
            integrate( _range=elements(mesh), _expr=trans(idv( bdf_poly ))*id( v ) );
        // add convective terms
        form1( _test=Xh, _vector=Ft ) +=
            integrate( _range=elements(mesh), _expr=trans(gradv(u)*idv( u ))*id(v) );
        // add contrib from time independent terms
        Ft->add( 1., F );

        // add time stepping terms from BDF to right hand side
        backend()->solve( _matrix=D, _solution=U, _rhs=Ft );

        this->exportResults( bdfns->time(), U );
    }





} // NavierNavierstokes::run
Beispiel #24
0
Expr phi( Expr cond, Expr ok, Expr ko ) {
    // known value ?
    bool v;
    if ( cond.get_val( v ) )
        return v ? ok : ko;

    // the same value in all the cases ?
    if ( ok == ko )
        return ok;

    // if ok or ko are undefined
    // if ( ok.inst->undefined() ) return ko;
    // if ( ko.inst->undefined() ) return ok;


    // phi( not c, a, b ) -> phi( c, b, a )
    if ( cond.inst->inst_id() == Inst::Id_Op_not )
        return phi( cond.inst->inp_expr( 0 ), ko, ok );

    // phi( c, true, false ) -> c
    // phi( c, false, true ) -> not c
    if ( ok.size_in_bits() == 1 and ko.size_in_bits() == 1 ) {
        bool va, vb;
        if ( ok.get_val( va ) and ko.get_val( vb ) ) {
            if ( va and not vb )
                return cond;
            if ( vb and not va )
                return op_not( bt_Bool, cond );
        }
    }

    // phi( c, b, c )
    if ( cond == ko )
        return phi( cond, ok, cst( false ) );

    // phi( c, c, b )
    if ( cond == ok )
        return phi( cond, cst( true ), ko );


    // if ok is a phi node tree which contain cond in the conditions
    if ( Expr nok = phi_with_cond( cond, 1, ok ) )
        return phi( cond, nok, ko );

    // if ko is a phi node tree which contain cond in the conditions
    if ( Expr nko = phi_with_cond( cond, 0, ko ) )
        return phi( cond, ok, nko );

    // phi( cond, a, phi( cond,  ) )

    // cond = bool( ... )
    //if ( cond.inst->inst_id() == Inst::Id_Conv and cond.inst->out_bt( 0 ) == bt_Bool )
    //    cond = cond.inst->inp_expr( 0 );

    // else, create a new inst
    Phi *res = new Phi;
    res->inp_repl( 0, cond );
    res->inp_repl( 1, ok );
    res->inp_repl( 2, ko );
    return Expr( Inst::factorized( res ), 0 );
}
void
TestInterpolationHCurl3D::testInterpolation( std::string one_element_mesh )
{
    //auto myexpr = unitX() + unitY() + unitZ() ; //(1,1,1)
    auto myexpr = vec( cst(1.), cst(1.), cst(1.));

    // one element mesh
    auto mesh_name = one_element_mesh + ".msh"; //create the mesh and load it
    fs::path mesh_path( mesh_name );

    mesh_ptrtype oneelement_mesh = loadMesh( _mesh=new mesh_type,
                                             _filename=mesh_name);

    // refined mesh (export)
    auto refine_level = std::floor(1 - math::log( 0.1 )); //Deduce refine level from meshSize (option)
    mesh_ptrtype mesh = loadMesh( _mesh=new mesh_type,
                                  _filename=mesh_name,
                                  _refine=( int )refine_level);

    space_ptrtype Xh = space_type::New( oneelement_mesh );

    std::vector<std::string> faces = {"yzFace","xyzFace","xyFace"};
    std::vector<std::string> edges = {"zAxis","yAxis","yzAxis","xyAxis","xzAxis","xAxis"};

    element_type U_h_int = Xh->element();
    element_type U_h_on = Xh->element();
    element_type U_h_on_boundary = Xh->element();

    submesh1d_ptrtype edgeMesh( new submesh1d_type );
    edgeMesh = createSubmesh(oneelement_mesh, boundaryedges(oneelement_mesh) ); //submesh of edges

    // Tangents on ref element
    auto t0 = vec(cst(0.),cst(0.),cst(-2.));
    auto t1 = vec(cst(0.),cst(2.),cst(0.));
    auto t2 = vec(cst(0.),cst(-2.),cst(2.));
    auto t3 = vec(cst(2.),cst(-2.),cst(0.));
    auto t4 = vec(cst(2.),cst(0.),cst(-2.));
    auto t5 = vec(cst(2.),cst(0.),cst(0.));

    // Jacobian of geometrical transforms
    std::string jac;
    if(mesh_path.stem().string() == "one-elt-ref-3d" || mesh_path.stem().string() == "one-elt-real-h**o-3d" )
        jac = "{1,0,0,0,1,0,0,0,1}:x:y:z";
    else if(mesh_path.stem().string() == "one-elt-real-rotx" )
        jac = "{1,0,0,0,0,-1,0,1,0}:x:y:z";
    else if(mesh_path.stem().string() == "one-elt-real-roty" )
        jac = "{0,0,1,0,1,0,-1,0,0}:x:y:z";
    else if(mesh_path.stem().string() == "one-elt-real-rotz" )
        jac = "{0,-1,0,1,0,0,0,0,1}:x:y:z";

    U_h_int(0) = integrate( markedelements(edgeMesh, edges[0]), trans(expr<3,3>(jac)*t0)*myexpr ).evaluate()(0,0);
    U_h_int(1) = integrate( markedelements(edgeMesh, edges[1]), trans(expr<3,3>(jac)*t1)*myexpr ).evaluate()(0,0);
    U_h_int(2) = integrate( markedelements(edgeMesh, edges[2]), trans(expr<3,3>(jac)*t2)*myexpr ).evaluate()(0,0);
    U_h_int(3) = integrate( markedelements(edgeMesh, edges[3]), trans(expr<3,3>(jac)*t3)*myexpr ).evaluate()(0,0);
    U_h_int(4) = integrate( markedelements(edgeMesh, edges[4]), trans(expr<3,3>(jac)*t4)*myexpr ).evaluate()(0,0);
    U_h_int(5) = integrate( markedelements(edgeMesh, edges[5]), trans(expr<3,3>(jac)*t5)*myexpr ).evaluate()(0,0);

    for(int i=0; i<edges.size(); i++)
        {
            double edgeLength = integrate( markedelements(edgeMesh, edges[i]), cst(1.) ).evaluate()(0,0);
            U_h_int(i) /= edgeLength;
        }

#if 0 //Doesn't work for now
    for(int i=0; i<Xh->nLocalDof(); i++)
        {
            CHECK( edgeMesh->hasMarkers( {edges[i]} ) );
            U_h_int(i) = integrate( markedelements(edgeMesh, edges[i]), trans( print(T(),"T=") )*myexpr ).evaluate()(0,0);
            std::cout << "U_h_int(" << i << ")= " << U_h_int(i) << std::endl;
        }
#endif

    // nedelec interpolant using on keyword
    // interpolate on element
    U_h_on.zero();
    U_h_on.on(_range=elements(oneelement_mesh), _expr=myexpr);
    U_h_on_boundary.on(_range=boundaryfaces(oneelement_mesh), _expr=myexpr);

    auto exporter_proj = exporter( _mesh=mesh, _name=( boost::format( "%1%" ) % this->about().appName() ).str() );
    exporter_proj->step( 0 )->add( "U_interpolation_handly_"+mesh_path.stem().string(), U_h_int );
    exporter_proj->step( 0 )->add( "U_interpolation_on_"+mesh_path.stem().string(), U_h_on );
    exporter_proj->save();

    // print coefficient only for reference element
    U_h_int.printMatlab( "U_h_int_" + mesh_path.stem().string() + ".m" );
    U_h_on.printMatlab( "U_h_on_" + mesh_path.stem().string() + ".m" );
    U_h_on_boundary.printMatlab( "U_h_on_boundary_" + mesh_path.stem().string() + ".m" );

    //L2 norm of error
    auto error = vf::project(_space=Xh, _range=elements(oneelement_mesh), _expr=idv(U_h_int) - idv(U_h_on) );
    double L2error = error.l2Norm();
    std::cout << "L2 error (elements) = " << L2error << std::endl;

    auto error_boundary = vf::project(_space=Xh, _range=elements(oneelement_mesh), _expr=idv(U_h_int) - idv(U_h_on_boundary) );
    double L2error_boundary = error_boundary.l2Norm();
    std::cout << "L2 error (boundary) = " << L2error_boundary << std::endl;
    BOOST_CHECK_SMALL( L2error_boundary - L2error, 1e-13 );
}
Beispiel #26
0
Expr Interpreter::cst_ptr( SI64 val ) {
    if ( arch->ptr_size == 32 )
        return cst( SI32( val ) );
    return cst( val );
}
 void initFromSpace( space_ptrtype const& space )
 {
     super_type::initFromSpace(space);
     M_fieldDensity = this->dynamicViscositySpace()->elementPtr( cst( this->cstDensity() ) );
     M_fieldCinematicViscosity = this->dynamicViscositySpace()->elementPtr( cst( this->cstCinematicViscosity() ) );
 }
Beispiel #28
0
Expr Var::expr() const {
    return data and data->ptr ? data->ptr->expr() : cst( Vec<PI8>() );
}
//#include <cplex.h>
//
void CliquePartitionProblem::cps(std::string const &fileName,
                                 ILpSolver & solver) const {
  int const n(nV());
//
  char const binary(solver.binary());
  char const continuous(solver.continuous());
  char const leq(solver.leq());
  char const eq(solver.eq());
  char const geq(solver.geq());
  //
  ColumnBuffer columnBuffer(continuous);
  DoubleVector denseCost(n * (n - 1), 0);
  for (auto const & e : _costs) {
    int const u(e._i);
    int const v(e._j);
    int const id(ijtok(n, u, v));
    denseCost[id] = e._v;
  }
  //cpCost(denseCost);
  //IntVector index(n * (n - 1));
  int nCols(0);
  for (int u(0); u < nV(); ++u) {
    for (int v(u + 1); v < nV(); ++v, ++nCols) {
      int const id(ijtok(n, u, v));

      columnBuffer.add(denseCost[id], binary, 0, 1, GetStr("x_", u, "_", v));
      if (id != nCols) {
        std::cout << "wrong numbering" << std::endl;
        std::exit(-1);
      }
    }
  }
  columnBuffer.add(cst(), continuous, 1, 1, "CST");
  solver.add(columnBuffer);

  RowBuffer rowBuffer;
  double const eps(1e-20);
  for (int u(0); u < nV(); ++u) {
    for (int v(u + 1); v < nV(); ++v) {
      int const uv(ijtok(n, u, v));
      for (int w(v + 1); w < nV(); ++w) {
        int const uw(ijtok(n, u, w));
        int const vw(ijtok(n, v, w));
        if (denseCost[uv] > -eps || denseCost[vw] > -eps) {
          rowBuffer.add(1, leq, GetStr("T_", u, "_", v, "_", w));
          rowBuffer.add(uv, 1);
          rowBuffer.add(vw, 1);
          rowBuffer.add(uw, -1);
        }
        if (denseCost[vw] > -eps || denseCost[uw] > -eps) {
          rowBuffer.add(1, leq, GetStr("T_", v, "_", w, "_", u));
          rowBuffer.add(vw, 1);
          rowBuffer.add(uw, 1);
          rowBuffer.add(uv, -1);
        }
        if (denseCost[uw] > -eps || denseCost[uv] > -eps) {
          rowBuffer.add(1, leq, GetStr("T_", w, "_", u, "_", v));
          rowBuffer.add(uw, 1);
          rowBuffer.add(uv, 1);
          rowBuffer.add(vw, -1);
        }
      }
    }
  }
  solver.add(rowBuffer);
  solver.maximize();
  solver.write(fileName + ".lp");

  solver.run();

  double objval = solver.objValue();
  std::cout << "optimal solution value  : " << std::setprecision(20) << objval << std::endl;

}
Beispiel #30
0
// <int Order_s, int Order_p, int Order_t>
void Convection ::initLinearOperator2( sparse_matrix_ptrtype& L )
{
    boost::timer ti;
    LOG(INFO) << "[initLinearOperator2] start\n";

    mesh_ptrtype mesh = Xh->mesh();
    element_type U( Xh, "u" );
    element_type Un( Xh, "un" );
    element_type V( Xh, "v" );
    element_0_type u = U. element<0>(); // fonction vitesse
    element_0_type un = Un. element<0>(); // fonction vitesse
    element_0_type v = V. element<0>(); // fonction test vitesse
    element_1_type p = U. element<1>(); // fonction pression
    element_1_type pn = Un. element<1>(); // fonction pression
    element_1_type q = V. element<1>(); // fonction test pression
    element_2_type t = U. element<2>(); // fonction temperature
    element_2_type tn = Un. element<2>(); // fonction temperature
    element_2_type s = V. element<2>(); // fonction test temperature
#if defined( FEELPP_USE_LM )
    element_3_type xi = U. element<3>(); // fonction multipliers
    element_3_type eta = V. element<3>(); // fonction test multipliers
#endif

    double gr= M_current_Grashofs;
    double sqgr( 1/math::sqrt( gr ) );
    double pr = M_current_Prandtl;
    double sqgrpr( 1/( pr*math::sqrt( gr ) ) );
    double gamma( this->vm()["penalbc"]. as<double>() );

    double k=this->vm()["k"]. as<double>();
    double nu=this->vm()["nu"]. as<double>();
    double rho=this->vm()["rho"]. as<double>();
    //double dt=this->vm()["dt"]. as<double>();
    int adim=this->vm()["adim"]. as<int>();
    int weakdir=this->vm()["weakdir"]. as<int>();
    //choix de la valeur des paramètres dimensionnés ou adimensionnés
    double a=0.0,b=0.0,c=0.0;
    double pC=1;

    if ( adim == 0 ) pC = this->vm()["pC"]. as<double>();

    if ( adim==1 )
    {
        a=1;
        b=sqgr;
        c=sqgrpr;
    }

    else
    {
        a=rho;
        b=nu;
        c=k;
    }

    double expansion = 1;

    if ( adim == 0 ) expansion=3.7e-3;

    auto bf = form2( _test=Xh, _trial=Xh, _matrix=L );
    // Temperature
#if CONVECTION_DIM==2
    // buyoancy forces c(theta,v)
    bf +=integrate( _range=elements( mesh ),
                    _expr=-expansion*idt( t )*( trans( vec( constant( 0. ),constant( 1.0 ) ) )*id( v ) ) );
#else
    bf +=integrate( _range=elements( mesh ),
                    _expr=-expansion*idt( t )*( trans( vec( cst(0.), constant( 0. ),constant( 1.0 ) ) )*id( v ) ) );
#endif

    LOG(INFO) << "[initLinearOperator] temperature Force terms done\n";
    // heat conduction/diffusion: e(beta1,theta,chi)+f(theta,chi)
    bf  += integrate( _range=elements( mesh ),
                      _expr=cst( c )*gradt( t )*trans( grad( s ) ) );
    LOG(INFO) << "[initLinearOperator] Temperature Diffusion terms done\n";

    if ( weakdir == 1 )
    {
        // weak Dirichlet on temperature (T=0|left wall)
        bf  += integrate ( markedfaces( mesh, "Tfixed"  ),
                           - gradt( t )*N()*id( s )*cst_ref( sqgrpr ) );
        bf  += integrate ( markedfaces( mesh, "Tfixed"  ),
                           - grad( s )*N()*idt( t )*cst_ref( sqgrpr ) );
        bf  += integrate ( markedfaces( mesh, "Tfixed"  ),
                           gamma*idt( t )*id( s )/hFace() );
    }

    LOG(INFO) << "[initLinearOperator2] done in " << ti.elapsed() << "s\n";
}