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 {
::std::list<DOFIndexedBase*>::iterator di;
::std::list<DOFIndexedBase*>::iterator end = dofIndexedList.end();
for(di = dofIndexedList.begin(); di != end; ++di) {
if((*di)->getSize() < newval) {
for (di = dofIndexedList.begin(); di != end; ++di) {
if ((*di)->getSize() < newval) {
(*di)->resize(newval);
}
}
......@@ -183,7 +183,7 @@ namespace AMDiS {
FUNCNAME("DOFAdmin::addDOFIndexed");
TEST_EXIT(dofIndexed)("no dofIndexed\n");
if(dofIndexed->getSize() < size) {
if (dofIndexed->getSize() < size) {
dofIndexed->resize(size);
}
......@@ -192,32 +192,35 @@ namespace AMDiS {
void DOFAdmin::removeDOFIndexed(DOFIndexedBase* dofIndexed)
{
FUNCNAME("DOFAdmin::removeDOFIndexed");
FUNCNAME("DOFAdmin::removeDOFIndexed()");
::std::list<DOFIndexedBase*>::iterator it;
::std::list<DOFIndexedBase*>::iterator end = dofIndexedList.end();
for(it=dofIndexedList.begin(); it != end; ++it) {
if(*it == dofIndexed) {
for (it = dofIndexedList.begin(); it != end; ++it) {
if (*it == dofIndexed) {
dofIndexedList.erase(it);
return;
}
}
ERROR("DOFIndexed not in list\n");
}
void DOFAdmin::addDOFContainer(DOFContainer* cont)
{
FUNCNAME("DOFAdmin::addDOFContainer");
FUNCNAME("DOFAdmin::addDOFContainer()");
TEST_EXIT(cont)("no container\n");
dofContainerList.push_back(cont);
}
void DOFAdmin::removeDOFContainer(DOFContainer* cont)
{
FUNCNAME("DOFAdmin::removeDOFContainer");
FUNCNAME("DOFAdmin::removeDOFContainer()");
::std::list<DOFContainer*>::iterator it;
::std::list<DOFContainer*>::iterator end = dofContainerList.end();
for(it=dofContainerList.begin(); it != end; ++it) {
if(*it == cont) {
for (it = dofContainerList.begin(); it != end; ++it) {
if (*it == cont) {
dofContainerList.erase(it);
return;
}
......
......@@ -112,7 +112,9 @@ namespace AMDiS {
/** \brief
* 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
* Adds a DOFIndexedBase object to the DOFAdmin. This object will be
......
......@@ -315,12 +315,16 @@ namespace AMDiS {
/** \brief
* 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
* 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
* Used by DOFAdmin to compress this DOFVector. Implementation of
......@@ -332,7 +336,9 @@ namespace AMDiS {
/** \brief
* Sets \ref refineInter to b
*/
inline void refineInterpol(bool b) { refineInter = b; };
inline void refineInterpol(bool b) {
refineInter = b;
};
/** \brief
* Sets \ref coarsenOperation to op
......@@ -375,12 +381,16 @@ namespace AMDiS {
/** \brief
* Returns size of \ref vec
*/
inline int getSize() const { return vec.size();};
inline int getSize() const {
return vec.size();
};
/** \brief
* Returns used size of the vector.
*/
inline int getUsedSize() const { return feSpace->getAdmin()->getUsedSize(); };
inline int getUsedSize() const {
return feSpace->getAdmin()->getUsedSize();
};
/** \brief
* Resizes \ref vec to n
......@@ -409,7 +419,9 @@ namespace AMDiS {
return vec[i];
};
inline int getSize() { return vec.size(); };
inline int getSize() {
return vec.size();
};
/** \brief
* Returns \ref vec[i]
......
......@@ -25,17 +25,16 @@ namespace AMDiS {
const BoundaryType *bound,
bool add)
{
FUNCNAME("DOFVector::addElementVector");
DegreeOfFreedom i, irow;
FUNCNAME("DOFVector::addElementVector()");
int n_row = elVec.getSize();
for (i = 0; i < n_row; i++) {
for (DegreeOfFreedom i = 0; i < n_row; i++) {
BoundaryCondition *condition =
bound ? this->getBoundaryManager()->getBoundaryCondition(bound[i]) : NULL;
if(!(condition && condition->isDirichlet())) {
irow = elVec.dofIndices[i];
DegreeOfFreedom irow = elVec.dofIndices[i];
(*this)[irow] = (add ? (*this)[irow] : 0.0);
(*this)[irow] += factor * elVec[i];
}
......@@ -46,7 +45,8 @@ namespace AMDiS {
DOFVector<T>::DOFVector(const FiniteElemSpace* f,::std::string n)
: DOFVectorBase<T>(f, n),
//elementVector(NULL),
refineInter(false), coarsenOperation(NO_OPERATION)
refineInter(false),
coarsenOperation(NO_OPERATION)
{
init(f, n);
}
......@@ -56,7 +56,7 @@ namespace AMDiS {
{
name = n;
feSpace = f;
if(feSpace && feSpace->getAdmin()) {
if (feSpace && feSpace->getAdmin()) {
(feSpace->getAdmin())->addDOFIndexed(this);
}
this->boundaryManager = NEW BoundaryManager;
......@@ -65,7 +65,7 @@ namespace AMDiS {
template<typename T>
DOFVector<T>::~DOFVector()
{
if(feSpace && feSpace->getAdmin()) {
if (feSpace && feSpace->getAdmin()) {
(feSpace->getAdmin())->removeDOFIndexed(this);
}
......
......@@ -26,7 +26,6 @@ namespace AMDiS {
// === create vertex info vector ===
vertexInfos_ = NEW DOFVector< ::std::list<VertexInfo> >(feSpace, "vertex infos");
interpPointInd_ = NEW DOFVector<int>(feSpace, "interpolation point indices");
dofCoords_ = NEW DOFVector< ::std::list<WorldVector<double> > >(feSpace, "dof coords");
......
......@@ -18,21 +18,11 @@ namespace AMDiS {
Mesh *mesh_,
DOFVector<double> *vec)
: 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_)
{
FUNCNAME("FileWriter::FileWriter()");
initialize();
readParameters();
feSpace = vec->getFESpace();
......@@ -41,27 +31,16 @@ namespace AMDiS {
solutionVecs_[0] = vec;
}
FileWriter::FileWriter(const ::std::string &name_,
Mesh *mesh_,
::std::vector< DOFVector<double>* > vecs)
: 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_)
{
FUNCNAME("FileWriter::FileWriter()");
initialize();
readParameters();
for (int i = 0; i < static_cast<int>(vecs.size()); i++) {
......@@ -73,6 +52,69 @@ namespace AMDiS {
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()
{
FUNCNAME("FileWriter::readParamters()");
......@@ -136,7 +178,6 @@ namespace AMDiS {
}
}
if (writeTecPlotFormat) {
TecPlotWriter<DOFVector<double> >::writeValues(solutionVecs_[0],
const_cast<char*>((fn + tecplotExt).c_str()),
......
......@@ -128,10 +128,18 @@ namespace AMDiS {
Mesh *mesh_,
::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
* Destructor.
*/
virtual ~FileWriter() {};
virtual ~FileWriter();
/** \brief
* Implementation of FileWriterInterface::writeFiles().
......@@ -142,6 +150,11 @@ namespace AMDiS {
bool (*writeElem)(ElInfo*) = NULL);
protected:
/** \brief
* Initialization of the filewriter.
*/
void initialize();
/** \brief
* Reads all file writer dependend parameters from the init file.
*/
......@@ -237,11 +250,16 @@ namespace AMDiS {
const FiniteElemSpace *feSpace;
/** \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_;
/** \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 {
template<typename T>
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(v2.getSize() == result.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 in test v2 == result\n");
T *v1It, *v2It, *resultIt;
for (v1It = v1.begin(), v2It = v2.begin(), resultIt = result.begin();
v1It != v1.end();
......
......@@ -134,9 +134,8 @@ namespace AMDiS {
vectors(rhs.vectors.getSize())
{
int i;
for (i=0;i<vectors.getSize();i++) {
vectors[i]=new DOFVector<double>(*rhs.vectors[i]);
for (int i = 0; i < vectors.getSize();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