LifeV
MultiscaleModelMultiscale.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 Multiscale
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/MultiscaleModelMultiscale.hpp>
38 
39 #include <lifev/multiscale/algorithms/MultiscaleAlgorithmAitken.hpp>
40 #include <lifev/multiscale/algorithms/MultiscaleAlgorithmBroyden.hpp>
41 #include <lifev/multiscale/algorithms/MultiscaleAlgorithmExplicit.hpp>
42 #include <lifev/multiscale/algorithms/MultiscaleAlgorithmNewton.hpp>
43 
44 #include <lifev/multiscale/couplings/MultiscaleCouplingBoundaryCondition.hpp>
45 #include <lifev/multiscale/couplings/MultiscaleCouplingMeanNormalStress.hpp>
46 #include <lifev/multiscale/couplings/MultiscaleCouplingMeanNormalStressValve.hpp>
47 #include <lifev/multiscale/couplings/MultiscaleCouplingMeanTotalNormalStress.hpp>
48 
49 #if defined(LIFEV_HAS_ONEDFSI) && defined(LIFEV_HAS_FSI)
50 #include <lifev/multiscale/couplings/MultiscaleCouplingMeanNormalStressArea.hpp>
51 #include <lifev/multiscale/couplings/MultiscaleCouplingMeanTotalNormalStressArea.hpp>
52 #endif
53 
54 namespace LifeV
55 {
56 namespace Multiscale
57 {
58 
59 // ===================================================
60 // Constructors & Destructor
61 // ===================================================
65  M_modelsList (),
66  M_couplingsList (),
67  M_algorithm ()
68 {
69 
70 #ifdef HAVE_LIFEV_DEBUG
71  debugStream ( 8110 ) << "MultiscaleModelMultiscale::MultiscaleModelMultiscale() \n";
72 #endif
73 
75 
76  multiscaleAlgorithmFactory_Type::instance().registerProduct ( Aitken, &createMultiscaleAlgorithmAitken );
77  multiscaleAlgorithmFactory_Type::instance().registerProduct ( Broyden, &createMultiscaleAlgorithmBroyden );
78  multiscaleAlgorithmFactory_Type::instance().registerProduct ( Explicit, &createMultiscaleAlgorithmExplicit );
79  multiscaleAlgorithmFactory_Type::instance().registerProduct ( Newton, &createMultiscaleAlgorithmNewton );
80 
81  multiscaleCouplingFactory_Type::instance().registerProduct ( BoundaryCondition, &createMultiscaleCouplingBoundaryCondition );
82  multiscaleCouplingFactory_Type::instance().registerProduct ( MeanNormalStress, &createMultiscaleCouplingMeanNormalStress );
83  multiscaleCouplingFactory_Type::instance().registerProduct ( MeanNormalStressValve, &createMultiscaleCouplingMeanNormalStressValve );
84  multiscaleCouplingFactory_Type::instance().registerProduct ( MeanTotalNormalStress, &createMultiscaleCouplingMeanTotalNormalStress );
85 
86 #if defined(LIFEV_HAS_ONEDFSI) && defined(LIFEV_HAS_FSI)
87  multiscaleCouplingFactory_Type::instance().registerProduct ( MeanNormalStressArea, &createMultiscaleCouplingMeanNormalStressArea );
88  multiscaleCouplingFactory_Type::instance().registerProduct ( MeanTotalNormalStressArea, &createMultiscaleCouplingMeanTotalNormalStressArea );
89 #endif
90 }
91 
93 {
94 
95 #ifdef HAVE_LIFEV_DEBUG
96  debugStream ( 8110 ) << "MultiscaleModelMultiscale::~MultiscaleModelMultiscale() \n";
97 #endif
98 
99  // Disconnect models and couplings to allow their destruction
100  for ( multiscaleModelsContainerConstIterator_Type i = M_modelsList.begin(); i != M_modelsList.end(); ++i )
101  {
102  ( *i )->clearCouplingsList();
103  }
104 
105  for ( multiscaleCouplingsContainerConstIterator_Type i = M_couplingsList.begin(); i != M_couplingsList.end(); ++i )
106  {
107  ( *i )->clearModelsList();
108  }
109 }
110 
111 // ===================================================
112 // MultiscaleModel Methods
113 // ===================================================
114 void
115 MultiscaleModelMultiscale::setupData ( const std::string& fileName )
116 {
117 
118 #ifdef HAVE_LIFEV_DEBUG
119  debugStream ( 8110 ) << "MultiscaleModelMultiscale::setupData( fileName ) \n";
120 #endif
121 
122  multiscaleModel_Type::setupData ( fileName );
123 
124  // Definitions
125  UInt fileID (0);
126  UInt myIDCounter (0);
127  std::map< UInt, UInt > modelsIDMap;
128 
129  Real load (0);
130 
131  models_Type model;
132  couplings_Type coupling;
133  algorithms_Type algorithm;
134 
135  std::array< Real, NDIM > geometryScale, geometryRotate, geometryTranslate;
136 
137  multiscaleIDContainer_Type modelsIDVector;
138  multiscaleIDContainer_Type boundaryIDVector;
139 
140  // Open file
141  GetPot dataFile ( fileName );
142 
143  UInt modelsColumnsNumber = 3.0;
144  UInt couplingsColumnsNumber = 5.0;
145  UInt mpiGroupsColumnsNumber = 3.0;
146  UInt geometryColumnsNumber = 10.0;
147 
148  UInt modelsLinesNumber = dataFile.vector_variable_size ( "Problem/models" ) / modelsColumnsNumber;
149  UInt couplingsLinesNumber = dataFile.vector_variable_size ( "Problem/couplings" ) / couplingsColumnsNumber;
150  UInt mpiGroupsLinesNumber = dataFile.vector_variable_size ( "Problem/mpiGroups" ) / mpiGroupsColumnsNumber;
151  UInt geometryLinesNumber = dataFile.vector_variable_size ( "Problem/offset" ) / geometryColumnsNumber;
152 
153  // Load MPI groups
155 
156  for ( UInt fileMPIGroupsLine ( 0 ); fileMPIGroupsLine < mpiGroupsLinesNumber; ++fileMPIGroupsLine )
157  {
158  load = dataFile ( "Problem/mpiGroups", 0.0, fileMPIGroupsLine * mpiGroupsColumnsNumber + 1 );
159  string2numbersVector< UInt > ( dataFile ( "Problem/mpiGroups", "undefined", fileMPIGroupsLine * mpiGroupsColumnsNumber + 2 ), modelsIDVector );
160 
161  M_commManager.addGroup ( load, modelsIDVector );
162  modelsIDVector.clear();
163  }
164 
165  // Split the communicator
167 
168  // Load Models
169  std::string path = dataFile ( "Problem/modelsPath", "./" );
170  M_modelsList.resize ( M_commManager.myModelsNumber() );
171  for ( UInt fileModelsLine ( 0 ); fileModelsLine < modelsLinesNumber; ++fileModelsLine )
172  {
173  fileID = dataFile ( "Problem/models", 0, fileModelsLine * modelsColumnsNumber );
174  if ( M_commManager.myModel ( fileID ) )
175  {
176  modelsIDMap[fileID] = myIDCounter;
177  model = multiscaleModelsMap[dataFile ( "Problem/models", "undefined", fileModelsLine * modelsColumnsNumber + 1 )];
178 
179  // Set Geometry
180  geometryScale[0] = M_geometryScale[0];
181  geometryScale[1] = M_geometryScale[1];
182  geometryScale[2] = M_geometryScale[2];
183 
184  geometryRotate[0] = M_geometryRotate[0];
185  geometryRotate[1] = M_geometryRotate[1];
186  geometryRotate[2] = M_geometryRotate[2];
187 
188  geometryTranslate[0] = M_geometryTranslate[0];
189  geometryTranslate[1] = M_geometryTranslate[1];
190  geometryTranslate[2] = M_geometryTranslate[2];
191 
192  for ( UInt fileGeometryLine ( 0 ); fileGeometryLine < geometryLinesNumber; ++fileGeometryLine )
193  if ( fileID == dataFile ( "Problem/offset", 1., fileGeometryLine * geometryColumnsNumber ) )
194  {
195  geometryScale[0] *= dataFile ( "Problem/offset", 1., fileGeometryLine * geometryColumnsNumber + 1 );
196  geometryScale[1] *= dataFile ( "Problem/offset", 1., fileGeometryLine * geometryColumnsNumber + 2 );
197  geometryScale[2] *= dataFile ( "Problem/offset", 1., fileGeometryLine * geometryColumnsNumber + 3 );
198 
199  geometryRotate[0] += dataFile ( "Problem/offset", 0., fileGeometryLine * geometryColumnsNumber + 4 ) * M_PI / 180;
200  geometryRotate[1] += dataFile ( "Problem/offset", 0., fileGeometryLine * geometryColumnsNumber + 5 ) * M_PI / 180;
201  geometryRotate[2] += dataFile ( "Problem/offset", 0., fileGeometryLine * geometryColumnsNumber + 6 ) * M_PI / 180;
202 
203  geometryTranslate[0] += dataFile ( "Problem/offset", 0., fileGeometryLine * geometryColumnsNumber + 7 );
204  geometryTranslate[1] += dataFile ( "Problem/offset", 0., fileGeometryLine * geometryColumnsNumber + 8 );
205  geometryTranslate[2] += dataFile ( "Problem/offset", 0., fileGeometryLine * geometryColumnsNumber + 9 );
206  }
207 
208  M_modelsList[myIDCounter] = multiscaleModelPtr_Type ( multiscaleModelFactory_Type::instance().createObject ( model, multiscaleModelsMap ) );
209  M_modelsList[myIDCounter]->setID ( fileModelsLine + 1 );
210  M_modelsList[myIDCounter]->setCommunicator ( M_commManager.modelCommunicator ( fileID ) );
211  M_modelsList[myIDCounter]->setGeometry ( geometryScale, geometryRotate, geometryTranslate );
212  M_modelsList[myIDCounter]->setGlobalData ( M_globalData );
213  M_modelsList[myIDCounter]->setupData ( path + enum2String ( model, multiscaleModelsMap ) + "/"
214  + dataFile ( "Problem/models", "undefined", fileModelsLine * modelsColumnsNumber + 2 ) + ".dat" );
215 
216  // Increment my counter
217  ++myIDCounter;
218  }
219  }
220 
221  // Load Couplings
222  M_couplingsList.resize ( couplingsLinesNumber );
223  path = dataFile ( "Problem/couplingsPath", "./" );
224  for ( UInt fileCouplingsLine ( 0 ); fileCouplingsLine < couplingsLinesNumber; ++fileCouplingsLine )
225  {
226  //id = dataFile( "Problem/couplings", 0, i * couplingsColumnsNumber );
227  coupling = multiscaleCouplingsMap[dataFile ( "Problem/couplings", "undefined", fileCouplingsLine * couplingsColumnsNumber + 1 )];
228  M_couplingsList.reserve ( ++myIDCounter );
229  M_couplingsList[fileCouplingsLine] = multiscaleCouplingPtr_Type ( multiscaleCouplingFactory_Type::instance().createObject ( coupling, multiscaleCouplingsMap ) );
230  M_couplingsList[fileCouplingsLine]->setID ( fileCouplingsLine );
231  M_couplingsList[fileCouplingsLine]->setCommunicator ( M_comm );
232 
233  string2numbersVector< UInt > ( dataFile ( "Problem/couplings", "undefined", fileCouplingsLine * couplingsColumnsNumber + 3 ), modelsIDVector );
234  string2numbersVector< UInt > ( dataFile ( "Problem/couplings", "undefined", fileCouplingsLine * couplingsColumnsNumber + 4 ), boundaryIDVector );
235 
236  M_couplingsList[fileCouplingsLine]->setModelsNumber ( modelsIDVector.size() );
237  for ( UInt j ( 0 ); j < modelsIDVector.size(); ++j )
238  if ( M_commManager.myModel ( modelsIDVector[j] ) )
239  {
240  M_couplingsList[fileCouplingsLine]->setModel ( j, M_modelsList[modelsIDMap[modelsIDVector[j]]] );
241  M_couplingsList[fileCouplingsLine]->setBoundaryID ( j, boundaryIDVector[j] );
242  M_modelsList[modelsIDMap[modelsIDVector[j]]]->addCoupling ( M_couplingsList[fileCouplingsLine] );
243  }
244  modelsIDVector.clear();
245  boundaryIDVector.clear();
246 
247  M_couplingsList[fileCouplingsLine]->setGlobalData ( M_globalData );
248  M_couplingsList[fileCouplingsLine]->setupData ( path + enum2String ( coupling, multiscaleCouplingsMap ) + "/"
249  + dataFile ( "Problem/couplings", "undefined", fileCouplingsLine * couplingsColumnsNumber + 2 ) + ".dat" );
250  }
251 
252  // Load Algorithm
253  path = dataFile ( "Problem/algorithmsPath", "./" );
254  algorithm = multiscaleAlgorithmsMap[ dataFile ( "Problem/algorithm", "Explicit", 0 ) ];
255  M_algorithm = multiscaleAlgorithmPtr_Type ( multiscaleAlgorithmFactory_Type::instance().createObject ( algorithm, multiscaleAlgorithmsMap ) );
256  M_algorithm->setCommunicator ( M_comm );
257  M_algorithm->setupData ( path + enum2String ( algorithm, multiscaleAlgorithmsMap ) + "/" + dataFile ( "Problem/algorithm", "undefined", 1 ) + ".xml" );
258 }
259 
260 void
262 {
263 
264 #ifdef HAVE_LIFEV_DEBUG
265  debugStream ( 8110 ) << "MultiscaleModelMultiscale::setupModel() \n";
266 #endif
267 
268  for ( multiscaleCouplingsContainerConstIterator_Type i = M_couplingsList.begin(); i != M_couplingsList.end(); ++i )
269  {
270  ( *i )->setupCoupling();
271  }
272 
273  for ( multiscaleModelsContainerConstIterator_Type i = M_modelsList.begin(); i != M_modelsList.end(); ++i )
274  {
275  ( *i )->setupModel();
276  }
277 
278  M_algorithm->setMultiscaleModel ( this );
279  M_algorithm->setupAlgorithm();
280 }
281 
282 void
284 {
285 
286 #ifdef HAVE_LIFEV_DEBUG
287  debugStream ( 8110 ) << "MultiscaleModelMultiscale::buildModel() \n";
288 #endif
289 
290  for ( multiscaleModelsContainerConstIterator_Type i = M_modelsList.begin(); i != M_modelsList.end(); ++i )
291  {
292  ( *i )->buildModel();
293  }
294 
295  for ( multiscaleCouplingsContainerConstIterator_Type i = M_couplingsList.begin(); i != M_couplingsList.end(); ++i )
296  {
297  ( *i )->initializeCouplingVariables();
298 
299  // Necessary to perform a correct interpolation at the first time step
300  if ( M_algorithm->type() != Explicit )
301  {
302  ( *i )->extrapolateCouplingVariables();
303  }
304  }
305 }
306 
307 void
309 {
310 
311 #ifdef HAVE_LIFEV_DEBUG
312  debugStream ( 8110 ) << "MultiscaleModelMultiscale::updateModel() \n";
313 #endif
314 
315  for ( multiscaleModelsContainerConstIterator_Type i = M_modelsList.begin(); i != M_modelsList.end(); ++i )
316  {
317  ( *i )->updateModel();
318  }
319 
320  for ( multiscaleCouplingsContainerConstIterator_Type i = M_couplingsList.begin(); i != M_couplingsList.end(); ++i )
321  {
322  ( *i )->updateCoupling();
323 
324  if ( M_algorithm->type() != Explicit )
325  {
326  ( *i )->extrapolateCouplingVariables();
327  }
328  else
329  {
330  ( *i )->initializeCouplingVariables();
331  }
332  }
333 }
334 
335 void
337 {
338 
339 #ifdef HAVE_LIFEV_DEBUG
340  debugStream ( 8110 ) << "MultiscaleModelMultiscale::solveModel() \n";
341 #endif
342 
343  M_algorithm->subIterate();
344 }
345 
346 void
348 {
349 
350 #ifdef HAVE_LIFEV_DEBUG
351  debugStream ( 8110 ) << "MultiscaleModelMultiscale::updateSolution() \n";
352 #endif
353 
354  for ( multiscaleModelsContainerConstIterator_Type i = M_modelsList.begin(); i != M_modelsList.end(); ++i )
355  {
356  ( *i )->updateSolution();
357  }
358 }
359 
360 void
362 {
363 
364 #ifdef HAVE_LIFEV_DEBUG
365  debugStream ( 8110 ) << "MultiscaleModelMultiscale::saveSolution() \n";
366 #endif
367 
368  for ( multiscaleModelsContainerConstIterator_Type i = M_modelsList.begin(); i != M_modelsList.end(); ++i )
369  {
370  ( *i )->saveSolution();
371  }
372 
373  for ( multiscaleCouplingsContainerConstIterator_Type i = M_couplingsList.begin(); i != M_couplingsList.end(); ++i )
374  {
375  ( *i )->saveSolution();
376  }
377 
378  // Save the framework numbering
379  if ( M_globalData->dataTime()->isFirstTimeStep() )
380  {
381  // File name
382  std::string filename = multiscaleProblemFolder + multiscaleProblemPrefix + "_Model_" + number2string ( M_ID ) + "_" + number2string ( multiscaleProblemStep ) + ".mfile";
383 
384  // Remove the old file if present
385  if ( M_comm->MyPID() == 0 )
386  {
387  std::remove ( filename.c_str() );
388  }
389 
390  M_comm->Barrier();
391 
392  // Open the file
393  std::ofstream output;
394  output.open ( filename.c_str(), std::ios::app );
395 
396  // Models list
397  for ( multiscaleModelsContainerConstIterator_Type i = M_modelsList.begin(); i != M_modelsList.end(); ++i )
398  if ( ( *i )->communicator()->MyPID() == 0 )
399  {
400  output << "Model ID: " << ( *i )->ID() << ", Name: " << ( *i )->modelName() << std::endl;
401  }
402 
403  M_comm->Barrier();
404 
405  // Couplings list
406  if ( M_comm->MyPID() == 0 )
407  for ( multiscaleCouplingsContainerConstIterator_Type i = M_couplingsList.begin(); i != M_couplingsList.end(); ++i )
408  {
409  output << "Coupling ID: " << ( *i )->ID() << ", Name: " << ( *i )->couplingName() << std::endl;
410  }
411 
412  // Close the file
413  output.close();
414  }
415 }
416 
417 void
419 {
420  if ( M_comm->MyPID() == 0 )
421  {
422  multiscaleModel_Type::showMe();
423  std::cout << "Models number = " << M_modelsList.size() << std::endl
424  << "Couplings number = " << M_couplingsList.size() << std::endl << std::endl;
425 
426  std::cout << "==================== Models Information =====================" << std::endl << std::endl;
427  }
428 
429  for ( multiscaleModelsContainerConstIterator_Type i = M_modelsList.begin(); i != M_modelsList.end(); ++i )
430  {
431  ( *i )->showMe();
432  }
433 
434  if ( M_comm->MyPID() == 0 )
435  {
436  std::cout << "=================== Couplings Information ===================" << std::endl << std::endl;
437  }
438 
439  for ( multiscaleCouplingsContainerConstIterator_Type i = M_couplingsList.begin(); i != M_couplingsList.end(); ++i )
440  {
441  ( *i )->showMe();
442  }
443 
444  if ( M_comm->MyPID() == 0 )
445  {
446  std::cout << "================= Communicators Information =================" << std::endl << std::endl;
447  }
448 
450 
451  if ( M_comm->MyPID() == 0 )
452  {
453  std::cout << "=================== Algorithm Information ===================" << std::endl << std::endl;
454  }
455 
456  M_algorithm->showMe();
457 }
458 
459 Real
461 {
462  return M_algorithm->couplingVariables()->norm2();
463 }
464 
465 // ===================================================
466 // Methods
467 // ===================================================
468 void
470 {
471 
472 #ifdef HAVE_LIFEV_DEBUG
473  debugStream ( 8110 ) << "MultiscaleModelMultiscale::createCouplingMap( couplingMap ) \n";
474 #endif
475 
476  // for ( multiscaleModelsContainerConstIterator_Type i = M_modelsList.begin(); i != M_modelsList.end(); ++i )
477  // if ( ( *i )->type() == Multiscale )
478  // ( multiscaleDynamicCast< MultiscaleModelMultiscale > ( *i ) )->createCouplingMap( couplingMap );
479 
480  for ( multiscaleCouplingsContainerConstIterator_Type i = M_couplingsList.begin(); i != M_couplingsList.end(); ++i )
481  {
482  ( *i )->createCouplingMap ( couplingMap );
483  }
484 }
485 
486 void
488 {
489 
490 #ifdef HAVE_LIFEV_DEBUG
491  debugStream ( 8110 ) << "MultiscaleModelMultiscale::importCouplingVariables( couplingVariables ) \n";
492 #endif
493 
494  // for ( multiscaleModelsContainerConstIterator_Type i = M_modelsList.begin(); i != M_modelsList.end(); ++i )
495  // if ( ( *i )->type() == Multiscale )
496  // ( multiscaleDynamicCast< MultiscaleModelMultiscale > ( *i ) )->importCouplingVariables( couplingVariables );
497 
498  for ( multiscaleCouplingsContainerConstIterator_Type i = M_couplingsList.begin(); i != M_couplingsList.end(); ++i )
499  {
500  ( *i )->importCouplingVariables ( couplingVariables );
501  }
502 }
503 
504 void
506 {
507 
508 #ifdef HAVE_LIFEV_DEBUG
509  debugStream ( 8110 ) << "MultiscaleModelMultiscale::exportCouplingVariables( couplingVariables ) \n";
510 #endif
511 
512  // for ( multiscaleModelsContainerConstIterator_Type i = M_modelsList.begin(); i != M_modelsList.end(); ++i )
513  // if ( ( *i )->type() == Multiscale )
514  // ( multiscaleDynamicCast< MultiscaleModelMultiscale > ( *i ) )->exportCouplingVariables( couplingVariables);
515 
516  for ( multiscaleCouplingsContainerConstIterator_Type i = M_couplingsList.begin(); i != M_couplingsList.end(); ++i )
517  {
518  ( *i )->exportCouplingVariables ( couplingVariables );
519  }
520 }
521 
522 void
524 {
525 
526 #ifdef HAVE_LIFEV_DEBUG
527  debugStream ( 8110 ) << "MultiscaleModelMultiscale::computeCouplingResiduals() \n";
528 #endif
529 
530  displayModelStatus ( "Solve" );
531  for ( multiscaleModelsContainerConstIterator_Type i = M_modelsList.begin(); i != M_modelsList.end(); ++i )
532  {
533  ( *i )->solveModel();
534  }
535 
536  // for ( multiscaleModelsContainerConstIterator_Type i = M_modelsList.begin(); i != M_modelsList.end(); ++i )
537  // if ( ( *i )->type() == Multiscale )
538  // ( multiscaleDynamicCast< MultiscaleModelMultiscale > ( *i ) )->computeCouplingResiduals();
539 
540  for ( multiscaleCouplingsContainerConstIterator_Type i = M_couplingsList.begin(); i != M_couplingsList.end(); ++i )
541  {
542  ( *i )->computeCouplingResiduals();
543  }
544 }
545 
546 void
548 {
549 
550 #ifdef HAVE_LIFEV_DEBUG
551  debugStream ( 8110 ) << "MultiscaleModelMultiscale::exportCouplingResiduals( couplingResiduals ) \n";
552 #endif
553 
554  // for ( multiscaleModelsContainerConstIterator_Type i = M_modelsList.begin(); i != M_modelsList.end(); ++i )
555  // if ( ( *i )->type() == Multiscale )
556  // ( multiscaleDynamicCast< MultiscaleModelMultiscale > ( *i ) )->exportCouplingResiduals( couplingResiduals );
557 
558  for ( multiscaleCouplingsContainerConstIterator_Type i = M_couplingsList.begin(); i != M_couplingsList.end(); ++i )
559  {
560  ( *i )->exportCouplingResiduals ( couplingResiduals );
561  }
562 }
563 
564 void
566 {
567 
568 #ifdef HAVE_LIFEV_DEBUG
569  debugStream ( 8110 ) << "MultiscaleModelMultiscale::exportJacobian() \n";
570 #endif
571 
572  // for ( multiscaleModelsContainerConstIterator_Type i = M_modelsList.begin(); i != M_modelsList.end(); ++i )
573  // if ( ( *i )->type() == Multiscale )
574  // ( multiscaleDynamicCast< MultiscaleModelMultiscale > ( *i ) )->exportJacobian( jacobian );
575 
576  for ( multiscaleCouplingsContainerConstIterator_Type i = M_couplingsList.begin(); i != M_couplingsList.end(); ++i )
577  {
578  ( *i )->exportJacobian ( jacobian );
579  }
580 }
581 
582 bool
584 {
585 
586 #ifdef HAVE_LIFEV_DEBUG
587  debugStream ( 8110 ) << "MultiscaleModelMultiscale::topologyChange() \n";
588 #endif
589 
590  bool topologyChange ( false );
591 
592  for ( multiscaleCouplingsContainerConstIterator_Type i = M_couplingsList.begin(); i != M_couplingsList.end(); ++i )
593  {
594  topologyChange = topologyChange || ( *i )->topologyChange();
595  }
596 
597  return topologyChange;
598 }
599 
600 // ===================================================
601 // Get Methods
602 // ===================================================
603 UInt
605 {
606 
607 #ifdef HAVE_LIFEV_DEBUG
608  debugStream ( 8110 ) << "MultiscaleModelMultiscale::couplingVariablesNumber() \n";
609 #endif
610 
611  UInt couplingVariablesNumber = 0;
612 
613  // for ( multiscaleModelsContainerConstIterator_Type i = M_modelsList.begin(); i != M_modelsList.end(); ++i )
614  // if ( ( *i )->type() == Multiscale )
615  // couplingVariablesNumber += ( multiscaleDynamicCast< MultiscaleModelMultiscale > ( *i ) )->couplingVariablesNumber();
616 
617  for ( multiscaleCouplingsContainerConstIterator_Type i = M_couplingsList.begin(); i != M_couplingsList.end(); ++i )
618  {
619  couplingVariablesNumber += ( *i )->couplingVariablesNumber();
620  }
621 
622  return couplingVariablesNumber;
623 }
624 
625 } // Namespace multiscale
626 } // Namespace LifeV
void exportCouplingVariables(multiscaleVector_Type &couplingVariables)
Export the values of the coupling variables.
void showMe()
Display some information about the multiscale problem (call after SetupProblem)
bool topologyChange()
Check if the topology is changed.
Real checkSolution() const
Return a specific scalar quantity to be used for a comparison with a reference value.
MultiscaleModel()
The main constructor.
#define M_PI
Definition: winmath.h:20
void updateInverseJacobian(const UInt &iQuadPt)
#define NDIM
Definition: LifeV.hpp:265
void setCommunicator(const multiscaleCommPtr_Type &comm)
Set the main epetra communicator.
void showMe()
Display some information about the communicators.
Epetra_Import const & importer()
Getter for the Epetra_Import.
Definition: MapEpetra.cpp:394
void setupData(const std::string &fileName)
Setup the data of the model.
void addGroup(const Real &load, const modelsID_Type &modelsID)
Add a group of models.
MultiscaleModel multiscaleModel_Type
void createCouplingMap(MapEpetra &couplingMap)
Build the global map for the coupling vectors.
MatrixEpetra< Real > multiscaleMatrix_Type
void computeCouplingResiduals()
Compute the values of the interface residuals.
double Real
Generic real data.
Definition: LifeV.hpp:175
void exportJacobian(multiscaleMatrix_Type &jacobian)
Export the Jacobian matrix.
std::vector< multiscaleID_Type > multiscaleIDContainer_Type
bool myModel(const UInt &modelID) const
Determine if the model is owned by the process.
void splitCommunicator()
Split the communicator among the models.
void exportCouplingResiduals(multiscaleVector_Type &couplingResiduals)
Export the values of the interface residuals.
MultiscaleModelMultiscale - Multiscale model.
UInt couplingVariablesNumber()
Get the number of the coupling variables.
void importCouplingVariables(const multiscaleVector_Type &couplingVariables)
Import the values of the coupling variables.
uint32_type UInt
generic unsigned integer (used mainly for addressing)
Definition: LifeV.hpp:191
VectorEpetra multiscaleVector_Type