getfem-users
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: [Getfem-users] How to export and display deformed shape?


From: Andriy Andreykiv
Subject: Re: [Getfem-users] How to export and display deformed shape?
Date: Fri, 4 Nov 2011 14:50:01 +0100

Dear Somu,

The simplest answer is to use ParaView (a free VTK viewer). 
If a displayed VTK file contains vector fields ParaView allows to deform the mesh 
with those fields. 

Another answer is to use Salome/Getfem interface (mentioned earlier on this forum) and postprocess your results in Salome, which also allows to apply deformation to the mesh (but the advantage in comparison to ParaView is that you
can visualize doformation of quadratic elements, while VTK (hence ParaView) will convert your quadratic mesh to a finer linear mesh (you might not want that in some cases).

Yet another answer is to create a VTK with a deformed mesh yourself. This way you have more control how to deform it. For this I use code like this:


void export_deformed_VTK(getfem::mesh_fem& mf, plain_vector& def_U, plain_vector& res_U,
                                             std::string fname,std::string field_name)
{ getfem::mesh* pmesh_deformed=deform_mesh(mf, def_U);  // deform_mesh is defined below
        getfem::mesh_fem mf_deformed(*pmesh_deformed);
        mf_deformed.set_finite_element(pmesh_deformed->convex_index(), mf.fem_of_element(0));
std::string vtk_file_name=fname+".vtk";
        export_vtk(mf_deformed,res_U,vtk_file_name, field_name); // defined below
delete pmesh_deformed;
}

void export_vtk(const getfem::mesh_fem& mf, const std::vector<bgeot::scalar_type>& U, 
                                              std::string fname, std::string field_name)
{    getfem::vtk_export exp(fname,false);
     exp.exporting(mf);
     exp.write_point_data(mf, U,field_name);
}

getfem::mesh* deform_mesh(const getfem::mesh_fem& mf,plain_vector& def_U)
{ getfem::mesh* pmesh_deformed=new getfem::mesh();
dal::bit_vector nn=mf.linked_mesh().convex_index(); 
        bgeot::size_type i; 
for(i<<nn; i!=bgeot::size_type(-1); i<<nn) 
        {  
getfem::mesh::ind_cv_ct point=mf.linked_mesh().ind_points_of_convex(i);
        getfem::mesh_fem::ind_dof_ct dof=mf.ind_dof_of_element(i);
        bgeot::size_type num_points=mf.linked_mesh().structure_of_convex(i)->nb_points(); 
std::vector<bgeot::base_node> pt(num_points);
        for(bgeot::size_type j=0; j<num_points; j++) 
        { bgeot::base_node node=mf.linked_mesh().points()[point[j]]; 
 if(mf.linked_mesh().dim()==2)  // for 2D
                                   {pt[j]=bgeot::base_node(node[0]+def_U[dof[2*j]],node[1]+def_U[dof[2*j+1]]);}
 if(mf.linked_mesh().dim()==3)  // for 3D                   
                                           {pt[j]=bgeot::base_node(node[0]+def_U[dof[3*j]],node[1]+def_U[dof[3*j+1]],node[2]+def_U[dof[3*j+2]]);}
}
        pmesh_deformed->add_convex_by_points(mf.linked_mesh().trans_of_convex(i),pt.begin());
        }
return pmesh_deformed;


Best regards,
                      Andriy






2011/11/4 somu shabadi <address@hidden>
Hello Getfem-users,

I know it is very trivial question. But i really need to get the output in the form of deformed shape of the plane material. I get displacement as vector using both Mayavi2 and gmsh. Please help me.

Thanking you in advance,
Somu

On Tue, Nov 1, 2011 at 11:42 PM, somu shabadi <address@hidden> wrote:

Hello getfem-users,

I am using python interface to solve linear elastic problem ( Avoiding the model framework format). gmsh tripod.pos displays displacement as vector. Is it possible to display the deformed shape (instead of displacement vector) also? If yes, how do i display it?

Thanks in advance,
Somu



-------------------------------------------------------------
Somu Shabadi
Computational Engineering
Ruhr University, Bochum - 44803
Bochum




--
Thanks and Regards,
Somu


-------------------------------------------------------------
Somu Shabadi
Computational Engineering
Ruhr University, Bochum - 44803
Bochum


_______________________________________________
Getfem-users mailing list
address@hidden
https://mail.gna.org/listinfo/getfem-users



reply via email to

[Prev in Thread] Current Thread [Next in Thread]