Liebe Gitlab-Nutzerin, lieber Gitlab-Nutzer,
es ist nun möglich sich mittels des ZIH-Logins/LDAP an unserem Dienst anzumelden. Die Konten der externen Nutzer:innen sind über den Reiter "Standard" erreichbar.
Die Administratoren


Dear Gitlab user,
it is now possible to log in to our service using the ZIH login/LDAP. The accounts of external users can be accessed via the "Standard" tab.
The administrators

Commit 1a6ac357 authored by Thomas Witkowski's avatar Thomas Witkowski
Browse files

Modified Serializer for parallel serialization.

parent ded81b7f
......@@ -7,32 +7,31 @@ namespace AMDiS {
Element* otherChild,
int elTypeParent)
{
if (decorated_) {
PartitionElementData* ped=NULL;
ped=dynamic_cast<PartitionElementData*> (thisChild->getElementData(PARTITION_ED));
ped=NULL;
ped=dynamic_cast<PartitionElementData*> (otherChild->getElementData(PARTITION_ED));
ped=NULL;
ped=dynamic_cast<PartitionElementData*> (parent->getElementData(PARTITION_ED));
decorated_->coarsenElementData(parent, thisChild, otherChild, elTypeParent);
delete decorated_;
decorated_ = NULL;
if (decorated) {
PartitionElementData* ped = NULL;
ped = dynamic_cast<PartitionElementData*>(thisChild->getElementData(PARTITION_ED));
ped = NULL;
ped = dynamic_cast<PartitionElementData*>(otherChild->getElementData(PARTITION_ED));
ped = NULL;
ped = dynamic_cast<PartitionElementData*> (parent->getElementData(PARTITION_ED));
decorated->coarsenElementData(parent, thisChild, otherChild, elTypeParent);
delete decorated;
decorated = NULL;
}
}
bool ElementData::deleteDecorated(int typeID)
{
if (decorated_) {
if (decorated_->isOfType(typeID)) {
ElementData *tmp = decorated_;
decorated_ = decorated_->decorated_;
if (decorated) {
if (decorated->isOfType(typeID)) {
ElementData *tmp = decorated;
decorated = decorated->decorated;
delete tmp;
tmp = NULL;
return true;
} else {
return decorated_->deleteDecorated(typeID);
return decorated->deleteDecorated(typeID);
}
}
return false;
......@@ -40,9 +39,9 @@ namespace AMDiS {
void ElementData::deleteDecorated()
{
if (decorated_) {
decorated_->deleteDecorated();
delete decorated_;
if (decorated) {
decorated->deleteDecorated();
delete decorated;
}
}
......@@ -53,10 +52,10 @@ namespace AMDiS {
void ElementData::serialize(std::ostream& out)
{
std::string decoratedType;
if (decorated_) {
decoratedType = decorated_->getTypeName();
if (decorated) {
decoratedType = decorated->getTypeName();
out << decoratedType << "\n";
decorated_->serialize(out);
decorated->serialize(out);
} else {
out << "NULL\n";
}
......@@ -64,16 +63,16 @@ namespace AMDiS {
void ElementData::deserialize(std::istream& in)
{
TEST_EXIT(decorated_ == NULL)
TEST_EXIT(decorated == NULL)
("there are already decorated element data\n");
std::string decoratedType;
in >> decoratedType;
in.get();
if (decoratedType != "NULL") {
decorated_ = CreatorMap<ElementData>::getCreator(decoratedType)->create();
decorated_->deserialize(in);
decorated = CreatorMap<ElementData>::getCreator(decoratedType)->create();
decorated->deserialize(in);
} else {
decorated_ = NULL;
decorated = NULL;
}
}
......
......@@ -43,8 +43,8 @@ namespace AMDiS {
{
public:
/// constructor
ElementData(ElementData *decorated = NULL)
: decorated_(decorated)
ElementData(ElementData *dec = NULL)
: decorated(dec)
{}
/// destructor
......@@ -56,14 +56,14 @@ namespace AMDiS {
Element* child2,
int elType)
{
if (decorated_) {
if (decorated) {
bool remove =
decorated_->refineElementData(parent, child1, child2, elType);
decorated->refineElementData(parent, child1, child2, elType);
if (remove) {
ElementData *tmp = decorated_->decorated_;
delete decorated_;
decorated_ = tmp;
ElementData *tmp = decorated->decorated;
delete decorated;
decorated = tmp;
}
}
return false;
......@@ -78,8 +78,8 @@ namespace AMDiS {
/// Returns a copy of this ElementData object including all decorated data.
virtual ElementData *clone() const
{
if (decorated_)
return decorated_->clone();
if (decorated)
return decorated->clone();
return NULL;
}
......@@ -108,32 +108,32 @@ namespace AMDiS {
if (this->isOfType(typeID)) {
return this;
} else {
if (decorated_)
return decorated_->getElementData(typeID);
if (decorated)
return decorated->getElementData(typeID);
}
return NULL;
}
inline ElementData *getDecorated(int typeID)
{
if (decorated_)
return decorated_->getElementData(typeID);
if (decorated)
return decorated->getElementData(typeID);
return NULL;
}
/** \ref
* Search the \ref decorated_ chain for a specific type ID, and delets
* Search the \ref decorated chain for a specific type ID, and delets
* this entry.
*/
bool deleteDecorated(int typeID);
/// Delets the whole \ref decorated_ chain.
/// Delets the whole \ref decorated chain.
void deleteDecorated();
inline ElementData *getDecorated()
{
return decorated_;
return decorated;
}
inline void setDecorated(ElementData *d)
......@@ -142,12 +142,12 @@ namespace AMDiS {
if (d != NULL)
std::cout << "leafdata decorated with nonzero" << std::endl;
decorated_ = d;
decorated = d;
}
protected:
/// Pointer to next ElementData object in the chain of responsibility.
ElementData *decorated_;
ElementData *decorated;
};
}
......
......@@ -17,10 +17,10 @@
// == ==
// ============================================================================
/** \file ElementRegion_ED.h */
/** \file ElementRegionED.h */
#ifndef AMDIS_ELEMENTREGION_ED_H
#define AMDIS_ELEMENTREGION_ED_H
#ifndef AMDIS_ELEMENTREGIONED_H
#define AMDIS_ELEMENTREGIONED_H
#include "ElementData.h"
#include "FixVec.h"
......@@ -48,7 +48,7 @@ namespace AMDiS {
ElementRegion_ED(ElementData *decorated = NULL)
: ElementData(decorated),
region_(-1)
region(-1)
{}
bool refineElementData(Element* parent,
......@@ -61,11 +61,11 @@ namespace AMDiS {
ElementRegion_ED *ep;
ep = new ElementRegion_ED(child1->getElementData());
ep->region_ = region_;
ep->region = region;
child1->setElementData(ep);
ep = new ElementRegion_ED(child2->getElementData());
ep->region_ = region_;
ep->region = region;
child2->setElementData(ep);
return false;
......@@ -74,14 +74,14 @@ namespace AMDiS {
ElementData *clone() const
{
ElementRegion_ED *newObj = new ElementRegion_ED;
newObj->region_ = region_;
newObj->decorated_ = ElementData::clone();
newObj->region = region;
newObj->decorated = ElementData::clone();
return newObj;
}
inline std::string getTypeName() const
{
return "ElementRegion_ED";
return "ElementRegionED";
}
inline const int getTypeID() const
......@@ -92,27 +92,27 @@ namespace AMDiS {
void serialize(std::ostream& out)
{
ElementData::serialize(out);
out.write(reinterpret_cast<const char*>(&region_), sizeof(int));
out.write(reinterpret_cast<const char*>(&region), sizeof(int));
}
void deserialize(std::istream& in)
{
ElementData::deserialize(in);
in.read(reinterpret_cast<char*>(&region_), sizeof(int));
in.read(reinterpret_cast<char*>(&region), sizeof(int));
}
inline void setRegion(int region)
inline void setRegion(int r)
{
region_ = region;
region = r;
}
inline int getRegion() const
{
return region_;
return region;
}
protected:
int region_;
int region;
};
}
......
......@@ -102,7 +102,7 @@ namespace AMDiS {
newObj->errorEstimate = errorEstimate;
// clone decorated element data (=> deep copy)
newObj->decorated_ = ElementData::clone();
newObj->decorated = ElementData::clone();
// return the clone
return newObj;
......@@ -193,7 +193,7 @@ namespace AMDiS {
newObj->errorEstimate = errorEstimate;
// clone decorated element data (=> deep copy)
newObj->decorated_ = ElementData::clone();
newObj->decorated = ElementData::clone();
// return the clone
return newObj;
......@@ -298,7 +298,7 @@ namespace AMDiS {
LeafDataCoarsenable *newObj = new LeafDataCoarsenable(NULL);
// clone decorated element data (=> deep copy)
newObj->decorated_ = ElementData::clone();
newObj->decorated = ElementData::clone();
// return the clone
return newObj;
......@@ -377,7 +377,7 @@ namespace AMDiS {
newObj->coarseningError = coarseningError;
// clone decorated leaf data (=> deep copy)
newObj->decorated_ = ElementData::clone();
newObj->decorated = ElementData::clone();
// return the clone
return newObj;
......@@ -547,7 +547,7 @@ namespace AMDiS {
inline ElementData *clone() const
{
LeafDataPeriodic *newObj = new LeafDataPeriodic;
newObj->decorated_ = ElementData::clone();
newObj->decorated = ElementData::clone();
return newObj;
}
......
......@@ -14,6 +14,12 @@ namespace AMDiS {
probScal(problem)
{
info = problem->getInfo();
// Create parallel serialization file writer, if needed.
int writeSerialization = 0;
GET_PARAMETER(0, name + "->output->write serialization", "%d", &writeSerialization);
if (writeSerialization)
problem->getFileWriterList().push_back(new Serializer<ParallelDomainScal>(this));
}
void ParallelDomainScal::initParallelization(AdaptInfo *adaptInfo)
......
......@@ -23,6 +23,7 @@
#define AMDIS_PARALLELDOMAINSCAL_H
#include "ParallelDomainBase.h"
#include "ProblemScal.h"
namespace AMDiS {
......@@ -34,6 +35,20 @@ namespace AMDiS {
void initParallelization(AdaptInfo *adaptInfo);
// Writes all data of this object to an output stream.
virtual void serialize(std::ostream &out)
{
probScal->serialize(out);
ParallelDomainBase::serialize(out);
}
// Reads the object data from an input stream.
virtual void deserialize(std::istream &in)
{
probScal->deserialize(in);
ParallelDomainBase::deserialize(in);
}
protected:
/// Starts the solution of the linear system using Petsc.
void solve();
......
......@@ -2,6 +2,7 @@
#include "ProblemVec.h"
#include "ProblemInstat.h"
#include "SystemVector.h"
#include "Serializer.h"
namespace AMDiS {
......@@ -18,10 +19,18 @@ namespace AMDiS {
info = probVec->getInfo();
nComponents = probVec->getNumComponents();
// Test if all fe spaces are equal. Yet, different fe spaces are not supported for
// domain parallelization.
const FiniteElemSpace *fe = probVec->getFESpace(0);
for (int i = 0; i < nComponents; i++)
TEST_EXIT(fe == probVec->getFESpace(i))
("Parallelization does not supported different FE spaces!\n");
// Create parallel serialization file writer, if needed.
int writeSerialization = 0;
GET_PARAMETER(0, name + "->output->write serialization", "%d", &writeSerialization);
if (writeSerialization)
problem->getFileWriterList().push_back(new Serializer<ParallelDomainVec>(this));
}
......
......@@ -42,6 +42,20 @@ namespace AMDiS {
synchVectors(*(probVec->getSolution()));
}
// Writes all data of this object to an output stream.
virtual void serialize(std::ostream &out)
{
probVec->serialize(out);
ParallelDomainBase::serialize(out);
}
// Reads the object data from an input stream.
virtual void deserialize(std::istream &in)
{
probVec->deserialize(in);
ParallelDomainBase::deserialize(in);
}
protected:
/// Starts the solution of the linear system using Petsc.
void solve();
......
......@@ -40,16 +40,18 @@ namespace AMDiS {
class PartitionElementData : public ElementData
{
public:
inline bool isOfType(int typeID) const {
inline bool isOfType(int typeID) const
{
if (typeID == PARTITION_ED)
return true;
return true;
return false;
}
class Creator : public CreatorInterface<ElementData>
{
public:
ElementData* create() {
ElementData* create()
{
return new PartitionElementData;
}
};
......@@ -68,10 +70,12 @@ namespace AMDiS {
Element* child2,
int elType)
{
ElementData::refineElementData(parent, child1, child2, elType);
ElementData::refineElementData(parent, child1, child2, elType);
PartitionElementData *child1Data = new PartitionElementData(child1->getElementData());
PartitionElementData *child2Data = new PartitionElementData(child2->getElementData());
PartitionElementData *child1Data =
new PartitionElementData(child1->getElementData());
PartitionElementData *child2Data =
new PartitionElementData(child2->getElementData());
child1Data->setPartitionStatus(status);
child2Data->setPartitionStatus(status);
child1Data->setLevel(level + 1);
......@@ -79,51 +83,58 @@ namespace AMDiS {
child1->setElementData(child1Data);
child2->setElementData(child2Data);
return false;
};
}
ElementData *clone() const {
ElementData *clone() const
{
PartitionElementData *newObj = new PartitionElementData;
newObj->decorated_ = ElementData::clone();
newObj->decorated = ElementData::clone();
return newObj;
};
}
inline std::string getTypeName() const {
inline std::string getTypeName() const
{
return "PartitionElementData";
};
}
inline const int getTypeID() const {
inline const int getTypeID() const
{
return PARTITION_ED;
};
}
void serialize(std::ostream& out)
{
ElementData::serialize(out);
out.write(reinterpret_cast<const char*>(&status), sizeof(PartitionStatus));
out.write(reinterpret_cast<const char*>(&level), sizeof(int));
};
}
void deserialize(std::istream& in)
{
ElementData::deserialize(in);
in.read(reinterpret_cast<char*>(&status), sizeof(PartitionStatus));
in.read(reinterpret_cast<char*>(&level), sizeof(int));
};
}
inline void setPartitionStatus(PartitionStatus status_) {
inline void setPartitionStatus(PartitionStatus status_)
{
status = status_;
};
}
inline PartitionStatus getPartitionStatus() {
inline PartitionStatus getPartitionStatus()
{
return status;
};
}
inline void setLevel(int level_) {
level = level_;
};
inline void setLevel(int l)
{
level = l;
}
inline int getLevel() {
inline int getLevel()
{
return level;
};
}
void descend(Element *element)
{
......@@ -145,7 +156,7 @@ namespace AMDiS {
child0Data->descend(child0);
child1Data->descend(child1);
}
};
}
protected:
PartitionStatus status;
......
......@@ -186,7 +186,7 @@ namespace AMDiS {
/// Adds robin boundary conditions.
virtual void addRobinBC(BoundaryType type,
DOFVector<double> *n,
DOFVector<double> *n,
DOFVector<double> *r);
/// Adds Neumann boundary conditions.
......@@ -317,7 +317,7 @@ namespace AMDiS {
virtual void deserialize(std::istream &in);
/// Returns \ref fileWriters.
std::vector<FileWriterInterface*> getFileWriterList()
std::vector<FileWriterInterface*>& getFileWriterList()
{
return fileWriters;
}
......
......@@ -40,11 +40,17 @@ namespace AMDiS {
tsModulo(1),
timestepNumber(-1)
{
GET_PARAMETER(0, problem->getName() + "->output->serialization filename",
&name);
GET_PARAMETER(0, problem->getName() + "->output->write every i-th timestep",
FUNCNAME("Serializer::Serializer()");
GET_PARAMETER(0, problem->getName() + "->output->serialization filename", &name);
GET_PARAMETER(0, problem->getName() + "->output->write every i-th timestep",
"%d", &tsModulo);
TEST_EXIT(name != "")("no filename\n");
#if HAVE_PARALLEL_DOMAIN_AMDIS
name += ".p";
name += MPI::COMM_WORLD.Get_rank();
#endif
}
virtual ~Serializer() {}
......
......@@ -30,7 +30,8 @@ namespace AMDiS {
class SurfaceRegion_ED : public ElementData
{
public:
inline bool isOfType(int typeID) const {
inline bool isOfType(int typeID) const
{
if (typeID == SURFACE_REGION)
return true;
return false;
......@@ -47,8 +48,8 @@ namespace AMDiS {
SurfaceRegion_ED(ElementData *decorated = NULL)
: ElementData(decorated),
side_(-1),
region_(-1)
side(-1),
region(-1)
{}
bool refineElementData(Element* parent,
......@@ -61,19 +62,19 @@ namespace AMDiS {
int sideOfChild;
SurfaceRegion_ED *surfaceRegion;
sideOfChild = parent->getSideOfChild(0, side_, elType);
sideOfChild = parent->getSideOfChild(0, side, elType);
if (sideOfChild >= 0) {
surfaceRegion = new SurfaceRegion_ED(child1->getElementData());
surfaceRegion->setSide(sideOfChild);
surfaceRegion->setRegion(region_);
surfaceRegion->setRegion(region);
child1->setElementData(surfaceRegion);
}
sideOfChild = parent->getSideOfChild(1, side_, elType);
sideOfChild = parent->getSideOfChild(1, side, elType);
if (sideOfChild >= 0) {
surfaceRegion = new SurfaceRegion_ED(child2->getElementData());
surfaceRegion->side_ = sideOfChild;
surfaceRegion->region_ = region_;
surfaceRegion->side = sideOfChild;
surfaceRegion->region = region;
child2->setElementData(surfaceRegion);
}
......@@ -83,9 +84,9 @@ namespace AMDiS {
ElementData *clone() const