Commit 6292f560 authored by crosetto's avatar crosetto
Browse files

implementing the read variable method in the base virtual exporter class...

implementing the read variable method in the base virtual exporter class (since it is equal for all the exporters), and setting it public.
parent d16fb74a
......@@ -95,7 +95,9 @@ public:
//! Read only last timestep
void import(const Real& Tstart);
void M_rd_ascii ( ExporterData& dvar );
void rd_var(ExporterData& dvar)
{super::rd_var(dvar);}
private:
......@@ -109,8 +111,8 @@ private:
void M_case_variable_section(std::ofstream& casef);
void M_case_time_section(std::ofstream& casef, const Real& time);
void M_rd_ascii_scalar( ExporterData& dvar );
void M_rd_ascii_vector( ExporterData& dvar );
void M_rd_scalar( ExporterData& dvar );
void M_rd_vector( ExporterData& dvar );
......@@ -502,7 +504,7 @@ void Ensight<Mesh>::import(const Real& time)
chrono.start();
for (Iterator i=this->M_listData.begin(); i != this->M_listData.end(); ++i)
{
M_rd_ascii(*i);
this->rd_var(*i);
}
chrono.stop();
if (!this->M_procId) std::cout << " done in " << chrono.diff() << " s." << std::endl;
......@@ -510,25 +512,7 @@ void Ensight<Mesh>::import(const Real& time)
}
template <typename Mesh>
void Ensight<Mesh>::M_rd_ascii( ExporterData& dvar )
{
switch( dvar.type() )
{
case ExporterData::Scalar:
M_rd_ascii_scalar(dvar);
break;
case ExporterData::Vector:
M_rd_ascii_vector(dvar);
break;
}
}
template <typename Mesh>
void Ensight<Mesh>::M_rd_ascii_scalar( ExporterData& dvar )
void Ensight<Mesh>::M_rd_scalar( ExporterData& dvar )
{
std::string filename( this->M_import_dir+super::M_prefix+"_"+dvar.variableName()+this->M_postfix+this->M_me+".scl" );
......@@ -574,7 +558,7 @@ void Ensight<Mesh>::M_rd_ascii_scalar( ExporterData& dvar )
ASSERT(!sclf.fail(), std::stringstream("There is an error while reading " + filename).str().c_str() );
}
template <typename Mesh> void Ensight<Mesh>::M_rd_ascii_vector(ExporterData& dvar)
template <typename Mesh> void Ensight<Mesh>::M_rd_vector(ExporterData& dvar)
{
std::string filename( this->M_import_dir+super::M_prefix+"_"+dvar.variableName()+this->M_postfix+this->M_me+".vct" );
......
......@@ -267,6 +267,8 @@ public:
//! Read only last timestep
virtual void import(const Real& Tstart) = 0;
virtual void rd_var(ExporterData& dvar);
//! Set the output folder for postprocessing
/*!
* @param outputDirectory output folder
......@@ -283,6 +285,9 @@ protected:
//! compute postfix
void computePostfix();
virtual void M_rd_scalar( ExporterData& dvar )=0;
virtual void M_rd_vector( ExporterData& dvar )=0;
//@}
public:
......@@ -445,6 +450,21 @@ void Exporter<Mesh>::addVariable(const ExporterData::Type type, const std::strin
M_listData.push_back( ExporterData(type,variableName,vr,start, size, steady) );
}
template <typename Mesh>
void Exporter<Mesh>::rd_var(ExporterData& dvar)
{
switch( dvar.type() )
{
case ExporterData::Scalar:
M_rd_scalar(dvar);
break;
case ExporterData::Vector:
M_rd_vector(dvar);
break;
}
}
}
......
......@@ -146,6 +146,8 @@ public:
//! returns the type of the map to use for the EpetraVector
EpetraMapType mapType() const;
void rd_var ( ExporterData& dvar);
//@}
......@@ -176,7 +178,6 @@ private:
void M_wr_geo();
void M_rd_var ( ExporterData& dvar);
void M_rd_scalar( ExporterData& dvar);
void M_rd_vector( ExporterData& dvar);
......@@ -795,7 +796,7 @@ void Hdf5exporter<Mesh>::import(const Real& time)
chrono.start();
for (Iterator i=this->M_listData.begin(); i != this->M_listData.end(); ++i)
{
M_rd_var(*i); ///!!! Simone
this->rd_var(*i); ///!!! Simone
}
chrono.stop();
if (!this->M_procId) std::cout << " done in " << chrono.diff() << " s." << std::endl;
......@@ -803,19 +804,14 @@ void Hdf5exporter<Mesh>::import(const Real& time)
}
template <typename Mesh>
void Hdf5exporter<Mesh>::M_rd_var(ExporterData& dvar)
void Hdf5exporter<Mesh>::rd_var(ExporterData& dvar)
{
switch( dvar.type() )
{
case ExporterData::Scalar:
M_rd_scalar(dvar);
break;
case ExporterData::Vector:
M_rd_vector(dvar);
break;
}
if ( M_HDF5.get() == 0)
{
M_HDF5.reset(new hdf5_type(dvar.storedArray()->BlockMap().Comm()));
M_HDF5->Open(this->M_post_dir+this->M_prefix+".h5"); //!! Simone
}
super::rd_var(dvar);
}
......@@ -830,7 +826,11 @@ void Hdf5exporter<Mesh>::M_rd_scalar(ExporterData& dvar)
EpetraMap subMap(dvar.storedArray()->BlockMap(), start, dim);
Epetra_MultiVector* subVar(0);
std::string varname (dvar.variableName()+ this->M_postfix); // see also in M_wr_attributes
std::string varname (dvar.variableName()); // see also in M_wr_attributes
if(this->M_postfix!="")
{
varname += this->M_postfix;
}
bool readTranspose (true);
M_HDF5->Read(varname, *subMap.getMap(this->mapType()), subVar, readTranspose);
......@@ -856,7 +856,11 @@ void Hdf5exporter<Mesh>::M_rd_vector( ExporterData& dvar)
Epetra_MultiVector* subVar(0);
bool readTranspose (true);
std::string varname (dvar.variableName() + this->M_postfix); // see also in M_wr_attributes
std::string varname (dvar.variableName()); // see also in M_wr_attributes
if(this->M_postfix!="")
{
varname += this->M_postfix;
}
M_HDF5->Read(varname, *subMap.getMap(this->mapType()), subVar, readTranspose);
......
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