LifeV
fsi_blocks/examples/fsi_offline_partition/main_write.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 the DOFInterfaceIO class - write
30 
31  @author Radu Popescu <radu.popescu@epfl.ch>
32  @maintainer Radu Popescu <radu.popescu@epfl.ch>
33  @date 2013-04-30
34 
35  */
36 
37 #include <lifev/core/LifeV.hpp>
38 
39 #ifdef LIFEV_HAS_HDF5
40 
41 // Tell the compiler to ignore specific kind of warnings:
42 #pragma GCC diagnostic ignored "-Wunused-variable"
43 #pragma GCC diagnostic ignored "-Wunused-parameter"
44 
45 #include "Epetra_config.h"
46 
47 #ifdef HAVE_MPI
48 
49 #include <Epetra_MpiComm.h>
50 
51 //Tell the compiler to restore the warning previously silented
52 #pragma GCC diagnostic warning "-Wunused-variable"
53 #pragma GCC diagnostic warning "-Wunused-parameter"
54 
55 #include <lifev/core/mesh/MeshPartitioner.hpp>
56 #include <lifev/core/filter/PartitionIO.hpp>
57 #include <lifev/core/filter/ExporterHDF5Mesh3D.hpp>
58 #include <lifev/core/mesh/RegionMesh.hpp>
59 #include <lifev/core/mesh/MeshData.hpp>
60 
61 #include <lifev/fsi_blocks/mesh/MeshPartitionerOfflineFSI.hpp>
62 #include <lifev/fsi_blocks/filter/DOFInterfaceIO.hpp>
63 
64 using namespace LifeV;
65 
66 #endif /* HAVE_MPI */
67 #endif /* LIFEV_HAS_HDF5 */
68 
69 int main (int argc, char** argv)
70 {
71 #ifdef LIFEV_HAS_HDF5
72 #ifdef HAVE_MPI
73 
74  typedef RegionMesh<LinearTetra> mesh_Type;
75 
76  MPI_Init (&argc, &argv);
77  std::shared_ptr<Epetra_Comm> comm (new Epetra_MpiComm (MPI_COMM_WORLD) );
78 
79  if (comm->NumProc() != 1)
80  {
81  std::cout << "This test needs to be run "
82  << "with a single process. Aborting."
83  << std::endl;
84  return (EXIT_FAILURE);
85  }
86 
87  GetPot commandLine (argc, argv);
88  std::string dataFileName = commandLine.follow ("data", 2, "-f", "--file");
89  GetPot dataFile (dataFileName);
90 
91  const UInt numParts (dataFile ("test/num_parts", 4) );
92  const std::string fluidPartsFileName (dataFile ("test/fluid_hdf5_file_name",
93  "fluid.h5") );
94  const std::string solidPartsFileName (dataFile ("test/solid_hdf5_file_name",
95  "solid.h5") );
96  const std::string interfacePartsFileName (dataFile ("test/interface_hdf5_file_name",
97  "solid.h5") );
98 
99  UInt fluidVertexFlag = dataFile ("test/fluidVertexFlag", 33 );
100 
101  std::cout << "Number of parts: " << numParts << std::endl;
102  std::cout << "Name of fluid HDF5 container: "
103  << fluidPartsFileName << std::endl;
104  std::cout << "Name of solid HDF5 container: "
105  << solidPartsFileName << std::endl;
106  std::cout << "Name of interface HDF5 container: "
107  << interfacePartsFileName << std::endl;
108 
109  std::shared_ptr<mesh_Type> fluidMeshPtr (new mesh_Type ( comm ) );
110  std::shared_ptr<mesh_Type> solidMeshPtr (new mesh_Type ( comm ) );
111 
112  //Fluid
113  MeshData fluidMeshData (dataFile, "fluid_mesh");
114  readMesh (*fluidMeshPtr, fluidMeshData);
115 
116  //Solid
117  MeshData solidMeshData (dataFile, "solid_mesh");
118  readMesh (*solidMeshPtr, solidMeshData);
119 
120  // Reading info about the discretizations
121  std::string fluidOrder (dataFile ("fluid_mesh/order", "P1") );
122  std::string solidOrder (dataFile ("solid_mesh/order", "P1") );
123 
124  // Reading the flags of the interface
125  markerID_Type fluidInterfaceFlag (dataFile ("fluid_mesh/interface_flag", 1) );
126  markerID_Type solidInterfaceFlag (dataFile ("solid_mesh/interface_flag", 1) );
127 
128  // Create the FSI partitioner
129  MeshPartitionerOfflineFSI<mesh_Type> fsiPartitioner (
130  fluidMeshPtr, solidMeshPtr, numParts, numParts, fluidOrder, solidOrder,
131  fluidInterfaceFlag, solidInterfaceFlag, 0, fluidVertexFlag, 0, comm);
132 
133 
134  fsiPartitioner.showMe();
135 
136  // Release the original mesh from the MeshPartitioner object and
137  // delete the RegionMesh object
138  fluidMeshPtr.reset();
139  solidMeshPtr.reset();
140 
141  // Write fluid, solid, and interface parts
142  std::shared_ptr<Epetra_MpiComm> mpiComm =
143  std::dynamic_pointer_cast<Epetra_MpiComm> (comm);
144 
145  PartitionIO<mesh_Type> fluidPartitionIO (fluidPartsFileName, mpiComm);
146  fluidPartitionIO.write (fsiPartitioner.fluidPartitions() );
147  PartitionIO<mesh_Type> solidPartitionIO (solidPartsFileName, mpiComm);
148  solidPartitionIO.write (fsiPartitioner.solidPartitions() );
149  DOFInterfaceIO interfaceIO (interfacePartsFileName, mpiComm);
150  interfaceIO.write (fsiPartitioner.dofStructureToHarmonicExtension() );
151 
152  MPI_Finalize();
153 
154 #else
155  std::cout << "This test needs MPI to run. Aborting." << std::endl;
156  return (EXIT_FAILURE);
157 #endif /* HAVE_MPI */
158 #else
159  std::cout << "This test needs HDF5 to run. Aborting." << std::endl;
160  return (EXIT_FAILURE);
161 #endif /* LIFEV_HAS_HDF5 */
162 
163  return (EXIT_SUCCESS);
164 }
int main(int argc, char **argv)
Definition: dummy.cpp:5