Ejemplo n.º 1
0
  /*!Add a field*/
 void addvector(const string& nameoffield, Fem2D::Mesh* mesh, const KN<double>&val, const KN<double>&val2)
  {
   _ofdata.flags(std::ios_base::scientific);
   _ofdata.precision(15);

   _ofdata << "<DataArray type=\"Float32\" Name=\"";
   _ofdata << nameoffield<<"\" NumberOfComponents=\"3\" format=\"ascii\">";
   _ofdata << std::endl;
   for(int i=0;i<val.size();++i) _ofdata<<checkprecision(val[i])<< " " << checkprecision(val2[i]) << " " << 0.0 << std::endl;
   _ofdata << "</DataArray>" << std::endl;
   _ofdata.flush();
  }
Ejemplo n.º 2
0
 void addmesh(Fem2D::Mesh* mesh)
  {
   Fem2D::Mesh& Th(*mesh);
   _vecmesh.push_back(mesh);
   _ofdata.flags(std::ios_base::scientific);
   _ofdata.precision(15);

   _ofdata << "<?xml version=\"1.0\"?>" << std::endl;
   _ofdata << "<VTKFile type=\"UnstructuredGrid\" version=\"0.1\" byte_order=\"LittleEndian\">" ;
   _ofdata << std::endl;
   _ofdata << "<UnstructuredGrid>" ; _ofdata << std::endl;
   _ofdata << "<Piece NumberOfPoints=\"" << Th.nv << "\" NumberOfCells=\"" << Th.nt << "\">"; 
   _ofdata << std::endl;
   _ofdata << "<Points>" << std::endl;
   _ofdata << "<DataArray type=\"Float32\" Name=\"Position\" NumberOfComponents=\"3\" format=\"ascii\">"; 
   _ofdata << std::endl;
   for(int k=0;k<Th.nv;++k) _ofdata << Th(k).x<<" "<<Th(k).y<< " " << 0.0 << std::endl;
   _ofdata << "</DataArray>" << std::endl;
   _ofdata << "</Points>" << std::endl;
   _ofdata << "<Cells>" << std::endl;
   _ofdata << "<DataArray type=\"Int32\" Name=\"connectivity\" NumberOfComponents=\"1\" format=\"ascii\">"; 
   _ofdata << std::endl;
   for(int i=0;i<Th.nt;++i)
    for (int j=0; j <3; j++) _ofdata << Th(i,j) << " " ;
   _ofdata << std::endl;
   _ofdata << "</DataArray>" << std::endl;
   _ofdata << "<DataArray type=\"Int32\" Name=\"offsets\" NumberOfComponents=\"1\" format=\"ascii\">"; 
   _ofdata << std::endl;	
   for(int i=0;i<Th.nt;++i)  _ofdata << 3+3*(i) << " ";
   _ofdata << std::endl;
   _ofdata << "</DataArray>" << std::endl;
   _ofdata << "<DataArray type=\"UInt8\" Name=\"types\" NumberOfComponents=\"1\" format=\"ascii\">" ; 
   _ofdata<< std::endl;	
   for(int i=0;i<Th.nt;++i)  _ofdata << 5 << " ";
   _ofdata << std::endl;
   _ofdata << "</DataArray>" << std::endl;
   _ofdata << "</Cells>" << std::endl; 
   _ofdata << "<PointData >" << endl; 
  }