LifeV
lifev/multiscale/testsuite/multiscale/main.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 Test
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  * This is a very general main file to run a Multiscale simulation.
37  *
38  * Models available:
39  * <ol>
40  * <li> Fluid3D
41  * <li> FSI3D
42  * <li> OneDimensional
43  * <li> Multiscale
44  * <li> Windkessel0D
45  * </ol>
46  *
47  * Couplings available:
48  * <ol>
49  * <li> BoundaryCondition
50  * <li> MeanNormalStress
51  * <li> MeanNormalStressArea
52  * <li> MeanNormalStressValve
53  * <li> MeanTotalNormalStress
54  * <li> MeanTotalNormalStressArea
55  * </ol>
56  *
57  * Algorithms available:
58  * <ol>
59  * <li> Aitken
60  * <li> Broyden
61  * <li> Explicit
62  * <li> Newton
63  * </ol>
64  */
65 
66 
67 #include <sys/stat.h>
68 #include <sys/types.h>
69 
70 #include <Epetra_ConfigDefs.h>
71 #ifdef EPETRA_MPI
72 #include <mpi.h>
73 #include <Epetra_MpiComm.h>
74 #else
75 #include <Epetra_SerialComm.h>
76 #endif
77 
78 
79 #include <lifev/core/LifeV.hpp>
80 #include <lifev/multiscale/framework/MultiscaleSolver.hpp>
81 
82 using namespace LifeV;
83 using namespace Multiscale;
84 
85 Int
86 main ( Int argc, char** argv )
87 {
88  //Setup main communicator
89  std::shared_ptr< Epetra_Comm > comm;
90 
91  //Setup MPI variables
92  Int numberOfProcesses (1);
93  Int rank (0);
94 
95 #ifdef HAVE_MPI
96  MPI_Init ( &argc, &argv );
97 
98  MPI_Comm_size ( MPI_COMM_WORLD, &numberOfProcesses );
99  MPI_Comm_rank ( MPI_COMM_WORLD, &rank );
100 #endif
101 
102  if ( rank == 0 )
103  {
104  std::cout << "MPI Processes: " << numberOfProcesses << std::endl;
105  }
106 
107 #ifdef EPETRA_MPI
108  if ( rank == 0 )
109  {
110  std::cout << "MPI Epetra Initialization ... " << std::endl;
111  }
112  comm.reset ( new Epetra_MpiComm ( MPI_COMM_WORLD ) );
113 #else
114  std::cout << "SERIAL Epetra Initialization ... " << std::endl;
115  comm.reset ( new Epetra_SerialComm() );
116 #endif
117 
118  // Setup Multiscale problem
119  bool exitFlag = EXIT_SUCCESS;
120  MultiscaleSolver multiscale;
121 
122  // Set the communicator
123  multiscale.setCommunicator ( comm );
124 
125  // Command line parameters
126  GetPot commandLine ( argc, argv );
127  std::string dataFile = commandLine.follow ( "./Multiscale.dat", 2, "-f", "--file" );
128  bool verbose = commandLine.follow ( true, 2, "-s", "--showme" );
129  std::string problemFolder = commandLine.follow ( "Output", 2, "-o", "--output" );
130  Real referenceSolution = commandLine.follow ( -1., 2, "-c", "--check" );
131  UInt coresPerNode = commandLine.follow ( 1, 2, "-ns", "--nodesize" );
132  Real tolerance = commandLine.follow ( 1e-3, 2, "-t", "--tolerance" );
133 
134  if ( coresPerNode > static_cast<UInt> ( numberOfProcesses ) )
135  {
136  coresPerNode = numberOfProcesses;
137  }
138 
139  // Create the problem folder
140  if ( problemFolder.compare ("./") )
141  {
142  problemFolder += "/";
143 
144  if ( comm->MyPID() == 0 )
145  {
146  mkdir ( problemFolder.c_str(), 0777 );
147  }
148  }
149 
150  // Setup the problem
151  multiscale.setupProblem ( dataFile, problemFolder, coresPerNode );
152 
153  // Display problem information
154  if ( verbose )
155  {
156  multiscale.showMe();
157  }
158 
159  // Solve the problem
160  exitFlag = multiscale.solveProblem ( referenceSolution, tolerance );
161 
162 #ifdef HAVE_MPI
163  if ( rank == 0 )
164  {
165  std::cout << "MPI Finalization" << std::endl;
166  }
167  MPI_Finalize();
168 #endif
169 
170  return exitFlag;
171 }
void showMe() const
Display some information about the Multiscale problem (should be called after setupProblem) ...
GetPot(const int argc_, char **argv_, const char *FieldSeparator=0x0)
Definition: GetPot.hpp:507
int32_type Int
Generic integer data.
Definition: LifeV.hpp:188
void updateInverseJacobian(const UInt &iQuadPt)
double follow(const double &Default, unsigned No, const char *Option,...)
Definition: GetPot.hpp:1482
bool solveProblem(const Real &referenceSolution=-1., const Real &tolerance=1e-8)
Run the time-loop to solve the Multiscale problem.
int main(int argc, char **argv)
Definition: dummy.cpp:5
double Real
Generic real data.
Definition: LifeV.hpp:175
const std::string follow(const char *Default, unsigned No, const char *Option,...)
Definition: GetPot.hpp:1510
MultiscaleSolver - The Multiscale solver.
uint32_type UInt
generic unsigned integer (used mainly for addressing)
Definition: LifeV.hpp:191
int follow(int Default, unsigned No, const char *Option,...)
Definition: GetPot.hpp:1453