Commit 7f20a146 authored by Praetorius, Simon's avatar Praetorius, Simon
Browse files

Elementfunction.h: Aenderung nach AMDiS Umstellung Pointer->Referenz noetig,...

Elementfunction.h: Aenderung nach AMDiS Umstellung Pointer->Referenz noetig, VTK-Writer: Moeglichkeit zu Schreiben von Vektoren von DOFVectoren geschaffen
parent d57e9afc
......@@ -35,21 +35,21 @@ namespace AMDiS {
public:
/// constructor.
ElementFunction()
: elInfo_(NULL)
: elInfo(NULL)
{}
/// destructor.
virtual ~ElementFunction() {}
/// sets \ref elInfo_;
inline void setElInfo(const ElInfo *elInfo)
inline void setElInfo(const ElInfo *elInfo_)
{
elInfo_ = elInfo;
elInfo = elInfo_;
}
protected:
/// ElInfo the function currently lives on.
const ElInfo *elInfo_;
const ElInfo *elInfo;
};
/// ElementFunction wich encapsulates the evaluation of an analytical function.
......@@ -58,22 +58,22 @@ namespace AMDiS {
{
public:
/// constructor
ElementFunctionAnalytic(const AbstractFunction<T, WorldVector<double> > *fct)
ElementFunctionAnalytic(const AbstractFunction<T, WorldVector<double> > *fct_)
: ElementFunction<T>(),
fct_(fct)
fct(fct_)
{}
/// evaluation at given coordinates.
T operator()(const DimVec<double>& bary) const
{
WorldVector<double> worldCoords;
this->elInfo_->coordToWorld(bary, &worldCoords);
return (*fct_)(worldCoords);
this->elInfo->coordToWorld(bary, worldCoords);
return (*fct)(worldCoords);
}
protected:
/// function to be avaluated at world coordinates.
const AbstractFunction<T, WorldVector<double> > *fct_;
const AbstractFunction<T, WorldVector<double> > *fct;
};
......@@ -92,7 +92,7 @@ namespace AMDiS {
T operator()(const DimVec<double>& bary) const
{
T* localVec = new T[dofVector->getFESpace()->getBasisFcts()->getNumber()];
dofVector->getLocalVector(this->elInfo_->getElement(), localVec);
dofVector->getLocalVector(this->elInfo->getElement(), localVec);
T t = dofVector->getFESpace()->getBasisFcts()->evalUh(bary, localVec);
delete [] localVec;
......
......@@ -129,32 +129,65 @@ namespace AMDiS {
}
void VtkWriter::writeFile(DOFVector<double> *values,
std::string filename,
bool writeParallel)
std::string filename,
bool writeParallel)
{
FUNCNAME("VtkWriter::writeFile()");
DataCollector dc(values->getFESpace(), values);
std::vector<DataCollector*> dcList(0);
dcList.push_back(&dc);
VtkWriter writer(&dcList);
#ifdef HAVE_PARALLEL_DOMAIN_AMDIS
if (writeParallel) {
using boost::lexical_cast;
int sPos = filename.find(".vtu");
TEST_EXIT(sPos >= 0)("Failed to find file postfix!\n");
std::string name = filename.substr(0, sPos);
if (MPI::COMM_WORLD.Get_rank() == 0)
writer.writeParallelFile(name + ".pvtu", MPI::COMM_WORLD.Get_size(), name, ".vtu");
filename = name + "-p" + lexical_cast<std::string>(MPI::COMM_WORLD.Get_rank()) + "-.vtu";
}
#endif
writer.writeFile(filename);
}
FUNCNAME("VtkWriter::writeFile()");
DataCollector dc(values->getFESpace(), values);
std::vector<DataCollector*> dcList(0);
dcList.push_back(&dc);
VtkWriter::writeFile(dcList,filename,writeParallel);
};
void VtkWriter::writeFile(std::vector<DOFVector<double>* > &values,
std::string filename,
bool writeParallel)
{
std::vector<DataCollector*> dcList(0);
for(unsigned i=0; i<values.size(); ++i) {
dcList.push_back(new DataCollector(values[i]->getFESpace(), values[i]));
}
VtkWriter::writeFile(dcList,filename,writeParallel);
for(unsigned i=0; i<values.size(); ++i) {
delete dcList[i];
}
};
void VtkWriter::writeFile(SystemVector *values,
std::string filename,
bool writeParallel)
{
std::vector<DataCollector*> dcList(0);
for(unsigned i=0; i<values->getSize(); ++i) {
dcList.push_back(new DataCollector(values->getDOFVector(i)->getFESpace(), values->getDOFVector(i)));
}
VtkWriter::writeFile(dcList,filename,writeParallel);
for(unsigned i=0; i<dcList.size(); ++i) {
delete dcList[i];
}
};
void VtkWriter::writeFile(std::vector<DataCollector*> &dcList,
std::string filename,
bool writeParallel)
{
VtkWriter writer(&dcList);
#ifdef HAVE_PARALLEL_DOMAIN_AMDIS
if (writeParallel) {
using boost::lexical_cast;
int sPos = filename.find(".vtu");
TEST_EXIT(sPos >= 0)("Failed to find file postfix!\n");
std::string name = filename.substr(0, sPos);
if (MPI::COMM_WORLD.Get_rank() == 0)
writer.writeParallelFile(name + ".pvtu", MPI::COMM_WORLD.Get_size(), name, ".vtu");
filename = name + "-p" + lexical_cast<std::string>(MPI::COMM_WORLD.Get_rank()) + "-.vtu";
}
#endif
writer.writeFile(filename);
};
}
......@@ -33,6 +33,7 @@
#include "BasisFunction.h"
#include "DataCollector.h"
#include "FileWriter.h"
#include "SystemVector.h"
namespace AMDiS {
......@@ -67,6 +68,18 @@ namespace AMDiS {
writeFile(&values, filename, writeParallel);
}
/// May be used to simply write ParaView files with a list of values.
static void writeFile(std::vector<DOFVector<double>*> &values,
std::string filename,
bool writeParallel = true);
static void writeFile(SystemVector *values,
std::string filename,
bool writeParallel = true);
static void writeFile(std::vector<DataCollector*> &dcList,
std::string filename,
bool writeParallel = true);
/// Set a compressing method for file output.
void setCompression(FileCompression c)
{
......
Markdown is supported
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