18template<
class T,
int MatOrder>
22 m_tarDim = getPatches().dim();
23 m_isInitialized =
false;
24 m_isBaseReady =
false;
25 m_isSystemReady =
false;
29template<
class T,
int MatOrder>
32 GISMO_ASSERT(ddofVector.rows() == m_dofMappers[basisID].boundarySize(),
"Dirichlet DOF vector has wrong size.");
37 switch (getAssemblerOptions().dirValues)
39 case dirichlet::homogeneous:
42 case dirichlet::interpolation:
43 computeDirichletDofsIntpl(unk, mapper, mbasis, ddofVector);
45 case dirichlet::l2Projection:
46 computeDirichletDofsL2Proj(unk, mapper, mbasis, ddofVector);
49 GISMO_ERROR(
"Something went wrong with Dirichlet values.");
53 for (
typename gsBoundaryConditions<T>::const_citerator
54 it = getBCs().cornerBegin();
55 it != getBCs().cornerEnd(); ++it)
57 if (it->unknown == unk)
59 const index_t i = mbasis[it->patch].functionAtCorner(it->corner);
61 ddofVector.row(ii).setConstant(it->value);
69template<
class T,
int MatOrder>
72 for (
typename gsBoundaryConditions<T>::const_iterator
73 it = getBCs().dirichletBegin();
74 it != getBCs().dirichletEnd(); ++it)
76 if (it->unknown() != unk)
79 const index_t patchID = it->patch();
86 if (it->isHomogeneous())
91 ddofVector.row(ii).setZero();
97 short_t dir = it->side().direction();
98 index_t param = (it->side().parameter() ? 1 : 0);
101 std::vector< gsVector<T> > rr;
102 rr.reserve(getPatches().parDim());
104 for (short_t i = 0; i < getPatches().parDim(); ++i)
109 b[0] = (basis.component(i).support()) (0, param);
114 rr.push_back(basis.component(i).anchors().transpose());
119 "Given Dirichlet boundary function does not match problem dimension."
120 << it->function()->targetDim() <<
" != " << ddofVector.cols() <<
"\n");
123 gsMatrix<T> pts = getPatches().patch(it->patch()).eval(gsPointGrid<T>(rr));
125 if (!it->parametric())
127 fpts = it->function()->eval(pts);
136 fpts = it->function()->eval(gsPointGrid<T>(rr));
144 for (index_t i = 0; i !=
boundary.size(); ++i)
147 ddofVector.row(ii) = dVals.row(i);
153template<
class T,
int MatOrder>
160 globProjRhs.setZero(ddofVector.rows(), ddofVector.cols());
170 for (
typename gsBoundaryConditions<T>::const_iterator
171 it = getBCs().dirichletBegin();
172 it != getBCs().dirichletEnd(); ++it)
174 if (it->unknown() != unk)
177 if (it->isHomogeneous())
180 GISMO_ASSERT(it->function()->targetDim() == ddofVector.cols(),
181 "Given Dirichlet boundary function does not match problem dimension."
182 << it->function()->targetDim() <<
" != " << ddofVector.cols() <<
"\n");
184 const index_t patchID = it->patch();
195 typename gsBasis<T>::domainIter bdryIter = basis.makeDomainIterator(it->side());
197 for (; bdryIter->good(); bdryIter->next())
199 bdQuRule.
mapTo(bdryIter->lowerCorner(), bdryIter->upperCorner(),
200 mapData.
points, quWeights);
202 patch.computeMap(mapData);
207 rhsVals = it->function()->eval(getPatches()[patchID].eval(mapData.
points));
209 basis.eval_into(mapData.
points, basisVals);
212 basis.active_into(mapData.
points.col(0), globIdxAct);
217 std::vector<index_t> eltBdryFcts;
219 for (
index_t i = 0; i < globIdxAct.rows(); i++)
221 eltBdryFcts.push_back(i);
226 const T weight_k = quWeights[k] * mapData.measure(k);
229 for (
size_t i0 = 0; i0 < eltBdryFcts.size(); i0++)
233 const index_t i = eltBdryFcts[i0];
237 for (
size_t j0 = 0; j0 < eltBdryFcts.size(); j0++)
239 const index_t j = eltBdryFcts[j0];
246 projMatEntries.add(ii, jj, weight_k * basisVals(i, k) * basisVals(j, k));
249 globProjRhs.row(ii) += weight_k * basisVals(i, k) * rhsVals.col(k).transpose();
257 globProjMat.setFrom(projMatEntries);
258 globProjMat.makeCompressed();
264 typename gsSparseSolver<T>::CGDiagonal solver;
265 ddofVector = solver.compute(globProjMat).solve(globProjRhs);
269template<
class T,
int MatOrder>
272 for(
size_t p = 0; p < getPatches().nPatches(); p++)
276 if (m_params.options().getString(
"assemb.loop") ==
"RbR")
278 index_t nBases = m_params.getBases()[testBasisID].piece(p).size();
280 for(
index_t i = 0; i < nBases; i++)
289 if (m_params.options().getString(
"assemb.loop") !=
"EbE")
290 gsWarn <<
"Unknown matrix formation method, using EbE (element by element)!\n";
292 typename gsBasis<T>::domainIter domIt = m_params.getBases().front().piece(p).makeDomainIterator(boundary::none);
294 while (domIt->good())
305 block.makeCompressed();
309template<
class T,
int MatOrder>
312 for(
size_t p = 0; p < getPatches().nPatches(); p++)
316 if (m_params.options().getString(
"assemb.loop") ==
"RbR")
318 index_t nBases = m_params.getBases()[testBasisID].piece(p).size();
320 for(
index_t i = 0; i < nBases; i++)
329 typename gsBasis<T>::domainIter domIt = m_params.getBases().front().piece(p).makeDomainIterator(boundary::none);
331 while (domIt->good())
344template<
class T,
int MatOrder>
347 assembleNonlinearPart();
351template<
class T,
int MatOrder>
354 assembleLinearPart();
355 m_isInitialized =
true;
359template<
class T,
int MatOrder>
362 GISMO_ASSERT(m_isInitialized,
"Assembler must be initialized first, call initialize()");
364 updateCurrentSolField(solVector, updateSol);
A basis represents a family of scalar basis functions defined over a common parameter domain.
Definition gsBasis.h:79
memory::unique_ptr< gsBasis > uPtr
Unique pointer for gsBasis.
Definition gsBasis.h:89
virtual memory::unique_ptr< gsGeometry< T > > interpolateAtAnchors(gsMatrix< T > const &vals) const
Applies interpolation of values pts using the anchors as parameter points. May be reimplemented in de...
Definition gsBasis.hpp:267
Maintains a mapping from patch-local dofs to global dof indices and allows the elimination of individ...
Definition gsDofMapper.h:69
void localToGlobal(const gsMatrix< index_t > &locals, index_t patchIndex, gsMatrix< index_t > &globals, index_t comp=0) const
Computes the global indices of the input local indices.
Definition gsDofMapper.cpp:25
index_t bindex(index_t i, index_t k=0, index_t c=0) const
Returns the boundary index of local dof i of patch k.
Definition gsDofMapper.h:334
index_t boundarySize() const
Returns the number of eliminated dofs.
Definition gsDofMapper.h:457
index_t global_to_bindex(index_t gl) const
Returns the boundary index of global dof gl.
Definition gsDofMapper.h:364
bool is_boundary_index(index_t gl) const
Returns true if global dof gl is eliminated.
Definition gsDofMapper.h:386
void assembleBlock(gsFlowVisitor< T, MatOrder > &visitor, index_t testBasisID, gsSparseMatrix< T, MatOrder > &block, gsMatrix< T > &blockRhs)
Assemble a matrix block.
Definition gsFlowAssemblerBase.hpp:270
virtual void initialize()
Initialize the assembler.
Definition gsFlowAssemblerBase.hpp:352
void computeDirichletDofs(const index_t unk, const index_t basisID, gsMatrix< T > &ddofVector)
Compute the coefficients of the basis functions at the Dirichlet boundaries.
Definition gsFlowAssemblerBase.hpp:30
void computeDirichletDofsIntpl(const index_t unk, const gsDofMapper &mapper, const gsMultiBasis< T > &mbasis, gsMatrix< T > &ddofVector)
Compute the coefficients of the basis functions at the Dirichlet boundaries using interpolation.
Definition gsFlowAssemblerBase.hpp:70
void computeDirichletDofsL2Proj(const index_t unk, const gsDofMapper &mapper, const gsMultiBasis< T > &mbasis, gsMatrix< T > &ddofVector)
Compute the coefficients of the basis functions at the Dirichlet boundaries using L2-projection.
Definition gsFlowAssemblerBase.hpp:154
void assembleRhs(gsFlowVisitor< T, MatOrder > &visitor, index_t testBasisID, gsMatrix< T > &rhs)
Assemble the right-hand side.
Definition gsFlowAssemblerBase.hpp:310
void initMembers()
Initialize the class members.
Definition gsFlowAssemblerBase.hpp:19
virtual void update(const gsMatrix< T > &solVector, bool updateSol=true)
Update the assembler in new nonlinear iteration.
Definition gsFlowAssemblerBase.hpp:360
virtual void updateAssembly()
Assemble all that needs to be updated in each nonlinear iteration.
Definition gsFlowAssemblerBase.hpp:345
Base class for incompressible flow visitors.
Definition gsFlowVisitors.h:29
void evaluate(index_t testFunID)
Evaluate basis data on the support of a given test function (used for row-by-row assembly).
Definition gsFlowVisitors.hpp:230
void initOnPatch(index_t patchID)
Initialize the visitor on the given patch.
Definition gsFlowVisitors.hpp:150
virtual void localToGlobal(const std::vector< gsMatrix< T > > &eliminatedDofs, gsSparseMatrix< T, MatOrder > &globalMat, gsMatrix< T > &globalRhs)
Map local matrix to the global matrix.
Definition gsFlowVisitors.h:162
virtual void assemble()
Assemble the local matrix.
Definition gsFlowVisitors.hpp:190
Class that represents the (tensor) Gauss-Legendre quadrature rule.
Definition gsGaussRule.h:28
Abstract base class representing a geometry map.
Definition gsGeometry.h:93
gsMatrix< T > & coefs()
Definition gsGeometry.h:340
memory::unique_ptr< gsGeometry > uPtr
Unique pointer for gsGeometry.
Definition gsGeometry.h:100
the gsMapData is a cache of pre-computed function (map) values.
Definition gsFuncData.h:349
gsMatrix< T > points
input (parametric) points
Definition gsFuncData.h:372
A matrix with arbitrary coefficient type and fixed or dynamic size.
Definition gsMatrix.h:41
Holds a set of patch-wise bases and their topology information.
Definition gsMultiBasis.h:37
const gsBasis< T > & piece(const index_t i) const
Returns the piece(s) of the function(s) at subdomain k.
Definition gsMultiBasis.h:274
const_reference at(size_t i) const
Assess i-th parametric basis.
Definition gsMultiBasis.h:163
virtual void mapTo(const gsVector< T > &lower, const gsVector< T > &upper, gsMatrix< T > &nodes, gsVector< T > &weights) const
Maps quadrature rule (i.e., points and weights) from the reference domain to an element.
Definition gsQuadRule.h:177
Class that provides a container for triplets (i,j,value) to be filled in a sparse matrix.
Definition gsSparseMatrix.h:34
Sparse matrix class, based on gsEigen::SparseMatrix.
Definition gsSparseMatrix.h:139
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_ERROR(message)
Definition gsDebug.h:118
#define gsWarn
Definition gsDebug.h:50
#define GISMO_ASSERT(cond, message)
Definition gsDebug.h:89
The G+Smo namespace, containing all definitions for the library.
@ NEED_MEASURE
The density of the measure pull back.
Definition gsForwardDeclarations.h:76
Struct that defines the boundary sides and corners and types of a geometric object.
Definition gsBoundary.h:56