LifeV
lifev/navier_stokes_blocks/examples/example_aorta_semi_implicit/main.cpp
Go to the documentation of this file.
1 /* -*- mode: c++ -*-
2 
3  This file is part of the LifeV library.
4  Copyright (C) 2010 EPFL
5 
6  This program is free software; you can redistribute it and/or modify
7  it under the terms of the GNU General Public License as published by
8  the Free Software Foundation; either version 2.1 of the License, or
9  (at your option) any later version.
10 
11  This program is distributed in the hope that it will be useful, but
12  WITHOUT ANY WARRANTY; without even the implied warranty of
13  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
14  General Public License for more details.
15 
16  You should have received a copy of the GNU General Public License
17  along with this program; if not, write to the Free Software
18  Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307
19  USA
20 */
21 /**
22  \file main.cpp
23  \author Davide Forti <davide.forti@epfl.ch>
24  \date 2014-02-06
25  */
26 
27 
28 #include <Epetra_ConfigDefs.h>
29 #ifdef EPETRA_MPI
30 #include <mpi.h>
31 #include <Epetra_MpiComm.h>
32 #else
33 #include <Epetra_SerialComm.h>
34 #endif
35 
36 
37 #include <lifev/core/LifeV.hpp>
38 #include <lifev/core/mesh/MeshData.hpp>
39 #include <lifev/core/mesh/MeshPartitioner.hpp>
40 #include <lifev/navier_stokes_blocks/solver/NavierStokesSolverBlocks.hpp>
41 #include <lifev/core/fem/TimeAndExtrapolationHandler.hpp>
42 #include <lifev/core/filter/ExporterEnsight.hpp>
43 #include <lifev/core/filter/ExporterHDF5.hpp>
44 #include <lifev/core/filter/ExporterVTK.hpp>
45 #include <Teuchos_XMLParameterListHelpers.hpp>
46 
48 
49 using namespace LifeV;
50 
52 typedef VectorEpetra vector_Type;
54 
55 void scaleInflowVector( const vectorPtr_Type& vecNotScaled,
56  vectorPtr_Type& vecScaled,
57  const Real& coefficient );
58 
59 Real oneFunction (const Real& /*t*/, const Real& /*x*/, const Real& /*y*/, const Real& /*z*/, const ID& /*i*/)
60 {
61  return 1.0;
62 }
63 
64 int
65 main ( int argc, char** argv )
66 {
67  bool verbose (false);
68 #ifdef HAVE_MPI
69  MPI_Init (&argc, &argv);
70  std::shared_ptr<Epetra_Comm> Comm ( new Epetra_MpiComm (MPI_COMM_WORLD) );
71  if ( Comm->MyPID() == 0 )
72  {
73  verbose = true;
74  }
75 #else
76  std::shared_ptr<Epetra_Comm> Comm( new Epetra_SerialComm () );
77  verbose = true;
78 #endif
79 
80  {
81 
82 
83 
84  // Reading the dataFile
85  const std::string defaultDataName = "data";
86  GetPot command_line (argc, argv);
87  std::string data_file_name = command_line.follow (defaultDataName.c_str(), 2, "-f", "--file");
88  GetPot dataFile( data_file_name );
89 
90  // reading the mesh
91  std::shared_ptr<mesh_Type > fullMeshPtr ( new mesh_Type ( Comm ) );
92  MeshData meshData;
93  meshData.setup (dataFile, "fluid/space_discretization");
94  readMesh (*fullMeshPtr, meshData);
95 
96  // mesh partitioner
97  MeshPartitioner< mesh_Type > meshPart (fullMeshPtr, Comm);
98  std::shared_ptr<mesh_Type > localMeshPtr ( new mesh_Type ( Comm ) );
99  localMeshPtr = meshPart.meshPartition();
100  fullMeshPtr.reset();
101 
102  // create the solver
103  NavierStokesSolverBlocks ns( dataFile, Comm);
104  ns.setup(localMeshPtr);
106  ns.buildSystem();
108 
109  Real saveAfter = dataFile("fluid/save_after", 0.0);
110 
111  bool useStabilization = dataFile("fluid/stabilization/use", false);
112  std::string stabilizationType = dataFile("fluid/stabilization/type", "none");
113 
114  int saveEvery = dataFile ( "fluid/save_every", 1 );
115  int counterSaveEvery = saveEvery;
116 
117  // Time handler objects to deal with time advancing and extrapolation
118  TimeAndExtrapolationHandler timeVelocity;
119  Real dt = dataFile("fluid/time_discretization/timestep",0.0);
120  Real t0 = dataFile("fluid/time_discretization/initialtime",0.0);
121  Real tFinal = dataFile("fluid/time_discretization/endtime",0.0);
122  UInt orderBDF = dataFile("fluid/time_discretization/BDF_order",2);
123 
124  // Order of BDF and extrapolation for the velocity
125  timeVelocity.setBDForder(orderBDF);
126  timeVelocity.setMaximumExtrapolationOrder(orderBDF);
127  timeVelocity.setTimeStep(dt);
128 
129  // Initialize time advance
130  vector_Type velocityInitial ( ns.uFESpace()->map() );
131  std::vector<vector_Type> initialStateVelocity;
132  velocityInitial *= 0 ;
133  for ( UInt i = 0; i < orderBDF; ++i )
134  initialStateVelocity.push_back(velocityInitial);
135 
136  timeVelocity.initialize(initialStateVelocity);
137 
138  TimeAndExtrapolationHandler timePressure;
139  if ( useStabilization && stabilizationType.compare("VMSLES_SEMI_IMPLICIT")==0 )
140  {
141  timePressure.setBDForder(orderBDF);
142  timePressure.setMaximumExtrapolationOrder(orderBDF);
143  timePressure.setTimeStep(dt);
144 
145  vector_Type pressureInitial ( ns.pFESpace()->map() );
146  std::vector<vector_Type> initialStatePressure;
147  pressureInitial.zero();
148  for ( UInt i = 0; i < orderBDF; ++i )
149  initialStatePressure.push_back(pressureInitial);
150 
151  timePressure.initialize(initialStatePressure);
152  }
153 
154  // Exporter
155  std::string outputName = dataFile ( "exporter/filename", "result");
156  std::shared_ptr< ExporterHDF5<mesh_Type > > exporter;
157 
158  exporter.reset ( new ExporterHDF5<mesh_Type > ( dataFile, outputName ) );
159  exporter->setPostDir ( "./" );
160  exporter->setMeshProcId ( localMeshPtr, Comm->MyPID() );
161  vectorPtr_Type velocity( new vector_Type(ns.uFESpace()->map(), exporter->mapType() ) );
162  vectorPtr_Type pressure( new vector_Type(ns.pFESpace()->map(), exporter->mapType() ) );
163  exporter->addVariable ( ExporterData<mesh_Type>::VectorField, "velocity", ns.uFESpace(), velocity, UInt (0) );
164  exporter->addVariable ( ExporterData<mesh_Type>::ScalarField, "pressure", ns.pFESpace(), pressure, UInt (0) );
165 
166  // exporter->postProcess ( t0 );
167 
168  // Boundary conditions
169  std::shared_ptr<BCHandler> bc ( new BCHandler (*BCh_fluid ()) );
170  std::shared_ptr<BCHandler> bc_preprocessing ( new BCHandler (*BCh_preprocessing ()) );
171 
172  std::string preconditioner = dataFile("fluid/preconditionerType","none");
173 
174  // Time loop
175  LifeChrono iterChrono;
176  Real time = t0 + dt;
177 
178  vectorPtr_Type u_star( new vector_Type(ns.uFESpace()->map(), Unique ) );
179  vectorPtr_Type p_star( new vector_Type(ns.pFESpace()->map(), Unique ) );
180  vectorPtr_Type rhs_velocity( new vector_Type(ns.uFESpace()->map(), Unique ) );
181 
182  ns.setAlpha(timeVelocity.alpha());
183  ns.setTimeStep(dt);
184 
185  /* Preprocessing to define function phi used to define inflow of the aorta */
186 
187  UInt flag = 200;
188  vectorPtr_Type laplacianSolution( new vector_Type( ns.uFESpace_scalar()->map() ) );
189  laplacianSolution->zero();
190  ns.solveLaplacian(flag, bc_preprocessing, laplacianSolution);
191 
192  BCFunctionBase one (oneFunction);
193 
194  // Inflow
195 
196  Real Q_hat_inflow = 0.0;
197  vectorPtr_Type Phi_h_inflow;
198  vectorPtr_Type V_hat_x_inflow;
199  vectorPtr_Type V_hat_y_inflow;
200  vectorPtr_Type V_hat_z_inflow;
201  BCHandler bcH_laplacian_inflow;
202  bcH_laplacian_inflow.addBC( "Inflow", 3, Essential, Full, one, 1 );
203  bcH_laplacian_inflow.bcUpdate ( *ns.uFESpace_scalar()->mesh(), ns.uFESpace_scalar()->feBd(), ns.uFESpace_scalar()->dof() );
204 
205  ns.preprocessBoundary ( -ns.normal(3)[0], -ns.normal(3)[1], -ns.normal(3)[2], bcH_laplacian_inflow, Q_hat_inflow, laplacianSolution, 3,
206  Phi_h_inflow, V_hat_x_inflow, V_hat_y_inflow, V_hat_z_inflow );
207 
208  if (verbose)
209  std::cout << "\tValue of inflow, Q_hat = " << Q_hat_inflow << std::endl;
210 
211  // Outflow 4
212  Real Q_hat_flag4 = 0.0;
213  vectorPtr_Type Phi_h_outflow4;
214  vectorPtr_Type V_hat_x_flag4;
215  vectorPtr_Type V_hat_y_flag4;
216  vectorPtr_Type V_hat_z_flag4;
217  BCHandler bcH_laplacian_flag4;
218  bcH_laplacian_flag4.addBC( "Outflow4", 4, Essential, Full, one, 1 );
219  bcH_laplacian_flag4.bcUpdate ( *ns.uFESpace_scalar()->mesh(), ns.uFESpace_scalar()->feBd(), ns.uFESpace_scalar()->dof() );
220 
221  ns.preprocessBoundary ( ns.normal(4)[0], ns.normal(4)[1], ns.normal(4)[2], bcH_laplacian_flag4, Q_hat_flag4, laplacianSolution, 4,
222  Phi_h_outflow4, V_hat_x_flag4, V_hat_y_flag4, V_hat_z_flag4 );
223 
224  if (verbose)
225  std::cout << "\tValue of outflow 4, Q_hat = " << Q_hat_flag4 << std::endl;
226 
227  // Outflow 5
228  Real Q_hat_flag5 = 0.0;
229  vectorPtr_Type Phi_h_outflow5;
230  vectorPtr_Type V_hat_x_flag5;
231  vectorPtr_Type V_hat_y_flag5;
232  vectorPtr_Type V_hat_z_flag5;
233  BCHandler bcH_laplacian_flag5;
234  bcH_laplacian_flag5.addBC( "Outflow5", 5, Essential, Full, one, 1 );
235  bcH_laplacian_flag5.bcUpdate ( *ns.uFESpace_scalar()->mesh(), ns.uFESpace_scalar()->feBd(), ns.uFESpace_scalar()->dof() );
236 
237  ns.preprocessBoundary ( ns.normal(5)[0], ns.normal(5)[1], ns.normal(5)[2], bcH_laplacian_flag5, Q_hat_flag5, laplacianSolution, 5,
238  Phi_h_outflow5, V_hat_x_flag5, V_hat_y_flag5, V_hat_z_flag5 );
239 
240  if (verbose)
241  std::cout << "\tValue of outflow 5, Q_hat = " << Q_hat_flag5 << std::endl;
242 
243  // Outflow 6
244  Real Q_hat_flag6 = 0.0;
245  vectorPtr_Type Phi_h_outflow6;
246  vectorPtr_Type V_hat_x_flag6;
247  vectorPtr_Type V_hat_y_flag6;
248  vectorPtr_Type V_hat_z_flag6;
249  BCHandler bcH_laplacian_flag6;
250  bcH_laplacian_flag6.addBC( "Outflow6", 6, Essential, Full, one, 1 );
251  bcH_laplacian_flag6.bcUpdate ( *ns.uFESpace_scalar()->mesh(), ns.uFESpace_scalar()->feBd(), ns.uFESpace_scalar()->dof() );
252 
253  ns.preprocessBoundary ( ns.normal(6)[0], ns.normal(6)[1], ns.normal(6)[2], bcH_laplacian_flag6, Q_hat_flag6, laplacianSolution, 6,
254  Phi_h_outflow6, V_hat_x_flag6, V_hat_y_flag6, V_hat_z_flag6 );
255 
256  if (verbose)
257  std::cout << "\tValue of outflow 6, Q_hat = " << Q_hat_flag6 << std::endl;
258 
259  // Outflow 7
260  Real Q_hat_flag7 = 0.0;
261  vectorPtr_Type Phi_h_outflow7;
262  vectorPtr_Type V_hat_x_flag7;
263  vectorPtr_Type V_hat_y_flag7;
264  vectorPtr_Type V_hat_z_flag7;
265  BCHandler bcH_laplacian_flag7;
266  bcH_laplacian_flag7.addBC( "Outflow7", 7, Essential, Full, one, 1 );
267  bcH_laplacian_flag7.bcUpdate ( *ns.uFESpace_scalar()->mesh(), ns.uFESpace_scalar()->feBd(), ns.uFESpace_scalar()->dof() );
268 
269  ns.preprocessBoundary ( ns.normal(7)[0], ns.normal(7)[1], ns.normal(7)[2], bcH_laplacian_flag7, Q_hat_flag7, laplacianSolution, 7,
270  Phi_h_outflow7, V_hat_x_flag7, V_hat_y_flag7, V_hat_z_flag7 );
271 
272  if (verbose)
273  std::cout << "\tValue of outflow 7, Q_hat = " << Q_hat_flag7 << std::endl;
274 
275  // Outflow 8
276  Real Q_hat_flag8 = 0.0;
277  vectorPtr_Type Phi_h_outflow8;
278  vectorPtr_Type V_hat_x_flag8;
279  vectorPtr_Type V_hat_y_flag8;
280  vectorPtr_Type V_hat_z_flag8;
281  BCHandler bcH_laplacian_flag8;
282  bcH_laplacian_flag8.addBC( "Outflow8", 8, Essential, Full, one, 1 );
283  bcH_laplacian_flag8.bcUpdate ( *ns.uFESpace_scalar()->mesh(), ns.uFESpace_scalar()->feBd(), ns.uFESpace_scalar()->dof() );
284 
285  ns.preprocessBoundary ( ns.normal(8)[0], ns.normal(8)[1], ns.normal(8)[2], bcH_laplacian_flag8, Q_hat_flag8, laplacianSolution, 8,
286  Phi_h_outflow8, V_hat_x_flag8, V_hat_y_flag8, V_hat_z_flag8);
287 
288  if (verbose)
289  std::cout << "\tValue of outflow 8, Q_hat = " << Q_hat_flag8 << std::endl;
290 
291  // Outflow 9
292  Real Q_hat_flag9 = 0.0;
293  vectorPtr_Type Phi_h_outflow9;
294  vectorPtr_Type V_hat_x_flag9;
295  vectorPtr_Type V_hat_y_flag9;
296  vectorPtr_Type V_hat_z_flag9;
297  BCHandler bcH_laplacian_flag9;
298  bcH_laplacian_flag9.addBC( "Outflow9", 9, Essential, Full, one, 1 );
299  bcH_laplacian_flag9.bcUpdate ( *ns.uFESpace_scalar()->mesh(), ns.uFESpace_scalar()->feBd(), ns.uFESpace_scalar()->dof() );
300 
301  ns.preprocessBoundary ( ns.normal(9)[0], ns.normal(9)[1], ns.normal(9)[2], bcH_laplacian_flag9, Q_hat_flag9, laplacianSolution, 9,
302  Phi_h_outflow9, V_hat_x_flag9, V_hat_y_flag9, V_hat_z_flag9);
303 
304  /* end preprocessing */
305 
306  /* Vectors needed to impose flowrates */
307 
308  vectorPtr_Type velAndPressure_flowrates;
309  velAndPressure_flowrates.reset ( new vector_Type ( ns.uFESpace()->map(), Unique ) );
310 
311  // Inflow
312  vectorPtr_Type velAndPressure_inflow_reference;
313  velAndPressure_inflow_reference.reset ( new vector_Type (ns.uFESpace()->map(), Unique ) );
314  velAndPressure_inflow_reference->zero();
315  velAndPressure_inflow_reference->subset(*V_hat_x_inflow,ns.uFESpace_scalar()->map(), 0, 0);
316  velAndPressure_inflow_reference->subset(*V_hat_y_inflow,ns.uFESpace_scalar()->map(), 0, ns.uFESpace()->map().mapSize()/3 );
317  velAndPressure_inflow_reference->subset(*V_hat_z_inflow,ns.uFESpace_scalar()->map(), 0, 2*ns.uFESpace()->map().mapSize()/3 );
318 
319  // Flag 4
320  vectorPtr_Type velAndPressure_outflow4_reference;
321  velAndPressure_outflow4_reference.reset ( new vector_Type (ns.uFESpace()->map(), Unique ) );
322  velAndPressure_outflow4_reference->zero();
323  velAndPressure_outflow4_reference->subset(*V_hat_x_flag4,ns.uFESpace_scalar()->map(), 0, 0);
324  velAndPressure_outflow4_reference->subset(*V_hat_y_flag4,ns.uFESpace_scalar()->map(), 0, ns.uFESpace()->map().mapSize()/3 );
325  velAndPressure_outflow4_reference->subset(*V_hat_z_flag4,ns.uFESpace_scalar()->map(), 0, 2*ns.uFESpace()->map().mapSize()/3 );
326 
327  // Flag 5
328  vectorPtr_Type velAndPressure_outflow5_reference;
329  velAndPressure_outflow5_reference.reset ( new vector_Type (ns.uFESpace()->map(), Unique ) );
330  velAndPressure_outflow5_reference->zero();
331  velAndPressure_outflow5_reference->subset(*V_hat_x_flag5,ns.uFESpace_scalar()->map(), 0, 0);
332  velAndPressure_outflow5_reference->subset(*V_hat_y_flag5,ns.uFESpace_scalar()->map(), 0, ns.uFESpace()->map().mapSize()/3 );
333  velAndPressure_outflow5_reference->subset(*V_hat_z_flag5,ns.uFESpace_scalar()->map(), 0, 2*ns.uFESpace()->map().mapSize()/3 );
334 
335  // Flag 6
336  vectorPtr_Type velAndPressure_outflow6_reference;
337  velAndPressure_outflow6_reference.reset ( new vector_Type (ns.uFESpace()->map(), Unique ) );
338  velAndPressure_outflow6_reference->zero();
339  velAndPressure_outflow6_reference->subset(*V_hat_x_flag6,ns.uFESpace_scalar()->map(), 0, 0);
340  velAndPressure_outflow6_reference->subset(*V_hat_y_flag6,ns.uFESpace_scalar()->map(), 0, ns.uFESpace()->map().mapSize()/3 );
341  velAndPressure_outflow6_reference->subset(*V_hat_z_flag6,ns.uFESpace_scalar()->map(), 0, 2*ns.uFESpace()->map().mapSize()/3 );
342 
343  // Flag 7
344  vectorPtr_Type velAndPressure_outflow7_reference;
345  velAndPressure_outflow7_reference.reset ( new vector_Type (ns.uFESpace()->map(), Unique ) );
346  velAndPressure_outflow7_reference->zero();
347  velAndPressure_outflow7_reference->subset(*V_hat_x_flag7,ns.uFESpace_scalar()->map(), 0, 0);
348  velAndPressure_outflow7_reference->subset(*V_hat_y_flag7,ns.uFESpace_scalar()->map(), 0, ns.uFESpace()->map().mapSize()/3 );
349  velAndPressure_outflow7_reference->subset(*V_hat_z_flag7,ns.uFESpace_scalar()->map(), 0, 2*ns.uFESpace()->map().mapSize()/3 );
350 
351  // Flag 8
352  vectorPtr_Type velAndPressure_outflow8_reference;
353  velAndPressure_outflow8_reference.reset ( new vector_Type (ns.uFESpace()->map(), Unique ) );
354  velAndPressure_outflow8_reference->zero();
355  velAndPressure_outflow8_reference->subset(*V_hat_x_flag8,ns.uFESpace_scalar()->map(), 0, 0);
356  velAndPressure_outflow8_reference->subset(*V_hat_y_flag8,ns.uFESpace_scalar()->map(), 0, ns.uFESpace()->map().mapSize()/3 );
357  velAndPressure_outflow8_reference->subset(*V_hat_z_flag8,ns.uFESpace_scalar()->map(), 0, 2*ns.uFESpace()->map().mapSize()/3 );
358 
359  // Flag 9
360  vectorPtr_Type velAndPressure_outflow9_reference;
361  velAndPressure_outflow9_reference.reset ( new vector_Type (ns.uFESpace()->map(), Unique ) );
362  velAndPressure_outflow9_reference->zero();
363  velAndPressure_outflow9_reference->subset(*V_hat_x_flag9,ns.uFESpace_scalar()->map(), 0, 0);
364  velAndPressure_outflow9_reference->subset(*V_hat_y_flag9,ns.uFESpace_scalar()->map(), 0, ns.uFESpace()->map().mapSize()/3 );
365  velAndPressure_outflow9_reference->subset(*V_hat_z_flag9,ns.uFESpace_scalar()->map(), 0, 2*ns.uFESpace()->map().mapSize()/3 );
366 
367  vectorPtr_Type velAndPressure_inflow;
368  velAndPressure_inflow.reset ( new vector_Type ( ns.uFESpace()->map(), Unique ) );
369 
370  vectorPtr_Type velAndPressure_outflow4;
371  velAndPressure_outflow4.reset ( new vector_Type ( ns.uFESpace()->map(), Unique ) );
372 
373  vectorPtr_Type velAndPressure_outflow5;
374  velAndPressure_outflow5.reset ( new vector_Type ( ns.uFESpace()->map(), Unique ) );
375 
376  vectorPtr_Type velAndPressure_outflow6;
377  velAndPressure_outflow6.reset ( new vector_Type ( ns.uFESpace()->map(), Unique ) );
378 
379  vectorPtr_Type velAndPressure_outflow7;
380  velAndPressure_outflow7.reset ( new vector_Type ( ns.uFESpace()->map(), Unique ) );
381 
382  vectorPtr_Type velAndPressure_outflow8;
383  velAndPressure_outflow8.reset ( new vector_Type ( ns.uFESpace()->map(), Unique ) );
384 
385  vectorPtr_Type velAndPressure_outflow9;
386  velAndPressure_outflow9.reset ( new vector_Type ( ns.uFESpace()->map(), Unique ) );
387 
388  /* end preprocessing */
389 
390  Real i_HeartBeat = 0.0;
391 
392  int time_step_count = 0;
393 
394  for ( ; time <= tFinal + dt / 2.; time += dt)
395  {
396  time_step_count += 1;
397 
398  // ---------------------------------
399  // Evaluation of the inflow velocity
400  // ---------------------------------
401 
402  Real Q = 0;
403  Real Q_inflow = 0;
404  Real Q_flag4 = 0;
405  Real Q_flag5 = 0;
406  Real Q_flag6 = 0;
407  Real Q_flag7 = 0;
408  Real Q_flag8 = 0;
409  Real Q_flag9 = 0;
410 
411  Real T_heartbeat = 0.8;
412 
413  if ( time < T_heartbeat )
414  {
415  i_HeartBeat = 0.0;
416  }
417  else if ( time >= T_heartbeat && time < 2*T_heartbeat )
418  {
419  i_HeartBeat = 1.0;
420  }
421  else if ( time >= 2*T_heartbeat && time < 3*T_heartbeat )
422  {
423  i_HeartBeat = 2.0;
424  }
425  else if ( time >= 3*T_heartbeat && time < 4*T_heartbeat )
426  {
427  i_HeartBeat = 3.0;
428  }
429 
430  if ( (time >= 0.05 && time <= 0.42) || (time >= (0.05+T_heartbeat) && time <= (0.42+T_heartbeat) ) || (time >= (0.05+2*T_heartbeat) && time <= (0.42+2*T_heartbeat) ) || (time >= (0.05+3*T_heartbeat) && time <= (0.42+3*T_heartbeat) ) )
431  {
432  Q = -2.314569820334801e+09*std::pow(time-i_HeartBeat*T_heartbeat,9) +
433  4.952537061974133e+09*std::pow(time-i_HeartBeat*T_heartbeat,8) -
434  4.532060231242586e+09*std::pow(time-i_HeartBeat*T_heartbeat,7) +
435  2.325743716202249e+09*std::pow(time-i_HeartBeat*T_heartbeat,6) -
436  7.387577876374097e+08*std::pow(time-i_HeartBeat*T_heartbeat,5) +
437  1.514516710083440e+08*std::pow(time-i_HeartBeat*T_heartbeat,4) -
438  2.018053394181958e+07*std::pow(time-i_HeartBeat*T_heartbeat,3) +
439  1.667954643625200e+06*std::pow(time-i_HeartBeat*T_heartbeat,2) -
440  7.160662399848596e+04*(time-i_HeartBeat*T_heartbeat) +
441  1.184312187078482e+03;
442  Q = Q/394;
443 
444  }
445  else
446  {
447  Q = 0.0;
448  }
449 
450  Q_inflow = 394*Q;
451  Q_flag4 = 20.25*Q; // left_common_carotid
452  Q_flag5 = 21.82*Q; // right_common_carotid
453  Q_flag6 = 1.43*Q; // right_vertebral
454  Q_flag7 = 24.77*Q; // right_subclavian
455  Q_flag8 = 4.69*Q; // left_vertebral
456  Q_flag9 = 21.54*Q; // left_subclavian
457 
458  Real pressureValue = 1500.0/2.51*(Q_inflow - Q_flag4 - Q_flag5 - Q_flag6 - Q_flag7 - Q_flag8 - Q_flag9);
459 
460  if (verbose)
461  {
462  std::cout << "\nImposing outflow pressure of " << pressureValue << " dyne/cm^2\n\n";
463  }
464 
465  Real alpha_flowrate_inflow = Q_inflow/Q_hat_inflow;
466  Real alpha_flowrate_flag4 = Q_flag4/Q_hat_flag4;
467  Real alpha_flowrate_flag5 = Q_flag5/Q_hat_flag5;
468  Real alpha_flowrate_flag6 = Q_flag6/Q_hat_flag6;
469  Real alpha_flowrate_flag7 = Q_flag7/Q_hat_flag7;
470  Real alpha_flowrate_flag8 = Q_flag8/Q_hat_flag8;
471  Real alpha_flowrate_flag9 = Q_flag9/Q_hat_flag9;
472 
473  if (verbose)
474  {
475  std::cout << "Q_inflow: " << Q_inflow << std::endl << std::endl;
476  std::cout << "Q_flag4: " << Q_flag4 << std::endl << std::endl;
477  std::cout << "Q_flag5: " << Q_flag5 << std::endl << std::endl;
478  std::cout << "Q_flag6: " << Q_flag6 << std::endl << std::endl;
479  std::cout << "Q_flag7: " << Q_flag7 << std::endl << std::endl;
480  std::cout << "Q_flag8: " << Q_flag8 << std::endl << std::endl;
481  std::cout << "Q_flag9: " << Q_flag9 << std::endl << std::endl;
482  std::cout << "Q_outflow: " << Q_inflow - Q_flag4 - Q_flag5 - Q_flag6 - Q_flag7 - Q_flag8 - Q_flag9 << std::endl << std::endl;
483  }
484 
485  scaleInflowVector(velAndPressure_inflow_reference, velAndPressure_inflow, alpha_flowrate_inflow );
486 
487  scaleInflowVector(velAndPressure_outflow4_reference, velAndPressure_outflow4, alpha_flowrate_flag4 );
488  scaleInflowVector(velAndPressure_outflow5_reference, velAndPressure_outflow5, alpha_flowrate_flag5 );
489  scaleInflowVector(velAndPressure_outflow6_reference, velAndPressure_outflow6, alpha_flowrate_flag6 );
490  scaleInflowVector(velAndPressure_outflow7_reference, velAndPressure_outflow7, alpha_flowrate_flag7 );
491  scaleInflowVector(velAndPressure_outflow8_reference, velAndPressure_outflow8, alpha_flowrate_flag8 );
492  scaleInflowVector(velAndPressure_outflow9_reference, velAndPressure_outflow9, alpha_flowrate_flag9 );
493 
494  /*
495  velAndPressure_inflow->zero();
496  *velAndPressure_inflow += *velAndPressure_inflow_reference;
497  *velAndPressure_inflow *= alpha_flowrate_inflow;
498 
499  velAndPressure_outflow4->zero();
500  *velAndPressure_outflow4 += *velAndPressure_outflow4_reference;
501  *velAndPressure_outflow4 *= alpha_flowrate_flag4;
502 
503  velAndPressure_outflow5->zero();
504  *velAndPressure_outflow5 += *velAndPressure_outflow5_reference;
505  *velAndPressure_outflow5 *= alpha_flowrate_flag5;
506 
507  velAndPressure_outflow6->zero();
508  *velAndPressure_outflow6 += *velAndPressure_outflow6_reference;
509  *velAndPressure_outflow6 *= alpha_flowrate_flag6;
510 
511  velAndPressure_outflow7->zero();
512  *velAndPressure_outflow7 += *velAndPressure_outflow7_reference;
513  *velAndPressure_outflow7 *= alpha_flowrate_flag7;
514 
515  velAndPressure_outflow8->zero();
516  *velAndPressure_outflow8 += *velAndPressure_outflow8_reference;
517  *velAndPressure_outflow8 *= alpha_flowrate_flag8;
518 
519  velAndPressure_outflow9->zero();
520  *velAndPressure_outflow9 += *velAndPressure_outflow9_reference;
521  *velAndPressure_outflow9 *= alpha_flowrate_flag9;
522  */
523 
524  velAndPressure_flowrates->zero();
525  *velAndPressure_flowrates += *velAndPressure_inflow;
526  *velAndPressure_flowrates += *velAndPressure_outflow4;
527  *velAndPressure_flowrates += *velAndPressure_outflow5;
528  *velAndPressure_flowrates += *velAndPressure_outflow6;
529  *velAndPressure_flowrates += *velAndPressure_outflow7;
530  *velAndPressure_flowrates += *velAndPressure_outflow8;
531  *velAndPressure_flowrates += *velAndPressure_outflow9;
532 
533  if (verbose)
534  std::cout << "\nWe are at time " << time << " s\n\n";
535 
536  iterChrono.reset();
537  iterChrono.start();
538 
539  u_star->zero();
540  rhs_velocity->zero();
541  timeVelocity.extrapolate (orderBDF, *u_star);
542  timeVelocity.rhsContribution (*rhs_velocity);
543 
544  if ( useStabilization && stabilizationType.compare("VMSLES_SEMI_IMPLICIT")==0 )
545  {
546  timePressure.extrapolate (orderBDF,*p_star);
548  }
549 
550  ns.updateSystem ( u_star, rhs_velocity );
551  ns.iterate( bc, time, velAndPressure_flowrates );
552 
553  ns.updateVelocity(velocity);
554  ns.updatePressure(pressure);
555 
556  iterChrono.stop();
557 
558  if (verbose)
559  std::cout << "\nTimestep solved in " << iterChrono.diff() << " s\n";
560 
561  // This part below handles the exporter of the solution.
562  // In particular, given a number of timesteps at which
563  // we ask to export the solution (from datafile), here
564  // the code takes care of exporting the solution also at
565  // the previous timesteps such that, if later a restart
566  // of the simulation is performed, it works correctly.
567  if ( orderBDF == 1 )
568  {
569  if ( time_step_count == (counterSaveEvery-1) )
570  {
571  exporter->postProcess ( time );
572  }
573  else if ( time_step_count == counterSaveEvery )
574  {
575  exporter->postProcess ( time );
576  counterSaveEvery += saveEvery;
577  }
578  }
579  else if ( orderBDF == 2 )
580  {
581 // if ( time_step_count == (counterSaveEvery-2) )
582 // {
583 // exporter->postProcess ( time );
584 // }
585 // else if ( time_step_count == (counterSaveEvery-1) )
586 // {
587 // exporter->postProcess ( time );
588 // }
589  if ( time_step_count == counterSaveEvery )
590  {
591  if ( time >= saveAfter )
592  {
593  exporter->postProcess ( time );
594  }
595  counterSaveEvery += saveEvery;
596  }
597  }
598 
599  timeVelocity.shift(*velocity);
600 
601  if ( useStabilization && stabilizationType.compare("VMSLES_SEMI_IMPLICIT")==0 )
602  timePressure.shift(*pressure);
603 
604  }
605 
606  exporter->closeFile();
607 
608  }
609 
610 #ifdef HAVE_MPI
611  if (verbose)
612  {
613  std::cout << "\nMPI Finalization" << std::endl;
614  }
615  MPI_Finalize();
616 #endif
617  return ( EXIT_SUCCESS );
618 }
619 
620 void scaleInflowVector( const vectorPtr_Type& vecNotScaled,
621  vectorPtr_Type& vecScaled,
622  const Real& coefficient )
623 {
624  vecScaled->zero();
625  *vecScaled += *vecNotScaled;
626  *vecScaled *= coefficient;
627 }
void setAlpha(const Real &alpha)
Set coefficient associated to the time discretization scheme.
double operator()(const char *VarName, const double &Default) const
Definition: GetPot.hpp:2033
void updateSystem(const vectorPtr_Type &u_star, const vectorPtr_Type &rhs_velocity)
Update the convective term and the right hand side.
GetPot(const int argc_, char **argv_, const char *FieldSeparator=0x0)
Definition: GetPot.hpp:507
Real oneFunction(const Real &, const Real &, const Real &, const Real &, const ID &)
uint32_type ID
IDs.
Definition: LifeV.hpp:194
void setupPostProc()
Additional setup for postprocessing on boundaries.
std::shared_ptr< std::vector< Int > > M_isOnProc
void setExtrapolatedPressure(const vectorPtr_Type &pressure_extrapolated)
Set the extrapolated pressure vector (used by semi-implicit VMS-LES stabilization) ...
MeshData - class for handling spatial discretization.
Definition: MeshData.hpp:72
void setParameters()
Set parameters of the solver.
double Real
Generic real data.
Definition: LifeV.hpp:175
void updateVelocity(vectorPtr_Type &velocity)
Get the velocity vector.
void updatePressure(vectorPtr_Type &pressure)
Get the pressure vector.
void setTimeStep(const Real &dt)
Set time step.
int operator()(const char *VarName, int Default) const
Definition: GetPot.hpp:2021
void buildSystem()
Assemble constant terms.
bool operator()(const char *VarName, bool Default) const
Definition: GetPot.hpp:2008
int main(int argc, char **argv)
void scaleInflowVector(const vectorPtr_Type &vecNotScaled, vectorPtr_Type &vecScaled, const Real &coefficient)
uint32_type UInt
generic unsigned integer (used mainly for addressing)
Definition: LifeV.hpp:191