G+Smo  25.01.0
Geometry + Simulation Modules
 
Loading...
Searching...
No Matches
gsCrossApPatch.hpp
Go to the documentation of this file.
1
14#pragma once
15
18#include<gsNurbs/gsBSpline.h>
20
21namespace gismo
22{
23
24template <typename T>
26{
27 const short_t dim = m_boundary.dim();
28
29 delete m_result;
30 m_result = NULL;
31
32 switch ( dim ) // dispatch to implementation
33 {
34 case 1:
35 compute_impl<2>();
36 break;
37 /*
38 case 2:
39 compute_impl<3>();
40 break;
41 case 3:
42 compute_impl<4>();
43 break;
44 */
45 default:
46 GISMO_ERROR("Dimension "<< dim << "is invalid.");
47 break;
48 }
49 return *m_result;
50}
51
52template <typename T>
53template <unsigned d>
55{
56 GISMO_STATIC_ASSERT(d==2,"gsCrossApPatch<T>::compute_impl only works for d=2 dimensions.");
57
58 gsTensorBSplineBasis<d,T> resultBasis; // Basis
59 gsMatrix<T> coefs; // CPs
60
61 // Resolve boundary configuration and set boundary coefficients
62 this->preparePatch(resultBasis, coefs);
63
65 // Check whether there are any interior points to fill in
66 resultBasis.size_cwise(sz);
67 if ( (sz.array() < 3).all() )
68 {
69 gsWarn<<"There where no interior control points.\n";
70 m_result = resultBasis.makeGeometry( give(coefs) ).release();
71 return;
72 }
73
74 gsMatrix<T> tmp0(sz[0],2), tmp1(sz[1],2), tmp;
75 gsMatrix<T,d,d> cross;
76
77 for (index_t i = 0; i!=coefs.cols(); ++i)
78 {
79 tmp0.col(0) = m_boundary[0].coefs().col(i);
80 tmp0.col(1) = m_boundary[1].coefs().col(i);
81 tmp1.col(0) = m_boundary[2].coefs().col(i);
82 tmp1.col(1) = m_boundary[3].coefs().col(i);
83 cross(0,0) = tmp0(0 ,0);
84 cross(1,0) = tmp0(sz[0]-1,0);
85 cross(0,1) = tmp0(0 ,1);
86 cross(1,1) = tmp0(sz[0]-1,1);
87
88 if ( math::abs(cross.determinant()) < (T)(1e-11) )
89 {
90 gsWarn <<"Corner data is rank-deficient ("<<i<<")\n";
91 //gsDebugVar(cross);
92 tmp = tmp0 *
93 cross.colPivHouseholderQr().solve(gsMatrix<T,2,2>::Identity())
94 * tmp1.transpose();
95 }
96 else
97 {
98 tmp = tmp0 * cross.inverse() * tmp1.transpose();
99 }
100
101 coefs.col(i) = tmp.asVector();
102 }
103
104 // return the patch
105 m_result = resultBasis.makeGeometry( give(coefs) ).release();
106}
107
108
109}// namespace gismo
virtual memory::unique_ptr< gsGeometry< T > > makeGeometry(gsMatrix< T > coefs) const =0
Create a gsGeometry of proper type for this basis with the given coefficient matrix.
Computes a parametrization based on low rank cross approximation, given a set of boundary geometries.
Definition gsCrossApPatch.h:27
const gsGeometry< T > & compute()
Main routine that performs the computation.
Definition gsCrossApPatch.hpp:25
Abstract base class representing a geometry map.
Definition gsGeometry.h:93
A matrix with arbitrary coefficient type and fixed or dynamic size.
Definition gsMatrix.h:41
A tensor product B-spline basis.
Definition gsTensorBSplineBasis.h:37
void size_cwise(gsVector< index_t, s > &result) const
The number of basis functions in the direction of the k-th parameter component.
Definition gsTensorBasis.h:441
A vector with arbitrary coefficient type and fixed or dynamic size.
Definition gsVector.h:37
Represents a B-spline curve/function with one parameter.
#define short_t
Definition gsConfig.h:35
#define index_t
Definition gsConfig.h:32
Provides cross approximation parameterizations from boundary data.
#define GISMO_ERROR(message)
Definition gsDebug.h:118
#define gsWarn
Definition gsDebug.h:50
Provides iteration over integer or numeric points in a (hyper-)cube.
Provides declaration of TensorBSplineBasis abstract interface.
The G+Smo namespace, containing all definitions for the library.
S give(S &x)
Definition gsMemory.h:266