24 #define PLOT_PRECISION 11
35 std::string
const & fn)
43 gsMatrix<T> anch = Geo.basis().anchors();
45 for (std::size_t i = 0; i!= msh.numVertices(); ++i)
47 msh.vertex(i)[d] = msh.vertex(i)[0];
48 msh.vertex(i).topRows(d) = anch.col(i);
53 gsDebug<<
"Writing 4th coordinate\n";
54 const gsMatrix<T> & cp = Geo.coefs();
55 gsWriteParaviewPoints<T>(cp.transpose(), fn );
59 gsWriteParaview(msh, fn,
false);
64 std::string
const & fn,
unsigned resolution)
66 gsMesh<T> msh(basis, resolution);
67 Geo.evaluateMesh(msh);
68 gsWriteParaview(msh, fn,
false);
77 std::string
const & fn,
78 unsigned npts,
bool mesh,
bool ctrlNet)
81 const unsigned numP = fields.begin()->second->patches().nPatches();
85 for (
unsigned i=0; i < numP; ++i )
87 const gsBasis<> & dom = fields.begin()->second->isParametrized() ?
88 fields.begin()->second->igaFunction(i).
basis() : fields.begin()->second->patch(i).basis();
112 const unsigned numP = fields.begin()->second->patches().nPatches();
113 for (
size_t p = 0; p < numP; ++p)
124 const unsigned patchNum,
125 std::string
const & fn,
128 const gsGeometry<> & geometry = fields.begin()->second->patches().patch(patchNum);
139 std::map<std::string, gsMatrix<> > data;
140 for (
typename std::map<std::string,
const gsField<T> *>::iterator it = fields.begin(); it != fields.end(); it++)
142 data[it->first] = it->second->isParametric() ?
143 it->second->function(patchNum).eval(pts) : it->second->function(patchNum).eval(eval_geo);
145 if ( data[it->first].rows() == 2 )
147 data[it->first].conservativeResize(3,eval_geo.cols() );
148 data[it->first].row(2).setZero();
154 np.conservativeResize(3);
155 np.bottomRows(3-d).setOnes();
159 gsWarn<<
"Cannot plot 4D data.\n";
165 eval_geo.conservativeResize(3,eval_geo.cols() );
166 eval_geo.bottomRows(3-n).setZero();
170 gsWarn<<
"Data is more than 3 dimensions.\n";
189 std::string
const & fn)
191 const int n = points.rows();
195 std::ofstream file(mfn.c_str());
197 file << std::setprecision (PLOT_PRECISION);
199 file <<
"<?xml version=\"1.0\"?>\n";
200 file <<
"<VTKFile type=\"StructuredGrid\" version=\"0.1\">\n";
201 file <<
"<StructuredGrid WholeExtent=\"0 "<< np(0)-1<<
" 0 "<<np(1)-1<<
" 0 "
202 << (np.size()>2 ? np(2)-1 : 0) <<
"\">\n";
203 file <<
"<Piece Extent=\"0 "<< np(0)-1<<
" 0 "<<np(1)-1<<
" 0 "
204 << (np.size()>2 ? np(2)-1 : 0) <<
"\">\n";
206 file <<
"<PointData>\n";
207 for (
typename std::map<std::string,
gsMatrix<T> >::iterator it = data.begin(); it != data.end(); it++)
209 file <<
"<DataArray type=\"Float32\" Name=\""<< it->first <<
"\" format=\"ascii\" NumberOfComponents=\""<< ( it->second.rows()==1 ? 1 : 3) <<
"\">\n";
210 if ( it->second.rows()==1 )
211 for (
index_t j=0; j<it->second.cols(); ++j)
212 file<< it->second.at(j) <<
" ";
215 for (
index_t j=0; j<it->second.cols(); ++j)
217 for (
index_t i=0; i!=it->second.rows(); ++i)
218 file<< it->second(i,j) <<
" ";
219 for (
index_t i=it->second.rows(); i<3; ++i)
223 file <<
"</DataArray>\n";
225 file <<
"</PointData>\n";
227 file <<
"<DataArray type=\"Float32\" NumberOfComponents=\"3\">\n";
228 for (
index_t j=0; j<points.cols(); ++j)
231 file<< points(i,j) <<
" ";
235 file <<
"</DataArray>\n";
236 file <<
"</Points>\n";
238 file <<
"</StructuredGrid>\n";
239 file <<
"</VTKFile>\n";
247 #undef PLOT_PRECISION
Abstract base class representing a geometry map.
Definition: gsGeometry.h:92
void gsWriteParaviewMultiTPgrid(gsMatrix< T > const &points, std::map< std::string, gsMatrix< T > > &data, const gsVector< index_t > &np, std::string const &fn)
Utility function to actually write prepaired matrices with data into Paraview file.
Definition: gsWriteParaviewMultiPhysics.hpp:186
#define gsDebug
Definition: gsDebug.h:61
A scalar of vector field defined on a m_parametric geometry.
Definition: gsField.h:54
#define short_t
Definition: gsConfig.h:35
std::string to_string(const C &value)
Converts value to string, assuming "operator<<" defined on C.
Definition: gsUtils.h:56
#define index_t
Definition: gsConfig.h:32
static std::string getFilename(std::string const &fn)
Returns the filename without the path of fn.
Definition: gsFileManager.cpp:597
Provides declaration of functions writing Paraview files.
A matrix with arbitrary coefficient type and fixed or dynamic size.
Definition: gsMatrix.h:38
A vector with arbitrary coefficient type and fixed or dynamic size.
Definition: gsVector.h:35
Provides isogeometric meshing and modelling routines.
#define gsWarn
Definition: gsDebug.h:50
const gsBasis< T > & basis(const index_t k) const
Helper which casts and returns the k-th piece of this function set as a gsBasis.
Definition: gsFunctionSet.hpp:33
virtual short_t domainDim() const
Dimension d of the parameter domain (overriding gsFunction::domainDim()).
Definition: gsGeometry.hpp:184
void gsWriteParaviewMultiPhysicsTimeStep(std::map< std::string, const gsField< T > * > fields, std::string const &fn, gsParaviewCollection &collection, int time, unsigned npts=NS)
Write a file containing several fields defined on the same geometry to ONE paraview file and adds it ...
Definition: gsWriteParaviewMultiPhysics.hpp:109
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
void save()
Definition: gsParaviewCollection.h:203
void gsWriteParaviewMultiPhysicsSinglePatch(std::map< std::string, const gsField< T > * > fields, const unsigned patchNum, std::string const &fn, unsigned npts)
Extract and evaluate geometry and the fields for a single patch.
Definition: gsWriteParaviewMultiPhysics.hpp:123
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
Provides declaration of the Mesh class.
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
gsMatrix< T > support() const
Returns the range of parameters (same as parameterRange())
Definition: gsGeometry.hpp:193
Provides functions to generate structured point data.
Allows to write several fields defined on the same geometry in one file, making it easier to operate ...
void gsWriteParaviewMultiPhysics(std::map< std::string, const gsField< T > * > fields, std::string const &fn, unsigned npts=NS, bool mesh=false, bool ctrlNet=false)
Write a file containing several fields defined on the same geometry to ONE paraview file...
Definition: gsWriteParaviewMultiPhysics.hpp:76
short_t targetDim() const
Dimension of the ambient physical space (overriding gsFunction::targetDim())
Definition: gsGeometry.h:286
Provides declaration of Function abstract interface.
void writeSingleControlNet(const gsGeometry< T > &Geo, std::string const &fn)
Export a control net.
Definition: gsWriteParaview.hpp:248
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.