G+Smo  25.01.0
Geometry + Simulation Modules
 
Loading...
Searching...
No Matches
gsC1SurfVisitorBasisEdge.h
1
14#pragma once
15
16#include <gsUnstructuredSplines/src/gsC1SurfGluingData.h>
17
18namespace gismo
19{
20 template <class T>
21 class gsC1SurfVisitorBasisEdge
22 {
23 public:
24
25 gsC1SurfVisitorBasisEdge()
26 {
27 }
28
29 void initialize(const gsBasis<T> & basis, //
30 gsQuadRule<T> & rule)
31 {
32 gsVector<index_t> numQuadNodes( basis.dim() );
33 for (index_t i = 0; i < basis.dim(); ++i) // to do: improve
34 numQuadNodes[i] = basis.degree(i) + 1;
35
36 // Setup Quadrature
37 rule = gsGaussRule<T>(numQuadNodes);// NB!
38
39 // Set Geometry evaluation flags
40 md.flags = NEED_MEASURE ;
41 }
42
43 // Evaluate on element.
44 inline void evaluate(const index_t bfID,
45 std::string typeBf,
46 gsBasis<T> & basis, //
47 gsBasis<T> & basis_geo,
48 gsBasis<T> & basis_plus,
49 gsBasis<T> & basis_minus,
50 const gsGeometry<T> & geo, // patch
51 gsMatrix<T> & quNodes,
52 index_t & uv,
53 gsC1SurfGluingData<T> & gluingData,
54 bool & isBoundary)
55 {
56 md.points = quNodes;
57
58 // Compute the active basis functions
59 // Assumes actives are the same for all quadrature points on the elements
60 basis.active_into(md.points.col(0), actives);
61
62 // Evaluate basis functions on element
63 basis.eval_into(md.points, basisData);
64
65 // Compute geometry related values
66 geo.computeMap(md);
67
68 numActive = actives.rows();
69
70 // tau/p
71 gsBSplineBasis<T> bsp_temp = dynamic_cast<gsBSplineBasis<T> & >(basis_geo);
72
73 T p = basis_geo.maxDegree();
74 T tau_1 = bsp_temp.knots().at(p + 2);
75
76 gsMatrix<T> alpha, beta,
77 N_0, N_1,
78 N_j_minus, N_i_plus,
79 der_N_i_plus;
80
81
82 if (uv == 1) // edge is in v-direction
83 {
84
85 alpha = gluingData.evalAlpha_R(md.points.bottomRows(1));
86 beta = gluingData.evalBeta_R(md.points.bottomRows(1));
87
88 basis_geo.evalSingle_into(0,md.points.topRows(1),N_0); // u
89 basis_geo.evalSingle_into(1,md.points.topRows(1),N_1); // u
90
91 // Initialize local matrix/rhs
92 if (typeBf == "plus")
93 {
94 basis_plus.evalSingle_into(bfID,md.points.bottomRows(1),N_i_plus); // v
95 basis_plus.derivSingle_into(bfID,md.points.bottomRows(1),der_N_i_plus);
96
97
98 beta = isBoundary ? beta.setZero() : beta; // For the boundary, only on Patch 0
99
100 gsMatrix<T> temp = beta.cwiseProduct(N_1);
101 rhsVals = N_i_plus.cwiseProduct(N_0 + N_1) - temp.cwiseProduct(der_N_i_plus) * tau_1 / p;
102
103 localMat.setZero(numActive, numActive);
104 localRhs.setZero(numActive, rhsVals.rows());//multiple right-hand sides
105
106 } // n_plus
107 else if (typeBf == "minus")
108 {
109 basis_minus.evalSingle_into(bfID,md.points.bottomRows(1),N_j_minus); // v
110
111
112 alpha = isBoundary ? alpha.setOnes() : alpha; // For the boundary, only on Patch 0
113
114 rhsVals = alpha.cwiseProduct(N_j_minus.cwiseProduct(N_1));
115
116 localMat.setZero(numActive, numActive);
117 localRhs.setZero(numActive, rhsVals.rows());//multiple right-hand sides
118 } // n_minus
119
120 } // Patch 0
121 else if (uv == 0) // edge is in u-direction
122 {
123
124 alpha = gluingData.evalAlpha_L(md.points.topRows(1));
125 beta = gluingData.evalBeta_L(md.points.topRows(1));
126
127 basis_geo.evalSingle_into(0,md.points.bottomRows(1),N_0); // v
128 basis_geo.evalSingle_into(1,md.points.bottomRows(1),N_1); // v
129
130 // Initialize local matrix/rhs
131 if (typeBf == "plus")
132 {
133 basis_plus.evalSingle_into(bfID,md.points.topRows(1),N_i_plus); // u
134 basis_plus.derivSingle_into(bfID,md.points.topRows(1),der_N_i_plus);
135
136 beta = isBoundary ? beta.setZero() : beta; // For the boundary, only on Patch 0
137
138 gsMatrix<T> temp = beta.cwiseProduct(N_1);
139 rhsVals = N_i_plus.cwiseProduct(N_0 + N_1) - temp.cwiseProduct(der_N_i_plus) * tau_1 / p;
140
141 localMat.setZero(numActive, numActive);
142 localRhs.setZero(numActive, rhsVals.rows());//multiple right-hand sides
143
144 } // n_tilde
145 else if (typeBf == "minus")
146 {
147 basis_minus.evalSingle_into(bfID,md.points.topRows(1),N_j_minus); // u
148
149
150 alpha = isBoundary ? alpha.setOnes() : alpha; // For the boundary, only on Patch 0
151
152 rhsVals = - alpha.cwiseProduct(N_j_minus.cwiseProduct(N_1));
153
154 localMat.setZero(numActive, numActive);
155 localRhs.setZero(numActive, rhsVals.rows());//multiple right-hand sides
156 } // n_bar
157
158 } // Patch 1
159 } // evaluate1
160
161 inline void assemble(gsDomainIterator<T> & element,
162 const gsVector<T> & quWeights)
163 {
164 GISMO_UNUSED(element);
165
166 gsMatrix<T> & basisVals = basisData;
167
168 // ( u, v)
169 localMat.noalias() =
170 basisData * quWeights.asDiagonal() *
171 md.measures.asDiagonal() * basisData.transpose();
172
173 for (index_t k = 0; k < quWeights.rows(); ++k) // loop over quadrature nodes
174 {
175 // Multiply weight by the geometry measure
176 const T weight = quWeights[k] * md.measure(k);
177 localRhs.noalias() += weight * (basisVals.col(k) * rhsVals.col(k).transpose());
178 }
179
180 }
181
182 inline void localToGlobal(const index_t patchIndex,
183 const std::vector<gsMatrix<T> > & eliminatedDofs,
184 gsSparseSystem<T> & system)
185 {
186 // Map patch-local DoFs to global DoFs
187 system.mapColIndices(actives, patchIndex, actives);
188 // Add contributions to the system matrix and right-hand side
189 system.push(localMat, localRhs, actives, eliminatedDofs[0], 0, 0);
190 }
191
192 protected:
193 gsMatrix<index_t> actives;
194 gsMatrix<T> basisData;
195 index_t numActive;
196
197 protected:
198 // Local values of the right hand side
199 gsMatrix<T> rhsVals;
200
201 protected:
202 // Local matrices
203 gsMatrix<T> localMat;
204 gsMatrix<T> localRhs;
205
206 gsMapData<T> md;
207
208 }; // class gsVisitorG1BasisEdge
209} // namespace gismo
A univariate B-spline basis.
Definition gsBSplineBasis.h:700
A basis represents a family of scalar basis functions defined over a common parameter domain.
Definition gsBasis.h:79
virtual short_t maxDegree() const
If the basis is of polynomial or piecewise polynomial type, then this function returns the maximum po...
Definition gsBasis.hpp:687
virtual void evalSingle_into(index_t i, const gsMatrix< T > &u, gsMatrix< T > &result) const
Evaluate the i-th basis function at points u into result.
Definition gsBasis.hpp:470
virtual void derivSingle_into(index_t i, const gsMatrix< T > &u, gsMatrix< T > &result) const
Evaluates the (partial) derivatives of the i-th basis function at points u into result.
Definition gsBasis.hpp:478
Class which enables iteration over all elements of a parameter domain.
Definition gsDomainIterator.h:68
virtual void computeMap(gsMapData< T > &InOut) const
Computes map function data.
Definition gsFunction.hpp:817
Class that represents the (tensor) Gauss-Legendre quadrature rule.
Definition gsGaussRule.h:28
Abstract base class representing a geometry map.
Definition gsGeometry.h:93
the gsMapData is a cache of pre-computed function (map) values.
Definition gsFuncData.h:349
A matrix with arbitrary coefficient type and fixed or dynamic size.
Definition gsMatrix.h:41
Class representing a reference quadrature rule.
Definition gsQuadRule.h:29
A sparse linear system indexed by sets of degrees of freedom.
Definition gsSparseSystem.h:30
void push(const gsMatrix< T > &localMat, const gsMatrix< T > &localRhs, const gsMatrix< index_t > &actives, const gsMatrix< T > &eliminatedDofs, const size_t r=0, const size_t c=0)
push pushes the local system matrix and rhs for an element to the global system,
Definition gsSparseSystem.h:972
void mapColIndices(const gsMatrix< index_t > &actives, const index_t patchIndex, gsMatrix< index_t > &result, const index_t c=0) const
mapColIndices Maps a set of basis indices by the corresponding dofMapper.
Definition gsSparseSystem.h:584
const KnotVectorType & knots(int i=0) const
Returns the knot vector of the basis.
Definition gsBSplineBasis.h:371
A vector with arbitrary coefficient type and fixed or dynamic size.
Definition gsVector.h:37
#define index_t
Definition gsConfig.h:32
#define GISMO_UNUSED(x)
Definition gsDebug.h:112
The G+Smo namespace, containing all definitions for the library.
@ NEED_MEASURE
The density of the measure pull back.
Definition gsForwardDeclarations.h:76