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/RBFlocallyRescaledVectorial.hpp> 54 #include <lifev/core/interpolation/RBFrescaledVectorial.hpp> 55 #include <Teuchos_ParameterList.hpp> 56 #include <Teuchos_XMLParameterListHelpers.hpp> 57 #include <Teuchos_RCP.hpp> 60 #pragma GCC diagnostic warning "-Wunused-variable" 61 #pragma GCC diagnostic warning "-Wunused-parameter" 63 using namespace LifeV;
65 double fx (
double x,
double y,
double z)
67 return sin (x) + y + z;
70 double fy (
double x,
double y,
double z)
72 return sin (y) + x + z;
75 double fz (
double x,
double y,
double z)
77 return sin (z) + x + y ;
85 return sin (x) + y + z;
88 return sin (y) + x + z;
91 return sin (z) + x + y ;
94 ERROR_MSG (
"This entry is not allowed: ud_functions.hpp");
114 ERROR_MSG (
"This entry is not allowed: ud_functions.hpp");
120 int main (
int argc,
char** argv )
122 typedef VectorEpetra vector_Type;
123 typedef std::shared_ptr<vector_Type > vectorPtr_Type;
124 typedef RegionMesh<LinearTetra > mesh_Type;
125 typedef std::shared_ptr< mesh_Type > meshPtr_Type;
127 typedef std::shared_ptr<interpolation_Type> interpolationPtr_Type;
128 typedef FESpace< RegionMesh<LinearTetra>, MapEpetra > FESpace_Type;
130 std::shared_ptr<Epetra_Comm> Comm;
132 MPI_Init (&argc, &argv);
133 Comm.reset (
new Epetra_MpiComm (MPI_COMM_WORLD) );
135 Comm.reset (
new Epetra_SerialComm() );
143 Teuchos::RCP< Teuchos::ParameterList > belosList = Teuchos::rcp (
new Teuchos::ParameterList );
144 belosList = Teuchos::getParametersFromXmlFile (
"SolverParamList_rbf3d.xml" );
147 MeshData Solid_mesh_data;
148 meshPtr_Type Solid_mesh_ptr (
new mesh_Type ( Comm ) );
149 Solid_mesh_data.setup (dataFile,
"solid/space_discretization");
150 readMesh (*Solid_mesh_ptr, Solid_mesh_data);
152 MeshData Fluid_mesh_data;
153 meshPtr_Type Fluid_mesh_ptr (
new mesh_Type ( Comm ) );
154 Fluid_mesh_data.setup (dataFile,
"fluid/space_discretization");
155 readMesh (*Fluid_mesh_ptr, Fluid_mesh_data);
158 MeshPartitioner<mesh_Type> Solid_mesh_part;
159 std::shared_ptr<mesh_Type> Solid_localMesh;
160 Solid_mesh_part.doPartition (Solid_mesh_ptr, Comm);
161 Solid_localMesh = Solid_mesh_part.meshPartition();
163 MeshPartitioner<mesh_Type> Fluid_mesh_part;
164 std::shared_ptr<mesh_Type> Fluid_localMesh;
165 Fluid_mesh_part.doPartition (Fluid_mesh_ptr, Comm);
166 Fluid_localMesh = Fluid_mesh_part.meshPartition();
169 std::shared_ptr<FESpace<mesh_Type, MapEpetra> > Solid_fieldFESpace (
new FESpace<mesh_Type, MapEpetra> (Solid_localMesh,
"P1", 3, Comm) );
170 vectorPtr_Type Solid_vector (
new vector_Type (Solid_fieldFESpace->map(), Unique) );
171 vectorPtr_Type Solid_vector_one (
new vector_Type (Solid_fieldFESpace->map(), Unique) );
172 Solid_fieldFESpace->interpolate (
static_cast<FESpace_Type::function_Type> ( exact_sol_easy ), *Solid_vector_one, 0.0 );
175 Solid_fieldFESpace->interpolate (
static_cast<FESpace_Type::function_Type> ( exact_sol ), *Solid_vector, 0.0 );
178 std::shared_ptr<FESpace<mesh_Type, MapEpetra> > Fluid_fieldFESpace (
new FESpace<mesh_Type, MapEpetra> (Fluid_localMesh,
"P1", 3, Comm) );
179 vectorPtr_Type Fluid_solution (
new vector_Type (Fluid_fieldFESpace->map(), Unique) );
184 std::vector<
int> flags (nFlags);
189 interpolationPtr_Type RBFinterpolant;
192 RBFinterpolant.reset ( interpolation_Type::InterpolationFactory::instance().createObject (dataFile(
"interpolation/interpolation_Type",
"none")));
195 RBFinterpolant->setup(Solid_mesh_ptr, Solid_localMesh, Fluid_mesh_ptr, Fluid_localMesh, flags);
198 RBFinterpolant->setupRBFData (Solid_vector_one, Fluid_solution, dataFile, belosList);
201 RBFinterpolant->buildOperators();
204 vectorPtr_Type solidVectorOnGamma;
205 vectorPtr_Type solidVectorOnOmega;
207 RBFinterpolant->restrictOmegaToGamma_Known(Solid_vector, solidVectorOnGamma);
208 RBFinterpolant->expandGammaToOmega_Known(solidVectorOnGamma, solidVectorOnOmega);
211 ExporterHDF5<mesh_Type> Solid_exporter (dataFile, Solid_localMesh,
"InputField", Comm->MyPID() );
212 Solid_exporter.setMeshProcId (Solid_localMesh, Comm->MyPID() );
213 Solid_exporter.exportPID (Solid_localMesh, Comm,
true );
214 Solid_exporter.addVariable (ExporterData<mesh_Type>::VectorField,
"f(x,y,z)", Solid_fieldFESpace, Solid_vector, UInt (0) );
215 Solid_exporter.addVariable (ExporterData<mesh_Type>::VectorField,
"restrict-expand", Solid_fieldFESpace, solidVectorOnOmega, UInt (0) );
216 Solid_exporter.postProcess (0);
217 Solid_exporter.closeFile();
220 RBFinterpolant->interpolate();
223 RBFinterpolant->solution (Fluid_solution);
226 vectorPtr_Type Fluid_solutionOnGamma;
227 RBFinterpolant->getSolutionOnGamma (Fluid_solutionOnGamma);
230 RBFinterpolant->updateRhs (Solid_vector);
233 RBFinterpolant->interpolate();
236 RBFinterpolant->solution (Fluid_solution);
239 vectorPtr_Type Fluid_exact_solution (
new vector_Type (Fluid_fieldFESpace->map(), Unique) );
240 vectorPtr_Type myError (
new vector_Type (Fluid_fieldFESpace->map(), Unique) );
241 vectorPtr_Type rbfError (
new vector_Type (Fluid_fieldFESpace->map(), Unique) );
245 for ( UInt j = 0; j < 3; ++j)
246 for ( UInt i = 0; i < Fluid_exact_solution->epetraVector().MyLength(); ++i )
247 if ( Fluid_exact_solution->blockMap().GID (i) < Fluid_mesh_ptr->pointList.size())
248 if ( Fluid_mesh_ptr->point ( Fluid_exact_solution->blockMap().GID (i) ).markerID() == flags[0] ||
249 Fluid_mesh_ptr->point ( Fluid_exact_solution->blockMap().GID (i) ).markerID() == flags[1] )
250 if ( Fluid_exact_solution->blockMap().LID (
static_cast<EpetraInt_Type> ( Fluid_exact_solution->blockMap().GID (i) + Fluid_exact_solution->size()/3*j ) ) != -1)
255 (*Fluid_exact_solution) [Fluid_exact_solution->blockMap().GID (i) + Fluid_exact_solution->size()/3*j ] = fx ( Fluid_mesh_ptr->point (Fluid_exact_solution->blockMap().GID (i) ).x(), Fluid_mesh_ptr->point (Fluid_exact_solution->blockMap().GID (i) ).y(), Fluid_mesh_ptr->point (Fluid_exact_solution->blockMap().GID (i) ).z() );
258 (*Fluid_exact_solution) [Fluid_exact_solution->blockMap().GID (i) + Fluid_exact_solution->size()/3*j ] = fy ( Fluid_mesh_ptr->point (Fluid_exact_solution->blockMap().GID (i) ).x(), Fluid_mesh_ptr->point (Fluid_exact_solution->blockMap().GID (i) ).y(), Fluid_mesh_ptr->point (Fluid_exact_solution->blockMap().GID (i) ).z() );
261 (*Fluid_exact_solution) [Fluid_exact_solution->blockMap().GID (i) + Fluid_exact_solution->size()/3*j ] = fz ( Fluid_mesh_ptr->point (Fluid_exact_solution->blockMap().GID (i) ).x(), Fluid_mesh_ptr->point (Fluid_exact_solution->blockMap().GID (i) ).y(), Fluid_mesh_ptr->point (Fluid_exact_solution->blockMap().GID (i) ).z() );
265 (*myError) [myError->blockMap().GID (i) + Fluid_exact_solution->size()/3*j ] = (*Fluid_exact_solution) [Fluid_exact_solution->blockMap().GID (i) + Fluid_exact_solution->size()/3*j ] - (*Fluid_solution) [Fluid_solution->blockMap().GID (i) + Fluid_exact_solution->size()/3*j ];
269 Real err_inf = myError->normInf();
272 ExporterHDF5<mesh_Type> Fluid_exporter (dataFile, Fluid_localMesh,
"Results", Comm->MyPID() );
273 Fluid_exporter.setMeshProcId (Fluid_localMesh, Comm->MyPID() );
274 Fluid_exporter.exportPID (Fluid_localMesh, Comm,
true );
275 Fluid_exporter.addVariable (ExporterData<mesh_Type>::VectorField,
"Solution", Fluid_fieldFESpace, Fluid_solution, UInt (0) );
276 Fluid_exporter.postProcess (0);
277 Fluid_exporter.closeFile();
283 if ( std::abs(err_inf) < 1.0e-1 )
285 return ( EXIT_SUCCESS );
289 return ( EXIT_FAILURE );
Real exact_sol_easy(const Real &, const Real &, const Real &, const Real &, const ID &i)
GetPot(const int argc_, char **argv_, const char *FieldSeparator=0x0)
double fy(double x, double y, double z)
Real exact_sol(const Real &, const Real &x, const Real &y, const Real &z, const ID &i)
double fz(double x, double y, double z)
double Real
Generic real data.
GetPot(const STRING_VECTOR &FileNameList)
const std::string follow(const char *Default, unsigned No, const char *Option,...)
double fx(double x, double y, double z)
int main(int argc, char **argv)