Commit 7cac7d4c authored by Thomas Witkowski's avatar Thomas Witkowski
Browse files

Work on Rosenbrock methods.

parent 6fbfd7ec
...@@ -515,17 +515,8 @@ namespace AMDiS { ...@@ -515,17 +515,8 @@ namespace AMDiS {
solution->getDOFVector(i))); solution->getDOFVector(i)));
} }
// Check for serializer
int writeSerialization = 0; int writeSerialization = 0;
Parameters::get(name + "->write serialization", writeSerialization);
if (writeSerialization) {
MSG("Use are using the obsolete parameter: %s->write serialization\n", name.c_str());
MSG("Please use instead the following parameter: %s->output->write serialization\n", name.c_str());
ERROR_EXIT("Usage of an obsolete parameter (see message above)!\n");
}
Parameters::get(name + "->output->write serialization", writeSerialization); Parameters::get(name + "->output->write serialization", writeSerialization);
if (writeSerialization) if (writeSerialization)
fileWriters.push_back(new Serializer<ProblemStatSeq>(this)); fileWriters.push_back(new Serializer<ProblemStatSeq>(this));
} }
......
...@@ -45,7 +45,10 @@ namespace AMDiS { ...@@ -45,7 +45,10 @@ namespace AMDiS {
: name(""), : name(""),
problem(prob), problem(prob),
tsModulo(1), tsModulo(1),
timestepNumber(-1) timestepNumber(-1),
appendIndex(0),
indexLength(5),
indexDecimals(3)
{ {
FUNCNAME("Serializer::Serializer()"); FUNCNAME("Serializer::Serializer()");
...@@ -55,9 +58,9 @@ namespace AMDiS { ...@@ -55,9 +58,9 @@ namespace AMDiS {
tsModulo); tsModulo);
TEST_EXIT(name != "")("No filename!\n"); TEST_EXIT(name != "")("No filename!\n");
#if HAVE_PARALLEL_DOMAIN_AMDIS Parameters::get(problem->getName() + "->output->append index", appendIndex);
name += ".p" + boost::lexical_cast<std::string>(MPI::COMM_WORLD.Get_rank()); Parameters::get(problem->getName() + "->output->index length", indexLength);
#endif Parameters::get(problem->getName() + "->output->index decimals", indexDecimals);
} }
...@@ -65,15 +68,18 @@ namespace AMDiS { ...@@ -65,15 +68,18 @@ namespace AMDiS {
: name(filename), : name(filename),
problem(prob), problem(prob),
tsModulo(writeEveryIth), tsModulo(writeEveryIth),
timestepNumber(-1) timestepNumber(-1),
appendIndex(0),
indexLength(5),
indexDecimals(3)
{ {
FUNCNAME("Serializer::Serializer()"); FUNCNAME("Serializer::Serializer()");
TEST_EXIT(name != "")("No filename!\n"); TEST_EXIT(name != "")("No filename!\n");
#if HAVE_PARALLEL_DOMAIN_AMDIS Parameters::get(problem->getName() + "->output->append index", appendIndex);
name += ".p" + boost::lexical_cast<std::string>(MPI::COMM_WORLD.Get_rank()); Parameters::get(problem->getName() + "->output->index length", indexLength);
#endif Parameters::get(problem->getName() + "->output->index decimals", indexDecimals);
} }
...@@ -97,14 +103,35 @@ namespace AMDiS { ...@@ -97,14 +103,35 @@ namespace AMDiS {
TEST_EXIT(adaptInfo)("No AdaptInfo\n"); TEST_EXIT(adaptInfo)("No AdaptInfo\n");
std::ofstream out(name.c_str()); string filename = name;
if (appendIndex) {
TEST_EXIT(indexLength <= 99)("index lenght > 99\n");
TEST_EXIT(indexDecimals <= 97)("index decimals > 97\n");
TEST_EXIT(indexDecimals < indexLength)("index length <= index decimals\n");
char formatStr[9];
char timeStr[20];
sprintf(formatStr, "%%0%d.%df", indexLength, indexDecimals);
sprintf(timeStr, formatStr, adaptInfo ? adaptInfo->getTime() : 0.0);
filename += string(timeStr);
}
filename += ".ser";
#if HAVE_PARALLEL_DOMAIN_AMDIS
filename += ".p" + boost::lexical_cast<std::string>(MPI::COMM_WORLD.Get_rank());
#endif
std::ofstream out(filename.c_str());
TEST_EXIT(out.is_open())("Cannot open serialization file!\n"); TEST_EXIT(out.is_open())("Cannot open serialization file!\n");
out.write(reinterpret_cast<const char*>(&amdisRevisionNumber), sizeof(int)); out.write(reinterpret_cast<const char*>(&amdisRevisionNumber), sizeof(int));
problem->serialize(out); problem->serialize(out);
adaptInfo->serialize(out); adaptInfo->serialize(out);
out.close(); out.close();
MSG("problem serialized to %s \n", name.c_str()); MSG("Problem serialized to %s \n", filename.c_str());
} }
protected: protected:
...@@ -117,6 +144,16 @@ namespace AMDiS { ...@@ -117,6 +144,16 @@ namespace AMDiS {
/// The problem is serialized every tsModulo-th timestep. /// The problem is serialized every tsModulo-th timestep.
int tsModulo; int tsModulo;
/// 0: Don't append time index to filename prefix.
/// 1: Append time index to filename prefix.
int appendIndex;
/// Total length of appended time index.
int indexLength;
/// Number of decimals in time index.
int indexDecimals;
/// Current timestep number. /// Current timestep number.
int timestepNumber; int timestepNumber;
}; };
......
...@@ -97,7 +97,7 @@ namespace AMDiS { ...@@ -97,7 +97,7 @@ namespace AMDiS {
public: public:
/// Constructor. /// Constructor.
VecAtQP_ZOT(DOFVectorBase<double> *dv, VecAtQP_ZOT(DOFVectorBase<double> *dv,
AbstractFunction<double, double> *ab); AbstractFunction<double, double> *ab = NULL);
/// Implementation of \ref OperatorTerm::initElement(). /// Implementation of \ref OperatorTerm::initElement().
void initElement(const ElInfo* elInfo, void initElement(const ElInfo* elInfo,
......
...@@ -261,14 +261,16 @@ namespace AMDiS { ...@@ -261,14 +261,16 @@ namespace AMDiS {
#if HAVE_PARALLEL_DOMAIN_AMDIS #if HAVE_PARALLEL_DOMAIN_AMDIS
if (MPI::COMM_WORLD.Get_rank() == 0) { if (MPI::COMM_WORLD.Get_rank() == 0) {
VtkWriter vtkWriter(&dataCollectors); VtkWriter vtkWriter(&dataCollectors);
vtkWriter.updateAnimationFile(paraFilename + paraviewParallelFileExt, vtkWriter.updateAnimationFile(adaptInfo,
paraFilename + paraviewParallelFileExt,
&paraviewAnimationFrames, &paraviewAnimationFrames,
filename + ".pvd"); filename + ".pvd");
} }
#else #else
VtkWriter vtkWriter(&dataCollectors); VtkWriter vtkWriter(&dataCollectors);
vtkWriter.updateAnimationFile(fn + paraviewFileExt, vtkWriter.updateAnimationFile(adaptInfo,
fn + paraviewFileExt,
&paraviewAnimationFrames, &paraviewAnimationFrames,
filename + ".pvd"); filename + ".pvd");
#endif #endif
......
...@@ -35,6 +35,8 @@ ...@@ -35,6 +35,8 @@
namespace AMDiS { namespace AMDiS {
using namespace std;
typedef enum { typedef enum {
NONE = 0, NONE = 0,
GZIP = 1, GZIP = 1,
...@@ -73,19 +75,19 @@ namespace AMDiS { ...@@ -73,19 +75,19 @@ namespace AMDiS {
writeElement = writeElem; writeElement = writeElem;
} }
std::string getFilename() string getFilename()
{ {
return filename; return filename;
} }
void setFilename(std::string n) void setFilename(string n)
{ {
filename = n; filename = n;
} }
protected: protected:
/// Used filename prefix. /// Used filename prefix.
std::string filename; string filename;
int traverseLevel; int traverseLevel;
...@@ -105,18 +107,18 @@ namespace AMDiS { ...@@ -105,18 +107,18 @@ namespace AMDiS {
{ {
public: public:
/// Constructor for a filewriter for one data component. /// Constructor for a filewriter for one data component.
FileWriter(std::string name, Mesh *mesh, DOFVector<double> *vec); FileWriter(string name, Mesh *mesh, DOFVector<double> *vec);
/// Constructor for a filewriter with more than one data component. /// Constructor for a filewriter with more than one data component.
FileWriter(std::string name, FileWriter(string name,
Mesh *mesh, Mesh *mesh,
std::vector< DOFVector<double>* > vecs); vector< DOFVector<double>* > vecs);
/** \brief /** \brief
* Constructor for a filewriter, when the solution vector is a vector * Constructor for a filewriter, when the solution vector is a vector
* of WorldVectors. * of WorldVectors.
*/ */
FileWriter(std::string name, FileWriter(string name,
Mesh *mesh, Mesh *mesh,
DOFVector< WorldVector<double> > *vec); DOFVector< WorldVector<double> > *vec);
...@@ -137,22 +139,22 @@ namespace AMDiS { ...@@ -137,22 +139,22 @@ namespace AMDiS {
void readParameters(); void readParameters();
/// Name of the writer. /// Name of the writer.
std::string name; string name;
/// AMDiS mesh-file extension. /// AMDiS mesh-file extension.
std::string amdisMeshExt; string amdisMeshExt;
/// AMDiS solution-file extension. /// AMDiS solution-file extension.
std::string amdisDataExt; string amdisDataExt;
/// VTK file extension. /// VTK file extension.
std::string paraviewFileExt; string paraviewFileExt;
/// Parallel VTK file extension. /// Parallel VTK file extension.
std::string paraviewParallelFileExt; string paraviewParallelFileExt;
/// Periodic file extension. /// Periodic file extension.
std::string periodicFileExt; string periodicFileExt;
/// 0: Don't write AMDiS files; 1: Write AMDiS files. /// 0: Don't write AMDiS files; 1: Write AMDiS files.
int writeAMDiSFormat; int writeAMDiSFormat;
...@@ -182,18 +184,16 @@ namespace AMDiS { ...@@ -182,18 +184,16 @@ namespace AMDiS {
int writeArhFormat; int writeArhFormat;
/// camera position for povray script files /// camera position for povray script files
std::string povrayCameraLocation; string povrayCameraLocation;
/// orientation for camera in povray script files /// orientation for camera in povray script files
std::string povrayCameraLookAt; string povrayCameraLookAt;
/// name of the template file that will be prepended to all created *.pov files /// name of the template file that will be prepended to all created *.pov files
std::string povrayTemplate; string povrayTemplate;
/** \brief /// 0: Don't append time index to filename prefix.
* 0: Don't append time index to filename prefix. /// 1: Append time index to filename prefix.
* 1: Append time index to filename prefix.
*/
int appendIndex; int appendIndex;
/// Total length of appended time index. /// Total length of appended time index.
...@@ -205,8 +205,9 @@ namespace AMDiS { ...@@ -205,8 +205,9 @@ namespace AMDiS {
/// Timestep modulo: write only every tsModulo-th timestep! /// Timestep modulo: write only every tsModulo-th timestep!
int tsModulo; int tsModulo;
/// Stores all writen filename to a ParaView animation file. /// Stores a set of pairs of timepoint and filename to write a ParaView
std::vector< std::string > paraviewAnimationFrames; /// animation file.
vector<pair<double, string> > paraviewAnimationFrames;
/// ///
int timestepNumber; int timestepNumber;
...@@ -218,7 +219,7 @@ namespace AMDiS { ...@@ -218,7 +219,7 @@ namespace AMDiS {
const FiniteElemSpace *feSpace; const FiniteElemSpace *feSpace;
/// Pointers to the vectors which store the solution. /// Pointers to the vectors which store the solution.
std::vector<DOFVector<double>*> solutionVecs; vector<DOFVector<double>*> solutionVecs;
/** \brief /** \brief
* Stores the number of temporal solutions vectors, which have been created * Stores the number of temporal solutions vectors, which have been created
......
...@@ -31,7 +31,9 @@ ...@@ -31,7 +31,9 @@
namespace AMDiS { namespace AMDiS {
int VtkWriter::writeFile(std::string name) using namespace std;
int VtkWriter::writeFile(string name)
{ {
FUNCNAME("VtkWriter::writeFile()"); FUNCNAME("VtkWriter::writeFile()");
...@@ -50,32 +52,32 @@ namespace AMDiS { ...@@ -50,32 +52,32 @@ namespace AMDiS {
} }
{ {
std::ofstream swapfile(name.c_str(), std::ios::out | std::ios::trunc); ofstream swapfile(name.c_str(), ios::out | ios::trunc);
TEST_EXIT(swapfile.is_open()) TEST_EXIT(swapfile.is_open())
("Cannot open file %s for writing!\n", name.c_str()); ("Cannot open file %s for writing!\n", name.c_str());
swapfile.close(); swapfile.close();
} }
file.push(boost::iostreams::file_descriptor_sink(name, std::ios::trunc)); file.push(boost::iostreams::file_descriptor_sink(name, ios::trunc));
writeFileToStream(file); writeFileToStream(file);
return 0; return 0;
} }
void VtkWriter::writeParallelFile(std::string name, int nRanks, void VtkWriter::writeParallelFile(string name, int nRanks,
std::string fnPrefix, std::string fnPostfix) string fnPrefix, string fnPostfix)
{ {
FUNCNAME("VtkWriter::writeParallelFile()"); FUNCNAME("VtkWriter::writeParallelFile()");
boost::iostreams::filtering_ostream file; boost::iostreams::filtering_ostream file;
{ {
std::ofstream swapfile(name.c_str(), std::ios::out | std::ios::trunc); ofstream swapfile(name.c_str(), ios::out | ios::trunc);
TEST_EXIT(swapfile.is_open()) TEST_EXIT(swapfile.is_open())
("Cannot open file %s for writing!\n", name.c_str()); ("Cannot open file %s for writing!\n", name.c_str());
swapfile.close(); swapfile.close();
} }
file.push(boost::iostreams::file_descriptor_sink(name, std::ios::trunc)); file.push(boost::iostreams::file_descriptor_sink(name, ios::trunc));
file << "<?xml version=\"1.0\"?>\n"; file << "<?xml version=\"1.0\"?>\n";
file << "<VTKFile type=\"PUnstructuredGrid\">\n"; file << "<VTKFile type=\"PUnstructuredGrid\">\n";
...@@ -97,7 +99,7 @@ namespace AMDiS { ...@@ -97,7 +99,7 @@ namespace AMDiS {
file << " </PPointData>\n"; file << " </PPointData>\n";
for (int i = 0; i < nRanks; i++) { for (int i = 0; i < nRanks; i++) {
std::stringstream oss; stringstream oss;
oss << fnPrefix << "-p" << i << "-" << fnPostfix; oss << fnPrefix << "-p" << i << "-" << fnPostfix;
boost::filesystem::path filepath(oss.str()); boost::filesystem::path filepath(oss.str());
file << " <Piece Source=\"" file << " <Piece Source=\""
...@@ -111,38 +113,36 @@ namespace AMDiS { ...@@ -111,38 +113,36 @@ namespace AMDiS {
} }
int VtkWriter::updateAnimationFile(std::string valueFilename, int VtkWriter::updateAnimationFile(AdaptInfo *adaptInfo,
std::vector< std::string > *paraViewAnimationFrames, string valueFilename,
std::string animationFilename) vector<pair<double, string > > *paraViewAnimationFrames,
string animationFilename)
{ {
FUNCNAME("VtkWriter::updateAnimationFile()"); FUNCNAME("VtkWriter::updateAnimationFile()");
size_t found = valueFilename.find_last_of("/\\"); size_t found = valueFilename.find_last_of("/\\");
paraViewAnimationFrames->push_back(valueFilename.substr(found + 1)); paraViewAnimationFrames->push_back(make_pair(adaptInfo->getTime(),
valueFilename.substr(found + 1)));
boost::iostreams::filtering_ostream file; boost::iostreams::filtering_ostream file;
{ {
std::ofstream swapfile(animationFilename.c_str(), ofstream swapfile(animationFilename.c_str(),
std::ios::out | std::ios::trunc); ios::out | ios::trunc);
TEST_EXIT(swapfile.is_open()) TEST_EXIT(swapfile.is_open())
("Cannot open file %s for writing!\n", animationFilename.c_str()); ("Cannot open file %s for writing!\n", animationFilename.c_str());
swapfile.close(); swapfile.close();
} }
file.push(boost::iostreams::file_descriptor_sink(animationFilename, file.push(boost::iostreams::file_descriptor_sink(animationFilename,
std::ios::trunc)); ios::trunc));
file << "<?xml version=\"1.0\"?>\n"; file << "<?xml version=\"1.0\"?>\n";
file << "<VTKFile type=\"Collection\" version=\"0.1\" >" << "\n"; file << "<VTKFile type=\"Collection\" version=\"0.1\" >" << "\n";
file << "<Collection>\n"; file << "<Collection>\n";
int counter = 0; for (vector<pair<double, string> >::iterator it = paraViewAnimationFrames->begin();
std::vector< std::string >::iterator it; it < paraViewAnimationFrames->end(); ++it)
for (it = paraViewAnimationFrames->begin(); file << "<DataSet timestep=\"" << it->first
it < paraViewAnimationFrames->end(); << "\" part=\"0\" file=\"" << it->second << "\"/>\n";
++it, counter++) {
file << "<DataSet timestep=\"" << counter
<< "\" part=\"0\" file=\"" << (*it) << "\"/>\n";
}
file << "</Collection>\n"; file << "</Collection>\n";
file << "</VTKFile>\n"; file << "</VTKFile>\n";
...@@ -152,23 +152,23 @@ namespace AMDiS { ...@@ -152,23 +152,23 @@ namespace AMDiS {
void VtkWriter::writeFile(DOFVector<double> *values, void VtkWriter::writeFile(DOFVector<double> *values,
std::string filename, string filename,
bool writeParallel) bool writeParallel)
{ {
FUNCNAME("VtkWriter::writeFile()"); FUNCNAME("VtkWriter::writeFile()");
DataCollector dc(values->getFeSpace(), values); DataCollector dc(values->getFeSpace(), values);
std::vector<DataCollector*> dcList(0); vector<DataCollector*> dcList(0);
dcList.push_back(&dc); dcList.push_back(&dc);
writeFile(dcList, filename, writeParallel); writeFile(dcList, filename, writeParallel);
} }
void VtkWriter::writeFile(std::vector<DOFVector<double>* > &values, void VtkWriter::writeFile(vector<DOFVector<double>* > &values,
std::string filename, string filename,
bool writeParallel) bool writeParallel)
{ {
std::vector<DataCollector*> dcList(0); vector<DataCollector*> dcList(0);
for (unsigned int i = 0; i < values.size(); i++) for (unsigned int i = 0; i < values.size(); i++)
dcList.push_back(new DataCollector(values[i]->getFeSpace(), values[i])); dcList.push_back(new DataCollector(values[i]->getFeSpace(), values[i]));
writeFile(dcList, filename, writeParallel); writeFile(dcList, filename, writeParallel);
...@@ -178,10 +178,10 @@ namespace AMDiS { ...@@ -178,10 +178,10 @@ namespace AMDiS {
void VtkWriter::writeFile(WorldVector<DOFVector<double>* > &values, void VtkWriter::writeFile(WorldVector<DOFVector<double>* > &values,
std::string filename, string filename,
bool writeParallel) bool writeParallel)
{ {
std::vector<DataCollector*> dcList(0); vector<DataCollector*> dcList(0);
for (int i = 0; i < values.getSize(); i++) for (int i = 0; i < values.getSize(); i++)
dcList.push_back(new DataCollector(values[i]->getFeSpace(), values[i])); dcList.push_back(new DataCollector(values[i]->getFeSpace(), values[i]));
writeFile(dcList, filename, writeParallel); writeFile(dcList, filename, writeParallel);
...@@ -191,7 +191,7 @@ namespace AMDiS { ...@@ -191,7 +191,7 @@ namespace AMDiS {
void VtkWriter::writeFile(DOFVector<WorldVector<double> > *values, void VtkWriter::writeFile(DOFVector<WorldVector<double> > *values,
std::string filename, string filename,
bool writeParallel) bool writeParallel)
{ {
WorldVector<DOFVector<double>*> valuesWV; WorldVector<DOFVector<double>*> valuesWV;
...@@ -205,10 +205,10 @@ namespace AMDiS { ...@@ -205,10 +205,10 @@ namespace AMDiS {