LifeV
MultiscaleModelFluid3D.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 Multiscale Model Fluid3D
30  *
31  * @date 12-03-2009
32  * @author Cristiano Malossi <cristiano.malossi@epfl.ch>
33  *
34  * @maintainer Cristiano Malossi <cristiano.malossi@epfl.ch>
35  */
36 
37 #include <lifev/multiscale/models/MultiscaleModelFluid3D.hpp>
38 
39 namespace LifeV
40 {
41 namespace Multiscale
42 {
43 
44 // ===================================================
45 // Constructors & Destructor
46 // ===================================================
48  multiscaleModel_Type (),
49  MultiscaleInterface (),
50  M_exporter (),
51  M_importer (),
52  M_fileName (),
53  M_fluid (),
54  M_bc ( new bcInterface_Type() ),
55  M_bdf (),
56  M_data ( new data_Type() ),
57  M_meshData ( new MeshData() ),
58  M_mesh (),
59  M_map (),
60  M_solution (),
61  M_linearBC ( new bc_Type() ),
62  M_updateLinearModel ( true ),
63  M_uFESpace (),
64  M_pFESpace (),
65  M_lmDOF ( 0 ),
66  M_alpha ( 0 ),
67  M_beta (),
68  M_rhs (),
70  M_tolerance (),
72 {
73 
74 #ifdef HAVE_LIFEV_DEBUG
75  debugStream ( 8120 ) << "MultiscaleModelFluid3D::MultiscaleModelFluid3D() \n";
76 #endif
77 
78  M_type = Fluid3D;
79 }
80 
81 // ===================================================
82 // MultiscaleModel Methods
83 // ===================================================
84 void
85 MultiscaleModelFluid3D::setupData ( const std::string& fileName )
86 {
87 
88 #ifdef HAVE_LIFEV_DEBUG
89  debugStream ( 8120 ) << "MultiscaleModelFluid3D::setupData( fileName ) \n";
90 #endif
91 
92  multiscaleModel_Type::setupData ( fileName );
93  M_fileName = fileName;
94 
95  GetPot dataFile ( fileName );
96 
97  // Load data
98  M_data->setup ( dataFile );
99  if ( M_globalData.get() )
100  {
101  setupGlobalData ( fileName );
102  }
103 
104  // Mesh data
105  M_meshData->setup ( dataFile, "fluid/space_discretization" );
106 
107  // Parameters for the NS Iterations
108  M_subiterationsMaximumNumber = dataFile ( "fluid/miscellaneous/SubITMax", 0 );
109  M_tolerance = dataFile ( "fluid/miscellaneous/Tolerance", 1.e-6 );
110 
111  M_generalizedAitken.setDefaultOmega ( dataFile ( "fluid/miscellaneous/Omega", 1.e-3 ) );
112  M_generalizedAitken.setOmegaMin ( dataFile ( "fluid/miscellaneous/range", M_generalizedAitken.defaultOmegaFluid() / 1024, 0 ) );
113  M_generalizedAitken.setOmegaMax ( dataFile ( "fluid/miscellaneous/range", M_generalizedAitken.defaultOmegaFluid() * 1024, 1 ) );
114  M_generalizedAitken.useDefaultOmega ( dataFile ( "fluid/miscellaneous/fixedOmega", false ) );
115  M_generalizedAitken.setMinimizationType ( dataFile ( "fluid/miscellaneous/inverseOmega", true ) );
116 
117  //Boundary Conditions for the problem
118  M_bc->fillHandler ( fileName, "fluid" );
119 
120  //Setup Exporter & Importer
121  setupExporterImporter ( fileName );
122 }
123 
124 void
126 {
127 
128 #ifdef HAVE_LIFEV_DEBUG
129  debugStream ( 8120 ) << "MultiscaleModelFluid3D::setupModel() \n";
130 #endif
131 
132  //Mesh
133  setupMesh();
134 
135  //FEspace
137 
138  //Add flow rate offset to BC
139  M_lmDOF = M_bc->handler()->numberOfBCWithType ( Flux );
140  setupBCOffset ( M_bc->handler() );
141 
142  //Fluid
143  M_fluid.reset ( new fluid_Type ( M_data, *M_uFESpace, *M_pFESpace, M_comm, M_lmDOF ) );
144  M_bc->setPhysicalSolver ( M_fluid );
145 
146  GetPot dataFile ( M_fileName );
147  M_fluid->setUp ( dataFile ); //Remove Preconditioner and Solver if possible!
148 
149  //Fluid MAP
150  M_map.reset ( new MapEpetra ( M_fluid->getMap() ) );
151 
152  //BDF
153  M_bdf.reset ( new bdf_Type);
154  M_bdf->setup (M_data->dataTimeAdvance()->orderBDF() );
155 
156  //Problem coefficients
157  M_beta.reset ( new fluidVector_Type ( M_map ) );
158  M_rhs.reset ( new fluidVector_Type ( M_map ) );
159 
160  //Post-processing
161  M_exporter->setMeshProcId ( M_mesh->meshPartition(), M_comm->MyPID() );
162 
163  M_solution.reset ( new fluidVector_Type ( *M_fluid->solution(), M_exporter->mapType() ) );
164  if ( M_exporter->mapType() == Unique )
165  {
166  M_solution->setCombineMode ( Zero );
167  }
168 
169  M_exporter->addVariable ( IOData_Type::VectorField, "Velocity (fluid)", M_uFESpace, M_solution, static_cast<UInt> ( 0 ) );
170  M_exporter->addVariable ( IOData_Type::ScalarField, "Pressure (fluid)", M_pFESpace, M_solution, static_cast<UInt> ( 3 * M_uFESpace->dof().numTotalDof() ) );
171 
172  //Setup linear model
174 
175  //Setup solution
177 }
178 
179 void
181 {
182 
183 #ifdef HAVE_LIFEV_DEBUG
184  debugStream ( 8120 ) << "MultiscaleModelFluid3D::buildModel() \n";
185 #endif
186 
187  // Display data
188  // if ( M_comm->MyPID() == 0 )
189  // M_data->showMe();
190 
191  //Build constant matrices
192  M_fluid->buildSystem();
193 
194  //Initialize BDF
195  M_bdf->bdfVelocity().setInitialCondition ( *M_fluid->solution() );
196 
197  //Define problem coefficients
198  if ( M_data->isStokes() )
199  {
200  M_alpha = 0.0;
201  *M_beta = *M_fluid->solution(); //It is a stationary Navier-Stokes
202  *M_rhs *= 0.0;
203  }
204  else
205  {
206  M_alpha = M_bdf->bdfVelocity().coefficientFirstDerivative ( 0 ) / M_data->dataTime()->timeStep();
207  M_bdf->bdfVelocity().extrapolation (*M_beta);
208 
209  M_bdf->bdfVelocity().updateRHSContribution ( M_data->dataTime()->timeStep() );
210  *M_rhs = M_fluid->matrixMass() * M_bdf->bdfVelocity().rhsContributionFirstDerivative();
211  }
212 
213  //Set problem coefficients
214  M_fluid->updateSystem ( M_alpha, *M_beta, *M_rhs );
215 
216  //Update operator BC
217  M_bc->updatePhysicalSolverVariables();
218 }
219 
220 void
222 {
223 
224 #ifdef HAVE_LIFEV_DEBUG
225  debugStream ( 8120 ) << "MultiscaleModelFluid3D::updateModel() \n";
226 #endif
227 
228  //Update BDF
229  M_bdf->bdfVelocity().shiftRight ( *M_fluid->solution() );
230 
231  //Update problem coefficients
232  M_alpha = M_bdf->bdfVelocity().coefficientFirstDerivative ( 0 ) / M_data->dataTime()->timeStep();
233  M_bdf->bdfVelocity().extrapolation (*M_beta);
234 
235  M_bdf->bdfVelocity().updateRHSContribution ( M_data->dataTime()->timeStep() );
236  *M_rhs = M_fluid->matrixMass() * M_bdf->bdfVelocity().rhsContributionFirstDerivative();
237 
238  //Set problem coefficients
239  M_fluid->updateSystem ( M_alpha, *M_beta, *M_rhs );
240 
241  //Update operator BC
242  M_bc->updatePhysicalSolverVariables();
243 
244  //Recompute preconditioner
245  M_fluid->resetPreconditioner ( true );
246 
247  //Linear system need to be updated
248  M_updateLinearModel = true;
249 }
250 
251 void
253 {
254 
255 #ifdef HAVE_LIFEV_DEBUG
256  debugStream ( 8120 ) << "MultiscaleModelFluid3D::solveModel() \n";
257 #endif
258 
259  // Solve the problem
260  displayModelStatus ( "Solve" );
261  M_fluid->iterate ( *M_bc->handler() );
262 
263  // Non linear convective term with Aitken
265  {
266  Real residual = ( *M_beta - *M_fluid->solution() ).norm2(); // residual is computed on the whole solution vector;
267 
268  if ( M_comm->MyPID() == 0 )
269  {
270  std::cout << " F- Residual: " << residual << std::endl;
271  }
272 
273  M_generalizedAitken.restart();
274  for ( UInt subIT = 1; subIT <= M_subiterationsMaximumNumber; ++subIT )
275  {
276  // Verify tolerance
277  if ( residual <= M_tolerance )
278  {
279  break;
280  }
281 
282  *M_beta += M_generalizedAitken.computeDeltaLambdaScalar ( *M_beta, *M_beta - *M_fluid->solution() );
283 
284  //Linear model need to be updated!
285  M_fluid->updateSystem ( M_alpha, *M_beta, *M_rhs );
286  M_bc->updatePhysicalSolverVariables();
287  M_updateLinearModel = true;
288 
289  //Solve system
290  M_fluid->iterate ( *M_bc->handler() );
291 
292  // Check the new residual
293  residual = ( *M_beta - *M_fluid->solution() ).norm2(); // residual is computed on the whole solution vector
294 
295  // Display subiteration information
296  if ( M_comm->MyPID() == 0 )
297  {
298  std::cout << " F- Sub-iteration n.: " << subIT << std::endl;
299  std::cout << " F- Residual: " << residual << std::endl;
300  }
301  }
302  }
303 }
304 
305 void
307 {
308 
309 #ifdef HAVE_LIFEV_DEBUG
310  debugStream ( 8120 ) << "MultiscaleModelFluid3D::updateSolution() \n";
311 #endif
312 
313  *M_solution = *M_fluid->solution();
314 }
315 
316 void
318 {
319 
320 #ifdef HAVE_LIFEV_DEBUG
321  debugStream ( 8120 ) << "MultiscaleModelFluid3D::saveSolution() \n";
322 #endif
323 
324  //Post-processing
325  M_exporter->postProcess ( M_data->dataTime()->time() );
326 
327 #ifdef HAVE_HDF5
328  if ( M_data->dataTime()->isLastTimeStep() )
329  {
330  M_exporter->closeFile();
331  }
332 #endif
333 
334 }
335 
336 void
338 {
339  if ( M_comm->MyPID() == 0 )
340  {
341  multiscaleModel_Type::showMe();
342 
343  std::cout << "Velocity FE order = " << M_data->uOrder() << std::endl
344  << "Pressure FE order = " << M_data->pOrder() << std::endl << std::endl;
345 
346  std::cout << "Velocity DOF = " << 3 * M_uFESpace->dof().numTotalDof() << std::endl
347  << "Pressure DOF = " << M_pFESpace->dof().numTotalDof() << std::endl
348  << "lmDOF = " << M_lmDOF << std::endl << std::endl;
349 
350  std::cout << "Fluid mesh maxH = " << MeshUtility::MeshStatistics::computeSize ( *M_mesh->meshPartition() ).maxH << std::endl
351  << "Fluid mesh meanH = " << MeshUtility::MeshStatistics::computeSize ( *M_mesh->meshPartition() ).meanH << std::endl << std::endl;
352 
353  std::cout << "NS SubITMax = " << M_subiterationsMaximumNumber << std::endl
354  << "NS Tolerance = " << M_tolerance << std::endl << std::endl << std::endl << std::endl;
355  }
356 }
357 
358 Real
360 {
361  return M_solution->norm2();
362 }
363 
364 // ===================================================
365 // MultiscaleInterface Methods
366 // ===================================================
367 void
368 MultiscaleModelFluid3D::imposeBoundaryFlowRate ( const multiscaleID_Type& boundaryID, const function_Type& function )
369 {
370  BCFunctionBase base;
371  base.setFunction ( function );
372 
373  M_bc->handler()->addBC ( "CouplingFlowRate_Model_" + number2string ( M_ID ) + "_BoundaryID_" + number2string ( boundaryID ), boundaryFlag ( boundaryID ), Flux, Full, base, 3 );
374 }
375 
376 void
377 MultiscaleModelFluid3D::imposeBoundaryMeanNormalStress ( const multiscaleID_Type& boundaryID, const function_Type& function )
378 {
379  BCFunctionBase base;
380  base.setFunction ( function );
381 
382  M_bc->handler()->addBC ( "CouplingStress_Model_" + number2string ( M_ID ) + "_BoundaryID_" + number2string ( boundaryID ), boundaryFlag ( boundaryID ), Natural, Normal, base );
383 }
384 
385 Real
386 MultiscaleModelFluid3D::boundaryDeltaFlowRate ( const multiscaleID_Type& boundaryID, bool& solveLinearSystem )
387 {
388  solveLinearModel ( solveLinearSystem );
389 
390  return M_fluid->linearFlux ( boundaryFlag ( boundaryID ) );
391 }
392 
393 Real
394 MultiscaleModelFluid3D::boundaryDeltaMeanNormalStress ( const multiscaleID_Type& boundaryID, bool& solveLinearSystem )
395 {
396  solveLinearModel ( solveLinearSystem );
397 
398  return M_fluid->linearMeanNormalStress ( boundaryFlag ( boundaryID ), *M_linearBC );
399 }
400 
401 Real
402 MultiscaleModelFluid3D::boundaryDeltaMeanTotalNormalStress ( const multiscaleID_Type& boundaryID, bool& solveLinearSystem )
403 {
404  solveLinearModel ( solveLinearSystem );
405 
406  return M_fluid->linearMeanTotalNormalStress ( boundaryFlag ( boundaryID ), *M_linearBC );
407 }
408 
409 // ===================================================
410 // Set Methods
411 // ===================================================
412 void
414 {
415  M_solution = solution;
416 
417  M_fluid->initialize ( *M_solution );
418 }
419 
420 // ===================================================
421 // Private Methods
422 // ===================================================
423 void
424 MultiscaleModelFluid3D::setupGlobalData ( const std::string& fileName )
425 {
426 
427 #ifdef HAVE_LIFEV_DEBUG
428  debugStream ( 8120 ) << "MultiscaleModelFluid3D::setupGlobalData( fileName ) \n";
429 #endif
430 
431  GetPot dataFile ( fileName );
432 
433  //Global data time
434  M_data->setTimeData ( M_globalData->dataTime() );
435 
436  //Global physical quantities
437  if ( !dataFile.checkVariable ( "fluid/physics/density" ) )
438  {
439  M_data->setDensity ( M_globalData->fluidDensity() );
440  }
441  if ( !dataFile.checkVariable ( "fluid/physics/viscosity" ) )
442  {
443  M_data->setViscosity ( M_globalData->fluidViscosity() );
444  }
445 }
446 
447 void
449 {
450 
451 #ifdef HAVE_LIFEV_DEBUG
452  debugStream ( 8120 ) << "MultiscaleModelFluid3D::initializeSolution() \n";
453 #endif
454 
455  if ( multiscaleProblemStep > 0 )
456  {
457  M_importer->setMeshProcId ( M_mesh->meshPartition(), M_comm->MyPID() );
458 
459  M_importer->addVariable ( IOData_Type::VectorField, "Velocity (fluid)", M_uFESpace, M_solution, static_cast <UInt> ( 0 ) );
460  M_importer->addVariable ( IOData_Type::ScalarField, "Pressure (fluid)", M_pFESpace, M_solution, static_cast <UInt> ( 3 * M_uFESpace->dof().numTotalDof() ) );
461 
462  // Import
463  M_exporter->setTimeIndex ( M_importer->importFromTime ( M_data->dataTime()->initialTime() ) + 1 );
464 
465 #ifdef HAVE_HDF5
466  M_importer->closeFile();
467 #endif
468  }
469  else
470  {
471  *M_solution = 0.0;
472  }
473 
474  M_fluid->initialize ( *M_solution );
475 }
476 
477 void
478 MultiscaleModelFluid3D::setupExporterImporter ( const std::string& fileName )
479 {
480  GetPot dataFile ( fileName );
481 
482  //Exporter
483  const std::string exporterType = dataFile ( "exporter/type", "ensight" );
484 
485 #ifdef HAVE_HDF5
486  if ( !exporterType.compare ( "hdf5" ) )
487  {
488  M_exporter.reset ( new hdf5IOFile_Type() );
489  }
490  else
491 #endif
492  M_exporter.reset ( new ensightIOFile_Type() );
493 
494  M_exporter->setDataFromGetPot ( dataFile );
495  M_exporter->setPrefix ( multiscaleProblemPrefix + "_Model_" + number2string ( M_ID ) + "_" + number2string ( multiscaleProblemStep ) );
496  M_exporter->setPostDir ( multiscaleProblemFolder );
497 
498  //Importer
499  const std::string importerType = dataFile ( "importer/type", "ensight" );
500 
501 #ifdef HAVE_HDF5
502  if ( !importerType.compare ( "hdf5" ) )
503  {
504  M_importer.reset ( new hdf5IOFile_Type() );
505  }
506  else
507 #endif
508  M_importer.reset ( new ensightIOFile_Type() );
509 
510  M_importer->setDataFromGetPot ( dataFile );
511  M_importer->setPrefix ( multiscaleProblemPrefix + "_Model_" + number2string ( M_ID ) + "_" + number2string ( multiscaleProblemStep - 1 ) );
512  M_importer->setPostDir ( multiscaleProblemFolder );
513 }
514 
515 void
517 {
518  //Read fluid mesh from file
519  std::shared_ptr< mesh_Type > fluidMesh ( new mesh_Type ( M_comm ) );
520  readMesh ( *fluidMesh, *M_meshData );
521 
522  //Transform mesh
523  fluidMesh->meshTransformer().transformMesh ( M_geometryScale, M_geometryRotate, M_geometryTranslate );
524 
525  //Partition mesh
526  M_mesh.reset ( new MeshPartitioner_Type ( fluidMesh, M_comm ) );
527 }
528 
529 void
531 {
532 
533 #ifdef HAVE_LIFEV_DEBUG
534  debugStream ( 8120 ) << "MultiscaleModelFluid3D::setupFEspace() \n";
535 #endif
536 
537  //Velocity FE Space
538  const ReferenceFE* u_refFE;
539  const QuadratureRule* u_qR;
540  const QuadratureRule* u_bdQr;
541 
542  if ( M_data->uOrder().compare ( "P2" ) == 0 )
543  {
544  u_refFE = &feTetraP2;
545  u_qR = &quadRuleTetra15pt; // DoE 5
546  u_bdQr = &quadRuleTria3pt; // DoE 2
547  }
548  else if ( M_data->uOrder().compare ( "P1" ) == 0 )
549  {
550  u_refFE = &feTetraP1;
551  u_qR = &quadRuleTetra4pt; // DoE 2
552  u_bdQr = &quadRuleTria3pt; // DoE 2
553  }
554  else if ( M_data->uOrder().compare ( "P1Bubble" ) == 0 )
555  {
556  u_refFE = &feTetraP1bubble;
557  u_qR = &quadRuleTetra64pt; // DoE 2
558  u_bdQr = &quadRuleTria3pt; // DoE 2
559  }
560  else
561  {
562  if ( M_comm->MyPID() == 0 )
563  {
564  std::cout << M_data->uOrder() << " Velocity FE not implemented yet." << std::endl;
565  }
566  exit ( EXIT_FAILURE );
567  }
568 
569  //Pressure FE Space
570  const ReferenceFE* p_refFE;
571  const QuadratureRule* p_qR;
572  const QuadratureRule* p_bdQr;
573 
574  if ( M_data->pOrder().compare ( "P2" ) == 0 )
575  {
576  p_refFE = &feTetraP2;
577  p_qR = u_qR;
578  p_bdQr = &quadRuleTria3pt; // DoE 2
579  }
580  else if ( M_data->pOrder().compare ( "P1" ) == 0 )
581  {
582  p_refFE = &feTetraP1;
583  p_qR = u_qR;
584  p_bdQr = &quadRuleTria3pt; // DoE 2
585  }
586  else
587  {
588  if ( M_comm->MyPID() == 0 )
589  {
590  std::cout << M_data->pOrder() << " pressure FE not implemented yet." << std::endl;
591  }
592  exit ( EXIT_FAILURE );
593  }
594 
595  M_uFESpace.reset ( new FESpace_Type ( M_mesh->meshPartition(), *u_refFE, *u_qR, *u_bdQr, 3, M_comm ) );
596  M_pFESpace.reset ( new FESpace_Type ( M_mesh->meshPartition(), *p_refFE, *p_qR, *p_bdQr, 1, M_comm ) );
597 }
598 
599 void
601 {
602 
603 #ifdef HAVE_LIFEV_DEBUG
604  debugStream ( 8120 ) << "MultiscaleModelFluid3D::setupDOF \n";
605 #endif
606 
607  M_lmDOF = M_bc->handler()->numberOfBCWithType ( Flux );
608 }
609 
610 void
612 {
613 
614 #ifdef HAVE_LIFEV_DEBUG
615  debugStream ( 8120 ) << "MultiscaleModelFluid3D::setupBCOffset( BC ) \n";
616 #endif
617 
618  UInt offset = M_uFESpace->map().map ( Unique )->NumGlobalElements() + M_pFESpace->map().map ( Unique )->NumGlobalElements();
619 
620  std::vector< bcName_Type > fluxVector = bc->findAllBCWithType ( Flux );
621  for ( UInt i = 0; i < M_lmDOF; ++i )
622  {
623  bc->setOffset ( fluxVector[i], offset + i );
624  }
625 }
626 
627 void
629 {
630 
631 #ifdef HAVE_LIFEV_DEBUG
632  debugStream ( 8120 ) << "MultiscaleModelFluid3D::setupLinearModel( ) \n";
633 #endif
634 
635  // The linear BCHandler is a copy of the original BCHandler with all BCFunctions giving zero
636  M_linearBC.reset ( new bc_Type ( *M_bc->handler() ) );
637 
638  // Set all the BCFunctions to zero
639  BCFunctionBase bcBaseDeltaZero;
640  bcBaseDeltaZero.setFunction ( std::bind ( &MultiscaleModelFluid3D::bcFunctionDeltaZero, this, std::placeholders::_1, std::placeholders::_2, std::placeholders::_3, std::placeholders::_4, std::placeholders::_5 ) );
641 
642  for ( bc_Type::bcBaseIterator_Type i = M_linearBC->begin() ; i != M_linearBC->end() ; ++i )
643  {
644  i->setBCFunction ( bcBaseDeltaZero );
645  }
646 }
647 
648 void
650 {
651 
652 #ifdef HAVE_LIFEV_DEBUG
653  debugStream ( 8120 ) << "MultiscaleModelFluid3D::updateLinearModel() \n";
654 #endif
655 
656  //Create an empty vector
657  fluidVector_Type vectorZero ( *M_solution );
658  vectorZero = 0.0;
659 
660  //updateLinearModel TODO REMOVE ?
661  M_fluid->updateLinearSystem ( M_fluid->matrixNoBC(), M_alpha, *M_beta, *M_fluid->solution(),
662  vectorZero, vectorZero, vectorZero, vectorZero );
663 
664  //Linear System Updated
665  M_updateLinearModel = false;
666 }
667 
668 void
669 MultiscaleModelFluid3D::solveLinearModel ( bool& solveLinearSystem )
670 {
671 
672 #ifdef HAVE_LIFEV_DEBUG
673  debugStream ( 8120 ) << "MultiscaleModelFluid3D::solveLinearModel() \n";
674 #endif
675 
676  if ( !solveLinearSystem )
677  {
678  return;
679  }
680 
682 
683  if ( M_updateLinearModel )
684  {
686  }
687 
688  //Solve the linear problem
689  displayModelStatus ( "Solve linear" );
690  M_fluid->solveLinearSystem ( *M_linearBC );
691 
693 
694  //This flag avoid recomputation of the same system
695  solveLinearSystem = false;
696 }
697 
698 void
700 {
701 
702 #ifdef HAVE_LIFEV_DEBUG
703  debugStream ( 8120 ) << "MultiscaleModelFluid3D::imposePerturbation() \n";
704 #endif
705 
706  for ( multiscaleCouplingsContainerConstIterator_Type i = M_couplings.begin(); i < M_couplings.end(); ++i )
707  if ( ( *i )->isPerturbed() )
708  {
709  BCFunctionBase bcBaseDeltaOne;
710  bcBaseDeltaOne.setFunction ( std::bind ( &MultiscaleModelFluid3D::bcFunctionDeltaOne, this, std::placeholders::_1, std::placeholders::_2, std::placeholders::_3, std::placeholders::_4, std::placeholders::_5 ) );
711 
712  M_linearBC->findBCWithFlag ( boundaryFlag ( ( *i )->boundaryID ( ( *i )->modelGlobalToLocalID ( M_ID ) ) ) ).setBCFunction ( bcBaseDeltaOne );
713 
714  break;
715  }
716 }
717 
718 void
720 {
721 
722 #ifdef HAVE_LIFEV_DEBUG
723  debugStream ( 8120 ) << "MultiscaleModelFluid3D::resetPerturbation() \n";
724 #endif
725 
726  for ( multiscaleCouplingsContainerConstIterator_Type i = M_couplings.begin(); i < M_couplings.end(); ++i )
727  if ( ( *i )->isPerturbed() )
728  {
729  BCFunctionBase bcBaseDeltaZero;
730  bcBaseDeltaZero.setFunction ( std::bind ( &MultiscaleModelFluid3D::bcFunctionDeltaZero, this, std::placeholders::_1, std::placeholders::_2, std::placeholders::_3, std::placeholders::_4, std::placeholders::_5 ) );
731 
732  M_linearBC->findBCWithFlag ( boundaryFlag ( ( *i )->boundaryID ( ( *i )->modelGlobalToLocalID ( M_ID ) ) ) ).setBCFunction ( bcBaseDeltaZero );
733 
734  break;
735  }
736 }
737 
738 } // Namespace multiscale
739 } // Namespace LifeV
Real boundaryDeltaMeanTotalNormalStress(const multiscaleID_Type &boundaryID, bool &solveLinearSystem)
Get the variation of the integral of the mean total normal stress (on a specific boundary interface) ...
const QuadratureRule quadRuleTetra64pt(pt_tetra_64pt, 6, "Quadrature rule 64 points on a tetraedra", TETRA, 64, 7)
void setupDOF()
Setup the DOF of the model.
void solveLinearModel(bool &solveLinearSystem)
Solve the linear problem.
const QuadratureRule quadRuleTetra15pt(pt_tetra_15pt, 5, "Quadrature rule 15 points on a tetraedra", TETRA, 15, 5)
const QuadratureRule quadRuleTetra4pt(pt_tetra_4pt, 2, "Quadrature rule 4 points on a tetraedra", TETRA, 4, 2)
Real boundaryDeltaMeanNormalStress(const multiscaleID_Type &boundaryID, bool &solveLinearSystem)
Get the variation of the integral of the mean normal stress (on a specific boundary interface) using ...
void setupBCOffset(const bcPtr_Type &BC)
Setup the offset for fluxes boundary conditions.
Real checkSolution() const
Return a specific scalar quantity to be used for a comparison with a reference value.
void initializeSolution()
Initialize the solution.
Real boundaryDeltaFlowRate(const multiscaleID_Type &boundaryID, bool &solveLinearSystem)
Get the variation of the flow rate (on a specific boundary interface) using the linear model...
void setupGlobalData(const std::string &fileName)
Setup the global data of the model.
void setupFEspace()
Setup the FE space for pressure and velocity.
void setSolution(const fluidVectorPtr_Type &solution)
Set the solution vector.
void imposePerturbation()
Impose the coupling perturbation on the correct BC inside the BCHandler.
void imposeBoundaryMeanNormalStress(const multiscaleID_Type &boundaryID, const function_Type &function)
Impose the integral of the mean normal stress on a specific boundary interface of the model...
void setupMesh()
Setup the mesh for the fluid problem.
double Real
Generic real data.
Definition: LifeV.hpp:175
const QuadratureRule quadRuleTria3pt(pt_tria_3pt, 2, "Quadrature rule 3 points on a triangle", TRIANGLE, 3, 2)
The class for a reference Lagrangian finite element.
void resetPerturbation()
Reset all the coupling perturbations imposed on the BCHandler.
void setupExporterImporter(const std::string &fileName)
Setup the exporter and the importer.
QuadratureRule - The basis class for storing and accessing quadrature rules.
void updateLinearModel()
Update the linear system matrix and vectors.
uint32_type UInt
generic unsigned integer (used mainly for addressing)
Definition: LifeV.hpp:191
void showMe()
Display some information about the model.
void imposeBoundaryFlowRate(const multiscaleID_Type &boundaryID, const function_Type &function)
Impose the flow rate on a specific interface of the model.
std::shared_ptr< fluidVector_Type > fluidVectorPtr_Type
void setupData(const std::string &fileName)
Setup the data of the model.