Commit 495c8656 authored by thomaskummer's avatar thomaskummer
Browse files

external power

parent 202c8a03
......@@ -144,6 +144,10 @@ public:
//@{
virtual void postProcess (const Real& time);
void postProcess (const Real& time, const bool& restart);
//! Import data from previous simulations at a certain time
/*!
@param Time the time of the data to be imported
......@@ -296,7 +300,66 @@ ExporterHDF5<MeshType>::ExporterHDF5 (const GetPot& dfile, const std::string& pr
template<typename MeshType>
void ExporterHDF5<MeshType>::postProcess (const Real& time)
{
if ( M_HDF5.get() == 0)
if ( M_HDF5.get() == 0 )
{
M_HDF5.reset (new hdf5_Type (this->M_dataVector.begin()->storedArrayPtr()->comm() ) );
M_outputFileName = this->M_prefix + ".h5";
M_HDF5->Create (this->M_postDir + M_outputFileName);
// write empty xdmf file
writeInitXdmf();
if (!this->M_multimesh)
{
writeGeometry(); // see also writeGeometry
M_HDF5->Flush();
}
}
// typedef std::list< exporterData_Type >::const_iterator Iterator;
this->computePostfix();
std::size_t found ( this->M_postfix.find ( "*" ) );
if ( found == std::string::npos )
{
if (!this->M_procId)
{
std::cout << " X- HDF5 post-processing ... " << std::flush;
}
LifeChrono chrono;
chrono.start();
for (typename super::dataVectorIterator_Type i = this->M_dataVector.begin(); i != this->M_dataVector.end(); ++i)
{
writeVariable (*i);
}
// pushing time
this->M_timeSteps.push_back (time);
writeXdmf (time);
if (this->M_multimesh)
{
writeGeometry(); // see also writeGeometry
}
chrono.stop();
// Write to file without closing the file
M_HDF5->Flush();
if (!this->M_procId)
{
std::cout << "done in " << chrono.diff() << " s." << std::endl;
}
}
}
template<typename MeshType>
void ExporterHDF5<MeshType>::postProcess (const Real& time, const bool& restart)
{
if ( M_HDF5.get() == 0 && !restart )
{
M_HDF5.reset (new hdf5_Type (this->M_dataVector.begin()->storedArrayPtr()->comm() ) );
M_outputFileName = this->M_prefix + ".h5";
......@@ -313,7 +376,18 @@ void ExporterHDF5<MeshType>::postProcess (const Real& time)
}
// typedef std::list< exporterData_Type >::const_iterator Iterator;
if ( restart )
{
M_HDF5.reset (new hdf5_Type (this->M_dataVector.begin()->storedArrayPtr()->comm() ) );
if (this->M_procId == 0)
{
M_xdmf.open ( (this->M_postDir + this->M_prefix + ".xmf").c_str(), std::ios_base::out );
}
}
this->computePostfix();
std::size_t found ( this->M_postfix.find ( "*" ) );
......@@ -350,6 +424,7 @@ void ExporterHDF5<MeshType>::postProcess (const Real& time)
}
}
}
template<typename MeshType>
UInt ExporterHDF5<MeshType>::importFromTime ( const Real& Time )
......
......@@ -572,7 +572,7 @@ int main (int argc, char** argv)
// Get most recent restart index
if ( restartInput == "." )
{
restartInput = pipeToString( ("tail -n 1 " + restartDir + "solution.dat | awk -F '[. ]' '{print $1 \".\" $2}' | awk '{printf \"%05g\", $1*1000/" + std::to_string(dt_activation) + " + 1}'").c_str() );
restartInput = pipeToString( ("tail -n 1 " + restartDir + "solution.dat | awk -F '[. ]' '{print $1 \".\" $2}' | awk '{printf \"%05g\", $1*1000/" + std::to_string(dt_mechanics) + " + 1}'").c_str() );
}
std::cout << comm->MyPID() << " ----------------------- " << restartInput << std::endl;
......@@ -580,11 +580,11 @@ int main (int argc, char** argv)
// Set time variable
const unsigned int restartInputStr = std::stoi(restartInput);
const unsigned int nIter = (restartInputStr - 1) / saveIter;
const unsigned int nIter = (restartInputStr - 1);
t = nIter * dt_mechanics;
activationTimeExporter.setTimeIndex(nIter * saveIter + 2);
solver.setTimeIndex(nIter * saveIter + 2);
activationTimeExporter.setTimeIndex(nIter + 2);
solver.setTimeIndex(nIter + 2);
std::string polynomialDegree = dataFile ( "solid/space_discretization/order", "P1");
......@@ -652,13 +652,6 @@ int main (int argc, char** argv)
{
if ( 0 == comm->MyPID() )
{
std::cout << "\n" << fmod(i, 10) << std::endl;
std::cout << "\n" << fmod(9, 10) << std::endl;
std::cout << "\n" << fmod(10, 10) << std::endl;
std::cout << "\n" << fmod(10.5, 10.) << std::endl;
std::cout << "\n" << (fmod(10.5, 10.) > 5 )<< std::endl;
std::cout << "\n" << (fmod(10.5, 10.) < 5 )<< std::endl;
std::cout << "\n*********************";
std::cout << "\nPreload step: " << i << " / " << preloadSteps;
std::cout << "\n*********************\n";
......@@ -914,8 +907,10 @@ int main (int argc, char** argv)
//============================================//
// Export FE-solution
//============================================//
solver.saveSolution(t);
activationTimeExporter.postProcess(t);
bool save ( fmod(t, 5.) < 0.01 );
std::cout << "\n---------------------------------------------------------------------------save: " << save << std::endl;
solver.saveSolution(t, restart);
activationTimeExporter.postProcess(t, restart);
}
}
......
......@@ -325,7 +325,7 @@ public:
return M_activationModelPtr;
}
void saveSolution (Real time);
void saveSolution (Real time, const bool& restart = 0);
void setTimeIndex (const UInt& time);
......@@ -646,14 +646,14 @@ EMSolver<Mesh, ElectroSolver>::setTimeIndex (const UInt& time)
template<typename Mesh , typename ElectroSolver>
void
EMSolver<Mesh, ElectroSolver>::saveSolution (Real time)
EMSolver<Mesh, ElectroSolver>::saveSolution (Real time, const bool& restart)
{
M_electroExporterPtr -> postProcess (time);
if(M_activationExporterPtr) std::cout << "\nActivation exporter available.";
if(M_activationModelPtr -> fiberActivationPtr()) std::cout << "\nFiber activation exporter available.";
M_activationExporterPtr -> postProcess (time);
if(M_mechanicsExporterPtr) std::cout << "\nMechanics exporter available.";
M_mechanicsExporterPtr -> postProcess (time);
M_electroExporterPtr -> postProcess (time, restart);
//if(M_activationExporterPtr) std::cout << "\nActivation exporter available.";
//if(M_activationModelPtr -> fiberActivationPtr()) std::cout << "\nFiber activation exporter available.";
M_activationExporterPtr -> postProcess (time, restart);
//if(M_mechanicsExporterPtr) std::cout << "\nMechanics exporter available.";
M_mechanicsExporterPtr -> postProcess (time, restart);
}
template<typename Mesh , typename ElectroSolver>
......
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