36 #pragma GCC diagnostic ignored "-Wunused-variable" 37 #pragma GCC diagnostic ignored "-Wunused-parameter" 39 #include <Epetra_ConfigDefs.h> 42 #include <Epetra_MpiComm.h> 44 #include <Epetra_SerialComm.h> 47 #include <lifev/core/LifeV.hpp> 48 #include <lifev/core/filter/GetPot.hpp> 49 #include <lifev/core/mesh/MeshPartitioner.hpp> 50 #include <lifev/core/mesh/MeshData.hpp> 51 #include <lifev/core/filter/ExporterHDF5.hpp> 52 #include <lifev/core/interpolation/RBFInterpolation.hpp> 53 #include <lifev/core/interpolation/RBFlocallyRescaledScalar.hpp> 54 #include <lifev/core/interpolation/RBFrescaledScalar.hpp> 55 #include <Teuchos_ParameterList.hpp> 56 #include <Teuchos_XMLParameterListHelpers.hpp> 57 #include <Teuchos_RCP.hpp> 62 #pragma GCC diagnostic warning "-Wunused-variable" 63 #pragma GCC diagnostic warning "-Wunused-parameter" 65 using namespace LifeV;
67 double f (
double x,
double y,
double z)
69 double r = std::sqrt (x * x + y * y);
70 return sin (z) + sin (r);
73 int main (
int argc,
char** argv )
75 typedef VectorEpetra vector_Type;
76 typedef std::shared_ptr<vector_Type > vectorPtr_Type;
77 typedef RegionMesh<LinearTetra > mesh_Type;
78 typedef std::shared_ptr< mesh_Type > meshPtr_Type;
80 typedef std::shared_ptr<interpolation_Type> interpolationPtr_Type;
82 std::shared_ptr<Epetra_Comm> Comm;
84 MPI_Init (&argc, &argv);
85 Comm.reset (
new Epetra_MpiComm (MPI_COMM_WORLD) );
87 Comm.reset (
new Epetra_SerialComm() );
94 Teuchos::RCP< Teuchos::ParameterList > belosList = Teuchos::rcp (
new Teuchos::ParameterList );
95 belosList = Teuchos::getParametersFromXmlFile (
"SolverParamList_rbf3d.xml" );
98 MeshData Solid_mesh_data;
99 meshPtr_Type Solid_mesh_ptr (
new mesh_Type ( Comm ) );
100 Solid_mesh_data.setup (dataFile,
"solid/space_discretization");
101 readMesh (*Solid_mesh_ptr, Solid_mesh_data);
103 MeshData Fluid_mesh_data;
104 meshPtr_Type Fluid_mesh_ptr (
new mesh_Type ( Comm ) );
105 Fluid_mesh_data.setup (dataFile,
"fluid/space_discretization");
106 readMesh (*Fluid_mesh_ptr, Fluid_mesh_data);
109 MeshPartitioner<mesh_Type> Solid_mesh_part;
110 std::shared_ptr<mesh_Type> Solid_localMesh;
111 Solid_mesh_part.setPartitionOverlap (0);
112 Solid_mesh_part.doPartition (Solid_mesh_ptr, Comm);
113 Solid_localMesh = Solid_mesh_part.meshPartition();
115 MeshPartitioner<mesh_Type> Fluid_mesh_part;
116 std::shared_ptr<mesh_Type> Fluid_localMesh;
117 Fluid_mesh_part.setPartitionOverlap (0);
118 Fluid_mesh_part.doPartition (Fluid_mesh_ptr, Comm);
119 Fluid_localMesh = Fluid_mesh_part.meshPartition();
122 std::shared_ptr<FESpace<mesh_Type, MapEpetra> > Fluid_fieldFESpace (
new FESpace<mesh_Type, MapEpetra> (Fluid_localMesh,
"P1", 1, Comm) );
123 vectorPtr_Type Fluid_vector (
new vector_Type (Fluid_fieldFESpace->map(), Unique) );
124 vectorPtr_Type Fluid_vector_one (
new vector_Type (Fluid_fieldFESpace->map(), Unique) );
127 for ( UInt i = 0; i < Fluid_vector->epetraVector().MyLength(); ++i )
128 if (Fluid_vector->blockMap().LID (Fluid_vector->blockMap().GID (i) ) != -1)
129 (*Fluid_vector) [Fluid_vector->blockMap().GID (i)] = f ( Fluid_mesh_ptr->point (Fluid_vector->blockMap().GID (i) ).x(),
130 Fluid_mesh_ptr->point (Fluid_vector->blockMap().GID (i) ).y(),
131 Fluid_mesh_ptr->point (Fluid_vector->blockMap().GID (i) ).z() );
134 ExporterHDF5<mesh_Type> Fluid_exporter (dataFile, Fluid_localMesh,
"Input field", Comm->MyPID() );
135 Fluid_exporter.setMeshProcId (Fluid_localMesh, Comm->MyPID() );
136 Fluid_exporter.exportPID (Fluid_localMesh, Comm,
true );
137 Fluid_exporter.addVariable (ExporterData<mesh_Type>::ScalarField,
"f(x,y,z)", Fluid_fieldFESpace, Fluid_vector, UInt (0) );
138 Fluid_exporter.postProcess (0);
139 Fluid_exporter.closeFile();
141 std::shared_ptr<FESpace<mesh_Type, MapEpetra> > Solid_fieldFESpace (
new FESpace<mesh_Type, MapEpetra> (Solid_localMesh,
"P1", 1, Comm) );
142 vectorPtr_Type Solid_solution (
new vector_Type (Solid_fieldFESpace->map(), Unique) );
143 vectorPtr_Type Solid_solution_rbf (
new vector_Type (Solid_fieldFESpace->map(), Unique) );
146 std::vector<
int> flags (nFlags);
149 interpolationPtr_Type RBFinterpolant;
150 RBFinterpolant.reset ( interpolation_Type::InterpolationFactory::instance().createObject (dataFile(
"interpolation/interpolation_Type",
"none")));
152 RBFinterpolant->setup(Fluid_mesh_ptr, Fluid_localMesh, Solid_mesh_ptr, Solid_localMesh, flags);
154 RBFinterpolant->setupRBFData (Fluid_vector, Solid_solution, dataFile, belosList);
156 if(dataFile(
"interpolation/interpolation_Type",
"none")!=
"RBFlocallyRescaledScalar")
157 RBFinterpolant->setRadius((
double) MeshUtility::MeshStatistics::computeSize (*Fluid_mesh_ptr).maxH);
159 RBFinterpolant->buildOperators();
161 RBFinterpolant->interpolate();
163 RBFinterpolant->solution (Solid_solution);
166 vectorPtr_Type Solid_exact_solution (
new vector_Type (Solid_fieldFESpace->map(), Unique) );
167 vectorPtr_Type myError (
new vector_Type (Solid_fieldFESpace->map(), Unique) );
169 for ( UInt i = 0; i < Solid_exact_solution->epetraVector().MyLength(); ++i )
170 if (Solid_mesh_ptr->point (Solid_exact_solution->blockMap().GID (i) ).markerID() == 1 || Solid_mesh_ptr->point (Solid_exact_solution->blockMap().GID (i) ).markerID() == 20 )
171 if (Solid_exact_solution->blockMap().LID (Solid_exact_solution->blockMap().GID (i) ) != -1)
173 (*Solid_exact_solution) [Solid_exact_solution->blockMap().GID (i)] = f ( Solid_mesh_ptr->point (Solid_exact_solution->blockMap().GID (i) ).x(),
174 Solid_mesh_ptr->point (Solid_exact_solution->blockMap().GID (i) ).y(),
175 Solid_mesh_ptr->point (Solid_exact_solution->blockMap().GID (i) ).z() );
177 (*myError) [myError->blockMap().GID (i)] = (*Solid_exact_solution) [Solid_exact_solution->blockMap().GID (i)] - (*Solid_solution) [Solid_solution->blockMap().GID (i)];
181 ExporterHDF5<mesh_Type> Solid_exporter (dataFile, Solid_localMesh,
"Results", Comm->MyPID() );
182 Solid_exporter.setMeshProcId (Solid_localMesh, Comm->MyPID() );
183 Solid_exporter.exportPID (Solid_localMesh, Comm,
true );
184 Solid_exporter.addVariable (ExporterData<mesh_Type>::ScalarField,
"Solution", Solid_fieldFESpace, Solid_solution, UInt (0) );
185 Solid_exporter.postProcess (0);
186 Solid_exporter.closeFile();
188 Real err_inf = myError->normInf();
194 if ( std::abs(err_inf) < 1.0e-1 )
196 return ( EXIT_SUCCESS );
200 return ( EXIT_FAILURE );
GetPot(const int argc_, char **argv_, const char *FieldSeparator=0x0)
double f(double x, double y, double z)
GetPot(const STRING_VECTOR &FileNameList)
const std::string follow(const char *Default, unsigned No, const char *Option,...)
int main(int argc, char **argv)