Skip to content
Snippets Groups Projects
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
No related branches found
No related tags found
No related merge requests found
...@@ -35,21 +35,21 @@ namespace AMDiS { ...@@ -35,21 +35,21 @@ namespace AMDiS {
public: public:
/// constructor. /// constructor.
ElementFunction() ElementFunction()
: elInfo_(NULL) : elInfo(NULL)
{} {}
/// destructor. /// destructor.
virtual ~ElementFunction() {} virtual ~ElementFunction() {}
/// sets \ref elInfo_; /// sets \ref elInfo_;
inline void setElInfo(const ElInfo *elInfo) inline void setElInfo(const ElInfo *elInfo_)
{ {
elInfo_ = elInfo; elInfo = elInfo_;
} }
protected: protected:
/// ElInfo the function currently lives on. /// ElInfo the function currently lives on.
const ElInfo *elInfo_; const ElInfo *elInfo;
}; };
/// ElementFunction wich encapsulates the evaluation of an analytical function. /// ElementFunction wich encapsulates the evaluation of an analytical function.
...@@ -58,22 +58,22 @@ namespace AMDiS { ...@@ -58,22 +58,22 @@ namespace AMDiS {
{ {
public: public:
/// constructor /// constructor
ElementFunctionAnalytic(const AbstractFunction<T, WorldVector<double> > *fct) ElementFunctionAnalytic(const AbstractFunction<T, WorldVector<double> > *fct_)
: ElementFunction<T>(), : ElementFunction<T>(),
fct_(fct) fct(fct_)
{} {}
/// evaluation at given coordinates. /// evaluation at given coordinates.
T operator()(const DimVec<double>& bary) const T operator()(const DimVec<double>& bary) const
{ {
WorldVector<double> worldCoords; WorldVector<double> worldCoords;
this->elInfo_->coordToWorld(bary, &worldCoords); this->elInfo->coordToWorld(bary, worldCoords);
return (*fct_)(worldCoords); return (*fct)(worldCoords);
} }
protected: protected:
/// function to be avaluated at world coordinates. /// 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 { ...@@ -92,7 +92,7 @@ namespace AMDiS {
T operator()(const DimVec<double>& bary) const T operator()(const DimVec<double>& bary) const
{ {
T* localVec = new T[dofVector->getFESpace()->getBasisFcts()->getNumber()]; 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); T t = dofVector->getFESpace()->getBasisFcts()->evalUh(bary, localVec);
delete [] localVec; delete [] localVec;
......
...@@ -129,32 +129,65 @@ namespace AMDiS { ...@@ -129,32 +129,65 @@ namespace AMDiS {
} }
void VtkWriter::writeFile(DOFVector<double> *values, void VtkWriter::writeFile(DOFVector<double> *values,
std::string filename, std::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); std::vector<DataCollector*> dcList(0);
dcList.push_back(&dc); dcList.push_back(&dc);
VtkWriter writer(&dcList); VtkWriter::writeFile(dcList,filename,writeParallel);
};
#ifdef HAVE_PARALLEL_DOMAIN_AMDIS
if (writeParallel) { void VtkWriter::writeFile(std::vector<DOFVector<double>* > &values,
using boost::lexical_cast; std::string filename,
bool writeParallel)
int sPos = filename.find(".vtu"); {
TEST_EXIT(sPos >= 0)("Failed to find file postfix!\n"); std::vector<DataCollector*> dcList(0);
std::string name = filename.substr(0, sPos); for(unsigned i=0; i<values.size(); ++i) {
dcList.push_back(new DataCollector(values[i]->getFESpace(), values[i]));
if (MPI::COMM_WORLD.Get_rank() == 0) }
writer.writeParallelFile(name + ".pvtu", MPI::COMM_WORLD.Get_size(), name, ".vtu"); VtkWriter::writeFile(dcList,filename,writeParallel);
for(unsigned i=0; i<values.size(); ++i) {
filename = name + "-p" + lexical_cast<std::string>(MPI::COMM_WORLD.Get_rank()) + "-.vtu"; delete dcList[i];
} }
#endif };
writer.writeFile(filename); 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 @@ ...@@ -33,6 +33,7 @@
#include "BasisFunction.h" #include "BasisFunction.h"
#include "DataCollector.h" #include "DataCollector.h"
#include "FileWriter.h" #include "FileWriter.h"
#include "SystemVector.h"
namespace AMDiS { namespace AMDiS {
...@@ -67,6 +68,18 @@ namespace AMDiS { ...@@ -67,6 +68,18 @@ namespace AMDiS {
writeFile(&values, filename, writeParallel); 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. /// Set a compressing method for file output.
void setCompression(FileCompression c) void setCompression(FileCompression c)
{ {
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment