LifeV
OseenData.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
29  @brief File containing the implementation of the file OseenData.hpp
30 
31  @author Gilles Fourestey <gilles.fourestey@epfl.ch>
32  @contributor Alexis Aposporidis <aapospo@emory.edu>
33  @maintainer
34 
35  @date 01-09-2009
36 
37  */
38 
39 
40 #include <lifev/navier_stokes/solver/OseenData.hpp>
41 #include <lifev/core/LifeV.hpp>
42 
43 
44 namespace LifeV
45 {
46 
47 
48 // ===================================================
49 // Constructors
50 // ===================================================
51 
52 OseenData::OseenData( ) :
53  M_time ( ),
54  M_timeAdvance ( ),
55  M_density ( ),
56  M_viscosity ( ),
57  M_uOrder ( ),
58  M_pOrder ( ),
59  M_verbose ( ),
60  M_dumpInit ( ),
61  M_dumpPeriod ( ),
62  M_factor ( ),
63  M_stokes ( false ),
64  M_stabMethod ( ),
65  M_semiImplicit ( false ),
66  M_shapeDerivatives ( false ),
67  M_domainVelImplicit ( false ),
68  M_convectiveImplicit ( false ),
69  M_computeMeanValuesPerSection ( ),
70  M_NbZSections ( ),
71  M_ToleranceSection ( ),
72  M_XSectionFrontier ( ),
73  M_ZSectionInit ( ),
74  M_ZSectionFinal ( ),
75  M_NbPolygonEdges ( ),
76  M_stabilizationList ( "fluid/space_discretization/stabilization" ),
77  M_conservativeFormulation (true)
78 {
79 }
80 
81 
82 OseenData::OseenData ( const OseenData& oseenData ) :
83  M_time ( oseenData.M_time ),
84  M_timeAdvance ( oseenData.M_timeAdvance ),
85  M_fluidNumber ( oseenData.M_fluidNumber ),
86  M_density ( oseenData.M_density ),
87  M_viscosity ( oseenData.M_viscosity ),
88  M_uOrder ( oseenData.M_uOrder ),
89  M_pOrder ( oseenData.M_pOrder ),
90  M_verbose ( oseenData.M_verbose ),
91  M_dumpInit ( oseenData.M_dumpInit ),
92  M_dumpPeriod ( oseenData.M_dumpPeriod ),
93  M_factor ( oseenData.M_factor ),
94  M_stokes ( oseenData.M_stokes ),
95  M_stabMethod ( oseenData.M_stabMethod ),
96  M_semiImplicit ( false ),
97  M_shapeDerivatives ( false ),
98  M_domainVelImplicit ( false ),
99  M_convectiveImplicit ( false ),
100  M_computeMeanValuesPerSection ( oseenData.M_computeMeanValuesPerSection ),
101  M_NbZSections ( oseenData.M_NbZSections ),
102  M_ToleranceSection ( oseenData.M_ToleranceSection ),
103  M_XSectionFrontier ( oseenData.M_XSectionFrontier ),
104  M_ZSectionInit ( oseenData.M_ZSectionInit ),
105  M_ZSectionFinal ( oseenData.M_ZSectionFinal ),
106  M_NbPolygonEdges ( oseenData.M_NbPolygonEdges ),
107  M_stabilizationList ( oseenData.M_stabilizationList ),
108  M_conservativeFormulation ( false )
109 {
110 }
111 
112 
113 
114 
115 
116 
117 // ===================================================
118 // Methods
119 // ===================================================
120 
121 OseenData&
122 OseenData::operator= ( const OseenData& oseenData )
123 {
124  if ( this != &oseenData )
125  {
126  M_time = oseenData.M_time;
127  M_timeAdvance = oseenData.M_timeAdvance;
128  M_fluidNumber = oseenData.M_fluidNumber;
129  M_density = oseenData.M_density;
130  M_viscosity = oseenData.M_viscosity;
131  M_uOrder = oseenData.M_uOrder;
132  M_pOrder = oseenData.M_pOrder;
133  M_verbose = oseenData.M_verbose;
134  M_dumpInit = oseenData.M_dumpInit;
135  M_dumpPeriod = oseenData.M_dumpPeriod;
136  M_factor = oseenData.M_factor;
137  M_stokes = oseenData.M_stokes;
138  M_stabMethod = oseenData.M_stabMethod;
139  M_semiImplicit = oseenData.M_semiImplicit;
140  M_shapeDerivatives = oseenData.M_shapeDerivatives;
141  M_domainVelImplicit = oseenData.M_domainVelImplicit;
142  M_convectiveImplicit = oseenData.M_convectiveImplicit;
143  M_computeMeanValuesPerSection = oseenData.M_computeMeanValuesPerSection;
144  M_NbZSections = oseenData.M_NbZSections;
145  M_ToleranceSection = oseenData.M_ToleranceSection;
146  M_XSectionFrontier = oseenData.M_XSectionFrontier;
147  M_ZSectionInit = oseenData.M_ZSectionInit;
148  M_ZSectionFinal = oseenData.M_ZSectionFinal;
149  M_NbPolygonEdges = oseenData.M_NbPolygonEdges;
150  M_stabilizationList = oseenData.M_stabilizationList;
151  M_conservativeFormulation = oseenData.M_conservativeFormulation;
152  }
153 
154  return *this;
155 }
156 
157 
158 void
159 OseenData::setup ( const GetPot& dataFile, const std::string& section )
160 {
161  // If data time has not been set
162  if ( !M_time.get() )
163  {
164  M_time.reset ( new time_Type ( dataFile, section + "/time_discretization" ) );
165  }
166 
167  if ( !M_timeAdvance.get() )
168  {
169  M_timeAdvance.reset ( new timeAdvance_Type ( dataFile, section + "/time_discretization" ) );
170  }
171 
172  M_stabilizationList.add ( "ip", IP_STABILIZATION, "interior penalty " );
173  M_stabilizationList.add ( "sd", SD_STABILIZATION, "stream-line diffusion" );
174  M_stabilizationList.add ( "none", NO_STABILIZATION, "none (default)" );
175 
176  // Physics
177  UInt temp = dataFile ( (section + "/physics/fluid_number" ).data(), 0 );
178 
179  if (temp == 0) // Old fashion of declaring fluids
180  {
181  M_fluidNumber = 1;
182  M_density.push_back ( dataFile ( ( section + "/physics/density" ).data(), 1. ) );
183  M_viscosity.push_back ( dataFile ( ( section + "/physics/viscosity" ).data(), 1. ) );
184  }
185  else // New fashion of declaring fluids
186  {
187  M_fluidNumber = temp;
188  M_density = std::vector<Real> (temp, 0);
189  M_viscosity = std::vector<Real> (temp, 0);
190 
191  for (UInt iter_fluid (0); iter_fluid < temp; ++iter_fluid)
192  {
193  // build the section name
194  std::string iter_fluid_section ( section + "/physics/fluid_");
195  iter_fluid_section += number2string (iter_fluid);
196 
197  // Read the quantities
198  M_density[iter_fluid] = dataFile ( (iter_fluid_section + "/density").c_str() , 1.0);
199  M_viscosity[iter_fluid] = dataFile ( (iter_fluid_section + "/viscosity").c_str() , 1.0);
200  }
201  }
202 
203  // FE Order
204  M_uOrder = dataFile ( ( section + "/space_discretization/vel_order" ).data(), "P1");
205  M_pOrder = dataFile ( ( section + "/space_discretization/press_order" ).data(), "P1");
206 
207  // Miscellaneous
208  M_verbose = dataFile ( ( section + "/miscellaneous/verbose" ).data(), 1 );
209  M_dumpInit = dataFile ( ( section + "/miscellaneous/dump_init" ).data(), M_time->initialTime() );
210  M_dumpPeriod = dataFile ( ( section + "/miscellaneous/dump_period" ).data(), 1 );
211  M_factor = dataFile ( ( section + "/miscellaneous/factor" ).data(), 0. );
212  M_stokes = dataFile ( ( section + "/miscellaneous/Stokes" ).data(), false );
213 
214  M_stabMethod = NSStabilization ( M_stabilizationList.value (
215  dataFile ( ( section + "/space_discretization/stabilization" ).data(), "none") ) );
216 
217  // Semi-implicit and shape derivatives
218  M_shapeDerivatives = dataFile ( ( section + "/useShapeDerivatives" ).data(), false ) ;
219  setSemiImplicit ( dataFile ( ( section + "/semiImplicit" ).data(), false ) );
220  M_domainVelImplicit = dataFile ( (section + "/domainVelImplicit").data(), false );
221  M_convectiveImplicit = dataFile ( (section + "/convectiveImplicit").data(), false );
222  M_conservativeFormulation = dataFile ( ( section + "/conservativeFormulation" ).data(), true );
223 
224  // Mean values per section
225  M_computeMeanValuesPerSection = dataFile ( ( section + "/valuespersection/computeMeanValuesPerSection" ).data(), 0 );
226  M_NbZSections = dataFile ( ( section + "/valuespersection/nb_z_section" ).data(), 2 );
227  M_ToleranceSection = dataFile ( ( section + "/valuespersection/tol_section" ).data(), 2e-2 );
228  M_XSectionFrontier = dataFile ( ( section + "/valuespersection/x_section_frontier" ).data(), 0. );
229  M_ZSectionInit = dataFile ( ( section + "/valuespersection/z_section_init" ).data(), -1. );
230  M_ZSectionFinal = dataFile ( ( section + "/valuespersection/z_section_final" ).data(), 0. );
231  M_NbPolygonEdges = dataFile ( ( section + "/valuespersection/nb_polygon_edges" ).data(), 10 );
232 }
233 
234 
235 void
236 OseenData::showMe ( std::ostream& output ) const
237 {
238  if (M_fluidNumber == 1)
239  {
240  output << "\n*** Values for data [fluid/physics]\n\n";
241  output << "density = " << M_density[0] << std::endl;
242  output << "viscosity = " << M_viscosity[0] << std::endl;
243  }
244  else
245  {
246  output << "\n*** Values for data [fluid/physics]\n\n";
247  for (UInt iter_fluid (0); iter_fluid < M_fluidNumber; ++iter_fluid)
248  {
249  output << "fluid " << iter_fluid << std::endl;
250  output << "density = " << M_density[iter_fluid] << std::endl;
251  output << "viscosity = " << M_viscosity[iter_fluid] << std::endl;
252  }
253  }
254  output << "\n*** Values for data [fluid/miscellaneous]\n\n";
255  output << "verbose = " << M_verbose << std::endl;
256  output << "initial time for writing solution = " << M_dumpInit << std::endl;
257  output << "number of time steps between two consecutive dumps of the solution = " << M_dumpPeriod << std::endl;
258  output << "amplification factor = " << M_factor << std::endl;
259  output << "Stokes simulation = " << M_stokes << std::endl;
260 
261 
262  output << "\n*** Values for data [fluid/time_discretization]\n\n";
263  M_time->showMe ( output );
264  M_timeAdvance->showMe ( output );
265 
266  output << "stabilization = ";
267  switch ( M_stabMethod )
268  {
269  case NO_STABILIZATION:
270  output << "none" ;
271  break;
272  case IP_STABILIZATION:
273  output << "ip" ;
274  break;
275  case SD_STABILIZATION:
276  output << "sd" ;
277  break;
278  }
279  output << std::endl;
280 
281  output << "\n*** Values for data [fluid/valuespersection]\n\n";
282  output << "computeMeanValuesPerSection (switch 0: don't compute, 1: compute) = "
283  << M_computeMeanValuesPerSection << std::endl;
284  output << "nb_z_section = " << M_NbZSections << std::endl;
285  output << "tol_section = " << M_ToleranceSection << std::endl;
286  output << "x_section_frontier = " << M_XSectionFrontier << std::endl;
287  output << "z_section_init = " << M_ZSectionInit << std::endl;
288  output << "z_section_final = " << M_ZSectionFinal << std::endl;
289  output << "nb_polygon_edges = " << M_NbPolygonEdges << std::endl;
290 }
291 
292 
293 } //end namespace LifeV
void updateInverseJacobian(const UInt &iQuadPt)
uint32_type UInt
generic unsigned integer (used mainly for addressing)
Definition: LifeV.hpp:191