153{
154
155
156 libmesh_assert_equal_to (system_name, "Stokes");
157
158
160
161
163
164
167
168
172
173
174
176
177
179
180
181
183
184
185
187
188
189
191
192
193 fe_vel->attach_quadrature_rule (&qrule);
194 fe_pres->attach_quadrature_rule (&qrule);
195
196
197
198
199
200 const std::vector<Real> & JxW = fe_vel->get_JxW();
201
202
203
204 const std::vector<std::vector<RealGradient>> & dphi = fe_vel->get_dphi();
205
206
207
208 const std::vector<std::vector<Real>> & psi = fe_pres->get_phi();
209
210
211
212
213
215
216
217
218
219
222
224 Kuu(Ke), Kuv(Ke), Kup(Ke),
225 Kvu(Ke), Kvv(Ke), Kvp(Ke),
226 Kpu(Ke), Kpv(Ke), Kpp(Ke);
227
229 Fu(Fe),
230 Fv(Fe),
231 Fp(Fe);
232
233
234
235
236 std::vector<dof_id_type> dof_indices;
237 std::vector<dof_id_type> dof_indices_u;
238 std::vector<dof_id_type> dof_indices_v;
239 std::vector<dof_id_type> dof_indices_p;
240
242
243
244
245
246
247
248
249 for (
const auto & elem :
mesh.active_local_element_ptr_range())
250 {
251
252
253
254
259
260 const unsigned int n_dofs = dof_indices.size();
261 const unsigned int n_u_dofs = dof_indices_u.size();
262 const unsigned int n_v_dofs = dof_indices_v.size();
263 const unsigned int n_p_dofs = dof_indices_p.size();
264
265
266
267
268
269 fe_vel->reinit (elem);
270 fe_pres->reinit (elem);
271
272
273
274
275
276
277
278 Ke.
resize (n_dofs, n_dofs);
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294 Kuu.reposition (u_var*n_u_dofs, u_var*n_u_dofs, n_u_dofs, n_u_dofs);
295 Kuv.reposition (u_var*n_u_dofs, v_var*n_u_dofs, n_u_dofs, n_v_dofs);
296 Kup.reposition (u_var*n_u_dofs, p_var*n_u_dofs, n_u_dofs, n_p_dofs);
297
298 Kvu.reposition (v_var*n_v_dofs, u_var*n_v_dofs, n_v_dofs, n_u_dofs);
299 Kvv.reposition (v_var*n_v_dofs, v_var*n_v_dofs, n_v_dofs, n_v_dofs);
300 Kvp.reposition (v_var*n_v_dofs, p_var*n_v_dofs, n_v_dofs, n_p_dofs);
301
302 Kpu.reposition (p_var*n_u_dofs, u_var*n_u_dofs, n_p_dofs, n_u_dofs);
303 Kpv.reposition (p_var*n_u_dofs, v_var*n_u_dofs, n_p_dofs, n_v_dofs);
304 Kpp.reposition (p_var*n_u_dofs, p_var*n_u_dofs, n_p_dofs, n_p_dofs);
305
306 Fu.reposition (u_var*n_u_dofs, n_u_dofs);
307 Fv.reposition (v_var*n_u_dofs, n_v_dofs);
308 Fp.reposition (p_var*n_u_dofs, n_p_dofs);
309
310
311 for (unsigned int qp=0; qp<qrule.n_points(); qp++)
312 {
313
314
315 for (unsigned int i=0; i<n_u_dofs; i++)
316 for (unsigned int j=0; j<n_u_dofs; j++)
317 Kuu(i,j) += JxW[qp]*(dphi[i][qp]*dphi[j][qp]);
318
319
320 for (unsigned int i=0; i<n_u_dofs; i++)
321 for (unsigned int j=0; j<n_p_dofs; j++)
322 Kup(i,j) += -JxW[qp]*psi[j][qp]*dphi[i][qp](0);
323
324
325
326
327 for (unsigned int i=0; i<n_v_dofs; i++)
328 for (unsigned int j=0; j<n_v_dofs; j++)
329 Kvv(i,j) += JxW[qp]*(dphi[i][qp]*dphi[j][qp]);
330
331
332 for (unsigned int i=0; i<n_v_dofs; i++)
333 for (unsigned int j=0; j<n_p_dofs; j++)
334 Kvp(i,j) += -JxW[qp]*psi[j][qp]*dphi[i][qp](1);
335
336
337
338
339 for (unsigned int i=0; i<n_p_dofs; i++)
340 for (unsigned int j=0; j<n_u_dofs; j++)
341 Kpu(i,j) += -JxW[qp]*psi[i][qp]*dphi[j][qp](0);
342
343
344 for (unsigned int i=0; i<n_p_dofs; i++)
345 for (unsigned int j=0; j<n_v_dofs; j++)
346 Kpv(i,j) += -JxW[qp]*psi[i][qp]*dphi[j][qp](1);
347
348 }
349
350
351
352
353
354
355
356
357
358 {
359
361
362
363
364
365 for (auto s : elem->side_index_range())
366 if (elem->neighbor_ptr(s) == nullptr)
367 {
368 const Elem & side = side_builder(*elem, s);
369
370
371 for (auto ns : side.node_index_range())
372 {
373
374
375
376
378
379
380 const Real penalty = 1.e10;
381
382
383
384
385 const Real u_value = (yf > .99) ? 1. : 0.;
386
387
388 const Real v_value = 0.;
389
390
391
392
393 for (auto n : elem->node_index_range())
394 if (elem->node_id(n) == side.node_id(ns))
395 {
396
397 Kuu(n,n) += penalty;
398 Kvv(n,n) += penalty;
399
400
401 Fu(n) += penalty*u_value;
402 Fv(n) += penalty*v_value;
403 }
404 }
405 }
406 }
407
408
409
411
412
413
414
415
418 }
419}
Defines a dense matrix for use in Finite Element-type computations.
void resize(const unsigned int new_m, const unsigned int new_n)
Resizes the matrix to the specified size and calls zero().
Defines a dense submatrix for use in Finite Element-type computations.
Defines a dense subvector for use in finite element computations.
Defines a dense vector for use in Finite Element-type computations.
void resize(const unsigned int n)
Resize the vector.
This class handles the numbering of degrees of freedom on a mesh.
void dof_indices(const Elem *const elem, std::vector< dof_id_type > &di) const
void constrain_element_matrix_and_vector(DenseMatrix< Number > &matrix, DenseVector< Number > &rhs, std::vector< dof_id_type > &elem_dofs, bool asymmetric_constraint_rows=true) const
Constrains the element matrix and vector.
Helper for building element sides that minimizes the construction of new elements.
This is the base class from which all geometric element types are derived.
const Point & point(const unsigned int i) const
const MeshBase & get_mesh() const
const T_sys & get_system(std::string_view name) const
NumericVector< Number > * rhs
The system matrix.
static std::unique_ptr< FEGenericBase > build(const unsigned int dim, const FEType &type)
Builds a specific finite element type.
class FEType hides (possibly multiple) FEFamily and approximation orders, thereby enabling specialize...
Order default_quadrature_order() const
const SparseMatrix< Number > & get_system_matrix() const
Manages consistently variables, degrees of freedom, coefficient vectors, matrices and linear solvers ...
This is the MeshBase class.
unsigned int mesh_dimension() const
virtual void add_vector(const T *v, const std::vector< numeric_index_type > &dof_indices)
Computes , where v is a pointer and each dof_indices[i] specifies where to add value v[i].
This class implements specific orders of Gauss quadrature.
virtual void add_matrix(const DenseMatrix< T > &dm, const std::vector< numeric_index_type > &rows, const std::vector< numeric_index_type > &cols)=0
Add the full matrix dm to the SparseMatrix.
const FEType & variable_type(const unsigned int i) const
unsigned int variable_number(std::string_view var) const
const DofMap & get_dof_map() const
DIE A HORRIBLE DEATH HERE typedef LIBMESH_DEFAULT_SCALAR_TYPE Real