Commit 661f8c61 authored by grandper's avatar grandper
Browse files

Update of the hdf5 exporter policy

parent a40c59bb
......@@ -88,8 +88,8 @@ using namespace LifeV;
namespace
{
//typedef RegionMesh<LinearTetra> mesh_Type;
typedef RegionMesh<QuadraticTetra> mesh_Type;
typedef RegionMesh<LinearTetra> mesh_Type;
//typedef RegionMesh<QuadraticTetra> mesh_Type;
typedef MatrixEpetra<Real> matrix_Type;
typedef VectorEpetra vector_Type;
typedef boost::shared_ptr<VectorEpetra> vectorPtr_Type;
......@@ -110,7 +110,7 @@ typedef InitPolicySolver< mesh_Type, GStokes > InitGStokes;
typedef InitPolicyInterpolation< mesh_Type > InitInter;
typedef InitPolicyProjection<SolverPolicyLinearSolver> InitProj;
typedef ExporterPolicyNoExporter NoExporter;
typedef ExporterPolicyHDF5 HDF5Exporter;
typedef ExporterPolicyHDF5< mesh_Type > HDF5Exporter;
typedef NavierStokesSolver< mesh_Type, InitStokes, SemiImplicit, HDF5Exporter > nsSolver_Type;
void setPreconditioner ( basePrecPtr_Type& precPtr,
......
......@@ -23,7 +23,6 @@ SET(NavierStokesSolver_SOURCES
solver/NavierStokesSolver/AssemblyPolicyNavierStokesSemiImplicit.cpp
solver/NavierStokesSolver/AssemblyPolicyNavierStokesNewton.cpp
solver/NavierStokesSolver/AssemblyPolicyNavierStokesPicard.cpp
solver/NavierStokesSolver/ExporterPolicyHDF5.cpp
solver/NavierStokesSolver/SolverPolicyLinearSolver.cpp
CACHE INTERNAL "")
......
//@HEADER
/*
*******************************************************************************
Copyright (C) 2004, 2005, 2007 EPFL, Politecnico di Milano, INRIA
Copyright (C) 2010 EPFL, Politecnico di Milano, Emory University
This file is part of LifeV.
LifeV is free software; you can redistribute it and/or modify
it under the terms of the GNU Lesser General Public License as published by
the Free Software Foundation, either version 3 of the License, or
(at your option) any later version.
LifeV is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
Lesser General Public License for more details.
You should have received a copy of the GNU Lesser General Public License
along with LifeV. If not, see <http://www.gnu.org/licenses/>.
*******************************************************************************
*/
//@HEADER
/*!
@file ExporterPolicyHDF5 class
@brief This class contains all the informations necessary to export to HDF5
@author Gwenol Grandperrin <gwenol.grandperrin@epfl.ch>
@date 04-12-2012
*/
#include <lifev/navier_stokes/solver/NavierStokesSolver/ExporterPolicyHDF5.hpp>
#include <string>
#include <lifev/core/util/LifeChrono.hpp>
namespace LifeV
{
void
ExporterPolicyHDF5::initExporter ( Teuchos::ParameterList& list,
vectorPtr_Type solution )
{
// Loading the parameters
std::string outputPath = list.get ( "Output path", "." );
outputPath.append ("/");
std::string outputFilename = list.get ( "Output filename", "solution" );
GetPot datafile;
bool multipleMesh = list.get ( "Multiple mesh", false );
if ( multipleMesh )
{
datafile.set ( "exporter/multimesh", "true" );
}
else
{
datafile.set ( "exporter/multimesh", "false" );
}
int start = list.get ( "Start", 0 );
datafile.set ( "exporter/start", start );
int save = list.get ( "Save", 1 );
datafile.set ( "exporter/save", save );
LifeChrono exporterSetupChrono;
exporterSetupChrono.start();
displayer().leaderPrint ( "Defining the exporter... " );
M_exporter.reset ( new exporter_Type ( datafile, outputFilename ) );
M_exporter->setPostDir ( outputPath ); // This is a test to see if M_post_dir is working
M_exporter->setMeshProcId ( mesh(), mesh()->comm()->MyPID() );
displayer().leaderPrint ( "done\n" );
displayer().leaderPrint ( "Updating the exporter... " );
// Pressure offset in the vector
UInt pressureOffset = uFESpace()->fieldDim() * uFESpace()->dof().numTotalDof();
M_exporter->addVariable ( ExporterData<mesh_Type>::VectorField, "velocity", uFESpace(),
solution, UInt ( 0 ) );
M_exporter->addVariable ( ExporterData<mesh_Type>::ScalarField, "pressure", pFESpace(),
solution, pressureOffset );
displayer().leaderPrint ( "done\n" );
exporterSetupChrono.stop();
displayer().leaderPrintMax ("Exporter setup time: ", exporterSetupChrono.diff(), " s.\n");
}
void
ExporterPolicyHDF5::exportSolution ()
{
displayer().leaderPrint ( "Exporting solution at time t = ", currentTime(), "... \n" );
M_exporter->postProcess ( currentTime() );
}
void
ExporterPolicyHDF5::finalizeExporter()
{
LifeChrono finalizeChrono;
finalizeChrono.start();
M_exporter->closeFile();
finalizeChrono.stop();
displayer().leaderPrintMax ("Exporter finalization time: ", finalizeChrono.diff(), " s.\n");
}
} // namespace LifeV
......@@ -36,6 +36,7 @@
#define EXPORTERPOLICYHDF5_HPP
#include <iostream>
#include <string>
#include <boost/shared_ptr.hpp>
// Tell the compiler to ignore specific kind of warnings:
......@@ -62,17 +63,18 @@
#include <lifev/core/mesh/RegionMesh.hpp>
#include <lifev/core/fem/FESpace.hpp>
#include <lifev/core/filter/ExporterHDF5.hpp>
#include <lifev/core/util/LifeChrono.hpp>
namespace LifeV
{
template< class mesh_Type >
struct ExporterPolicyHDF5
{
typedef VectorEpetra vector_Type;
typedef boost::shared_ptr<VectorEpetra> vectorPtr_Type;
typedef RegionMesh<LinearTetra> mesh_Type;
typedef boost::shared_ptr<mesh_Type> meshPtr_Type;
typedef MapEpetra map_Type;
typedef boost::shared_ptr<map_Type> mapPtr_Type;
......@@ -96,6 +98,74 @@ struct ExporterPolicyHDF5
};
template< class mesh_Type >
void
ExporterPolicyHDF5< mesh_Type >::initExporter ( Teuchos::ParameterList& list,
vectorPtr_Type solution )
{
// Loading the parameters
std::string outputPath = list.get ( "Output path", "." );
outputPath.append ("/");
std::string outputFilename = list.get ( "Output filename", "solution" );
GetPot datafile;
bool multipleMesh = list.get ( "Multiple mesh", false );
if ( multipleMesh )
{
datafile.set ( "exporter/multimesh", "true" );
}
else
{
datafile.set ( "exporter/multimesh", "false" );
}
int start = list.get ( "Start", 0 );
datafile.set ( "exporter/start", start );
int save = list.get ( "Save", 1 );
datafile.set ( "exporter/save", save );
LifeChrono exporterSetupChrono;
exporterSetupChrono.start();
displayer().leaderPrint ( "Defining the exporter... " );
M_exporter.reset ( new exporter_Type ( datafile, outputFilename ) );
M_exporter->setPostDir ( outputPath ); // This is a test to see if M_post_dir is working
M_exporter->setMeshProcId ( mesh(), mesh()->comm()->MyPID() );
displayer().leaderPrint ( "done\n" );
displayer().leaderPrint ( "Updating the exporter... " );
// Pressure offset in the vector
UInt pressureOffset = uFESpace()->fieldDim() * uFESpace()->dof().numTotalDof();
M_exporter->addVariable ( ExporterData<mesh_Type>::VectorField, "velocity", uFESpace(),
solution, UInt ( 0 ) );
M_exporter->addVariable ( ExporterData<mesh_Type>::ScalarField, "pressure", pFESpace(),
solution, pressureOffset );
displayer().leaderPrint ( "done\n" );
exporterSetupChrono.stop();
displayer().leaderPrintMax ("Exporter setup time: ", exporterSetupChrono.diff(), " s.\n");
}
template< class mesh_Type >
void
ExporterPolicyHDF5< mesh_Type >::exportSolution ()
{
displayer().leaderPrint ( "Exporting solution at time t = ", currentTime(), "... \n" );
M_exporter->postProcess ( currentTime() );
}
template< class mesh_Type >
void
ExporterPolicyHDF5< mesh_Type >::finalizeExporter()
{
LifeChrono finalizeChrono;
finalizeChrono.start();
M_exporter->closeFile();
finalizeChrono.stop();
displayer().leaderPrintMax ("Exporter finalization time: ", finalizeChrono.diff(), " s.\n");
}
} // namespace LifeV
#endif /* EXPORTERPOLICYHDF5_HPP */
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment