Commit 73542a30 authored by Thomas Witkowski's avatar Thomas Witkowski
Browse files

* FileWriter::FileWriter for writing data of type DOFVector< WorldVector<double> > introduced

parent ccb92991
...@@ -172,8 +172,8 @@ namespace AMDiS { ...@@ -172,8 +172,8 @@ namespace AMDiS {
::std::list<DOFIndexedBase*>::iterator di; ::std::list<DOFIndexedBase*>::iterator di;
::std::list<DOFIndexedBase*>::iterator end = dofIndexedList.end(); ::std::list<DOFIndexedBase*>::iterator end = dofIndexedList.end();
for(di = dofIndexedList.begin(); di != end; ++di) { for (di = dofIndexedList.begin(); di != end; ++di) {
if((*di)->getSize() < newval) { if ((*di)->getSize() < newval) {
(*di)->resize(newval); (*di)->resize(newval);
} }
} }
...@@ -183,41 +183,44 @@ namespace AMDiS { ...@@ -183,41 +183,44 @@ namespace AMDiS {
FUNCNAME("DOFAdmin::addDOFIndexed"); FUNCNAME("DOFAdmin::addDOFIndexed");
TEST_EXIT(dofIndexed)("no dofIndexed\n"); TEST_EXIT(dofIndexed)("no dofIndexed\n");
if(dofIndexed->getSize() < size) { if (dofIndexed->getSize() < size) {
dofIndexed->resize(size); dofIndexed->resize(size);
} }
dofIndexedList.push_back(dofIndexed); dofIndexedList.push_back(dofIndexed);
} }
void DOFAdmin::removeDOFIndexed(DOFIndexedBase* dofIndexed) void DOFAdmin::removeDOFIndexed(DOFIndexedBase* dofIndexed)
{ {
FUNCNAME("DOFAdmin::removeDOFIndexed"); FUNCNAME("DOFAdmin::removeDOFIndexed()");
::std::list<DOFIndexedBase*>::iterator it; ::std::list<DOFIndexedBase*>::iterator it;
::std::list<DOFIndexedBase*>::iterator end = dofIndexedList.end(); ::std::list<DOFIndexedBase*>::iterator end = dofIndexedList.end();
for(it=dofIndexedList.begin(); it != end; ++it) { for (it = dofIndexedList.begin(); it != end; ++it) {
if(*it == dofIndexed) { if (*it == dofIndexed) {
dofIndexedList.erase(it); dofIndexedList.erase(it);
return; return;
} }
} }
ERROR("DOFIndexed not in list\n"); ERROR("DOFIndexed not in list\n");
} }
void DOFAdmin::addDOFContainer(DOFContainer* cont) void DOFAdmin::addDOFContainer(DOFContainer* cont)
{ {
FUNCNAME("DOFAdmin::addDOFContainer"); FUNCNAME("DOFAdmin::addDOFContainer()");
TEST_EXIT(cont)("no container\n"); TEST_EXIT(cont)("no container\n");
dofContainerList.push_back(cont); dofContainerList.push_back(cont);
} }
void DOFAdmin::removeDOFContainer(DOFContainer* cont) void DOFAdmin::removeDOFContainer(DOFContainer* cont)
{ {
FUNCNAME("DOFAdmin::removeDOFContainer"); FUNCNAME("DOFAdmin::removeDOFContainer()");
::std::list<DOFContainer*>::iterator it; ::std::list<DOFContainer*>::iterator it;
::std::list<DOFContainer*>::iterator end = dofContainerList.end(); ::std::list<DOFContainer*>::iterator end = dofContainerList.end();
for(it=dofContainerList.begin(); it != end; ++it) { for (it = dofContainerList.begin(); it != end; ++it) {
if(*it == cont) { if (*it == cont) {
dofContainerList.erase(it); dofContainerList.erase(it);
return; return;
} }
......
...@@ -112,7 +112,9 @@ namespace AMDiS { ...@@ -112,7 +112,9 @@ namespace AMDiS {
/** \brief /** \brief
* Compares two DOFAdmins by their names. * Compares two DOFAdmins by their names.
*/ */
inline bool operator!=(const DOFAdmin& ad) const {return !(ad==*this);}; inline bool operator!=(const DOFAdmin& ad) const {
return !(ad==*this);
};
/** \brief /** \brief
* Adds a DOFIndexedBase object to the DOFAdmin. This object will be * Adds a DOFIndexedBase object to the DOFAdmin. This object will be
......
...@@ -315,12 +315,16 @@ namespace AMDiS { ...@@ -315,12 +315,16 @@ namespace AMDiS {
/** \brief /** \brief
* Returns iterator to the begin of \ref vec * Returns iterator to the begin of \ref vec
*/ */
typename ::std::vector<T>::iterator begin() { return vec.begin(); }; typename ::std::vector<T>::iterator begin() {
return vec.begin();
};
/** \brief /** \brief
* Returns iterator to the end of \ref vec * Returns iterator to the end of \ref vec
*/ */
typename ::std::vector<T>::iterator end() { return vec.end(); }; typename ::std::vector<T>::iterator end() {
return vec.end();
};
/** \brief /** \brief
* Used by DOFAdmin to compress this DOFVector. Implementation of * Used by DOFAdmin to compress this DOFVector. Implementation of
...@@ -332,7 +336,9 @@ namespace AMDiS { ...@@ -332,7 +336,9 @@ namespace AMDiS {
/** \brief /** \brief
* Sets \ref refineInter to b * Sets \ref refineInter to b
*/ */
inline void refineInterpol(bool b) { refineInter = b; }; inline void refineInterpol(bool b) {
refineInter = b;
};
/** \brief /** \brief
* Sets \ref coarsenOperation to op * Sets \ref coarsenOperation to op
...@@ -375,12 +381,16 @@ namespace AMDiS { ...@@ -375,12 +381,16 @@ namespace AMDiS {
/** \brief /** \brief
* Returns size of \ref vec * Returns size of \ref vec
*/ */
inline int getSize() const { return vec.size();}; inline int getSize() const {
return vec.size();
};
/** \brief /** \brief
* Returns used size of the vector. * Returns used size of the vector.
*/ */
inline int getUsedSize() const { return feSpace->getAdmin()->getUsedSize(); }; inline int getUsedSize() const {
return feSpace->getAdmin()->getUsedSize();
};
/** \brief /** \brief
* Resizes \ref vec to n * Resizes \ref vec to n
...@@ -409,7 +419,9 @@ namespace AMDiS { ...@@ -409,7 +419,9 @@ namespace AMDiS {
return vec[i]; return vec[i];
}; };
inline int getSize() { return vec.size(); }; inline int getSize() {
return vec.size();
};
/** \brief /** \brief
* Returns \ref vec[i] * Returns \ref vec[i]
......
...@@ -25,17 +25,16 @@ namespace AMDiS { ...@@ -25,17 +25,16 @@ namespace AMDiS {
const BoundaryType *bound, const BoundaryType *bound,
bool add) bool add)
{ {
FUNCNAME("DOFVector::addElementVector"); FUNCNAME("DOFVector::addElementVector()");
DegreeOfFreedom i, irow;
int n_row = elVec.getSize(); int n_row = elVec.getSize();
for (i = 0; i < n_row; i++) { for (DegreeOfFreedom i = 0; i < n_row; i++) {
BoundaryCondition *condition = BoundaryCondition *condition =
bound ? this->getBoundaryManager()->getBoundaryCondition(bound[i]) : NULL; bound ? this->getBoundaryManager()->getBoundaryCondition(bound[i]) : NULL;
if(!(condition && condition->isDirichlet())) { if(!(condition && condition->isDirichlet())) {
irow = elVec.dofIndices[i]; DegreeOfFreedom irow = elVec.dofIndices[i];
(*this)[irow] = (add ? (*this)[irow] : 0.0); (*this)[irow] = (add ? (*this)[irow] : 0.0);
(*this)[irow] += factor * elVec[i]; (*this)[irow] += factor * elVec[i];
} }
...@@ -46,7 +45,8 @@ namespace AMDiS { ...@@ -46,7 +45,8 @@ namespace AMDiS {
DOFVector<T>::DOFVector(const FiniteElemSpace* f,::std::string n) DOFVector<T>::DOFVector(const FiniteElemSpace* f,::std::string n)
: DOFVectorBase<T>(f, n), : DOFVectorBase<T>(f, n),
//elementVector(NULL), //elementVector(NULL),
refineInter(false), coarsenOperation(NO_OPERATION) refineInter(false),
coarsenOperation(NO_OPERATION)
{ {
init(f, n); init(f, n);
} }
...@@ -56,7 +56,7 @@ namespace AMDiS { ...@@ -56,7 +56,7 @@ namespace AMDiS {
{ {
name = n; name = n;
feSpace = f; feSpace = f;
if(feSpace && feSpace->getAdmin()) { if (feSpace && feSpace->getAdmin()) {
(feSpace->getAdmin())->addDOFIndexed(this); (feSpace->getAdmin())->addDOFIndexed(this);
} }
this->boundaryManager = NEW BoundaryManager; this->boundaryManager = NEW BoundaryManager;
...@@ -65,7 +65,7 @@ namespace AMDiS { ...@@ -65,7 +65,7 @@ namespace AMDiS {
template<typename T> template<typename T>
DOFVector<T>::~DOFVector() DOFVector<T>::~DOFVector()
{ {
if(feSpace && feSpace->getAdmin()) { if (feSpace && feSpace->getAdmin()) {
(feSpace->getAdmin())->removeDOFIndexed(this); (feSpace->getAdmin())->removeDOFIndexed(this);
} }
......
...@@ -17,7 +17,7 @@ namespace AMDiS { ...@@ -17,7 +17,7 @@ namespace AMDiS {
TEST_EXIT(feSpace)("no feSpace\n"); TEST_EXIT(feSpace)("no feSpace\n");
TEST_EXIT(values)("no value Vector\n"); TEST_EXIT(values)("no value Vector\n");
// === get mesh === // === get mesh ===
mesh_ = feSpace->getMesh(); mesh_ = feSpace->getMesh();
...@@ -26,7 +26,6 @@ namespace AMDiS { ...@@ -26,7 +26,6 @@ namespace AMDiS {
// === create vertex info vector === // === create vertex info vector ===
vertexInfos_ = NEW DOFVector< ::std::list<VertexInfo> >(feSpace, "vertex infos"); vertexInfos_ = NEW DOFVector< ::std::list<VertexInfo> >(feSpace, "vertex infos");
interpPointInd_ = NEW DOFVector<int>(feSpace, "interpolation point indices"); interpPointInd_ = NEW DOFVector<int>(feSpace, "interpolation point indices");
dofCoords_ = NEW DOFVector< ::std::list<WorldVector<double> > >(feSpace, "dof coords"); dofCoords_ = NEW DOFVector< ::std::list<WorldVector<double> > >(feSpace, "dof coords");
......
...@@ -18,21 +18,11 @@ namespace AMDiS { ...@@ -18,21 +18,11 @@ namespace AMDiS {
Mesh *mesh_, Mesh *mesh_,
DOFVector<double> *vec) DOFVector<double> *vec)
: name(name_), : name(name_),
tecplotExt(".tec"),
amdisMeshExt(".mesh"),
amdisDataExt(".dat"),
paraViewFileExt(".vtu"),
periodicFileExt(".per"),
writeTecPlotFormat(0),
writeAMDiSFormat(0),
writeParaViewFormat(0),
writePeriodicFormat(0),
appendIndex(0),
indexLength(5),
indexDecimals(3),
tsModulo(1),
mesh(mesh_) mesh(mesh_)
{ {
FUNCNAME("FileWriter::FileWriter()");
initialize();
readParameters(); readParameters();
feSpace = vec->getFESpace(); feSpace = vec->getFESpace();
...@@ -41,27 +31,16 @@ namespace AMDiS { ...@@ -41,27 +31,16 @@ namespace AMDiS {
solutionVecs_[0] = vec; solutionVecs_[0] = vec;
} }
FileWriter::FileWriter(const ::std::string &name_, FileWriter::FileWriter(const ::std::string &name_,
Mesh *mesh_, Mesh *mesh_,
::std::vector< DOFVector<double>* > vecs) ::std::vector< DOFVector<double>* > vecs)
: name(name_), : name(name_),
tecplotExt(".tec"),
amdisMeshExt(".mesh"),
amdisDataExt(".dat"),
paraViewFileExt(".vtu"),
periodicFileExt(".per"),
writeTecPlotFormat(0),
writeAMDiSFormat(0),
writeParaViewFormat(0),
writePeriodicFormat(0),
appendIndex(0),
indexLength(5),
indexDecimals(3),
tsModulo(1),
mesh(mesh_) mesh(mesh_)
{ {
FUNCNAME("FileWriter::FileWriter()"); FUNCNAME("FileWriter::FileWriter()");
initialize();
readParameters(); readParameters();
for (int i = 0; i < static_cast<int>(vecs.size()); i++) { for (int i = 0; i < static_cast<int>(vecs.size()); i++) {
...@@ -73,6 +52,69 @@ namespace AMDiS { ...@@ -73,6 +52,69 @@ namespace AMDiS {
solutionVecs_ = vecs; solutionVecs_ = vecs;
} }
FileWriter::FileWriter(const ::std::string &name_,
Mesh *mesh_,
DOFVector< WorldVector<double> > *vec)
: name(name_),
mesh(mesh_)
{
FUNCNAME("FileWriter::FileWriter()");
initialize();
readParameters();
// Create the temporal DOFVectors for all components of WorldVector.
nTmpSolutions_ = (*vec)[0].getSize();
solutionVecs_.resize(nTmpSolutions_);
for (int i = 0; i < nTmpSolutions_; i++) {
solutionVecs_[i] = NEW DOFVector<double>(vec->getFESpace(), "");
}
// Copy the components of the WorldVectors to different DOFVectors
// of double values.
DOFVector< WorldVector<double> >::Iterator it(vec, USED_DOFS);
int counter = 0;
for (it.reset(); !it.end(); ++it, counter++) {
for (int i = 0; i < nTmpSolutions_; i++) {
(*solutionVecs_[i])[counter] = (*it)[i];
}
}
feSpace = vec->getFESpace();
}
FileWriter::~FileWriter()
{
// Do not forget to delete temporal solution vector, if there have been
// some created in the constructor.
if (nTmpSolutions_ > 0) {
for (int i = 0; i < nTmpSolutions_; i++) {
DELETE solutionVecs_[i];
}
}
}
void FileWriter::initialize()
{
tecplotExt = ".tec";
amdisMeshExt = ".mesh";
amdisDataExt = ".dat";
paraViewFileExt = ".vtu";
periodicFileExt = ".per";
writeTecPlotFormat = 0;
writeAMDiSFormat = 0;
writeParaViewFormat = 0;
writePeriodicFormat = 0;
appendIndex = 0;
indexLength = 5;
indexDecimals = 3;
tsModulo = 1;
nTmpSolutions_ = 0;
}
void FileWriter::readParameters() void FileWriter::readParameters()
{ {
FUNCNAME("FileWriter::readParamters()"); FUNCNAME("FileWriter::readParamters()");
...@@ -136,7 +178,6 @@ namespace AMDiS { ...@@ -136,7 +178,6 @@ namespace AMDiS {
} }
} }
if (writeTecPlotFormat) { if (writeTecPlotFormat) {
TecPlotWriter<DOFVector<double> >::writeValues(solutionVecs_[0], TecPlotWriter<DOFVector<double> >::writeValues(solutionVecs_[0],
const_cast<char*>((fn + tecplotExt).c_str()), const_cast<char*>((fn + tecplotExt).c_str()),
......
...@@ -128,10 +128,18 @@ namespace AMDiS { ...@@ -128,10 +128,18 @@ namespace AMDiS {
Mesh *mesh_, Mesh *mesh_,
::std::vector< DOFVector<double>* > vecs); ::std::vector< DOFVector<double>* > vecs);
/** \brief
* Constructor for a filewriter, when the solution vector is a vector
* of WorldVectors.
*/
FileWriter(const ::std::string &name_,
Mesh *mesh_,
DOFVector< WorldVector<double> > *vec);
/** \brief /** \brief
* Destructor. * Destructor.
*/ */
virtual ~FileWriter() {}; virtual ~FileWriter();
/** \brief /** \brief
* Implementation of FileWriterInterface::writeFiles(). * Implementation of FileWriterInterface::writeFiles().
...@@ -142,6 +150,11 @@ namespace AMDiS { ...@@ -142,6 +150,11 @@ namespace AMDiS {
bool (*writeElem)(ElInfo*) = NULL); bool (*writeElem)(ElInfo*) = NULL);
protected: protected:
/** \brief
* Initialization of the filewriter.
*/
void initialize();
/** \brief /** \brief
* Reads all file writer dependend parameters from the init file. * Reads all file writer dependend parameters from the init file.
*/ */
...@@ -237,11 +250,16 @@ namespace AMDiS { ...@@ -237,11 +250,16 @@ namespace AMDiS {
const FiniteElemSpace *feSpace; const FiniteElemSpace *feSpace;
/** \brief /** \brief
* Pointer to a vector which stores the solution. * Pointers to the vectors which store the solution.
*/ */
DOFVector<double> *vec_;
::std::vector< DOFVector<double>* > solutionVecs_; ::std::vector< DOFVector<double>* > solutionVecs_;
/** \brief
* Stores the number of temporal solutions vectors, which have been created
* in the constructor. If this number is greater than zero, the vectors
* stored in solutionVecs_ must be deleted in the destructor.
*/
int nTmpSolutions_;
}; };
} }
......
...@@ -462,8 +462,8 @@ namespace AMDiS { ...@@ -462,8 +462,8 @@ namespace AMDiS {
template<typename T> template<typename T>
inline const Vector<T>& add(const Vector<T>& v1, const Vector<T>& v2, Vector<T>& result) inline const Vector<T>& add(const Vector<T>& v1, const Vector<T>& v2, Vector<T>& result)
{ {
TEST_EXIT(v1.getSize() == v2.getSize())("invalid size\n"); TEST_EXIT(v1.getSize() == v2.getSize())("invalid size in test v1 == v2\n");
TEST_EXIT(v2.getSize() == result.getSize())("invalid size\n"); TEST_EXIT(v2.getSize() == result.getSize())("invalid size in test v2 == result\n");
T *v1It, *v2It, *resultIt; T *v1It, *v2It, *resultIt;
for (v1It = v1.begin(), v2It = v2.begin(), resultIt = result.begin(); for (v1It = v1.begin(), v2It = v2.begin(), resultIt = result.begin();
v1It != v1.end(); v1It != v1.end();
......
...@@ -134,9 +134,8 @@ namespace AMDiS { ...@@ -134,9 +134,8 @@ namespace AMDiS {
vectors(rhs.vectors.getSize()) vectors(rhs.vectors.getSize())
{ {
int i; for (int i = 0; i < vectors.getSize();i++) {
for (i=0;i<vectors.getSize();i++) { vectors[i] = new DOFVector<double>(*rhs.vectors[i]);
vectors[i]=new DOFVector<double>(*rhs.vectors[i]);
} }
}; };
......
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