G+Smo  24.08.0
Geometry + Simulation Modules
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
gsGeometrySlice.h
Go to the documentation of this file.
1 
14 #pragma once
15 
16 #include <gsCore/gsFunction.h>
17 
18 namespace gismo
19 {
20 
26 template<class T>
27 class gsGeometrySlice : public gsFunction<T>
28 {
29  typedef gsFunction<T> Base;
30 public:
32  typedef memory::shared_ptr< gsGeometrySlice > Ptr;
33 
35  typedef memory::unique_ptr< gsGeometrySlice > uPtr;
36 
37  gsGeometrySlice(const gsFunction<T>* geo, index_t fixed_dir,T par)
38  : m_geo(geo),m_fixed_dir(fixed_dir),m_par(par)
39  {
40  GISMO_ASSERT(fixed_dir>=0 && geo->domainDim()>static_cast<int>(fixed_dir),"Geometry has not big enough dimension to fix the given fixed_dim.");
41  GISMO_ASSERT(geo->domainDim()!=1,"Cannot take a slice of a curve.");
42  }
43 
46  : m_geo(geoSlice->m_geo),m_fixed_dir(geoSlice->m_fixed_dir),m_par(geoSlice->m_par)
47  {
48  GISMO_ASSERT(geoSlice->m_fixed_dir>=0 && geoSlice->m_geo->domainDim()>static_cast<int>(geoSlice->m_fixed_dir),"Geometry has not big enough dimension to fix the given fixed_dim.");
49  GISMO_ASSERT(geoSlice->m_geo->domainDim()!=1,"Cannot take a slice of a curve.");
50  }
51 
56  {
57  return m_geo->domainDim()-1;
58  }
59 
64  {
65  return m_geo->targetDim();
66  }
67 
68  GISMO_CLONE_FUNCTION(gsGeometrySlice)
69 
70 
71  void eval_into(const gsMatrix<T>& u, gsMatrix<T>& result) const
72  {
73  gsMatrix<T> fullU;
74  getFullParMatrix(u,fullU);
75  m_geo->eval_into(fullU,result);
76  }
77 
79  void deriv_into(const gsMatrix<T>& u, gsMatrix<T>& result) const
80  {
81  gsMatrix<T> fullU;
82  getFullParMatrix(u,fullU);
83  m_geo->deriv_into(fullU,result);
84  }
85 
88  {
89  const gsMatrix<T> fullRange = m_geo->support();
90  const index_t rows = fullRange.rows()-1;
91  const index_t cols = fullRange.cols();
92  gsMatrix<T> range(rows,cols);
93  range.topRows(m_fixed_dir) = fullRange.topRows(m_fixed_dir);
94  range.bottomRows(rows - m_fixed_dir) = fullRange.bottomRows(rows - m_fixed_dir);
95  return range;
96  }
97 
98  inline gsMatrix<T> parameterRange() const { return support();}
99 
100 private:
101 
104  void getFullParMatrix(const gsMatrix<T>& u, gsMatrix<T>& fullU) const
105  {
106  const index_t rows = u.rows()+1;
107  const index_t cols = u.cols();
108  fullU.resize(rows,cols);
109  fullU.topRows(m_fixed_dir) = u.topRows(m_fixed_dir);
110  fullU.row(m_fixed_dir).setConstant(m_par);
111  fullU.bottomRows(rows - m_fixed_dir-1) = u.bottomRows(rows - m_fixed_dir-1);
112  }
113 
114 private:
115  const gsFunction<T> * m_geo; // pointer to the function object
116  const index_t m_fixed_dir; // fixed parameter direction
117  const T m_par; // value for the fixed direction
118 
119 }; // class gsGeometrySlice
120 
121 
122 }
short_t domainDim() const
Gives back the domain dimension of this slice Note that this is one less than the domain dimension of...
Definition: gsGeometrySlice.h:55
#define short_t
Definition: gsConfig.h:35
gsMatrix< T > support() const
Gives back the parameterRange of this slice in a Matrix.
Definition: gsGeometrySlice.h:87
#define index_t
Definition: gsConfig.h:32
A function from a n-dimensional domain to an m-dimensional image.
Definition: gsFunction.h:59
A matrix with arbitrary coefficient type and fixed or dynamic size.
Definition: gsMatrix.h:38
#define GISMO_ASSERT(cond, message)
Definition: gsDebug.h:89
void getFullParMatrix(const gsMatrix< T > &u, gsMatrix< T > &fullU) const
This function takes a point matrix u and adds the row of the fixed direction filled with the value fo...
Definition: gsGeometrySlice.h:104
memory::shared_ptr< gsGeometrySlice > Ptr
Shared pointer for gsGeometrySlice.
Definition: gsGeometrySlice.h:32
void deriv_into(const gsMatrix< T > &u, gsMatrix< T > &result) const
Gives back the derivative of this slice at points u in result.
Definition: gsGeometrySlice.h:79
void eval_into(const gsMatrix< T > &u, gsMatrix< T > &result) const
Gives back the values of this slice at points u in result.
Definition: gsGeometrySlice.h:71
gsGeometrySlice(const gsGeometrySlice *geoSlice)
Copyconstructor for new gsGeometrySlice(*this)
Definition: gsGeometrySlice.h:45
memory::unique_ptr< gsGeometrySlice > uPtr
Unique pointer for gsGeometrySlice.
Definition: gsGeometrySlice.h:35
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
short_t targetDim() const
Gives back the target dimension of this slice Note that this is the same as the target dimension of t...
Definition: gsGeometrySlice.h:63
Provides declaration of Function abstract interface.