void Bench1::run3d() { const int Dim = 3; typedef Mesh<Simplex<Dim> > mesh_type; boost::shared_ptr<mesh_type> aMesh; std::string shape = vm()["shape"].as<std::string>(); aMesh = createGMSHMesh( _mesh=new mesh_type, _desc=domain( _name=( boost::format( "%1%-%2%" ) % shape % Dim ).str() , _usenames=true, _shape=shape, _dim=Dim, _h=meshSize ), _update=MESH_CHECK|MESH_UPDATE_FACES|MESH_UPDATE_EDGES ); LOG(INFO) << "run3d starts" << "\n"; bench1<mesh_type, 1>( aMesh ); bench1<mesh_type, 2>( aMesh ); bench1<mesh_type, 4>( aMesh ); bench1<mesh_type, 6>( aMesh ); bench1<mesh_type, 8>( aMesh ); bench1<mesh_type,10>( aMesh ); LOG(INFO) << "run3d ends" << "\n"; }
boost::shared_ptr<Mesh<Simplex<1> > > unitSegment( double h ) { return createGMSHMesh(_mesh=new Mesh<Simplex<1> >, _desc=domain( _name="segment", _shape="hypercube", _dim=1, _h=h ) ); }
boost::shared_ptr<Mesh<Simplex<2> > > unitSquare( double h, PeriodicEntities pe ) { return createGMSHMesh(_mesh=new Mesh<Simplex<2> >, _desc=domain( _name="square", _shape="hypercube", _dim=2, _h=h), _periodic = pe ); }
inline boost::shared_ptr<Mesh<Simplex<2,Ngeo> > > unitCircle( double h = option(_name="gmsh.hsize").template as<double>() ) { return createGMSHMesh(_mesh=new Mesh<Simplex<2,Ngeo> >, _desc=domain( _name="circle", _shape="ellipsoid", _dim=2, _xmin=-1, _ymin=-1, _h=h ) ); }
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
std::shared_ptr<Mesh<Simplex<3> > > unitCube( double h ) { #ifdef FEELPP_HAS_GMSH return createGMSHMesh(_mesh=new Mesh<Simplex<3> >, _desc=domain( _name="cube", _shape="hypercube", _dim=3, _h= h ) ); #else LOG(WARNING) << "unitCube: Feel++ was not built with Gmsh. This function will return a empty mesh."; return std::make_shared<Mesh<Simplex<3> > >(); #endif }
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 }
void NavierStokes::init() { Environment::changeRepository( boost::format( "doc/manual/ns/%1%/%2%/P%3%P%4%/h_%5%/" ) % this->about().appName() % convex_type::name() % basis_u_type::nOrder % basis_p_type::nOrder % this->vm()["hsize"].as<double>() ); mesh = createGMSHMesh( _mesh=new mesh_type, _desc=geo( _filename=this->vm()["geofile"].as<std::string>() _dim=FEELPP_NS_DIM, _h=meshSize ) ); Xh = space_type::New( mesh ); }
void Partitioning<Dim>::run() { int p = 2; int* pm = new int[p]; for(unsigned short i = 0; i < p; ++i) pm[i] = i * (Environment::numberOfProcessors() / p); bool excluded = std::binary_search(pm, pm + p, Environment::rank()); mpi::group new_group; if(excluded) new_group = Environment::worldComm().group().include(pm,pm+p); else new_group = Environment::worldComm().group().exclude(pm,pm+p); delete [] pm; boost::mpi::communicator bComm(Environment::worldComm(), new_group); std::vector<int> active( bComm.size(), true ); WorldComm wComm(bComm,bComm,bComm,bComm.rank(),active); //wComm.showMe(); boost::shared_ptr<Mesh<Simplex<Dim>>> mesh; if(!excluded) { std::cout << "proc " << Environment::rank() << " is not excluded and is locally rank " << wComm.rank() << " and loads mesh with " << wComm.globalSize() << " partitions\n"; // mesh = loadMesh(_mesh = new Mesh<Simplex<Dim>>(wComm), _worldcomm=wComm ); mesh = createGMSHMesh(_mesh = new Mesh<Simplex<Dim>>(wComm), _worldcomm = wComm, _desc = domain(_worldcomm = wComm, _name = "hypercube", _shape = "hypercube", _xmin = 0.0, _xmax = 1.0, _ymin = 0.0, _ymax = 1.0, _zmin = 0.0, _zmax = 1.0)); std::cout << " - nelement(mesh)=" << nelements(elements(mesh)) << "\n"; std::cout << " - loading space\n"; auto Vh = Pch<2>( mesh ); auto u = Vh->element("u"); auto f = expr( soption(_name="functions.f"), "f", wComm ); auto g = expr( soption(_name="functions.g"), "g", wComm ); auto v = Vh->element( g, "g" ); auto l = form1( _test=Vh ); l = integrate(_range=elements(mesh),_expr=f*id(v)); auto a = form2( _trial=Vh, _test=Vh); a = integrate(_range=elements(mesh), _expr=gradt(u)*trans(grad(v)) ); if(boption("gmsh.domain.usenames")) { if(nelements(markedfaces(mesh, "Dirichlet"), boption("use_global")) > 0) a+=on(_range=markedfaces(mesh, "Dirichlet"), _rhs=l, _element=u, _expr=g); } else a+=on(_range=boundaryfaces(mesh), _rhs=l, _element=u, _expr=g); a.solve(_rhs=l,_solution=u); auto e = exporter( _mesh=mesh ); //e->addRegions(); e->add( "u", u ); e->add( "g", v ); e->save(); } else { std::cout << "proc " << Environment::rank() << " is excluded and does not load mesh"; int np = 0; mpi::all_reduce(wComm, 1, np, std::plus<int>()); std::cout << "proc " << Environment::rank() << " - nb proc = " << np << "\n"; } } // Partitioning::run
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