G+Smo  25.01.0
Geometry + Simulation Modules
 
Loading...
Searching...
No Matches
gsAffineFunction.hpp
Go to the documentation of this file.
1
15namespace gismo {
16
17template <typename T>
19:
20m_box1(box1),
21m_box2(box2)
22{
23 GISMO_ASSERT(box1.rows()==box2.rows(),
24 "The two boxes must be subset of Rn for the same n (same number of rows)");
25 GISMO_ASSERT(box1.cols()==2 && 2==box2.cols(),
26 "The two boxes must be described by the lower and upper corner, the matrices must have two columns");
27
28 const index_t dim = box1.rows();
29 const gsVector<T> size1 = box1.col(1) - box1.col(0);
30 const gsVector<T> size2 = box2.col(1) - box2.col(0);
31 m_mat.setZero(dim,dim);
32 m_trans.resize(dim);
33 for (index_t i=0; i<dim; ++i)
34 {
35 const T ratio = size1[i]==0 ? (T)(1) : size2(dir[i])/size1[i];
36 m_mat(dir(i),i) = o[i] ? ratio : -ratio;
37 m_trans(dir(i)) = o[i] ? box2(dir[i],0) : box2(dir[i],1);
38 }
39 m_trans -= m_mat * box1.col(0);
40}
41
42
43template <typename T>
45 : m_mat(mat), m_trans(trans)
46{
47 GISMO_ASSERT(m_mat.rows()==m_trans.rows(),
48 "Incompatible linear map and translation in affine map");
49}
50
51template <typename T>
53{
54 return m_mat.cols();
55}
56
57template <typename T>
59{
60 return m_mat.rows();
61}
62
63template <typename T>
65{
66 result = (m_mat*u).colwise()+m_trans;
67 for (index_t k=0; k!=result.rows(); k++)
68 result.row(k) = result.row(k).cwiseMax(m_box2(k,0)).cwiseMin(m_box2(k,1));
69}
70
71template <typename T>
73 const index_t comp,
74 gsMatrix<T>& result) const
75{
76 gsMatrix<T> temp;
77 eval_into(u,temp);
78 result=temp.row(comp);
79}
80
81template <typename T>
83{
84 result.resize(m_mat.rows()* m_mat.cols(), u.cols());
85 if (!u.cols())
86 {
87 return;
88 }
89 for (index_t col=0;col<m_mat.cols();++col)
90 {
91 result.block(m_mat.rows()*col,0,m_mat.rows(),1)=m_mat.col(col);
92 }
93 for (index_t col=1; col<result.cols();++col)
94 {
95 result.col(col)=result.col(0);
96 }
97}
98
99template <typename T>
101{
102 const index_t rows = domainDim()*domainDim()*targetDim();
103 result.setZero(rows,u.cols());
104}
105
106
107
108} // namespace gismo
virtual void deriv2_into(const gsMatrix< T > &u, gsMatrix< T > &result) const
Evaluate second derivatives of the function at points u into result.
Definition gsAffineFunction.hpp:100
gsAffineFunction(const gsAffineFunction &other)
copy constructor
Definition gsAffineFunction.h:45
virtual short_t targetDim() const
Dimension of the target space.
Definition gsAffineFunction.hpp:58
virtual void eval_into(const gsMatrix< T > &u, gsMatrix< T > &result) const
Evaluate the function at points u into result.
Definition gsAffineFunction.hpp:64
virtual void eval_component_into(const gsMatrix< T > &u, const index_t comp, gsMatrix< T > &result) const
Evaluate the function for component comp in the target dimension at points u into result.
Definition gsAffineFunction.hpp:72
virtual short_t domainDim() const
Dimension of the (source) domain.
Definition gsAffineFunction.hpp:52
virtual void deriv_into(const gsMatrix< T > &u, gsMatrix< T > &result) const
Evaluate derivatives of the function at points u into result.
Definition gsAffineFunction.hpp:82
A matrix with arbitrary coefficient type and fixed or dynamic size.
Definition gsMatrix.h:41
A vector with arbitrary coefficient type and fixed or dynamic size.
Definition gsVector.h:37
#define short_t
Definition gsConfig.h:35
#define index_t
Definition gsConfig.h:32
#define GISMO_ASSERT(cond, message)
Definition gsDebug.h:89
The G+Smo namespace, containing all definitions for the library.