AGraph::AGraph() { PrimaryActorTick.bCanEverTick = false; ConstructorHelpers::FObjectFinder<UStaticMesh> edgeMesh(TEXT("/Game/Models/EdgeVisualizer")); ConstructorHelpers::FObjectFinder<UStaticMesh> vertexMesh(TEXT("/Game/Models/VertexVisualizer")); edgeStaticMesh = edgeMesh.Object; vertexStaticMesh = vertexMesh.Object; }
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 ); }
//------------------------------------------------------------------------------ //! void DFPolygonRenderable::update() { Vector<float> egver; // vec3: pos, vec3: color Vector<float> vgver; // vec3: pos, vec3: color, flt: size Vector<uint32_t> eindices; Vector<uint32_t> vindices; const DFPolygon* poly = _editor->polygon(); // Vertices. for( auto v = poly->begin(); v != poly->end(); ++v ) { vindices.pushBack( uint(vindices.size()) ); pushBack( vgver, (*v) ); pushBack( vgver, _col_v_default ); pushBack( vgver, _siz_v_default ); pushBack( egver, (*v) ); pushBack( egver, _col_e_default ); } // Edges. const uint n = uint(poly->numVertices()); for( uint i = 0, j = n-1; i < n; j=i++ ) { eindices.pushBack( j ); eindices.pushBack( i ); } // Tweak for selection. auto& selection = _editor->selection(); for( auto cur = selection.begin(); cur != selection.end(); ++cur ) { float* ptr = vgver.data() + cur->_idx*7; Vec3f::as( ptr+3 ) = (*cur) == selection.last() ? _col_v_selected_p : _col_v_selected_s; ptr[6] = _siz_v_selected; } // Updating the meshes. MeshGeometry* emesh = edgeMesh(); MeshGeometry* vmesh = vertexMesh(); emesh->clearPatches(); emesh->deallocate(); if( !egver.empty() ) { emesh->allocateIndices( uint(eindices.size()) ); emesh->copyIndices( eindices.data() ); emesh->allocateVertices( uint(egver.size())/6 ); emesh->copyAttributes( egver.data(), 6, 6, 0 ); emesh->addPatch( 0, uint(eindices.size()) ); } emesh->updateProperties(); emesh->invalidateRenderableGeometry(); vmesh->clearPatches(); vmesh->deallocate(); if( !vgver.empty() ) { vmesh->allocateIndices( uint(vindices.size()) ); vmesh->copyIndices( vindices.data() ); vmesh->allocateVertices( uint(vgver.size())/7 ); vmesh->copyAttributes( vgver.data(), 7, 7, 0 ); vmesh->addPatch( 0, uint(vindices.size()) ); } vmesh->updateProperties(); vmesh->invalidateRenderableGeometry(); }