LifeV
NavierStokesCavity.cpp
Go to the documentation of this file.
1 //@HEADER
2 /*
3 *******************************************************************************
4 
5  Copyright (C) 2004, 2005, 2007 EPFL, Politecnico di Milano, INRIA
6  Copyright (C) 2010 EPFL, Politecnico di Milano, Emory University
7 
8  This file is part of LifeV.
9 
10  LifeV is free software; you can redistribute it and/or modify
11  it under the terms of the GNU Lesser General Public License as published by
12  the Free Software Foundation, either version 3 of the License, or
13  (at your option) any later version.
14 
15  LifeV is distributed in the hope that it will be useful,
16  but WITHOUT ANY WARRANTY; without even the implied warranty of
17  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
18  Lesser General Public License for more details.
19 
20  You should have received a copy of the GNU Lesser General Public License
21  along with LifeV. If not, see <http://www.gnu.org/licenses/>.
22 
23 *******************************************************************************
24 */
25 //@HEADER
26 
27 /*!
28  @file NavierStokesCavity.cpp
29  @brief Navier-Stokes cavity problem
30 
31  @author Gwenol Grandperrin <gwenol.grandperrin@epfl.ch>
32  @date 19-08-2011
33  */
34 
35 #include <vector>
36 #include <lifev/core/mesh/RegionMesh3DStructured.hpp>
37 #include <lifev/core/fem/BCFunction.hpp>
38 #include <lifev/navier_stokes/examples/TestCases/NavierStokesCavity.hpp>
39 #include <lifev/core/mesh/MeshLoadingUtility.hpp>
40 
41 namespace LifeV
42 {
43 
44 // Walls
45 const Int NavierStokesCavity::LEFTWALL = 4;
46 const Int NavierStokesCavity::RIGHTWALL = 2;
47 const Int NavierStokesCavity::FRONTWALL = 1;
48 const Int NavierStokesCavity::BACKWALL = 3;
49 const Int NavierStokesCavity::TOPWALL = 6;
50 const Int NavierStokesCavity::BOTTOMWALL = 5;
51 // Edges
52 const Int NavierStokesCavity::BOTTOMEDGE1 = 7;
53 const Int NavierStokesCavity::BOTTOMEDGE2 = 8;
54 const Int NavierStokesCavity::BOTTOMEDGE3 = 9;
55 const Int NavierStokesCavity::BOTTOMEDGE4 = 10;
56 const Int NavierStokesCavity::SIDEEDGE1 = 11;
57 const Int NavierStokesCavity::SIDEEDGE2 = 12;
58 const Int NavierStokesCavity::SIDEEDGE3 = 13;
59 const Int NavierStokesCavity::SIDEEDGE4 = 14;
60 const Int NavierStokesCavity::TOPEDGE1 = 15;
61 const Int NavierStokesCavity::TOPEDGE2 = 16;
62 const Int NavierStokesCavity::TOPEDGE3 = 17;
63 const Int NavierStokesCavity::TOPEDGE4 = 18;
64 // Corners
65 const Int NavierStokesCavity::BOTTOMCORNER1 = 19;
66 const Int NavierStokesCavity::BOTTOMCORNER2 = 20;
67 const Int NavierStokesCavity::BOTTOMCORNER3 = 21;
68 const Int NavierStokesCavity::BOTTOMCORNER4 = 22;
69 const Int NavierStokesCavity::TOPCORNER1 = 23;
70 const Int NavierStokesCavity::TOPCORNER2 = 24;
71 const Int NavierStokesCavity::TOPCORNER3 = 25;
72 const Int NavierStokesCavity::TOPCORNER4 = 26;
73 
74 NavierStokesCavity::NavierStokesCavity()
75  : NavierStokesProblem< RegionMesh< LinearTetra > >()
76 {
77 
78 }
79 
80 NavierStokesCavity::~NavierStokesCavity()
81 {
82 
83 }
84 
85 void
86 NavierStokesCavity::showMe ( std::ostream& output ) const
87 {
88  output << "To be implemented";
89 }
90 
91 Real
92 NavierStokesCavity::lidBC ( const LifeV::Real& /*t*/,
93  const LifeV::Real& /*x*/,
94  const LifeV::Real& /*y*/,
95  const LifeV::Real& /*z*/,
96  const LifeV::ID& i)
97 {
98  switch (i)
99  {
100  case 1:
101  return 1.0;
102  default:
103  return 0.0;
104  }
105 }
106 
107 Real
108 NavierStokesCavity::fZero ( const LifeV::Real& /* t */,
109  const LifeV::Real& /* x */,
110  const LifeV::Real& /* y */,
111  const LifeV::Real& /* z */,
112  const LifeV::ID& /* i */ )
113 {
114  return 0.0;
115 }
116 
117 void
118 NavierStokesCavity::mesh ( std::shared_ptr< RegionMesh<LinearTetra> >& mesh ) const
119 {
120  if ( M_refinement == 0 )
121  {
122  std::cout << "ERROR: The mesh refinement requested is not valid." << std::endl;
123  exit ( 0 );
124  }
125  std::vector<Real> width (3, -1.0);
126  std::vector<Real> shift (3, -1.0);
127  std::vector<UInt> numMeshElem (3, M_refinement);
128  MeshUtility::loadStructuredMesh ( mesh, 1, numMeshElem, false, width, shift );
129 
130 }
131 
132 void
133 NavierStokesCavity::boundaryConditions ( std::shared_ptr<BCHandler> bcHandler ) const
134 {
135  LifeV::BCFunctionBase uZero (fZero);
136  LifeV::BCFunctionBase uLid (lidBC);
137 
138  std::vector<LifeV::ID> yComp (1);
139  yComp[0] = 1;
140 
141  bcHandler->addBC ( "Top" , TOPWALL , LifeV::Essential , LifeV::Full , uLid , 3 );
142  bcHandler->addBC ( "Top" , TOPEDGE1 , LifeV::EssentialEdges , LifeV::Full , uLid , 3 );
143  bcHandler->addBC ( "Top" , TOPEDGE2 , LifeV::EssentialEdges , LifeV::Full , uLid , 3 );
144  bcHandler->addBC ( "Top" , TOPEDGE3 , LifeV::EssentialEdges , LifeV::Full , uLid , 3 );
145  bcHandler->addBC ( "Top" , TOPEDGE4 , LifeV::EssentialEdges , LifeV::Full , uLid , 3 );
146  bcHandler->addBC ( "Top" , TOPCORNER1 , LifeV::EssentialVertices, LifeV::Full , uLid , 3 );
147  bcHandler->addBC ( "Top" , TOPCORNER2 , LifeV::EssentialVertices, LifeV::Full , uLid , 3 );
148  bcHandler->addBC ( "Top" , TOPCORNER3 , LifeV::EssentialVertices, LifeV::Full , uLid , 3 );
149  bcHandler->addBC ( "Top" , TOPCORNER4 , LifeV::EssentialVertices, LifeV::Full , uLid , 3 );
150  bcHandler->addBC ( "Left" , LEFTWALL , LifeV::Essential , LifeV::Full , uZero, 3 );
151  bcHandler->addBC ( "Left" , SIDEEDGE1 , LifeV::EssentialEdges , LifeV::Full , uZero, 3 );
152  bcHandler->addBC ( "Left" , SIDEEDGE4 , LifeV::EssentialEdges , LifeV::Full , uZero, 3 );
153  bcHandler->addBC ( "Front" , FRONTWALL , LifeV::Essential , LifeV::Component, uZero, yComp );
154  bcHandler->addBC ( "Right" , RIGHTWALL , LifeV::Essential , LifeV::Full , uZero, 3 );
155  bcHandler->addBC ( "Right" , SIDEEDGE2 , LifeV::EssentialEdges , LifeV::Full , uZero, 3 );
156  bcHandler->addBC ( "Right" , SIDEEDGE3 , LifeV::EssentialEdges , LifeV::Full , uZero, 3 );
157  bcHandler->addBC ( "Back" , BACKWALL , LifeV::Essential , LifeV::Component, uZero, yComp );
158  bcHandler->addBC ( "Bottom", BOTTOMWALL , LifeV::Essential , LifeV::Full , uZero, 3 );
159  bcHandler->addBC ( "Bottom", BOTTOMEDGE1 , LifeV::EssentialEdges , LifeV::Full , uZero, 3 );
160  bcHandler->addBC ( "Bottom", BOTTOMEDGE2 , LifeV::EssentialEdges , LifeV::Full , uZero, 3 );
161  bcHandler->addBC ( "Bottom", BOTTOMEDGE3 , LifeV::EssentialEdges , LifeV::Full , uZero, 3 );
162  bcHandler->addBC ( "Bottom", BOTTOMEDGE4 , LifeV::EssentialEdges , LifeV::Full , uZero, 3 );
163  bcHandler->addBC ( "Bottom", BOTTOMCORNER1, LifeV::EssentialVertices, LifeV::Full , uZero, 3 );
164  bcHandler->addBC ( "Bottom", BOTTOMCORNER2, LifeV::EssentialVertices, LifeV::Full , uZero, 3 );
165  bcHandler->addBC ( "Bottom", BOTTOMCORNER3, LifeV::EssentialVertices, LifeV::Full , uZero, 3 );
166  bcHandler->addBC ( "Bottom", BOTTOMCORNER4, LifeV::EssentialVertices, LifeV::Full , uZero, 3 );
167 }
168 
169 std::string
170 NavierStokesCavity::name() const
171 {
172  return "Lid-driven cavity";
173 }
174 
175 } // namespace LifeV
int32_type Int
Generic integer data.
Definition: LifeV.hpp:188
double Real
Generic real data.
Definition: LifeV.hpp:175