示例#1
0
DrivenCavity<Dim>::DrivenCavity( )
    :
    super( ),
    Re(      doption("Re") ),
    penalbc( doption("bccoeff") ),
    exporter( Exporter<mesh_type>::New( this->vm(), this->about().appName() ) )
{

}
示例#2
0
void
runApplicationSolid()
{
    typedef FeelModels::SolidMechanics< Simplex<FEELPP_DIM,1>,
                                        Lagrange<OrderDisp, Vectorial,Continuous,PointSetFekete> > model_type;
    auto SM = model_type::New("solid");

    if ( SM->isStationary() )
    {
        bool algoQuasiStatic = boption(_name="solve-quasi-static");
        if ( !algoQuasiStatic )
        {
            SM->init();
            SM->printAndSaveInfo();
            SM->solve();
            SM->exportResults();
        }
        else
        {
            SM->init();
            SM->printAndSaveInfo();

            std::string variableSymbol = soption(_name="solve-quasi-static.variable-symbol");
            CHECK( SM->modelProperties().parameters().find(variableSymbol) != SM->modelProperties().parameters().end() ) << "not find symbol " << variableSymbol;
            double valueFinal = SM->modelProperties().parameters().find(variableSymbol)->second.value();
            double valueInitial = doption(_name="solve-quasi-static.variable-initial");
            double valueStep = doption(_name="solve-quasi-static.variable-step");
            int cptNeed = std::abs(valueFinal-valueInitial)/valueStep;
            double currentParam = valueInitial;

            std::string namefileVariableParameters = (fs::path(SM->rootRepository()) / fs::path("paramters-done.data")).string();

            std::string saveType = soption(_name="solve-quasi-static.save.file-format");

            int cptCurrent=1;
            if ( SM->doRestart() )
            {
                std::ifstream fileParameter(namefileVariableParameters.c_str());
                while ( ! fileParameter.eof() ) { fileParameter >> cptCurrent >> currentParam; }
                fileParameter.close();

                SM->fieldDisplacement().load(_path=SM->rootRepository()+"/"+(boost::format("uSol.field-%1%") %cptCurrent ).str(),
                                             _type=saveType );
                if ( SM->useDisplacementPressureFormulation() )
                    SM->fieldPressure().load(_path=SM->rootRepository()+"/"+(boost::format("pSol.field-%1%") %cptCurrent ).str(),
                                             _type=saveType );

                SM->restartExporters(cptCurrent);
                ++cptCurrent;
            }
            else
            {
示例#3
0
void
Assembly<Dim, Order, Type, OrderBis, TypeBis>::run()
{
    Environment::changeRepository(boost::format("assembly"));
    double hSize = doption("gmsh.hsize");
    int level = std::max(doption("parameters.l"), 1.0);
    const int nfields = 7;
    std::vector<double> stats(nfields * level, std::numeric_limits<double>::quiet_NaN());
    for(int i = 0; i < level; ++i) {
        if((OrderBis == MAX_ORDER && (hSize / std::pow(2.0, i) > 0.005 || !std::is_same<Type<Dim>, Vectorial<Dim>>::value)) || hSize / std::pow(2.0, i) > 0.001) {
            boost::shared_ptr<Mesh<Simplex<Dim>>> mesh;
            mesh = createGMSHMesh(_mesh = new Mesh<Simplex<Dim>>,
                                  _update = MESH_UPDATE_EDGES|MESH_UPDATE_FACES|MESH_CHECK,
                                  _desc = domain(_name = "hypercube_" + std::to_string(Dim) + "_" + std::to_string(i + 1), _shape = "hypercube", _h = hSize / std::pow(2.0, i),
                                                 _xmin = 0.0, _xmax = 10.0,
                                                 _ymin = 0.0, _ymax = 1.0,
                                                 _zmin = 0.0, _zmax = 1.0));
            mesh->addMarkerName("Dirichlet", Dim == 2 ? 1 : 19, Dim == 2 ? 1 : 2);
            stats[nfields * i] = mesh->numGlobalElements();
            assemble<Dim, Order, Type, OrderBis, TypeBis>(mesh, &(stats[nfields * i]));
        }
    }
    if(!std::is_same<Type<Dim>, Vectorial<Dim>>::value && OrderBis == MAX_ORDER && std::is_same<Type<Dim>, Scalar<Dim>>::value)
        std::cout << "hsize\t\tnelements\tnDof\t\tFunctionSpace\tmatrix\t\tform2\t\tform1\t\ttotal\t\tmemory" << std::endl;
    for(int i = 0; i < level; ++i) {
        std::cout.width(16);
        std::cout << std::left << hSize / std::pow(2.0, i);
        std::cout.width(16);
        if(stats[nfields * i + 0] != stats[nfields * i + 0])
            std::cout << std::left << "nan";
        else
            std::cout << std::left << int(stats[nfields * i + 0]);
        std::cout.width(16);
        if(stats[nfields * i + 1] != stats[nfields * i + 1])
            std::cout << std::left << "nan";
        else
            std::cout << std::left << int(stats[nfields * i + 1]);
        std::cout.width(16);
        std::cout << std::left << stats[nfields * i + 2];
        std::cout.width(16);
        std::cout << std::left << stats[nfields * i + 5];
        std::cout.width(16);
        std::cout << std::left << stats[nfields * i + 3];
        std::cout.width(16);
        std::cout << std::left << stats[nfields * i + 4];
        std::cout.width(16);std::cout.precision(2);
        std::cout << std::left << std::accumulate(&(stats[nfields * i + 2]), &(stats[nfields * i + 6]), 0.);
        std::cout.width(16);
        std::cout << std::left << stats[nfields * i + 6] << std::endl;
    }
    cleanup();
} // Assembly::run
 DensityViscosityModel( std::string prefix )
     :
     super_type( prefix )
     {
         M_cstDensity[self_type::defaultMaterialName()] = doption(_name="rho",_prefix=prefix);
         M_cstCinematicViscosity[self_type::defaultMaterialName()] = this->cstMu()/this->cstDensity();
     }
示例#5
0
文件: beam.cpp 项目: LANTZT/feelpp
    Beam()
        :
        super(),
        meshSize( doption("hsize"  )),
        beta(     doption("beta"   )),
        bcCoeff(  doption("bccoeff")),
        M_bctype( ioption("bctype" )),
        exporter( Exporter<mesh_type>::New( this->about().appName() ) ),
        timers()
    {
        LOG(INFO) << "[Beam] hsize = " << meshSize << "\n";
        LOG(INFO) << "[Beam] beta = " << beta << "\n";
        LOG(INFO) << "[Beam] bccoeff = " << bcCoeff << "\n";
        LOG(INFO) << "[Beam] bctype = " <<  M_bctype << "\n";

    }
示例#6
0
void run()
{
    BOOST_TEST_MESSAGE( "test_eval_at_point D=" << DimGeo << " P=" << OrderPoly << "..." );
    Environment::changeRepository( boost::format( "%1%/D%2%/P%3%" ) % Environment::about().appName() % DimGeo % OrderPoly );
    auto mesh = loadMesh(_mesh = new Mesh<Simplex<DimGeo>>);
    auto Vh = Pchv<OrderPoly>( mesh );
    auto u = Vh->element();
    std::string e_str;
    if ( DimGeo == 2 )
        e_str = "{x*x*y,x*y*y}:x:y";
    else if ( DimGeo == 3 )
        e_str = "{x*x*y*z,x*y*y*z,x*y*z*z}:x:y:z";

    auto e = expr<DimGeo,1>( e_str );
    u = vf::project(Vh,elements(mesh), e );

    node_type pt(DimGeo);
    pt[0] = 0.5;
    if ( DimGeo >= 2 )
        pt[1] = 0.5;
    if ( DimGeo >= 3 )
        pt[2] = 0.5;
    auto eval = u(pt)[0];

    auto e_eval = e.evaluate();
    if ( DimGeo >= 2 )
    {
        e.setParameterValues( { { "x", 0.5 },{ "y", 0.5 } } );
        if ( DimGeo >= 3 )
            e.setParameterValues( { { "x", 0.5 },{ "y", 0.5 }, { "z", 0.5 } } );
        auto sol = e.evaluate();

        double min = doption(_name="gmsh.hsize");

#if USE_BOOST_TEST
        if ( OrderPoly < 4 )
            BOOST_CHECK_SMALL( (eval-sol).cwiseQuotient(sol).norm(), min );
        else
            BOOST_CHECK_SMALL( (eval-sol).cwiseQuotient(sol).norm(), 1e-13 );
#else
        CHECK( (eval-sol).norm() < min ) << "Error in evaluation at point " << pt
                                         << " value = [ " << eval << " ] expected = [ " << sol << " ] ";
#endif
        BOOST_TEST_MESSAGE( "test_eval_at_point D=" << DimGeo << " P=" << OrderPoly << "done" );
    }
}
示例#7
0
inline
std::shared_ptr<Mesh<Simplex<3,Ngeo> > >
unitSphere( double h = doption(_name="gmsh.hsize") )
{
#ifdef FEELPP_HAS_GMSH
    return createGMSHMesh(_mesh=new Mesh<Simplex<3,Ngeo> >,
                          _desc=domain( _name="sphere",
                                        _shape="ellipsoid",
                                        _dim=3,
                                        _xmin=-1,
                                        _ymin=-1,
                                        _zmin=-1,
                                        _h= h ) );
#else
    LOG(WARNING) << "unitSphere: Feel++ was not built with Gmsh. This function will return a empty mesh.";
    return std::make_shared<Mesh<Simplex<3, Ngeo> > >();
#endif
}
示例#8
0
文件: beam.cpp 项目: LANTZT/feelpp
void
Beam<nDim,nOrder>::run()
{

    this->changeRepository( boost::format( "doc/manual/solid/%1%/%2%/P%3%/h_%4%/" )
                            % this->about().appName()
                            % entity_type::name()
                            % nOrder
                            % meshSize );
    /*
     * First we create the mesh
     */
    mesh_ptrtype mesh = createGMSHMesh( _mesh=new mesh_type,
                                        _update=MESH_UPDATE_EDGES|MESH_UPDATE_FACES|MESH_CHECK,
                                        _desc=domain( _name=( boost::format( "beam-%1%" ) % nDim ).str() ,

                                                      _shape="hypercube",
                                                      _xmin=0., _xmax=0.351,
                                                      _ymin=0., _ymax=0.02,
                                                      _zmin=0., _zmax=0.02,
                                                      _h=meshSize ) );
    // add marker clamped to the mesh
    mesh->addMarkerName( "clamped",( nDim==2 )?1:19, (nDim==2)?1:2);
    mesh->addMarkerName( "tip",( nDim==2)?3:27, (nDim==2)?1:2);
    /*
     * The function space and some associate elements are then defined
     */
    timers["init"].first.restart();
    space_ptrtype Xh = space_type::New( mesh );
    Xh->printInfo();

    element_type u( Xh, "u" );
    element_type v( Xh, "v" );
    timers["init"].second = timers["init"].first.elapsed();

    /*
     * Data associated with the simulation
     */
    auto E = doption(_name="E")*pascal;
    const double nu = doption(_name="nu");

    auto mu = E/( 2*( 1+nu ) );
    auto lambda = E*nu/( ( 1+nu )*( 1-2*nu ) );
    auto density = 1e3;
    auto gravity = -2*newton/pow<Dim>(meter);//-density*0.05;
    LOG(INFO) << "lambda = " << lambda << "\n"
          << "mu     = " << mu << "\n"
          << "gravity= " << gravity << "\n";

    /*
     * Construction of the right hand side
     *
     * \f$ f = \int_\Omega g * v \f$ where \f$ g \f$ is a vector
     * directed in the \f$ y \f$ direction.
     */
    auto F = backend()->newVector( Xh );
    F->zero();
    timers["assembly"].first.restart();

    if ( Dim == 3 )
        form1( _test=Xh, _vector=F ) = integrate( elements( mesh ), trans( gravity.value()*oneZ() )*id( v ) );
    else
        form1( _test=Xh, _vector=F ) = integrate( elements( mesh ), trans( gravity.value()*oneY() )*id( v ) );

    timers["assembly"].second = timers["assembly"].first.elapsed();

    /*
     * Construction of the left hand side
     */
    auto D = backend()->newMatrix( Xh, Xh );
    timers["assembly"].first.restart();
    auto deft = sym(gradt(u));
    auto def = sym(grad(u));
    auto a = form2( _test=Xh, _trial=Xh, _matrix=D );
    a = integrate( elements( mesh ),
                   lambda.value()*divt( u )*div( v )  +
                   2.*mu.value()*trace( trans( deft )*def ) );

    if ( M_bctype == 1 ) // weak Dirichlet bc
    {
        auto Id = eye<nDim>();
        a += integrate( markedfaces( mesh, "clamped" ),
                        - trans( ( 2.*mu.value()*deft+lambda.value()*trace( deft )*Id )*N() )*id( v )
                        - trans( ( 2.*mu.value()*def+lambda.value()*trace( def )*Id )*N() )*idt( u )
                        + bcCoeff*std::max(2.*mu.value(),lambda.value())*trans( idt( u ) )*id( v )/hFace() );
    }

    if ( M_bctype == 0 )
        a += on( markedfaces( mesh, "clamped" ), u, F, zero<nDim,1>() );

    timers["assembly"].second += timers["assembly"].first.elapsed();

    backend(_rebuild=true)->solve( _matrix=D, _solution=u, _rhs=F );

    v = vf::project( Xh, elements( Xh->mesh() ), P() );
    this->exportResults( 0, u, v );

    auto i1 = mean( _range=markedfaces( mesh, "tip"  ), _expr=idv( u ) );
    LOG(INFO) << "deflection: " << i1 << "\n";

} // Beam::run