32 #define PLOT_PRECISION 12
39 void writeSingleBasisMesh3D(
const gsMesh<T> & sl,
40 std::string
const & fn)
42 const unsigned numVer = sl.numVertices();
43 const unsigned numEl = numVer / 8;
46 std::ofstream file(mfn.c_str());
47 if ( ! file.is_open() )
48 gsWarn<<
"writeSingleBasisMesh3D: Problem opening file \""<<fn<<
"\""<<std::endl;
50 file << std::setprecision (PLOT_PRECISION);
52 file <<
"<?xml version=\"1.0\"?>\n";
53 file <<
"<VTKFile type=\"UnstructuredGrid\" version=\"0.1\" byte_order=\"LittleEndian\">\n";
54 file <<
"<UnstructuredGrid>\n";
57 file <<
"<Piece NumberOfPoints=\""<< numVer <<
"\" NumberOfCells=\""<<numEl<<
"\">\n";
61 file <<
"<DataArray type=\"Float32\" NumberOfComponents=\"3\" format=\"ascii\">\n";
62 for (
typename std::vector< gsVertex<T>* >::const_iterator it=sl.vertices().begin(); it!=sl.vertices().end(); ++it)
64 const gsVertex<T>& vertex = **it;
65 file << vertex[0] <<
" " << vertex[1] <<
" " << vertex[2] <<
" \n";
68 file <<
"</DataArray>\n";
72 file <<
"<PointData Scalars=\"CellVolume\">\n";
73 file <<
"<DataArray type=\"Float32\" Name=\"CellVolume\" format=\"ascii\" NumberOfComponents=\"1\">\n";
74 for (
typename std::vector< gsVertex<T>* >::const_iterator it=sl.vertices().begin(); it!=sl.vertices().end(); ++it)
76 file << (*it)->data <<
" ";
79 file <<
"</DataArray>\n";
80 file <<
"</PointData>\n";
86 file <<
"<DataArray type=\"Int32\" Name=\"connectivity\" format=\"ascii\">\n";
87 for (
unsigned i = 0; i!= numVer;++i)
92 file <<
"</DataArray>\n";
95 file <<
"<DataArray type=\"Int32\" Name=\"offsets\" format=\"ascii\">\n";
96 for (
unsigned i = 1; i<= numEl;++i)
101 file <<
"</DataArray>\n";
104 file <<
"<DataArray type=\"Int32\" Name=\"types\" format=\"ascii\">\n";
105 for (
unsigned i = 1; i<= numEl;++i)
110 file <<
"</DataArray>\n";
113 file <<
"</Piece>\n";
114 file <<
"</UnstructuredGrid>\n";
115 file <<
"</VTKFile>\n";
125 void writeSingleBasisMesh2D(
const gsMesh<T> & sl,
126 std::string
const & fn)
128 const unsigned numVer = sl.numVertices();
129 const unsigned numEl = numVer / 4;
132 std::ofstream file(mfn.c_str());
133 if ( ! file.is_open() )
134 gsWarn<<
"writeSingleBasisMesh2D: Problem opening file \""<<fn<<
"\""<<std::endl;
136 file << std::setprecision (PLOT_PRECISION);
138 file <<
"<?xml version=\"1.0\"?>\n";
139 file <<
"<VTKFile type=\"UnstructuredGrid\" version=\"0.1\" byte_order=\"LittleEndian\">\n";
140 file <<
"<UnstructuredGrid>\n";
143 file <<
"<Piece NumberOfPoints=\""<< numVer <<
"\" NumberOfCells=\""<<numEl<<
"\">\n";
147 file <<
"<DataArray type=\"Float32\" NumberOfComponents=\"3\" format=\"ascii\">\n";
148 for (
typename std::vector< gsVertex<T>* >::const_iterator it=sl.vertices().begin(); it!=sl.vertices().end(); it+=4)
151 const gsVertex<T>& vertex0 = **it;
152 const gsVertex<T>& vertex1 = **(it+1);
153 const gsVertex<T>& vertex3 = **(it+3);
154 const gsVertex<T>& vertex2 = **(it+2);
155 file << vertex0[0] <<
" " << vertex0[1] <<
" " << vertex0[2] <<
" \n";
156 file << vertex1[0] <<
" " << vertex1[1] <<
" " << vertex1[2] <<
" \n";
157 file << vertex3[0] <<
" " << vertex3[1] <<
" " << vertex3[2] <<
" \n";
158 file << vertex2[0] <<
" " << vertex2[1] <<
" " << vertex2[2] <<
" \n";
161 file <<
"</DataArray>\n";
162 file <<
"</Points>\n";
165 file <<
"<PointData Scalars=\"CellArea\">\n";
166 file <<
"<DataArray type=\"Float32\" Name=\"CellVolume\" format=\"ascii\" NumberOfComponents=\"1\">\n";
167 for (
typename std::vector< gsVertex<T>* >::const_iterator it=sl.vertices().begin(); it!=sl.vertices().end(); ++it)
169 file << (*it)->data <<
" ";
172 file <<
"</DataArray>\n";
173 file <<
"</PointData>\n";
179 file <<
"<DataArray type=\"Int32\" Name=\"connectivity\" format=\"ascii\">\n";
180 for (
unsigned i = 0; i!= numVer;++i)
185 file <<
"</DataArray>\n";
188 file <<
"<DataArray type=\"Int32\" Name=\"offsets\" format=\"ascii\">\n";
189 for (
unsigned i = 1; i<= numEl;++i)
194 file <<
"</DataArray>\n";
197 file <<
"<DataArray type=\"Int32\" Name=\"types\" format=\"ascii\">\n";
198 for (
unsigned i = 1; i<= numEl;++i)
203 file <<
"</DataArray>\n";
206 file <<
"</Piece>\n";
207 file <<
"</UnstructuredGrid>\n";
208 file <<
"</VTKFile>\n";
219 std::string
const & fn)
222 if ( basis.dim() == 3)
223 writeSingleBasisMesh3D(msh,fn);
224 else if ( basis.dim() == 2)
225 writeSingleBasisMesh2D(msh,fn);
227 gsWriteParaview(msh, fn,
false);
233 std::string
const & fn,
unsigned resolution)
243 gsWriteParaview(msh, fn,
false);
249 std::string
const & fn)
251 const int d = Geo.
parDim();
254 const unsigned n = Geo.
geoDim();
259 for (
size_t i = 0; i!= msh.numVertices(); ++i)
261 msh.vertex(i)[d] = msh.vertex(i)[0];
262 msh.vertex(i).topRows(d) = anch.col(i);
267 gsDebug<<
"Writing 4th coordinate\n";
269 gsWriteParaviewPoints<T>(cp.transpose(), fn );
273 gsWriteParaview(msh, fn,
false);
277 void gsWriteParaviewTPgrid(
const gsMatrix<T> & eval_geo ,
278 const gsMatrix<T> & eval_field,
279 const gsVector<index_t> & np,
280 std::string
const & fn)
282 const int n = eval_geo.rows();
284 &&
static_cast<index_t>(np.prod())==eval_geo.cols(),
285 "Data do not match");
289 std::ofstream file(mfn.c_str());
291 file << std::setprecision (PLOT_PRECISION);
293 index_t np1 = (np.size()>1 ? np(1)-1 : 0);
294 index_t np2 = (np.size()>2 ? np(2)-1 : 0);
296 file <<
"<?xml version=\"1.0\"?>\n";
297 file <<
"<VTKFile type=\"StructuredGrid\" version=\"0.1\">\n";
298 file <<
"<StructuredGrid WholeExtent=\"0 "<< np(0)-1<<
" 0 "<< np1 <<
" 0 "
300 file <<
"<Piece Extent=\"0 "<< np(0)-1<<
" 0 "<<np1<<
" 0 "
302 file <<
"<PointData "<< ( eval_field.rows()==1 ?
"Scalars":
"Vectors")<<
"=\"SolutionField\">\n";
303 file <<
"<DataArray type=\"Float32\" Name=\"SolutionField\" format=\"ascii\" NumberOfComponents=\""<< ( eval_field.rows()==1 ? 1 : 3) <<
"\">\n";
304 if ( eval_field.rows()==1 )
305 for (
index_t j=0; j<eval_field.cols(); ++j)
306 file<< eval_field.at(j) <<
" ";
309 for (
index_t j=0; j<eval_field.cols(); ++j)
311 for (
index_t i=0; i!=eval_field.rows(); ++i)
312 file<< eval_field(i,j) <<
" ";
313 for (
index_t i=eval_field.rows(); i<3; ++i)
317 file <<
"</DataArray>\n";
318 file <<
"</PointData>\n";
320 file <<
"<DataArray type=\"Float32\" NumberOfComponents=\"3\">\n";
321 for (
index_t j=0; j<eval_geo.cols(); ++j)
324 file<< eval_geo(i,j) <<
" ";
328 file <<
"</DataArray>\n";
329 file <<
"</Points>\n";
331 file <<
"</StructuredGrid>\n";
332 file <<
"</VTKFile>\n";
338 void writeSinglePatchField(
const gsFunction<T> & geometry,
339 const gsFunction<T> & parField,
341 std::string
const & fn,
unsigned npts)
343 const int n = geometry.targetDim();
344 const int d = geometry.domainDim();
346 gsMatrix<T> ab = geometry.support();
347 gsVector<T> a = ab.col(0);
348 gsVector<T> b = ab.col(1);
350 gsVector<unsigned> np = uniformSampleCount(a, b, npts);
353 gsMatrix<T> eval_geo = geometry.eval(pts);
354 gsMatrix<T> eval_field = isParam ? parField.eval(pts) : parField.eval(eval_geo);
358 np.conservativeResize(3);
359 np.bottomRows(3-d).setOnes();
363 gsWarn<<
"Cannot plot 4D data.\n";
369 eval_geo.conservativeResize(3,eval_geo.cols() );
370 eval_geo.bottomRows(3-n).setZero();
374 gsWarn<<
"Data is more than 3 dimensions.\n";
377 if ( eval_field.rows() == 2)
379 eval_field.conservativeResize(3,eval_geo.cols() );
380 eval_field.bottomRows(1).setZero();
383 gsWriteParaviewTPgrid(eval_geo, eval_field, np.template cast<index_t>(), fn);
388 void writeSinglePatchField(
const gsField<T> & field,
int patchNr,
389 std::string
const & fn,
unsigned npts)
471 std::string
const & fn,
unsigned npts)
485 np.conservativeResize(3);
486 np.bottomRows(3-d).setOnes();
491 eval_func.conservativeResize(3,eval_func.cols() );
492 eval_func.bottomRows(3-n).setZero();
499 eval_func.conservativeResize(4,eval_func.cols() );
503 eval_func.row(d) = eval_func.row(0);
504 eval_func.topRows(d) = pts;
510 std::ofstream file(mfn.c_str());
511 if ( ! file.is_open() )
512 gsWarn<<
"writeSingleGeometry: Problem opening file \""<<fn<<
"\""<<std::endl;
514 file << std::setprecision (PLOT_PRECISION);
515 file <<
"<?xml version=\"1.0\"?>\n";
516 file <<
"<VTKFile type=\"StructuredGrid\" version=\"0.1\">\n";
517 file <<
"<StructuredGrid WholeExtent=\"0 "<<np(0)-1<<
" 0 "<<np(1)-1<<
" 0 "<<np(2)-1<<
"\">\n";
518 file <<
"<Piece Extent=\"0 "<< np(0)-1<<
" 0 "<<np(1)-1<<
" 0 "<<np(2)-1<<
"\">\n";
532 file <<
"<PointData "<<
"Scalars=\"Coordinate4\">\n";
533 file <<
"<DataArray type=\"Float32\" Name=\"Coordinate4\" format=\"ascii\" NumberOfComponents=\"1\">\n";
534 for (
index_t j=0; j!=eval_func.cols(); ++j)
535 file<< eval_func(3,j) <<
" ";
536 file <<
"</DataArray>\n";
537 file <<
"</PointData>\n";
542 file <<
"<DataArray type=\"Float32\" NumberOfComponents=\"3\">\n";
543 for (
index_t j=0; j<eval_func.cols(); ++j)
545 file<< eval_func(i,j) <<
" ";
546 file <<
"</DataArray>\n";
547 file <<
"</Points>\n";
549 file <<
"</StructuredGrid>\n";
550 file <<
"</VTKFile>\n";
558 std::string
const & fn,
unsigned npts)
571 np.conservativeResize(3);
572 np.bottomRows(2).setOnes();
576 eval_func.conservativeResize(3,eval_func.cols() );
577 eval_func.bottomRows(3-n).setZero();
582 eval_func.row(d) = eval_func.row(0);
583 eval_func.topRows(d) = pts;
589 std::ofstream file(mfn.c_str());
590 if ( ! file.is_open() )
591 gsWarn<<
"writeSingleCurve: Problem opening file \""<<fn<<
"\""<<std::endl;
593 file << std::setprecision (PLOT_PRECISION);
594 file <<
"<?xml version=\"1.0\"?>\n";
595 file <<
"<VTKFile type=\"PolyData\" version=\"0.1\" byte_order=\"LittleEndian\">\n";
596 file <<
"<PolyData>\n";
598 file <<
"<Piece NumberOfPoints=\""<< npts
599 <<
"\" NumberOfVerts=\"0\" NumberOfLines=\""<< npts-1
600 <<
"\" NumberOfStrips=\"0\" NumberOfPolys=\"0\">\n";
602 file <<
"<DataArray type=\"Float32\" NumberOfComponents=\""<<eval_func.rows()<<
"\">\n";
603 for (
index_t j=0; j<eval_func.cols(); ++j)
604 for (
index_t i=0; i<eval_func.rows(); ++i)
605 file<< eval_func(i,j) <<
" ";
606 file <<
"\n</DataArray>\n";
607 file <<
"</Points>\n";
610 file <<
"<DataArray type=\"Int64\" Name=\"connectivity\" format=\"ascii\" RangeMin=\"0\" RangeMax=\""<<npts-1<<
"\">\n";
611 for (
unsigned i=0; i< npts-1; ++i )
613 file << i <<
" " << i+1 <<
" ";
616 file <<
"\n</DataArray>\n";
618 file <<
"<DataArray type=\"Int64\" Name=\"offsets\" format=\"ascii\" RangeMin=\"0\" RangeMax=\""<<npts-1<<
"\">\n";
619 for (
unsigned i=0; i< npts-1; ++i )
622 file << offset <<
" ";
624 file <<
"\n</DataArray>\n";
628 file <<
"</PolyData>\n";
629 file <<
"</VTKFile>\n";
634 void writeSingleCurve(
const gsGeometry<T> & Geo, std::string
const & fn,
unsigned npts)
636 gsMatrix<T> ab = Geo.parameterRange();
649 gsMatrix<T> ab = Geo.parameterRange();
654 void writeSingleTrimSurface(
const gsTrimSurface<T> & surf,
655 std::string
const & fn,
658 typename gsMesh<T>::uPtr msh = surf.toMesh(npts);
659 gsWriteParaview( *msh, fn);
665 std::string
const & fn,
666 unsigned npts,
bool mesh,
667 const std::string pDelim)
677 const unsigned n = field.
nPieces();
679 std::string fileName, fileName_nopath;
681 for (
unsigned i=0; i < n; ++i )
688 writeSinglePatchField( field, i, fileName, npts );
689 collection.
addPart(fileName_nopath +
".vts");
696 collection.
addPart(fileName_nopath +
".vtp");
707 std::string
const & fn,
708 unsigned npts,
const std::string pDelim)
720 const unsigned n = geo.
nPieces();
722 std::string fileName, fileName_nopath;
724 for (
unsigned i=0; i < n; ++i )
728 writeSinglePatchField( geo.
function(i), func.
function(i),
true, fileName, npts );
729 collection.
addPart(fileName_nopath +
".vts");
736 void gsWriteParaview(gsMappedSpline<2,T>
const& mspline,
737 std::string
const & fn,
741 std::string fileName, fileName_nopath;
742 for (
index_t p=0; p < mspline.nPieces(); ++p )
748 collection.
addPart(fileName_nopath +
".vts",-1,
"",p);
756 gsMappedBasis<2,T>
const& mbasis,
757 std::string
const & fn,
759 const bool fullsupport,
760 const std::vector<index_t> indices)
768 GISMO_ASSERT(geom.
nPieces()==mbasis.nPieces(),
"Function sets must have same number of pieces, but the basis has "<<mbasis.nPieces()<<
" and the geometry has "<<geom.
nPieces());
770 std::vector<index_t> plotIndices;
771 if (indices.size()==0)
773 plotIndices.resize(mbasis.globalSize());
774 std::generate(plotIndices.begin(), plotIndices.end(), [n = 0] ()
mutable {
return n++; });
777 plotIndices = indices;
780 std::string fileName, fileName_nopath;
789 ab = geom.
piece(p).support();
793 if (a.prod() == 0 && b.prod()==0)
796 np = uniformSampleCount(a, b, npts);
802 for (std::vector<index_t>::const_iterator i = plotIndices.begin(); i!=plotIndices.end(); i++)
807 ab = mbasis.piece(p).support(*i);
811 if (a.prod() == 0 && b.prod()==0)
814 np = uniformSampleCount(a, b, npts);
823 eval_basis = mbasis.piece(p).evalSingle(*i,pts);
824 gsWriteParaviewTPgrid(eval_geo, eval_basis, np.template cast<index_t>(), fileName);
826 collection.
addPart(fileName_nopath +
".vts",*i,
"",p);
845 unsigned npts,
bool mesh,
bool ctrlNet)
847 const bool curve = ( Geo.
domainDim() == 1 );
854 collection.
addPart(fn_nopath +
".vtp");
859 collection.
addPart(fn_nopath +
".vts");
864 const std::string fileName = fn +
"_mesh";
872 const T evalPtsPerElem = npts * (1.0 / Geo.
basis().numElements());
878 ptsPerEdge = cast<T,int>(
879 static_cast<T
>(math::max(Geo.
basis().maxDegree()-1, (
short_t)1)) * math::pow(evalPtsPerElem, T(1.0)/
static_cast<T
>(Geo.
domainDim())) );
887 collection.
addPart(fileName_nopath +
".vtp");
892 const std::string fileName = fn +
"_cnet";
895 collection.
addPart(fileName_nopath +
".vtp");
905 std::string
const & fn,
unsigned npts)
911 for (
size_t i = 0; i != domain.
nPatches(); ++i)
916 collection.
addPart(fileName_nopath +
".vtp");
926 std::string
const & fn,
939 std::string
const & fn,
940 unsigned npts,
bool mesh,
bool ctrlNet,
const std::string pDelim)
942 const size_t n = Geo.size();
945 std::string fnBase, fnBase_nopath;
947 for (
size_t i=0; i<n ; i++)
952 if ( Geo.at(i)->domainDim() == 1 )
955 collection.
addPart(fnBase_nopath +
".vtp");
960 collection.
addPart(fnBase_nopath +
".vts");
965 const std::string fileName = fnBase +
"_mesh";
968 collection.
addPart(fileName_nopath +
".vtp");
973 const std::string fileName = fnBase +
"_cnet";
976 collection.
addPart(fileName_nopath +
".vtp");
1001 np.conservativeResize(3);
1002 np.bottomRows(3-d).setOnes();
1007 pts.conservativeResize(2,eval_geo.cols());
1008 pts.bottomRows(2-d).setZero();
1015 pts.conservativeResize(2,eval_geo.cols());
1020 eval_geo.conservativeResize(3,eval_geo.cols() );
1021 eval_geo.bottomRows(3-n).setZero();
1024 std::string mfn(fn);
1026 std::ofstream file(mfn.c_str());
1027 if ( ! file.is_open() )
1028 gsWarn<<
"gsWriteParaview_basisFnct: Problem opening file \""<<fn<<
"\""<<std::endl;
1030 file << std::setprecision (PLOT_PRECISION);
1031 file <<
"<?xml version=\"1.0\"?>\n";
1032 file <<
"<VTKFile type=\"StructuredGrid\" version=\"0.1\">\n";
1033 file <<
"<StructuredGrid WholeExtent=\"0 "<<np(0)-1<<
" 0 "<<np(1)-1<<
" 0 "<<np(2)-1<<
"\">\n";
1034 file <<
"<Piece Extent=\"0 "<< np(0)-1<<
" 0 "<<np(1)-1<<
" 0 "<<np(2)-1<<
"\">\n";
1036 file <<
"<PointData "<<
"Scalars"<<
"=\"SolutionField\">\n";
1037 file <<
"<DataArray type=\"Float32\" Name=\"SolutionField\" format=\"ascii\" NumberOfComponents=\""<<1<<
"\">\n";
1038 for (
index_t j=0; j<eval_geo.cols(); ++j)
1039 file<< eval_geo(0,j) <<
" ";
1040 file <<
"</DataArray>\n";
1041 file <<
"</PointData>\n";
1043 file <<
"<Points>\n";
1044 file <<
"<DataArray type=\"Float32\" NumberOfComponents=\""<<3<<
"\">\n";
1045 for (
index_t j=0; j<eval_geo.cols(); ++j)
1047 for (
int l=0; l!=d; ++l)
1048 file<< pts(l,j) <<
" ";
1049 file<< eval_geo(0,j) <<
" ";
1050 for (
index_t l=d; l!=pts.rows(); ++l)
1051 file<< pts(l,j) <<
" ";
1053 file <<
"</DataArray>\n";
1054 file <<
"</Points>\n";
1055 file <<
"</Piece>\n";
1056 file <<
"</StructuredGrid>\n";
1057 file <<
"</VTKFile>\n";
1073 gsWriteParaview(func.
function(i), func.
function(i).support(), fileName, npts,
false);
1074 collection.
addPart(fileName_nopath +
".vts");
1097 np.conservativeResize(3);
1098 np.bottomRows(3-d).setOnes();
1101 std::string mfn(fn);
1103 std::ofstream file(mfn.c_str());
1104 if ( ! file.is_open() )
1105 gsWarn<<
"gsWriteParaview: Problem opening file \""<<fn<<
"\""<<std::endl;
1107 file << std::setprecision (PLOT_PRECISION);
1108 file <<
"<?xml version=\"1.0\"?>\n";
1109 file <<
"<VTKFile type=\"StructuredGrid\" version=\"0.1\">\n";
1110 file <<
"<StructuredGrid WholeExtent=\"0 "<<np(0)-1<<
" 0 "<<np(1)-1<<
" 0 "<<np(2)-1<<
"\">\n";
1111 file <<
"<Piece Extent=\"0 "<< np(0)-1<<
" 0 "<<np(1)-1<<
" 0 "<<np(2)-1<<
"\">\n";
1113 file <<
"<PointData "<<
"Scalars"<<
"=\"SolutionField\">\n";
1114 file <<
"<DataArray type=\"Float32\" Name=\"SolutionField\" format=\"ascii\" NumberOfComponents=\""<< 1 <<
"\">\n";
1115 for (
index_t j=0; j<ev.cols(); ++j)
1116 file<< ev(0,j) <<
" ";
1117 file <<
"</DataArray>\n";
1118 file <<
"</PointData>\n";
1120 file <<
"<Points>\n";
1121 file <<
"<DataArray type=\"Float32\" NumberOfComponents=\""<<3<<
"\">\n";
1124 for (
index_t j=0; j<ev.cols(); ++j)
1126 for (
int i=0; i< d; ++i)
1127 file<< pts(i,j) <<
" ";
1128 file<< ev(0,j) <<
" ";
1133 for (
index_t j=0; j<ev.cols(); ++j)
1135 for (
index_t i=0; i!=ev.rows(); ++i)
1136 file<< ev(i,j) <<
" ";
1137 for (
index_t i=ev.rows(); i<3; ++i)
1141 file <<
"</DataArray>\n";
1142 file <<
"</Points>\n";
1143 file <<
"</Piece>\n";
1144 file <<
"</StructuredGrid>\n";
1145 file <<
"</VTKFile>\n";
1152 void gsWriteParaview(
gsBasis<T> const& basis, std::string
const & fn,
1153 unsigned npts,
bool mesh)
1162 gsWriteParaview_basisFnct<T>(i, basis, fileName, npts ) ;
1163 collection.
addPart(fileName_nopath +
".vts");
1168 std::string fileName = fn +
"_mesh";
1172 collection.
addPart(fileName_nopath +
".vtu");
1187 values.row(0).setConstant(box.
level());
1188 values.row(1).setConstant(box.
error());
1190 gsWriteParaviewTPgrid(points,values,np,fn);
1200 collection.
addPart(fn +
".vts");
1213 std::string fileName;
1218 writeSingleHBox<T>(*Cit,fileName);
1220 collection.
addPart(fileName +
".vts",-1,
"",i);
1230 std::string
const & fn,
unsigned npts)
1240 for (
size_t p=0; p!=mp.
nPatches(); p++)
1244 ab = mb.
basis(p).support(i);
1251 eval_geo = mp.
patch(p).eval(pts);
1256 eval_basis = mb.
basis(p).evalSingle(i,pts);
1257 gsWriteParaviewTPgrid(eval_geo, eval_basis, np.template cast<index_t>(), fileName);
1260 collection.addPart(fileName_nopath +
".vts",k);
1269 assert( X.cols() == Y.cols() );
1270 assert( X.rows() == 1 && Y.rows() == 1 );
1273 std::string mfn(fn);
1275 std::ofstream file(mfn.c_str());
1276 if ( ! file.is_open() )
1277 gsWarn<<
"gsWriteParaviewPoints: Problem opening file \""<<fn<<
"\""<<std::endl;
1279 file << std::setprecision (PLOT_PRECISION);
1280 file <<
"<?xml version=\"1.0\"?>\n";
1281 file <<
"<VTKFile type=\"PolyData\" version=\"0.1\" byte_order=\"LittleEndian\">\n";
1282 file <<
"<PolyData>\n";
1283 file <<
"<Piece NumberOfPoints=\""<<np<<
"\" NumberOfVerts=\"1\" NumberOfLines=\"0\" NumberOfStrips=\"0\" NumberOfPolys=\"0\">\n";
1284 file <<
"<PointData>\n";
1285 file <<
"</PointData>\n";
1286 file <<
"<CellData>\n";
1287 file <<
"</CellData>\n";
1288 file <<
"<Points>\n";
1289 file <<
"<DataArray type=\"Float32\" Name=\"Points\" NumberOfComponents=\"3\" format=\"ascii\" RangeMin=\""<<X.minCoeff()<<
"\" RangeMax=\""<<X.maxCoeff()<<
"\">\n";
1290 for (
index_t i=0; i< np; ++i )
1291 file << X(0,i) <<
" "<<Y(0,i)<<
" "<< 0.0 <<
"\n";
1292 file <<
"\n</DataArray>\n";
1293 file <<
"</Points>\n";
1295 file <<
"<DataArray type=\"Int64\" Name=\"connectivity\" format=\"ascii\" RangeMin=\""<<0<<
"\" RangeMax=\""<<np-1<<
"\">\n";
1296 for (
index_t i=0; i< np; ++i )
1298 file <<
"\n</DataArray>\n";
1299 file <<
"<DataArray type=\"Int64\" Name=\"offsets\" format=\"ascii\" RangeMin=\""<<np<<
"\" RangeMax=\""<<np<<
"\">\n"<<np<<
"\n";
1300 file <<
"</DataArray>\n";
1301 file <<
"</Verts>\n";
1303 file <<
"<DataArray type=\"Int64\" Name=\"connectivity\" format=\"ascii\" RangeMin=\"0\" RangeMax=\""<<np-1<<
"\">\n";
1304 file <<
"</DataArray>\n";
1305 file <<
"<DataArray type=\"Int64\" Name=\"offsets\" format=\"ascii\" RangeMin=\""<<np<<
"\" RangeMax=\""<<np<<
"\">\n";
1306 file <<
"</DataArray>\n";
1307 file <<
"</Lines>\n";
1308 file <<
"<Strips>\n";
1309 file <<
"<DataArray type=\"Int64\" Name=\"connectivity\" format=\"ascii\" RangeMin=\"0\" RangeMax=\""<<np-1<<
"\">\n";
1310 file <<
"</DataArray>\n";
1311 file <<
"<DataArray type=\"Int64\" Name=\"offsets\" format=\"ascii\" RangeMin=\""<<np<<
"\" RangeMax=\""<<np<<
"\">\n";
1312 file <<
"</DataArray>\n";
1313 file <<
"</Strips>\n";
1315 file <<
"<DataArray type=\"Int64\" Name=\"connectivity\" format=\"ascii\" RangeMin=\"0\" RangeMax=\""<<np-1<<
"\">\n";
1316 file <<
"</DataArray>\n";
1317 file <<
"<DataArray type=\"Int64\" Name=\"offsets\" format=\"ascii\" RangeMin=\""<<np<<
"\" RangeMax=\""<<np<<
"\">\n";
1318 file <<
"</DataArray>\n";
1319 file <<
"</Polys>\n";
1320 file <<
"</Piece>\n";
1321 file <<
"</PolyData>\n";
1322 file <<
"</VTKFile>\n";
1332 std::string
const & fn)
1334 GISMO_ASSERT(X.cols() == Y.cols() && X.cols() == Z.cols(),
1335 "X, Y and Z must have the same size of columns!");
1336 GISMO_ASSERT(X.rows() == 1 && Y.rows() == 1 && Z.cols(),
1337 "X, Y and Z must be row matrices!");
1340 std::string mfn(fn);
1342 std::ofstream file(mfn.c_str());
1344 if (!file.is_open())
1346 gsWarn <<
"Problem opening " << fn <<
" Aborting..." << std::endl;
1351 file << std::setprecision (PLOT_PRECISION);
1353 file <<
"<?xml version=\"1.0\"?>\n";
1354 file <<
"<VTKFile type=\"PolyData\" version=\"0.1\" byte_order=\"LittleEndian\">\n";
1355 file <<
"<PolyData>\n";
1356 file <<
"<Piece NumberOfPoints=\""<<np<<
"\" NumberOfVerts=\"1\" NumberOfLines=\"0\" NumberOfStrips=\"0\" NumberOfPolys=\"0\">\n";
1357 file <<
"<PointData>\n";
1358 file <<
"</PointData>\n";
1359 file <<
"<CellData>\n";
1360 file <<
"</CellData>\n";
1361 file <<
"<Points>\n";
1362 file <<
"<DataArray type=\"Float32\" Name=\"Points\" NumberOfComponents=\"3\" format=\"ascii\" RangeMin=\""<<X.minCoeff()<<
"\" RangeMax=\""<<X.maxCoeff()<<
"\">\n";
1364 for (
index_t i = 0; i < np; ++i)
1366 file << X(0, i) <<
" " << Y(0, i) <<
" " << Z(0, i) <<
"\n";
1369 file <<
"\n</DataArray>\n";
1370 file <<
"</Points>\n";
1372 file <<
"<DataArray type=\"Int64\" Name=\"connectivity\" format=\"ascii\" RangeMin=\""<<0<<
"\" RangeMax=\""<<np-1<<
"\">\n";
1374 for (
index_t i=0; i< np; ++i )
1379 file <<
"\n</DataArray>\n";
1380 file <<
"<DataArray type=\"Int64\" Name=\"offsets\" format=\"ascii\" RangeMin=\""<<np<<
"\" RangeMax=\""<<np<<
"\">\n"<<np<<
"\n";
1381 file <<
"</DataArray>\n";
1382 file <<
"</Verts>\n";
1384 file <<
"<DataArray type=\"Int64\" Name=\"connectivity\" format=\"ascii\" RangeMin=\"0\" RangeMax=\""<<np-1<<
"\">\n";
1385 file <<
"</DataArray>\n";
1386 file <<
"<DataArray type=\"Int64\" Name=\"offsets\" format=\"ascii\" RangeMin=\""<<np<<
"\" RangeMax=\""<<np<<
"\">\n";
1387 file <<
"</DataArray>\n";
1388 file <<
"</Lines>\n";
1389 file <<
"<Strips>\n";
1390 file <<
"<DataArray type=\"Int64\" Name=\"connectivity\" format=\"ascii\" RangeMin=\"0\" RangeMax=\""<<np-1<<
"\">\n";
1391 file <<
"</DataArray>\n";
1392 file <<
"<DataArray type=\"Int64\" Name=\"offsets\" format=\"ascii\" RangeMin=\""<<np<<
"\" RangeMax=\""<<np<<
"\">\n";
1393 file <<
"</DataArray>\n";
1394 file <<
"</Strips>\n";
1396 file <<
"<DataArray type=\"Int64\" Name=\"connectivity\" format=\"ascii\" RangeMin=\"0\" RangeMax=\""<<np-1<<
"\">\n";
1397 file <<
"</DataArray>\n";
1398 file <<
"<DataArray type=\"Int64\" Name=\"offsets\" format=\"ascii\" RangeMin=\""<<np<<
"\" RangeMax=\""<<np<<
"\">\n";
1399 file <<
"</DataArray>\n";
1400 file <<
"</Polys>\n";
1401 file <<
"</Piece>\n";
1402 file <<
"</PolyData>\n";
1403 file <<
"</VTKFile>\n";
1411 gsMatrix<T>
const& Y,
1412 gsMatrix<T>
const& Z,
1413 gsMatrix<T>
const& V,
1414 std::string
const & fn)
1416 GISMO_ASSERT(X.cols() == Y.cols() && X.cols() == Z.cols(),
1417 "X, Y and Z must have the same size of columns!");
1418 GISMO_ASSERT(X.rows() == 1 && Y.rows() == 1 && Z.cols(),
1419 "X, Y and Z must be row matrices!");
1422 std::string mfn(fn);
1424 std::ofstream file(mfn.c_str());
1426 if (!file.is_open())
1428 gsWarn <<
"Problem opening " << fn <<
" Aborting..." << std::endl;
1433 file << std::setprecision (PLOT_PRECISION);
1435 file <<
"<?xml version=\"1.0\"?>\n";
1436 file <<
"<VTKFile type=\"PolyData\" version=\"0.1\" byte_order=\"LittleEndian\">\n";
1437 file <<
"<PolyData>\n";
1438 file <<
"<Piece NumberOfPoints=\""<<np<<
"\" NumberOfVerts=\"1\" NumberOfLines=\"0\" NumberOfStrips=\"0\" NumberOfPolys=\"0\">\n";
1440 file <<
"<PointData "<<
"Scalars=\"PointInfo\">\n";
1441 file <<
"<DataArray type=\"Float32\" Name=\"PointInfo\" format=\"ascii\" NumberOfComponents=\"1\">\n";
1443 file<< V(0,j) <<
" ";
1444 file <<
"</DataArray>\n";
1445 file <<
"</PointData>\n";
1447 file <<
"<CellData>\n";
1448 file <<
"</CellData>\n";
1449 file <<
"<Points>\n";
1450 file <<
"<DataArray type=\"Float32\" Name=\"Points\" NumberOfComponents=\"3\" format=\"ascii\" RangeMin=\""<<X.minCoeff()<<
"\" RangeMax=\""<<X.maxCoeff()<<
"\">\n";
1452 for (
index_t i = 0; i < np; ++i)
1454 file << X(0, i) <<
" " << Y(0, i) <<
" " << Z(0, i) <<
"\n";
1457 file <<
"\n</DataArray>\n";
1458 file <<
"</Points>\n";
1460 file <<
"<DataArray type=\"Int64\" Name=\"connectivity\" format=\"ascii\" RangeMin=\""<<0<<
"\" RangeMax=\""<<np-1<<
"\">\n";
1462 for (
index_t i=0; i< np; ++i )
1467 file <<
"\n</DataArray>\n";
1468 file <<
"<DataArray type=\"Int64\" Name=\"offsets\" format=\"ascii\" RangeMin=\""<<np<<
"\" RangeMax=\""<<np<<
"\">\n"<<np<<
"\n";
1469 file <<
"</DataArray>\n";
1470 file <<
"</Verts>\n";
1472 file <<
"<DataArray type=\"Int64\" Name=\"connectivity\" format=\"ascii\" RangeMin=\"0\" RangeMax=\""<<np-1<<
"\">\n";
1473 file <<
"</DataArray>\n";
1474 file <<
"<DataArray type=\"Int64\" Name=\"offsets\" format=\"ascii\" RangeMin=\""<<np<<
"\" RangeMax=\""<<np<<
"\">\n";
1475 file <<
"</DataArray>\n";
1476 file <<
"</Lines>\n";
1477 file <<
"<Strips>\n";
1478 file <<
"<DataArray type=\"Int64\" Name=\"connectivity\" format=\"ascii\" RangeMin=\"0\" RangeMax=\""<<np-1<<
"\">\n";
1479 file <<
"</DataArray>\n";
1480 file <<
"<DataArray type=\"Int64\" Name=\"offsets\" format=\"ascii\" RangeMin=\""<<np<<
"\" RangeMax=\""<<np<<
"\">\n";
1481 file <<
"</DataArray>\n";
1482 file <<
"</Strips>\n";
1484 file <<
"<DataArray type=\"Int64\" Name=\"connectivity\" format=\"ascii\" RangeMin=\"0\" RangeMax=\""<<np-1<<
"\">\n";
1485 file <<
"</DataArray>\n";
1486 file <<
"<DataArray type=\"Int64\" Name=\"offsets\" format=\"ascii\" RangeMin=\""<<np<<
"\" RangeMax=\""<<np<<
"\">\n";
1487 file <<
"</DataArray>\n";
1488 file <<
"</Polys>\n";
1489 file <<
"</Piece>\n";
1490 file <<
"</PolyData>\n";
1491 file <<
"</VTKFile>\n";
1500 const index_t rows = points.rows();
1504 gsWriteParaviewPoints<T>(points.row(0),
gsMatrix<T>::Zero(1, points.cols()), fn);
1507 gsWriteParaviewPoints<T>(points.row(0), points.row(1), fn);
1510 gsWriteParaviewPoints<T>(points.row(0), points.row(1), points.row(2), fn);
1513 gsWriteParaviewPoints<T>(points.row(0), points.row(1), points.row(2), points.row(3), fn);
1516 GISMO_ERROR(
"Point plotting is implemented just for 2D and 3D (rows== 1, 2 or 3).");
1524 void gsWriteParaview(
gsSolid<T> const& sl, std::string
const & fn,
unsigned numPoints_for_eachCurve,
int vol_Num,
1525 T edgeThick,
gsVector3d<T> const & translate,
int color_convex,
1526 int color_nonconvex,
int color_eloop, std::vector<unsigned>
const & eloop)
1529 int color=color_convex;
1531 gsSolidHalfFace<T>* face;
1533 int numOfPoints = numPoints_for_eachCurve;
1535 T faceThick = edgeThick;
1540 std::string mfn(fn);
1542 std::ofstream file(mfn.c_str());
1543 if ( ! file.is_open() )
1544 gsWarn<<
"gsWriteParaview: Problem opening file \""<<fn<<
"\""<<std::endl;
1546 file << std::setprecision (PLOT_PRECISION);
1547 file <<
"<?xml version=\"1.0\"?>\n";
1548 file <<
"<VTKFile type=\"PolyData\" version=\"0.1\" byte_order=\"LittleEndian\">\n";
1549 file <<
"<PolyData>\n";
1553 numOfCurves = eloop.size();
1554 gsSolidHalfEdge<T>* he;
1555 std::vector< typename gsSolid<T>::gsSolidHalfEdgeHandle > heSet;
1556 typename gsSolid<T>::gsSolidHeVertexHandle source,target;
1557 if (eloop.size()>0){
1558 for (
int iedge=0; iedge!= numOfCurves; iedge++)
1560 source = sl.vertex[eloop[iedge]];
1561 target = sl.vertex[eloop[(iedge+1)%numOfCurves]];
1562 he = source->getHalfEdge(target);
1563 heSet.push_back(he);
1569 for (
int iface=0;iface!= sl.nHalfFaces();iface++)
1571 face = sl.getHalfFaceFromID(iface);
1574 if (face->vol->getId()==vol_Num)
1576 numOfCurves=face->nCurvesOfOneLoop(0);
1579 for (
int iedge=0; iedge!= numOfCurves; iedge++)
1581 he = face->getHalfEdgeFromBoundaryOrder(iedge);
1583 bool isMember(
false);
1584 for (
size_t iheSet=0;iheSet<heSet.size();iheSet++)
1586 if ( he->isEquiv(heSet.at(iheSet))==
true || he->mate->isEquiv(heSet.at(iheSet))==
true)
1590 gsMatrix<T> curvePoints = face->surf->sampleBoundaryCurve(iedge, numPoints_for_eachCurve);
1591 if (iedge==0) assert( numOfPoints == curvePoints.cols());
1593 if (isMember==
true) color=color_eloop;
1594 if (face->getHalfEdgeFromBoundaryOrder(iedge)->is_convex==
false){color = color_nonconvex;}
1596 file <<
"<Piece NumberOfPoints=\""<< 2*numOfPoints <<
"\" NumberOfVerts=\"0\" NumberOfLines=\""<< 0
1597 <<
"\" NumberOfStrips=\"0\" NumberOfPolys=\""<< numOfPoints-1 <<
"\">\n";
1600 file <<
"<Points>\n";
1601 file <<
"<DataArray type=\"Float32\" NumberOfComponents=\"3\" format=\"ascii\">\n";
1603 for (
index_t iCol = 0;iCol!=curvePoints.cols();iCol++)
1605 file << curvePoints(0,iCol) + translate(0) <<
" " << curvePoints(1,iCol) + translate(1) <<
" " << curvePoints(2,iCol) + translate(2) <<
" \n";
1607 file << curvePoints(0,iCol) + faceThick + translate(0) <<
" " << curvePoints(1,iCol) + faceThick + translate(1)
1608 <<
" " << curvePoints(2,iCol) +faceThick + translate(2) <<
" \n";
1611 file <<
"</DataArray>\n";
1612 file <<
"</Points>\n";
1615 file <<
"<CellData Scalars=\"cell_scalars\">\n";
1616 file <<
"<DataArray type=\"Int32\" Name=\"cell_scalars\" format=\"ascii\">\n";
1618 for (
index_t iCol = 0;iCol!=curvePoints.cols()-1;iCol++)
1620 file << color <<
" ";
1623 file <<
"</DataArray>\n";
1624 file <<
"</CellData>\n";
1627 file <<
"<Polys>\n";
1628 file <<
"<DataArray type=\"Int32\" Name=\"connectivity\" format=\"ascii\">\n";
1629 for (
index_t iCol = 0;iCol<=curvePoints.cols()-2;iCol++)
1632 file << 2*iCol <<
" " << 2*iCol+1 <<
" "<< 2*iCol+3 <<
" " << 2*iCol+2 <<
" ";
1636 file <<
"</DataArray>\n";
1637 file <<
"<DataArray type=\"Int32\" Name=\"offsets\" format=\"ascii\">\n";
1638 unsigned offsets(0);
1639 for (
index_t iCol = 0;iCol!=curvePoints.cols()-1;iCol++)
1642 file << offsets <<
" ";
1645 file <<
"</DataArray>\n";
1646 file <<
"</Polys>\n";
1648 file <<
"</Piece>\n";
1657 file <<
"</PolyData>\n";
1658 file <<
"</VTKFile>\n";
1666 std::string
const & fn,
1667 unsigned numSamples)
1669 const size_t n = sl.numHalfFaces;
1675 for (
size_t i=0; i<n ; i++)
1679 writeSingleTrimSurface(*sl.face[i]->surf, fnBase, numSamples);
1680 collection.
addPart(fnBase_nopath +
".vtp");
1690 void gsWriteParaview(
gsMesh<T> const& sl, std::string
const & fn,
bool pvd)
1692 std::string mfn(fn);
1694 std::ofstream file(mfn.c_str());
1695 if ( ! file.is_open() )
1696 gsWarn<<
"gsWriteParaview: Problem opening file \""<<fn<<
"\""<<std::endl;
1698 file << std::setprecision (PLOT_PRECISION);
1700 file <<
"<?xml version=\"1.0\"?>\n";
1701 file <<
"<VTKFile type=\"PolyData\" version=\"0.1\" byte_order=\"LittleEndian\">\n";
1702 file <<
"<PolyData>\n";
1705 file <<
"<Piece NumberOfPoints=\""<< sl.numVertices() <<
"\" NumberOfVerts=\"0\" NumberOfLines=\""
1706 << sl.numEdges()<<
"\" NumberOfStrips=\"0\" NumberOfPolys=\""<< sl.numFaces() <<
"\">\n";
1709 file <<
"<Points>\n";
1710 file <<
"<DataArray type=\"Float32\" NumberOfComponents=\"3\" format=\"ascii\">\n";
1711 for (
typename std::vector<
gsVertex<T>* >::const_iterator it=sl.vertices().begin(); it!=sl.vertices().end(); ++it)
1714 file << vertex[0] <<
" ";
1715 file << vertex[1] <<
" ";
1716 file << vertex[2] <<
" \n";
1720 file <<
"</DataArray>\n";
1721 file <<
"</Points>\n";
1736 file <<
"<Lines>\n";
1737 file <<
"<DataArray type=\"Int32\" Name=\"connectivity\" format=\"ascii\">\n";
1738 for (
typename std::vector< gsEdge<T> >::const_iterator it=sl.edges().begin();
1739 it!=sl.edges().end(); ++it)
1741 file << it->source->getId() <<
" " << it->target->getId() <<
"\n";
1743 file <<
"</DataArray>\n";
1744 file <<
"<DataArray type=\"Int32\" Name=\"offsets\" format=\"ascii\">\n";
1746 for (
typename std::vector< gsEdge<T> >::const_iterator it=sl.edges().begin();
1747 it!=sl.edges().end(); ++it)
1750 file << count <<
" ";
1753 file <<
"</DataArray>\n";
1754 file <<
"</Lines>\n";
1769 file <<
"<Polys>\n";
1770 file <<
"<DataArray type=\"Int32\" Name=\"connectivity\" format=\"ascii\">\n";
1771 for (
typename std::vector< gsFace<T>* >::const_iterator it=sl.faces().begin();
1772 it!=sl.faces().end(); ++it)
1774 for (
typename std::vector<
gsVertex<T>* >::const_iterator vit= (*it)->vertices.begin();
1775 vit!=(*it)->vertices.end(); ++vit)
1777 file << (*vit)->getId() <<
" ";
1781 file <<
"</DataArray>\n";
1782 file <<
"<DataArray type=\"Int32\" Name=\"offsets\" format=\"ascii\">\n";
1784 for (
typename std::vector< gsFace<T>* >::const_iterator it=sl.faces().begin();
1785 it!=sl.faces().end(); ++it)
1787 count += (*it)->vertices.size();
1788 file << count <<
" ";
1791 file <<
"</DataArray>\n";
1792 file <<
"</Polys>\n";
1794 file <<
"</Piece>\n";
1795 file <<
"</PolyData>\n";
1796 file <<
"</VTKFile>\n";
1807 "Incorrect number of data: "<< params.cols() <<
" != "<< sl.numVertices() );
1809 std::string mfn(fn);
1811 std::ofstream file(mfn.c_str());
1812 if ( ! file.is_open() )
1813 gsWarn<<
"gsWriteParaview: Problem opening file \""<<fn<<
"\""<<std::endl;
1815 file << std::setprecision (PLOT_PRECISION);
1817 file <<
"# vtk DataFile Version 4.2\n";
1818 file <<
"vtk output\n";
1820 file <<
"DATASET POLYDATA\n";
1823 file <<
"POINTS " << sl.numVertices() <<
" float\n";
1824 for (
typename std::vector<
gsVertex<T>* >::const_iterator it=sl.vertices().begin(); it!=sl.vertices().end(); ++it)
1827 file << vertex[0] <<
" ";
1828 file << vertex[1] <<
" ";
1829 file << vertex[2] <<
" \n";
1834 file <<
"POLYGONS " << sl.numFaces() <<
" " <<
1835 (sl.faces().front()->vertices.size()+1) * sl.numFaces() << std::endl;
1836 for (
typename std::vector< gsFace<T>* >::const_iterator it=sl.faces().begin();
1837 it!=sl.faces().end(); ++it)
1839 file << (*it)->vertices.size() <<
" ";
1840 for (
typename std::vector<
gsVertex<T>* >::const_iterator vit=
1841 (*it)->vertices.begin(); vit!=(*it)->vertices.end(); ++vit)
1843 file << (*vit)->getId() <<
" ";
1850 file <<
"POINT_DATA " << sl.numVertices() << std::endl;
1852 if ( 3 == params.rows() )
1853 file <<
"VECTORS Data float\n";
1855 file <<
"SCALARS Data float "<<params.rows()<<
"\nLOOKUP_TABLE default\n";
1857 for(
index_t j=0; j<params.cols(); j++)
1859 for(
index_t i=0; i<params.rows(); i++)
1860 file << params(i,j) <<
" ";
1867 template <
typename T>
1869 const std::string& fn)
1871 for (
unsigned index = 0; index < meshes.size(); index++)
1874 gsWriteParaview(meshes[index], file,
false);
1881 std::vector<gsGeometry<T> *> all_curves;
1882 for(
index_t i =0; i<pdomain.numLoops();i++)
1883 for(
index_t j =0; j< pdomain.loop(i).numCurves() ; j++)
1884 all_curves.push_back( const_cast<
gsCurve<T> *>(&pdomain.loop(i).curve(j)) );
1886 gsWriteParaview( all_curves, fn, npts);
1891 unsigned npts,
bool trimCurves)
1895 writeSingleTrimSurface(surf, fn, npts);
1897 collection.
addPart(fn_nopath +
".vtp");
1901 gsWarn<<
"trimCurves: To do.\n";
1908 template<
typename T>
1909 void gsWriteParaview(
const gsVolumeBlock<T>& volBlock,
1910 std::string
const & fn,
1918 for (
unsigned idFace = 0; idFace != volBlock.face.size(); idFace++)
1920 typename gsVolumeBlock<T>::HalfFace* face = volBlock.face[idFace];
1924 unsigned numLoops =
static_cast<unsigned>(domain.numLoops());
1925 for (
unsigned idLoop = 0; idLoop < numLoops; idLoop++)
1929 unsigned clSize =
static_cast<unsigned>(curveLoop.size());
1932 for (
unsigned idCurve = 0; idCurve < clSize; idCurve++)
1935 std::string fileName = fn +
"_curve_F";
1944 collection.
addPart(fileName_nopath +
".vts");
1953 template<
typename T>
1955 std::string
const & fn,
1956 unsigned npts,
bool ctrlNet)
1958 typename gsMultiPatch<T>::BoundaryRep
const & brep = patches.boundaryRep();
1959 GISMO_ENSURE(brep.
size()!=0,
"Boundary representation is empty. Call gsMultiPatch::constructBoundaryRep first!");
1961 for (
auto it = brep.
begin(); it!=brep.
end(); ++it)
1963 gsWriteParaview<T>(bnd_net,fn,npts,
false,ctrlNet);
1966 template<
typename T>
1968 std::string
const & fn,
1969 unsigned npts,
bool ctrlNet)
1972 typename gsMultiPatch<T>::InterfaceRep
const & irep = patches.interfaceRep();
1973 GISMO_ENSURE(irep.
size()!=0,
"Interface representation is empty. Call gsMultiPatch::constructInterfaceRep first!");
1975 for (
auto it = irep.
begin(); it!=irep.
end(); ++it)
1977 gsWriteParaview<T>(iface_net,fn,npts,
false,ctrlNet);
1980 template<
typename T>
1982 typename gsBoundaryConditions<T>::bcContainer
const & bcs,
1983 std::string
const & fn,
unsigned npts,
bool ctrlNet)
1986 for (
typename gsBoundaryConditions<T>::const_iterator bc=bcs.
begin(); bc!=bcs.
end(); bc++)
1987 bc_net.
addPatch(patches[bc->patch()].boundary(bc->side()));
1988 gsWriteParaview<T>(bc_net,fn,npts,
false,ctrlNet);
1991 template<
typename T>
1993 const unsigned idLoop,
1994 const unsigned idCurve,
1995 const std::string fn,
2000 int idL =
static_cast<int>(idLoop);
2001 int idC =
static_cast<int>(idCurve);
2015 np.conservativeResize(3);
2016 np.bottomRows(3 - 1).setOnes();
2021 std::string myFile(fn);
2022 myFile.append(
".vts");
2024 std::ofstream file(myFile.c_str());
2025 if (!file.is_open())
2027 gsWarn <<
"Problem opening " << fn <<
" Aborting..." << std::endl;
2032 file << std::setprecision (PLOT_PRECISION);
2034 file <<
"<?xml version=\"1.0\"?>\n";
2035 file <<
"<VTKFile type=\"StructuredGrid\" version=\"0.1\">\n";
2036 file <<
"<StructuredGrid WholeExtent=\"0 "<< np(0) - 1 <<
2037 " 0 " << np(1) - 1 <<
" 0 " << np(2) - 1 <<
"\">\n";
2039 file <<
"<Piece Extent=\"0 " << np(0) - 1 <<
" 0 " << np(1) - 1 <<
" 0 "
2040 << np(2) - 1 <<
"\">\n";
2042 file <<
"<Points>\n";
2043 file <<
"<DataArray type=\"Float32\" NumberOfComponents=\"" << points.rows()
2046 for (
index_t j = 0; j < points.cols(); ++j)
2048 for (
index_t i = 0; i < points.rows(); ++i)
2050 file << points(i, j) <<
" ";
2055 file <<
"</DataArray>\n";
2056 file <<
"</Points>\n";
2057 file <<
"</Piece>\n";
2058 file <<
"</StructuredGrid>\n";
2059 file <<
"</VTKFile>\n";
2067 #undef PLOT_PRECISION
index_t addPatch(typename gsGeometry< T >::uPtr g)
Add a patch from a gsGeometry<T>::uPtr.
Definition: gsMultiPatch.hpp:210
T projectedErrorRef() const
The error contribution of *this when it is refined.
Definition: gsHBox.hpp:307
void evaluateMesh(gsMesh< T > &mesh) const
Definition: gsGeometry.hpp:255
Abstract base class representing a geometry map.
Definition: gsGeometry.h:92
A fixed-size, statically allocated 3D vector.
Definition: gsVector.h:218
gsCurve< T > & getCurve(int loopNumber, int curveNumber) const
Returns curveNumber-th curve in loopNumber-th loop.
Definition: gsTrimSurface.h:103
void controlNet(gsMesh< T > &mesh) const
Return the control net of the geometry.
Definition: gsGeometry.hpp:524
Class for a trim surface.
Definition: gsTrimSurface.h:33
void gsWriteParaview_basisFnct(int i, gsBasis< T > const &basis, std::string const &fn, unsigned npts=NS)
Export i-th Basis function to paraview file.
Definition: gsWriteParaview.hpp:984
Abstract base class representing a curve.
Definition: gsCurve.h:30
gsMatrix< T > parameterRange() const
Returns the range of parameters as a matrix with two columns, [lower upper].
Definition: gsGeometry.hpp:198
#define gsDebug
Definition: gsDebug.h:61
A scalar of vector field defined on a m_parametric geometry.
Definition: gsField.h:54
const gsFunction< T > & function(int i=0) const
Returns the gsFunction of patch i.
Definition: gsField.h:231
#define short_t
Definition: gsConfig.h:35
void writeSingleBasisMesh(const gsBasis< T > &basis, std::string const &fn)
Export a parametric mesh.
Definition: gsWriteParaview.hpp:218
const gsFunction< T > & function(const index_t k) const
Helper which casts and returns the k-th piece of this function set as a gsFunction.
Definition: gsFunctionSet.hpp:25
std::string to_string(const C &value)
Converts value to string, assuming "operator<<" defined on C.
Definition: gsUtils.h:56
const_iterator begin(const std::string &label) const
Returns a const-iterator to the beginning of the Bc container of type label.
Definition: gsBoundaryConditions.h:471
void gsWriteParaviewIfc(gsMultiPatch< T > const &patches, std::string const &fn, unsigned npts, bool ctrlNet)
Writes the interfaces of a multipatch to paraview.
Definition: gsWriteParaview.hpp:1967
This class provides a Hierarchical Box (gsHBox)
Definition: gsHBox.h:54
Provides interface of gsTrimSurface class. Represents a trimmed surface (= spline "master surface" in...
index_t level() const
Gets the level of the object.
Definition: gsHBox.hpp:287
virtual index_t size() const
size
Definition: gsFunctionSet.h:578
gsMatrix< T > eval(const gsMatrix< T > &u) const
Evaluate the function,.
Definition: gsFunctionSet.hpp:120
Provides declaration of Geometry abstract interface.
const gsMatrix< T > & getCoordinates() const
Gets the coordinates of the box (first column lower corner, second column higher corner).
Definition: gsHBox.hpp:231
#define index_t
Definition: gsConfig.h:32
#define GISMO_ENSURE(cond, message)
Definition: gsDebug.h:102
A function from a n-dimensional domain to an m-dimensional image.
Definition: gsFunction.h:59
void computeCoordinates() const
Computes the parametric coordinates of this.
Definition: gsHBox.hpp:633
static std::string getFilename(std::string const &fn)
Returns the filename without the path of fn.
Definition: gsFileManager.cpp:597
void gsWriteParaviewPoints(gsMatrix< T > const &X, gsMatrix< T > const &Y, std::string const &fn)
Export 2D Point set to Paraview file.
Definition: gsWriteParaview.hpp:1267
bool isParametrized() const
Definition: gsField.h:257
This file contains the debugging and messaging system of G+Smo.
#define GISMO_ASSERT(cond, message)
Definition: gsDebug.h:89
Input and output Utilities.
virtual short_t targetDim() const
Dimension of the target space.
Definition: gsFunctionSet.h:560
virtual const gsFunctionSet & piece(const index_t) const
Returns the piece(s) of the function(s) at subdomain k.
Definition: gsFunctionSet.h:239
Class Representing a triangle mesh with 3D vertices.
Definition: gsMesh.h:31
index_t size() const
size
Definition: gsMultiPatch.h:129
std::string to_string(const unsigned &i)
Helper to convert small unsigned to string.
Definition: gsXml.cpp:74
#define gsWarn
Definition: gsDebug.h:50
Holds a set of patch-wise bases and their topology information.
Definition: gsMultiBasis.h:36
void writeSingleGeometry(gsFunction< T > const &func, gsMatrix< T > const &supp, std::string const &fn, unsigned npts)
Export a geometry represented by func.
Definition: gsWriteParaview.hpp:469
gsMatrix< T > evalSingle(index_t i, const gsMatrix< T > &u) const
Evaluate a single basis function i at points u.
Definition: gsBasis.h:122
bool isParametric() const
Definition: gsField.h:252
Provides declaration of the MultiPatch class.
gsGeometry< T > & patch(size_t i) const
Return the i-th patch.
Definition: gsMultiPatch.h:226
void gsWriteParaviewTrimmedCurve(const gsTrimSurface< T > &surf, const unsigned idLoop, const unsigned idCurve, const std::string fn, unsigned npts=NS)
Export a boundary/hole curve in trimmed surface.
Definition: gsWriteParaview.hpp:1992
void gsWriteParaviewSolid(gsSolid< T > const &sl, std::string const &fn, unsigned numSamples=NS)
Export a gsSolid to Paraview file.
Definition: gsWriteParaview.hpp:1665
virtual short_t domainDim() const
Dimension d of the parameter domain (overriding gsFunction::domainDim()).
Definition: gsGeometry.hpp:184
size_t nPatches() const
Number of patches.
Definition: gsMultiPatch.h:208
Provides a helper class to write Paraview collection (.pvd) files.
const_iterator end(const std::string &label) const
Returns a const-iterator to the end of the Bc container of type label.
Definition: gsBoundaryConditions.h:477
gsMatrix< T > gsPointGrid(gsVector< T > const &a, gsVector< T > const &b, gsVector< unsigned > const &np)
Construct a Cartesian grid of uniform points in a hypercube, using np[i] points in direction i...
Definition: gsPointGrid.hpp:82
const_iterator end() const
Definition: gsMultiPatch.h:108
void save()
Definition: gsParaviewCollection.h:203
virtual short_t domainDim() const =0
Dimension of the (source) domain.
gsGeometrySlice is a class representing an iso parametric slice of a geometry object. It stores a pointer to the geometry object, which is only valid as long as this object is alive. Methods for printing to paraview are available in gsWriteToParaview.h
Definition: gsGeometrySlice.h:27
Interface for the set of functions defined on a domain (the total number of functions in the set equa...
Definition: gsFuncData.h:23
Container class for a set of geometry patches and their topology, that is, the interface connections ...
Definition: gsMultiPatch.h:33
This class is used to create a Paraview .pvd (collection) file.
Definition: gsParaviewCollection.h:76
void addPart(String const &fn, real_t tStep=-1, std::string name="", index_t part=-1)
Appends a file to the Paraview collection (.pvd file).
Definition: gsParaviewCollection.h:114
short_t parDim() const
Dimension d of the parameter domain (same as domainDim()).
Definition: gsGeometry.hpp:190
virtual void eval_into(const gsMatrix< T > &u, gsMatrix< T > &result) const =0
Evaluate the function at points u into result.
void evalCurve_into(int loopNumber, int curveNumber, const gsMatrix< T > &u, gsMatrix< T > &result) const
Definition: gsTrimSurface.h:133
void writeSingleCompMesh(const gsBasis< T > &basis, const gsGeometry< T > &Geo, std::string const &fn, unsigned resolution=8)
Export a computational mesh.
Definition: gsWriteParaview.hpp:232
Class representing a Planar domain with an outer boundary and a number of holes.
Definition: gsPlanarDomain.h:43
void gsWriteParaviewBdr(gsMultiPatch< T > const &patches, std::string const &fn, unsigned npts, bool ctrlNet)
Writes the boundaries of a multipatch to paraview.
Definition: gsWriteParaview.hpp:1954
const gsBasis< T > & basis(const size_t i) const
Return the i-th basis block.
Definition: gsMultiBasis.h:267
Provides a container for gsHBox.
void writeSingleHBox(gsHBox< 2, T > &box, std::string const &fn)
Export a gsHBox.
Definition: gsWriteParaview.hpp:1180
virtual index_t nPieces() const
Number of pieces in the domain of definition.
Definition: gsFunctionSet.h:584
size_t nBases() const
Number of patch-wise bases.
Definition: gsMultiBasis.h:264
Class for representing a solid made up of vertices, edges, faces, and volumes.
Definition: gsSolid.h:32
#define GISMO_ERROR(message)
Definition: gsDebug.h:118
int nPieces() const
Returns the number of pieces.
Definition: gsField.h:200
const_iterator begin() const
Definition: gsMultiPatch.h:103
A closed loop given by a collection of curves.
Definition: gsCurveLoop.h:36
void makeCollection(std::string const &fn, std::string const &ext, int n=0)
Definition: gsParaviewCollection.h:258
virtual const gsBasis< T > & basis() const =0
Returns a const reference to the basis of the geometry.
void writeSingleCurve(gsFunction< T > const &func, gsMatrix< T > const &supp, std::string const &fn, unsigned npts)
Export a curve geometry represented by func.
Definition: gsWriteParaview.hpp:556
void writeSingleControlNet(const gsGeometry< T > &Geo, std::string const &fn)
Export a control net.
Definition: gsWriteParaview.hpp:248
virtual gsMatrix< T > support() const
Returns (a bounding box for) the domain of the whole basis.
Definition: gsBasis.hpp:431
Provides declaration of the gsGeometrySlice class.
short_t geoDim() const
Dimension n of the absent physical space.
Definition: gsGeometry.h:292
const gsGeometry< T > & patch(int i=0) const
Returns the gsGeometry of patch i.
Definition: gsField.h:221
A basis represents a family of scalar basis functions defined over a common parameter domain...
Definition: gsBasis.h:78
Provides declaration of the Field class.
gsMatrix< T > & coefs()
Definition: gsGeometry.h:340
gsVertex class that represents a 3D vertex for a gsMesh.
Definition: gsVertex.h:26
const gsGeometry< T > & igaFunction(int i=0) const
Attempts to return an Isogeometric function for patch i.
Definition: gsField.h:239
Provides declaration of gsSolid class, a boundary-represented solid.
T error() const
Gets the error stored in the object.
Definition: gsHBox.hpp:304