GetFEM  5.4.3
getfem_Navier_Stokes.h
Go to the documentation of this file.
1 /* -*- c++ -*- (enables emacs c++ mode) */
2 /*===========================================================================
3 
4  Copyright (C) 2000-2020 Yves Renard
5 
6  This file is a part of GetFEM
7 
8  GetFEM is free software; you can redistribute it and/or modify it
9  under the terms of the GNU Lesser General Public License as published
10  by the Free Software Foundation; either version 3 of the License, or
11  (at your option) any later version along with the GCC Runtime Library
12  Exception either version 3.1 or (at your option) any later version.
13  This program is distributed in the hope that it will be useful, but
14  WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
15  or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public
16  License and GCC Runtime Library Exception for more details.
17  You should have received a copy of the GNU Lesser General Public License
18  along with this program; if not, write to the Free Software Foundation,
19  Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA.
20 
21  As a special exception, you may use this file as it is a part of a free
22  software library without restriction. Specifically, if other files
23  instantiate templates or use macros or inline functions from this file,
24  or you compile this file and link it with other files to produce an
25  executable, this file does not by itself cause the resulting executable
26  to be covered by the GNU Lesser General Public License. This exception
27  does not however invalidate any other reasons why the executable file
28  might be covered by the GNU Lesser General Public License.
29 
30 ===========================================================================*/
31 
32 /**@file getfem_Navier_Stokes.h
33  @author Yves Renard <Yves.Renard@insa-lyon.fr>, Julien Pommier <Julien.Pommier@insa-toulouse.fr>
34  @date April 15, 2005.
35  @brief Navier-Stokes dynamic brick.
36 */
37 #ifndef GETFEM_NAVIER_STOKES_H__
38 #define GETFEM_NAVIER_STOKES_H__
39 
40 
42 
43 namespace getfem {
44 
45  /**
46  assembly of Tangent matrix for Navier-Stokes.
47  @ingroup asm
48  */
49  template<typename MAT, typename VECT>
50  void asm_navier_stokes_tgm(const MAT &M,
51  const mesh_im &mim,
52  const mesh_fem &mf,
53  const VECT &U,
54  const mesh_region &rg = mesh_region::all_convexes()) {
55  GMM_ASSERT1(mf.get_qdim() == mf.linked_mesh().dim(),
56  "wrong qdim for the mesh_fem");
57 
59  assem.set("u=data(#1);"
60  "t=comp(vGrad(#1).vBase(#1).vBase(#1));"
61  "M(#1, #1) += u(i).t(i,k,j,:,k,:,j);"
62  "M(#1, #1) += u(i).t(:,j,k,:,k,i,j);"
63  "M(#1, #1) += u(i).t(i,j,j,:,k,:,k)/2;"
64  "M(#1, #1) += u(i).t(:,k,k,:,j,i,j)/2;");
65  assem.push_mi(mim);
66  assem.push_mf(mf);
67  assem.push_mat(const_cast<MAT&>(M));
68  assem.push_data(U);
69  assem.assembly(rg);
70  }
71 
72  /**
73  assembly of right hand side for Navier-Stokes.
74  @ingroup asm
75  */
76  template<typename VECT1, typename VECT2>
77  void asm_navier_stokes_rhs(const VECT1 &V,
78  const mesh_im &mim,
79  const mesh_fem &mf,
80  const VECT2 &U,
81  const mesh_region &rg = mesh_region::all_convexes()) {
82  GMM_ASSERT1(mf.get_qdim() == mf.linked_mesh().dim(),
83  "wrong qdim for the mesh_fem");
84 
86  assem.set("u=data(#1);"
87  "t=comp(vBase(#1).vGrad(#1).vBase(#1));"
88  "V(#1) += u(i).u(j).t(i,k,j,k,l,:,l);"
89  "V(#1) += u(i).u(j).t(i,k,j,l,l,:,k)/2;");
90  assem.push_mi(mim);
91  assem.push_mf(mf);
92  assem.push_vec(const_cast<VECT1&>(V));
93  assem.push_data(U);
94  assem.assembly(rg);
95  }
96 
97 
98 
99 } /* end of namespace getfem. */
100 
101 
102 #endif /* GETFEM_NAVIER_STOKES_H__ */
Generic assembly of vectors, matrices.
void push_vec(VEC &v)
Add a new output vector.
void push_data(const VEC &d)
Add a new data (dense array)
void push_mat(const MAT &m)
Add a new output matrix (fake const version..)
void assembly(const mesh_region &region=mesh_region::all_convexes())
do the assembly on the specified region (boundary or set of convexes)
void push_mi(const mesh_im &im_)
Add a new mesh_im.
void push_mf(const mesh_fem &mf_)
Add a new mesh_fem.
Describe a finite element method linked to a mesh.
virtual dim_type get_qdim() const
Return the Q dimension.
const mesh & linked_mesh() const
Return a reference to the underlying mesh.
Describe an integration method linked to a mesh.
structure used to hold a set of convexes and/or convex faces.
static mesh_region all_convexes()
provide a default value for the mesh_region parameters of assembly procedures etc.
Generic assembly implementation.
void asm_navier_stokes_tgm(const MAT &M, const mesh_im &mim, const mesh_fem &mf, const VECT &U, const mesh_region &rg=mesh_region::all_convexes())
assembly of Tangent matrix for Navier-Stokes.
void asm_navier_stokes_rhs(const VECT1 &V, const mesh_im &mim, const mesh_fem &mf, const VECT2 &U, const mesh_region &rg=mesh_region::all_convexes())
assembly of right hand side for Navier-Stokes.
GEneric Tool for Finite Element Methods.