19template <
class T,
int MatOrder>
22 index_t dim = m_params.getPde().dim();
23 const index_t uCompSize = m_dofMappers[m_testUnkID].freeSize();
24 index_t nComponents = globalMat.rows() / uCompSize;
26 GISMO_ASSERT(nComponents == 1 || nComponents == dim,
"Wrong matrix size in gsINSVisitorUU::localToGlobal.");
28 m_dofMappers[m_testUnkID].localToGlobal(m_testFunActives, m_patchID, m_testFunActives);
29 m_dofMappers[m_shapeUnkID].localToGlobal(m_shapeFunActives, m_patchID, m_shapeFunActives);
32 index_t numActTest = m_testFunActives.rows();
33 index_t numActShape = m_shapeFunActives.rows();
35 for (index_t i = 0; i < numActTest; ++i)
37 const index_t ii = m_testFunActives(i);
39 if (m_dofMappers[m_testUnkID].is_free_index(ii))
41 for (index_t j = 0; j < numActShape; ++j)
43 const index_t jj = m_shapeFunActives(j);
45 if (m_dofMappers[m_shapeUnkID].is_free_index(jj))
47 for (index_t d = 0; d < nComponents; d++)
48 globalMat.coeffRef(ii + d*uCompSize, jj + d*uCompSize) += m_localMat(i, j);
52 const int bb = m_dofMappers[m_shapeUnkID].global_to_bindex(jj);
54 for (index_t d = 0; d < dim; d++)
55 globalRhs(ii + d*uCompSize, 0) -= m_localMat(i, j) * eliminatedDofs[m_shapeUnkID](bb, d);
64template <
class T,
int MatOrder>
67 index_t dim = m_params.getPde().dim();
68 const index_t uCompSize = m_dofMappers[m_testUnkID].freeSize();
70 GISMO_ASSERT(globalMat.rows() == dim*uCompSize,
"Wrong matrix size in gsINSVisitorPU::localToGlobal.");
72 m_dofMappers[m_testUnkID].localToGlobal(m_testFunActives, m_patchID, m_testFunActives);
73 m_dofMappers[m_shapeUnkID].localToGlobal(m_shapeFunActives, m_patchID, m_shapeFunActives);
75 index_t numActTest = m_testFunActives.rows();
76 index_t numActShape = m_shapeFunActives.rows();
79 for (index_t i = 0; i < numActTest; ++i)
81 const index_t ii = m_testFunActives(i);
83 if (m_dofMappers[m_testUnkID].is_free_index(ii))
85 for (index_t j = 0; j < numActShape; ++j)
87 const index_t jj = m_shapeFunActives(j);
89 if (m_dofMappers[m_shapeUnkID].is_free_index(jj))
91 for (index_t d = 0; d < dim; d++)
92 globalMat.coeffRef(ii + d*uCompSize, jj) += m_locMatVec[d](i, j);
96 const int bb = m_dofMappers[m_shapeUnkID].global_to_bindex(jj);
98 for (index_t d = 0; d < dim; d++)
99 globalRhs(ii + d*uCompSize, 0) -= m_locMatVec[d](i, j) * eliminatedDofs[m_shapeUnkID](bb, 0);
108template <
class T,
int MatOrder>
111 index_t dim = m_params.getPde().dim();
112 const index_t uCompSize = m_dofMappers[m_testUnkID].freeSize();
114 GISMO_ASSERT(globalMat.rows() == dim*uCompSize,
"Wrong matrix size in gsINSVisitorPU::localToGlobal.");
116 m_dofMappers[m_testUnkID].localToGlobal(m_testFunActives, m_patchID, m_testFunActives);
117 m_dofMappers[m_shapeUnkID].localToGlobal(m_shapeFunActives, m_patchID, m_shapeFunActives);
119 index_t numActTest = m_testFunActives.rows();
120 index_t numActShape = m_shapeFunActives.rows();
122 for (index_t i = 0; i < numActTest; ++i)
124 const index_t ii = m_testFunActives(i);
126 if (m_dofMappers[m_testUnkID].is_free_index(ii))
128 for (index_t j = 0; j < numActShape; ++j)
130 const index_t jj = m_shapeFunActives(j);
132 if (m_dofMappers[m_shapeUnkID].is_free_index(jj))
134 for (index_t d = 0; d < dim; d++)
135 globalMat.coeffRef(ii + d*uCompSize, jj) += m_locMatVec[d](i, j);
139 const int bb = m_dofMappers[m_shapeUnkID].global_to_bindex(jj);
141 for (index_t d = 0; d < dim; d++)
142 globalRhs(ii + d*uCompSize, 0) -= m_locMatVec[d](i, j) * eliminatedDofs[m_shapeUnkID](bb, 0);
148 const int bb = m_dofMappers[m_testUnkID].global_to_bindex(ii);
149 for (index_t k = 0; k < numActShape; k++)
151 const int kk = m_shapeFunActives(k);
153 if (m_dofMappers[m_shapeUnkID].is_free_index(kk))
157 for (index_t d = 0; d < dim; d++)
158 tmp += m_locMatVec[d](i, k) * eliminatedDofs[m_testUnkID](bb, d);
160 globalRhs(dim*uCompSize + kk, 0) += tmp;
169template <
class T,
int MatOrder>
172 index_t dim = m_params.getPde().dim();
173 const index_t uCompSize = m_dofMappers[m_shapeUnkID].freeSize();
175 GISMO_ASSERT(globalMat.cols() == dim*uCompSize,
"Wrong matrix size in gsINSVisitorUP::localToGlobal.");
177 m_dofMappers[m_testUnkID].localToGlobal(m_testFunActives, m_patchID, m_testFunActives);
178 m_dofMappers[m_shapeUnkID].localToGlobal(m_shapeFunActives, m_patchID, m_shapeFunActives);
180 index_t numActTest = m_testFunActives.rows();
181 index_t numActShape = m_shapeFunActives.rows();
183 for (index_t i = 0; i < numActTest; ++i)
185 const index_t ii = m_testFunActives(i);
187 if (m_dofMappers[m_testUnkID].is_free_index(ii))
189 for (index_t j = 0; j < numActShape; ++j)
191 const index_t jj = m_shapeFunActives(j);
193 if (m_dofMappers[m_shapeUnkID].is_free_index(jj))
195 for (index_t d = 0; d < dim; d++)
196 globalMat.coeffRef(ii, jj + d*uCompSize) += m_locMatVec[d](i, j);
200 const int bb = m_dofMappers[m_shapeUnkID].global_to_bindex(jj);
204 for (index_t d = 0; d < dim; d++)
205 tmp -= m_locMatVec[d](i, j) * eliminatedDofs[m_shapeUnkID](bb, d);
207 globalRhs(ii, 0) += tmp;
216template <
class T,
int MatOrder>
219 m_dofMappers[m_testUnkID].localToGlobal(m_testFunActives, m_patchID, m_testFunActives);
220 m_dofMappers[m_shapeUnkID].localToGlobal(m_shapeFunActives, m_patchID, m_shapeFunActives);
222 index_t numActTest = m_testFunActives.rows();
223 index_t numActShape = m_shapeFunActives.rows();
225 for (index_t i = 0; i < numActTest; ++i)
227 const int ii = m_testFunActives(i);
229 if (m_dofMappers[m_testUnkID].is_free_index(ii))
231 for (index_t j = 0; j < numActShape; ++j)
233 const int jj = m_shapeFunActives(j);
235 if (m_dofMappers[m_shapeUnkID].is_free_index(jj))
237 globalMat.coeffRef(ii, jj) += m_localMat(i, j);
241 const int bb = m_dofMappers[m_shapeUnkID].global_to_bindex(jj);
243 globalRhs(ii, 0) -= m_localMat(i, j) * eliminatedDofs[m_shapeUnkID](bb, 0);
252template <
class T,
int MatOrder>
253void gsINSVisitorRhsU<T, MatOrder>::assemble()
255 m_localMat.setZero(m_testFunActives.rows(), m_params.getPde().dim());
257 for (
size_t i = 0; i < m_terms.size(); i++)
258 m_terms[i]->assemble(m_mapData, m_quWeights, m_testFunData, m_shapeFunData, m_localMat);
262template <
class T,
int MatOrder>
263void gsINSVisitorRhsU<T, MatOrder>::localToGlobal(
gsMatrix<T>& globalRhs)
265 index_t dim = m_params.getPde().dim();
266 const index_t uCompSize = m_dofMappers[0].freeSize();
268 m_dofMappers[m_testUnkID].localToGlobal(m_testFunActives, m_patchID, m_testFunActives);
270 index_t numActTest = m_testFunActives.rows();
272 for (index_t i = 0; i < numActTest; ++i)
274 const index_t ii = m_testFunActives(i);
276 if (m_dofMappers[m_testUnkID].is_free_index(ii))
278 for (index_t d = 0; d != dim; d++)
279 globalRhs(ii + d*uCompSize, 0) += m_localMat(i, d);
286template <
class T,
int MatOrder>
287void gsINSVisitorRhsP<T, MatOrder>::assemble()
289 m_localMat.setZero(m_testFunActives.rows(), 1);
291 for (
size_t i = 0; i < m_terms.size(); i++)
292 m_terms[i]->assemble(m_mapData, m_quWeights, m_testFunData, m_shapeFunData, m_localMat);
296template <
class T,
int MatOrder>
297void gsINSVisitorRhsP<T, MatOrder>::localToGlobal(
gsMatrix<T>& globalRhs)
299 index_t dim = m_params.getPde().dim();
300 const index_t uCompSize = m_dofMappers[0].freeSize();
302 m_dofMappers[m_testUnkID].localToGlobal(m_testFunActives, m_patchID, m_testFunActives);
304 index_t numActTest = m_testFunActives.rows();
306 for (index_t i = 0; i < numActTest; ++i)
308 const index_t ii = m_testFunActives(i);
310 if (m_dofMappers[m_testUnkID].is_free_index(ii))
311 globalRhs(dim*uCompSize + ii, 0) += m_localMat(i);
A matrix with arbitrary coefficient type and fixed or dynamic size.
Definition gsMatrix.h:41
Sparse matrix class, based on gsEigen::SparseMatrix.
Definition gsSparseMatrix.h:139
#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.