29 gsVisitorStokes(
const gsPde<T> & pde_)
30 : pde_ptr(static_cast<const gsBasePde<T>*>(&pde_))
33 void initialize(
const gsBasisRefs<T> & basisRefs,
35 const gsOptionList & options,
39 dim = basisRefs.front().dim();
44 viscosity = options.getReal(
"Viscosity");
45 density = options.getReal(
"Density");
47 globalIndices.resize(dim+1);
48 blockNumbers.resize(dim+1);
51 inline void evaluate(
const gsBasisRefs<T> & basisRefs,
52 const gsGeometry<T> & geo,
53 const gsMatrix<T> & quNodes)
64 basisRefs.front().active_into(quNodes.col(0),localIndicesVel);
65 N_V = localIndicesVel.rows();
66 basisRefs.back().active_into(quNodes.col(0), localIndicesPres);
67 N_P = localIndicesPres.rows();
69 basisRefs.front().evalAllDers_into(quNodes,1,basisValuesVel);
71 basisRefs.back().eval_into(quNodes,basisValuesPres);
73 pde_ptr->rhs()->eval_into(md.values[0],forceValues);
76 inline void assemble(gsDomainIterator<T> & element,
77 const gsVector<T> & quWeights)
80 localMat.setZero(dim*N_V + N_P, dim*N_V + N_P);
81 localRhs.setZero(dim*N_V + N_P,1);
84 for (
index_t q = 0; q < quWeights.rows(); ++q)
87 const T weight = quWeights[q] * md.measure(q);
89 transformGradients(md, q, basisValuesVel[1], physGradVel);
91 block = weight*viscosity*density * physGradVel.transpose()*physGradVel;
92 for (
short_t d = 0; d < dim; ++d)
93 localMat.block(d*N_V,d*N_V,N_V,N_V) += block.block(0,0,N_V,N_V);
95 for (
short_t d = 0; d < dim; ++d)
97 block = weight*basisValuesPres.col(q)*physGradVel.row(d);
98 localMat.block(dim*N_V,d*N_V,N_P,N_V) -= block.block(0,0,N_P,N_V);
99 localMat.block(d*N_V,dim*N_V,N_V,N_P) -= block.transpose().block(0,0,N_V,N_P);
102 for (
short_t d = 0; d < dim; ++d)
103 localRhs.middleRows(d*N_V,N_V).noalias() += weight *density * forceValues(d,q) * basisValuesVel[0].col(q) ;
107 inline void localToGlobal(
const int patchIndex,
108 const std::vector<gsMatrix<T> > & eliminatedDofs,
109 gsSparseSystem<T> & system)
112 for (
short_t d = 0; d < dim; ++d)
114 system.mapColIndices(localIndicesVel, patchIndex, globalIndices[d], d);
115 blockNumbers.at(d) = d;
118 system.mapColIndices(localIndicesPres, patchIndex, globalIndices[dim], dim);
119 blockNumbers.at(dim) = dim;
121 system.pushToRhs(localRhs,globalIndices,blockNumbers);
122 system.pushToMatrix(localMat,globalIndices,eliminatedDofs,blockNumbers,blockNumbers);
128 const gsBasePde<T> * pde_ptr;
129 T viscosity, density;
133 gsMatrix<T> localMat;
134 gsMatrix<T> localRhs;
136 gsMatrix<index_t> localIndicesVel;
137 gsMatrix<index_t> localIndicesPres;
142 std::vector<gsMatrix<T> > basisValuesVel;
145 gsMatrix<T> basisValuesPres;
147 gsMatrix<T> forceValues;
150 gsMatrix<T> block, physGradVel;
152 std::vector< gsMatrix<index_t> > globalIndices;
153 gsVector<index_t> blockNumbers;
#define short_t
Definition: gsConfig.h:35
#define index_t
Definition: gsConfig.h:32
static gsQuadRule< T > get(const gsBasis< T > &basis, const gsOptionList &options, short_t fixDir=-1)
Constructs a quadrature rule based on input options.
Definition: gsQuadrature.h:48
Creates a variety of quadrature rules.
IMHO, a useless class, but it is necessary to use the gsAssembler class. Contains proper information ...
The density of the measure pull back.
Definition: gsForwardDeclarations.h:76
Value of the object.
Definition: gsForwardDeclarations.h:72
Gradient transformation matrix.
Definition: gsForwardDeclarations.h:77
This object is a cache for computed values from an evaluator.