LifeV
fsi_blocks/examples/fsi_offline_partition/main_read.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, 2011, 2012 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 Example for DOFInterfaceIO class - read
30 
31  @author Radu Popescu <radu.popescu@epfl.ch>
32  @maintainer Radu Popescu <radu.popescu@epfl.ch>
33 
34  @date 2013-04-30
35 
36  */
37 
38 #include <lifev/core/LifeV.hpp>
39 
40 #include <map>
41 
42 #ifdef LIFEV_HAS_HDF5
43 
44 // Tell the compiler to ignore specific kind of warnings:
45 #pragma GCC diagnostic ignored "-Wunused-variable"
46 #pragma GCC diagnostic ignored "-Wunused-parameter"
47 
48 #include "Epetra_config.h"
49 
50 #ifdef HAVE_MPI
51 
52 #include <mpi.h>
53 
54 #include <Epetra_MpiComm.h>
55 
56 //Tell the compiler to restore the warning previously silented
57 #pragma GCC diagnostic warning "-Wunused-variable"
58 #pragma GCC diagnostic warning "-Wunused-parameter"
59 
60 #include <lifev/core/filter/GetPot.hpp>
61 #include <lifev/core/filter/PartitionIO.hpp>
62 #include <lifev/core/mesh/RegionMesh.hpp>
63 
64 #include <lifev/fsi_blocks/filter/DOFInterfaceIO.hpp>
65 
66 
67 using namespace LifeV;
68 
69 typedef RegionMesh<LinearTetra> mesh_Type;
70 
71 #endif /* HAVE_MPI */
72 #endif /* LIFEV_HAS_HDF5 */
73 
74 int
75 main ( int argc, char** argv )
76 {
77 #ifdef LIFEV_HAS_HDF5
78 #ifdef HAVE_MPI
79 
80  MPI_Init (&argc, &argv);
81  std::shared_ptr<Epetra_MpiComm> comm (new Epetra_MpiComm (MPI_COMM_WORLD) );
82 
83  const bool verbose (comm->MyPID() == 0);
84 
85  // Read first the data needed
86 
87  if (verbose)
88  {
89  std::cout << " -- Reading the data ... " << std::flush;
90  }
91  GetPot dataFile ( "data" );
92 
93  const std::string fluidHdf5File (dataFile ("test/fluid_hdf5_file_name",
94  "fluid.h5") );
95  const std::string solidHdf5File (dataFile ("test/solid_hdf5_file_name",
96  "fluid.h5") );
97  const std::string interfaceHdf5File (dataFile ("test/interface_hdf5_file_name",
98  "interface.h5") );
99  if (verbose)
100  {
101  std::cout << " done ! " << std::endl;
102  }
103 
104  std::shared_ptr<mesh_Type> fluidMesh;
105  std::shared_ptr<mesh_Type> solidMesh;
106  std::shared_ptr<std::map<UInt, UInt> > interfaceMap;
107 
108  {
109  // Load fluid mesh part from HDF5
110  if (verbose)
111  {
112  std::cout << " -- Reading the fluid mesh part ... " << std::endl;
113  std::cout << fluidHdf5File << std::endl;
114  }
115  PartitionIO<RegionMesh<LinearTetra> > partitionIO (fluidHdf5File, comm);
116  partitionIO.read (fluidMesh);
117 
118  fluidMesh->showMe();
119 
120  if (verbose)
121  {
122  std::cout << " done ! " << std::endl;
123  }
124  }
125  {
126  // Load solid mesh part from HDF5
127  if (verbose)
128  {
129  std::cout << " -- Reading the solid mesh part ... " << std::endl;
130  std::cout << solidHdf5File << std::endl;
131  }
132  PartitionIO<RegionMesh<LinearTetra> > partitionIO (solidHdf5File, comm);
133  partitionIO.read (solidMesh);
134 
135  solidMesh->showMe();
136 
137  if (verbose)
138  {
139  std::cout << " done ! " << std::endl;
140  }
141  }
142  {
143  // Load interface from HDF5
144  if (verbose)
145  {
146  std::cout << " -- Reading the interface ... " << std::endl;
147  std::cout << fluidHdf5File << std::endl;
148  }
149  DOFInterfaceIO interfaceIO (interfaceHdf5File, comm);
150  interfaceIO.read (interfaceMap);
151 
152  std::cout << "Interface " << comm->MyPID()
153  << " size: " << interfaceMap->size() << std::endl;
154 
155  if (verbose)
156  {
157  std::cout << " done ! " << std::endl;
158  }
159  }
160 
161  MPI_Finalize();
162 
163 #else
164  std::cout << "This test needs MPI to run. Aborting." << std::endl;
165  return (EXIT_FAILURE);
166 #endif /* HAVE_MPI */
167 #else
168  std::cout << "This test needs HDF5 to run. Aborting." << std::endl;
169  return (EXIT_FAILURE);
170 #endif /* LIFEV_HAS_HDF5 */
171 
172  return ( EXIT_SUCCESS );
173 }
int main(int argc, char **argv)
Definition: dummy.cpp:5