45 template <
typename Derived>
50 auto ders = secDers.reshaped(sz, secDers.size() / sz );
56 hessian = secDers.transpose();
59 hessian.row(0)=ders.row(0);
61 hessian.row(2)=ders.row(2);
62 hessian.row(3)=ders.row(1);
65 hessian.row(0)=ders.row(0);
67 hessian.row(1)=ders.row(3);
69 hessian.row(2)=ders.row(4);
70 hessian.row(4)=ders.row(1);
72 hessian.row(5)=ders.row(5);
73 hessian.row(8)=ders.row(2);
79 hessian.row((dim+1)*k) = ders.row(k);
80 for (
index_t l=k+1; l<dim; ++l )
81 hessian.row(dim*k+l) =
82 hessian.row(dim*l+k) = ders.row(dim + sz++);
89 template <
typename Derived>
90 void hessianToSecDer (
const gsEigen::DenseBase<Derived> & hessian,
94 GISMO_ASSERT(hessian.cols() == dim,
"single Hessian implemented");
95 secDers.resize(dim*(dim+1)/2, hessian.cols() / dim );
99 secDers=hessian.transpose();
102 secDers.
at(0)=hessian(0,0);
103 secDers.
at(1)=hessian(1,1);
104 secDers.
at(2)=hessian(1,0);
107 secDers.
at(0)=hessian(0,0);
108 secDers.
at(1)=hessian(1,1);
109 secDers.
at(2)=hessian(2,2);
110 secDers.
at(3)=hessian(0,1);
111 secDers.
at(4)=hessian(0,2);
112 secDers.
at(5)=hessian(1,2);
122 template <
typename T>
131 typedef gsEigen::Transpose<typename matrixView::Base> matrixTransposeView;
134 mutable unsigned flags;
142 std::vector<gsMatrix<T> > values;
151 std::pair<short_t, short_t> dim;
159 explicit gsFuncData(
unsigned flags = 0,
int patch = 0)
160 : flags(flags), patchId(patch)
170 void addFlags (
unsigned newFlags)
171 { flags = flags|newFlags; }
189 unsigned bytesUsed()
const
208 void swap(gsFuncData & other)
210 std::swap(flags , other.flags );
211 std::swap(patchId, other.patchId);
212 std::swap(dim, other.dim);
213 actives .swap(other.actives );
214 values .swap(other.values );
215 curls .swap(other.curls );
216 divs .swap(other.divs );
217 laplacians.swap(other.laplacians);
222 inline const gsMatrix<index_t> & allActives()
const
225 "actives are not computed unless the NEED_ACTIVE flag is set.");
226 GISMO_ASSERT(0!=actives.size(),
"actives were not computed.");
230 inline const gsMatrix<T> & allValues()
const
233 "values are not computed unless the NEED_ACTIVE flag is set.");
234 GISMO_ASSERT(0!=values.size(),
"values were not computed.");
235 return values.front();
238 inline gsMatrix<index_t>::constColumn active(
index_t point = 0)
const
241 "actives are not computed unless the NEED_ACTIVE flag is set.");
242 return actives.col(point);
245 inline matrixView eval (
index_t point)
const
248 "values are not computed unless the NEED_VALUE flag is set.");
249 return values[0].reshapeCol(point, dim.second, values[0].rows()/dim.second);
252 inline matrixView deriv (
index_t point)
const
255 "derivs are not computed unless the NEED_DERIV flag is set.");
256 return values[1].reshapeCol(point, derivSize(), values[1].rows()/derivSize());
259 inline matrixView deriv2 (
index_t point)
const
262 "deriv2s are not computed unless the NEED_DERIV2 flag is set.");
263 return values[2].reshapeCol(point, deriv2Size(), values[2].rows()/deriv2Size());
269 "curls are not computed unless the NEED_CURL flag is set.");
270 return curls.reshapeCol(point, dim.second, curls.rows()/dim.second );
273 inline matrixView div (
index_t point)
const
276 "divs are not computed unless the NEED_DIV flag is set.");
277 return divs.reshapeCol(point, divSize(), divs.rows()/divSize() );
280 inline matrixView laplacian (
index_t point)
const
283 "laplacians are not computed unless the NEED_LAPLACIAN flag is set.");
284 return laplacians.reshapeCol(point, dim.second, laplacians.rows()/dim.second );
288 inline matrixTransposeView jacobian(
index_t point,
index_t func = 0)
const
291 "jacobian access needs the computation of derivs: set the NEED_JACOBIAN flag.");
292 return gsAsConstMatrix<T, Dynamic, Dynamic>(&values[1].coeffRef(func*derivSize(),point),dim.first,dim.second).transpose();
298 "hessian access needs the computation of 2nd derivs: set the NEED_HESSIAN flag.");
299 gsMatrix<T> res(dim.first,dim.first);
300 const index_t dsz = dim.first*(dim.first+1) / 2;
301 res = util::secDerToHessian(values[2].block(func*dsz,point,dsz,1), dim.first);
302 res.resize(dim.first,dim.first);
309 int derivSize ()
const {
return dim.first*dim.second;}
311 int deriv2Size()
const {
return dim.second*dim.first*(dim.first+1) / 2; }
313 int divSize ()
const {
return dim.second/dim.first;}
323 template <
typename T>
327 typedef gsFuncData<T> Base;
328 typedef typename Base::constColumn constColumn;
330 typedef typename Base::matrixTransposeView matrixTransposeView;
357 inline constColumn point(
const index_t point)
const {
return points.col(point);}
359 inline T measure(
const index_t point)
const
362 "measures are not computed unless the NEED_MEASURE flag is set.");
363 return measures(0,point);
366 inline matrixView fundForm(
const index_t point)
const
369 "fundForms are not computed unless the NEED_2ND_FFORM flag is set.");
373 inline constColumn normal(
const index_t point)
const
376 "normals are not computed unless the NEED_NORMAL flag is set.");
377 return normals.col(point);
380 inline constColumn outNormal(
const index_t point)
const
383 "normals are not computed unless the NEED_NORMAL flag is set.");
384 return outNormals.col(point);
387 inline matrixTransposeView jacobians()
const
390 "jacobian access needs the computation of derivs: set the NEED_DERIV flag." << this->maxDeriv() );
391 return gsAsConstMatrix<T, Dynamic, Dynamic>(&values[1].coeffRef(0,0), dim.first,dim.second*values[1].cols()).transpose();
401 template <
typename T>
402 void swap(gismo::gsFuncData<T> & f1, gismo::gsFuncData<T> & f2)
Div operator.
Definition: gsForwardDeclarations.h:78
gsMatrix< T > fundForms
Second fundumental forms.
Definition: gsFuncData.h:351
gsMapData(unsigned flags=0)
Main constructor.
Definition: gsFuncData.h:337
Gradient of the object.
Definition: gsForwardDeclarations.h:73
Provides structs and classes related to interfaces and boundaries.
Struct that defines the boundary sides and corners and types of a geometric object.
Definition: gsBoundary.h:55
Outward normal on the boundary.
Definition: gsForwardDeclarations.h:86
the gsMapData is a cache of pre-computed function (map) values.
Definition: gsFuncData.h:324
Second derivatives.
Definition: gsForwardDeclarations.h:80
#define index_t
Definition: gsConfig.h:32
A matrix with arbitrary coefficient type and fixed or dynamic size.
Definition: gsMatrix.h:38
#define GISMO_ASSERT(cond, message)
Definition: gsDebug.h:89
gsMatrix< T > jacInvTr
Inverse of the Jacobian matrix (transposed)
Definition: gsFuncData.h:352
Laplacian.
Definition: gsForwardDeclarations.h:83
T at(index_t i) const
Returns the i-th element of the vectorization of the matrix.
Definition: gsMatrix.h:211
Normal vector of the object.
Definition: gsForwardDeclarations.h:85
Hessian matrix.
Definition: gsForwardDeclarations.h:82
Active function ids.
Definition: gsForwardDeclarations.h:84
Interface for the set of functions defined on a domain (the total number of functions in the set equa...
Definition: gsFuncData.h:23
gsAsMatrix< T, Dynamic, Dynamic > reshapeCol(index_t c, index_t n, index_t m)
Returns column c of the matrix resized to n x m matrix This function assumes that the matrix is size ...
Definition: gsMatrix.h:231
Curl operator.
Definition: gsForwardDeclarations.h:79
Struct which represents a certain side of a box.
Definition: gsBoundary.h:84
Creates a mapped object or data pointer to a const matrix without copying data.
Definition: gsLinearAlgebra.h:127
Second fundamental form.
Definition: gsForwardDeclarations.h:87
The density of the measure pull back.
Definition: gsForwardDeclarations.h:76
EIGEN_STRONG_INLINE curl_expr< T > curl(const gsFeVariable< T > &u)
The curl of a finite element variable.
Definition: gsExpressions.h:4500
Value of the object.
Definition: gsForwardDeclarations.h:72
#define GISMO_ERROR(message)
Definition: gsDebug.h:118
This is the main header file that collects wrappers of Eigen for linear algebra.
gsMatrix< T > points
input (parametric) points
Definition: gsFuncData.h:348
Gradient transformation matrix.
Definition: gsForwardDeclarations.h:77