G+Smo  25.01.0
Geometry + Simulation Modules
 
Loading...
Searching...
No Matches
gsParaviewUtils.h
Go to the documentation of this file.
1
13#pragma once
14
15// #include <gismo.h>
17#include <gsMSplines/gsMappedBasis.h> // Only to make linker happy
18#include <gsCore/gsDofMapper.h> // Only to make linker happy
21// #include <gsIO/gsIOUtils.h>
22
23
24
25#define VTK_BEZIER_QUADRILATERAL 77
26
27namespace gismo
28{
37 template <class T>
38 std::vector<std::string> toVTK(const gsFunctionSet<T>& funSet,
39 unsigned nPts = 1000,
40 unsigned precision = 5,
41 std::string label = "",
42 const bool& export_base64 = false);
43
44
45 template <class T>
46 std::vector<std::string> toVTK(const gsField<T>& field,
47 unsigned nPts = 1000,
48 unsigned precision = 5,
49 std::string label = "",
50 const bool& export_base64 = false);
51
52
63 template <class MatrixType>
64 std::string toDataArray(const MatrixType & matrix,
65 std::map<std::string, std::string> attributes={{"",""}},
66 unsigned precision = 5,
67 const bool& export_base64=false);
68
77 template <class E>
78 std::vector<std::string> toVTK(const expr::_expr<E>& expr,
79 gsExprEvaluator<> * evaltr,
80 unsigned nPts = 1000,
81 unsigned precision = 5,
82 std::string label = "SolutionField",
83 const bool& export_base64 = false)
84 {
85 std::vector<std::string> out;
86
87 // if false, embed topology ?
88 const index_t n = evaltr->exprData()->multiBasis().nBases();
89
90 gsMatrix<real_t> evaluated_values, bounding_box_dimensions;
91
92 for (index_t i = 0; i != n; ++i) {
93 // Get bounding box and sample evaluation points on current patch
94 bounding_box_dimensions =
95 evaltr->exprData()->multiBasis().piece(i).support();
96 gsGridIterator<real_t, CUBE> grid_iterator(bounding_box_dimensions,
97 nPts);
98 evaltr->eval(expr, grid_iterator, i);
99
100 // Evaluate Expression on grid_points
101 evaluated_values = evaltr->allValues(
102 evaltr->elementwise().size() / grid_iterator.numPoints(),
103 grid_iterator.numPoints());
104
105
106 GISMO_ASSERT(evaluated_values.rows() <= 3, "The expression can be scalar or have at most 3 components.");
107 if (evaluated_values.rows() == 2)
108 // Pad matrix with zeros
109 evaluated_values.conservativeResizeLike(gsEigen::MatrixXd::Zero(3,evaluated_values.cols()));
110
111 out.push_back(toDataArray(evaluated_values,{{"Name",label}}, precision,export_base64));
112
113 }
114 return out;
115 }
116
117
118
119
120
125 GISMO_EXPORT gsMatrix<real_t> vtkIDTransform(index_t nU, index_t nV);
126
127
128
134 GISMO_EXPORT std::string toDataArray(index_t num, std::map<std::string, std::string> attributes={{"",""}});
135
136
137
138 template<class T>
139 std::string BezierVTK(const gsMultiPatch<T> & mPatch);
140} // namespace gismo
141
142#undef VTK_BEZIER_QUADRILATERAL
143
144#ifndef GISMO_BUILD_LIB
145#include GISMO_HPP_HEADER(gsParaviewUtils.hpp)
146#endif
Generic evaluator of isogeometric expressions.
Definition gsExprEvaluator.h:39
gsAsConstVector< T > allValues() const
Returns a vector containing the last computed values per element.
Definition gsExprEvaluator.h:102
const std::vector< T > & elementwise() const
Returns an std::vector containing the last computed values per element.
Definition gsExprEvaluator.h:99
void eval(const expr::_expr< E > &expr, gsGridIterator< T, mode, d > &git, const index_t patchInd=0)
A matrix with arbitrary coefficient type and fixed or dynamic size.
Definition gsMatrix.h:41
#define index_t
Definition gsConfig.h:32
#define GISMO_ASSERT(cond, message)
Definition gsDebug.h:89
Provides the gsDofMapper class for re-indexing DoFs.
Generic expressions evaluator.
Generic expressions helper.
Provides forward declarations of types and structs.
Provides declaration of Basis abstract interface.
The G+Smo namespace, containing all definitions for the library.
gsMatrix< real_t > vtkIDTransform(index_t nU, index_t nV)
ID transformation between G+Smo and vtk control point IDs.
Definition gsParaviewUtils.cpp:23
std::vector< std::string > toVTK(const gsFunctionSet< T > &funSet, unsigned nPts=1000, unsigned precision=5, std::string label="", const bool &export_base64=false)
Evaluates gsFunctionSet over all pieces( patches ) and returns all <DataArray> xml tags as a vector o...
Definition gsParaviewUtils.hpp:35
std::string toDataArray(index_t num, std::map< std::string, std::string > attributes)
Converts an integer to a 'DataArray' xml tag, which is returned as a string.
Definition gsParaviewUtils.cpp:66