Commit 16575fa9 authored by Thomas Witkowski's avatar Thomas Witkowski
Browse files

Serialization works for different fe spaces.

parent 63d15da1
...@@ -82,13 +82,13 @@ AR="ar" ...@@ -82,13 +82,13 @@ AR="ar"
AR_FLAGS="cru" AR_FLAGS="cru"
# A C compiler. # A C compiler.
LTCC="/usr/lib/openmpi/1.2.7-gcc//bin/mpicc" LTCC="gcc"
# LTCC compiler flags. # LTCC compiler flags.
LTCFLAGS="-g -O2" LTCFLAGS="-g -O2"
# A language-specific compiler. # A language-specific compiler.
CC="/usr/lib/openmpi/1.2.7-gcc//bin/mpicc" CC="gcc"
# Is the compiler the GNU C compiler? # Is the compiler the GNU C compiler?
with_gcc=yes with_gcc=yes
...@@ -174,7 +174,7 @@ dlopen_self=unknown ...@@ -174,7 +174,7 @@ dlopen_self=unknown
dlopen_self_static=unknown dlopen_self_static=unknown
# Compiler flag to prevent dynamic linking. # Compiler flag to prevent dynamic linking.
link_static_flag="" link_static_flag="-static"
# Compiler flag to turn off builtin functions. # Compiler flag to turn off builtin functions.
no_builtin_flag=" -fno-builtin" no_builtin_flag=" -fno-builtin"
...@@ -6801,13 +6801,13 @@ AR="ar" ...@@ -6801,13 +6801,13 @@ AR="ar"
AR_FLAGS="cru" AR_FLAGS="cru"
# A C compiler. # A C compiler.
LTCC="/usr/lib/openmpi/1.2.7-gcc//bin/mpicc" LTCC="gcc"
# LTCC compiler flags. # LTCC compiler flags.
LTCFLAGS="-g -O2" LTCFLAGS="-g -O2"
# A language-specific compiler. # A language-specific compiler.
CC="/usr/lib/openmpi/1.2.7-gcc//bin/mpiCC" CC="g++"
# Is the compiler the GNU C compiler? # Is the compiler the GNU C compiler?
with_gcc=yes with_gcc=yes
...@@ -6893,7 +6893,7 @@ dlopen_self=unknown ...@@ -6893,7 +6893,7 @@ dlopen_self=unknown
dlopen_self_static=unknown dlopen_self_static=unknown
# Compiler flag to prevent dynamic linking. # Compiler flag to prevent dynamic linking.
link_static_flag="" link_static_flag="-static"
# Compiler flag to turn off builtin functions. # Compiler flag to turn off builtin functions.
no_builtin_flag=" -fno-builtin" no_builtin_flag=" -fno-builtin"
...@@ -6960,11 +6960,11 @@ predeps="" ...@@ -6960,11 +6960,11 @@ predeps=""
# Dependencies to place after the objects being linked to create a # Dependencies to place after the objects being linked to create a
# shared library. # shared library.
postdeps="-lmpi_cxx -lmpi -lopen-rte -lopen-pal -ldl -lnsl -lutil -ldl -lstdc++ -lm -lgcc_s -lpthread -lc -lgcc_s" postdeps="-lstdc++ -lm -lgcc_s -lc -lgcc_s"
# The library search path used internally by the compiler when linking # The library search path used internally by the compiler when linking
# a shared library. # a shared library.
compiler_lib_search_path=`echo "-L/usr/lib/openmpi/1.2.7-gcc/lib -L/usr/lib/gcc/i386-redhat-linux/4.1.2 -L/usr/lib/gcc/i386-redhat-linux/4.1.2 -L/usr/lib/gcc/i386-redhat-linux/4.1.2/../../.." | $SED -e "s@${gcc_dir}@\${gcc_dir}@g;s@${gcc_ver}@\${gcc_ver}@g"` compiler_lib_search_path=`echo "-L/usr/lib/gcc/i386-redhat-linux/4.1.2 -L/usr/lib/gcc/i386-redhat-linux/4.1.2 -L/usr/lib/gcc/i386-redhat-linux/4.1.2/../../.." | $SED -e "s@${gcc_dir}@\${gcc_dir}@g;s@${gcc_ver}@\${gcc_ver}@g"`
# Method to check whether dependent libraries are shared objects. # Method to check whether dependent libraries are shared objects.
deplibs_check_method="pass_all" deplibs_check_method="pass_all"
...@@ -7109,7 +7109,7 @@ AR="ar" ...@@ -7109,7 +7109,7 @@ AR="ar"
AR_FLAGS="cru" AR_FLAGS="cru"
# A C compiler. # A C compiler.
LTCC="/usr/lib/openmpi/1.2.7-gcc//bin/mpicc" LTCC="gcc"
# LTCC compiler flags. # LTCC compiler flags.
LTCFLAGS="-g -O2" LTCFLAGS="-g -O2"
......
...@@ -79,7 +79,7 @@ namespace AMDiS { ...@@ -79,7 +79,7 @@ namespace AMDiS {
int edgeNo = oppVertex_[i] = mel->getOppVertex(i); int edgeNo = oppVertex_[i] = mel->getOppVertex(i);
if (nb->getFirstChild() && (edgeNo != 2)) { if (nb->getFirstChild() && edgeNo != 2) {
// Search for the next neighbour. In many cases, the neighbour element // Search for the next neighbour. In many cases, the neighbour element
// may be refinemed in a way, such that there is no new vertex on the // may be refinemed in a way, such that there is no new vertex on the
...@@ -113,6 +113,7 @@ namespace AMDiS { ...@@ -113,6 +113,7 @@ namespace AMDiS {
// ------- // -------
// //
// nb el // nb el
//
// That means, the edge 0 of the same level neighbour is the common // That means, the edge 0 of the same level neighbour is the common
// edge, i.e., the direct neighbour is the second child of the same // edge, i.e., the direct neighbour is the second child of the same
// level neighbour. // level neighbour.
...@@ -178,10 +179,21 @@ namespace AMDiS { ...@@ -178,10 +179,21 @@ namespace AMDiS {
break; break;
case 2: case 2:
if (*(macroNeighbour->getElement()->getDOF(2)) == *(element_->getDOF(0))) {
neighbourCoord_[i][0] = macroNeighbour->coord[2];
neighbourCoord_[i][1] = macroNeighbour->coord[1];
} else if (*(macroNeighbour->getElement()->getDOF(2)) == *(element_->getDOF(1))) {
neighbourCoord_[i][0] = macroNeighbour->coord[0];
neighbourCoord_[i][1] = macroNeighbour->coord[2];
} else {
ERROR_EXIT("Should not happen!\n");
}
// I've deleted here some code, be I think that this case is not // I've deleted here some code, be I think that this case is not
// possible. If an error occurs in this line, please check AMDiS // possible. If an error occurs in this line, please check AMDiS
// revision <= 476 at the same position. // revision <= 476 at the same position.
ERROR_EXIT("Should not happen!\n"); // ERROR_EXIT("Should not happen!\n");
break; break;
default: default:
......
...@@ -156,14 +156,16 @@ namespace AMDiS { ...@@ -156,14 +156,16 @@ namespace AMDiS {
if (ndof > 0) { if (ndof > 0) {
for (int i = 0; i < mesh->getGeo(position); i++) { for (int i = 0; i < mesh->getGeo(position); i++) {
if (dof[j] != NULL) { if (dof[j] != NULL) {
if (Mesh::serializedDOFs[dof[j][0]] == NULL) { std::pair<DegreeOfFreedom, int> idx = std::make_pair(dof[j][0], pos);
if (Mesh::serializedDOFs[idx] == NULL) {
el->dof[j] = new DegreeOfFreedom[ndof]; el->dof[j] = new DegreeOfFreedom[ndof];
for (int k = 0; k < ndof; k++) for (int k = 0; k < ndof; k++)
el->dof[j][k] = dof[j][k]; el->dof[j][k] = dof[j][k];
Mesh::serializedDOFs[dof[j][0]] = el->dof[j]; Mesh::serializedDOFs[idx] = el->dof[j];
} else { } else {
el->dof[j] = Mesh::serializedDOFs[dof[j][0]]; el->dof[j] = Mesh::serializedDOFs[idx];
} }
} else { } else {
el->dof[j] = NULL; el->dof[j] = NULL;
...@@ -175,12 +177,10 @@ namespace AMDiS { ...@@ -175,12 +177,10 @@ namespace AMDiS {
/* =========== And clone the children ============= */ /* =========== And clone the children ============= */
if (child[0]) { if (child[0])
el->child[0] = child[0]->cloneWithDOFs(); el->child[0] = child[0]->cloneWithDOFs();
} if (child[1])
if (child[1]) {
el->child[1] = child[1]->cloneWithDOFs(); el->child[1] = child[1]->cloneWithDOFs();
}
return el; return el;
} }
...@@ -264,7 +264,7 @@ namespace AMDiS { ...@@ -264,7 +264,7 @@ namespace AMDiS {
int edges = mesh->getGeo(EDGE); int edges = mesh->getGeo(EDGE);
int faces = mesh->getGeo(FACE); int faces = mesh->getGeo(FACE);
if ((nd = admin->getNumberOfDOFs(VERTEX))) { if (nd = admin->getNumberOfDOFs(VERTEX)) {
nd0 = admin->getNumberOfPreDOFs(VERTEX); nd0 = admin->getNumberOfPreDOFs(VERTEX);
n0 = admin->getMesh()->getNode(VERTEX); n0 = admin->getMesh()->getNode(VERTEX);
for (i = 0; i < vertices; i++) { for (i = 0; i < vertices; i++) {
...@@ -273,7 +273,7 @@ namespace AMDiS { ...@@ -273,7 +273,7 @@ namespace AMDiS {
} }
if (mesh->getDim() > 1) { if (mesh->getDim() > 1) {
if ((nd = admin->getNumberOfDOFs(EDGE))) { if (nd = admin->getNumberOfDOFs(EDGE)) {
nd0 = admin->getNumberOfPreDOFs(EDGE); nd0 = admin->getNumberOfPreDOFs(EDGE);
n0 = admin->getMesh()->getNode(EDGE); n0 = admin->getMesh()->getNode(EDGE);
for (i = 0; i < edges; i++) { for (i = 0; i < edges; i++) {
...@@ -283,7 +283,7 @@ namespace AMDiS { ...@@ -283,7 +283,7 @@ namespace AMDiS {
} }
if (mesh->getDim() == 3) { if (mesh->getDim() == 3) {
if ((nd = admin->getNumberOfDOFs(FACE))) { if (nd = admin->getNumberOfDOFs(FACE)) {
nd0 = admin->getNumberOfPreDOFs(FACE); nd0 = admin->getNumberOfPreDOFs(FACE);
n0 = admin->getMesh()->getNode(FACE); n0 = admin->getMesh()->getNode(FACE);
for (i = 0; i < faces; i++) { for (i = 0; i < faces; i++) {
...@@ -292,10 +292,11 @@ namespace AMDiS { ...@@ -292,10 +292,11 @@ namespace AMDiS {
} }
} }
if ((nd = admin->getNumberOfDOFs(CENTER))) { if (nd = admin->getNumberOfDOFs(CENTER)) {
nd0 = admin->getNumberOfPreDOFs(CENTER); nd0 = admin->getNumberOfPreDOFs(CENTER);
n0 = admin->getMesh()->getNode(CENTER); n0 = admin->getMesh()->getNode(CENTER);
i = 0; /* only one center */ // only one center
i = 0;
CHANGE_DOFS_2(this); CHANGE_DOFS_2(this);
} }
} }
...@@ -389,18 +390,26 @@ namespace AMDiS { ...@@ -389,18 +390,26 @@ namespace AMDiS {
if (ndof > 0) { if (ndof > 0) {
for (int i = 0; i < mesh->getGeo(position); i++) { for (int i = 0; i < mesh->getGeo(position); i++) {
if (dof[j] != NULL) { if (dof[j] != NULL) {
if (Mesh::serializedDOFs[dof[j][0]] == NULL) { // Create index to check if the dofs were already written.
Mesh::serializedDOFs[dof[j][0]] = dof[j]; std::pair<DegreeOfFreedom, int> idx = std::make_pair(dof[j][0], pos);
if (Mesh::serializedDOFs[idx] == NULL) {
Mesh::serializedDOFs[idx] = dof[j];
out.write(reinterpret_cast<const char*>(&ndof), sizeof(int)); out.write(reinterpret_cast<const char*>(&ndof), sizeof(int));
out.write(reinterpret_cast<const char*>(dof[j]), ndof * sizeof(DegreeOfFreedom)); out.write(reinterpret_cast<const char*>(&pos), sizeof(int));
out.write(reinterpret_cast<const char*>(dof[j]),
ndof * sizeof(DegreeOfFreedom));
} else { } else {
int minusOne = -1; int minusOne = -1;
out.write(reinterpret_cast<const char*>(&minusOne), sizeof(int)); out.write(reinterpret_cast<const char*>(&minusOne), sizeof(int));
out.write(reinterpret_cast<const char*>(&(dof[j][0])), sizeof(DegreeOfFreedom)); out.write(reinterpret_cast<const char*>(&pos), sizeof(int));
out.write(reinterpret_cast<const char*>(&(dof[j][0])),
sizeof(DegreeOfFreedom));
} }
} else { } else {
int zero = 0; int zero = 0;
out.write(reinterpret_cast<const char*>(&zero), sizeof(int)); out.write(reinterpret_cast<const char*>(&zero), sizeof(int));
out.write(reinterpret_cast<const char*>(&pos), sizeof(int));
} }
j++; j++;
} }
...@@ -466,32 +475,35 @@ namespace AMDiS { ...@@ -466,32 +475,35 @@ namespace AMDiS {
dof = new DegreeOfFreedom*[nodes]; dof = new DegreeOfFreedom*[nodes];
// std::cout << "-- n = " << nodes << std::endl;
for (int i = 0; i < nodes; i++) { for (int i = 0; i < nodes; i++) {
int nDofs; int nDofs, pos;
in.read(reinterpret_cast<char*>(&nDofs), sizeof(int)); in.read(reinterpret_cast<char*>(&nDofs), sizeof(int));
in.read(reinterpret_cast<char*>(&pos), sizeof(int));
// std::cout << "d = " << nDofs << std::endl;
if (nDofs) { if (nDofs) {
if (nDofs != -1) { if (nDofs != -1) {
dof[i] = new DegreeOfFreedom[nDofs]; dof[i] = new DegreeOfFreedom[nDofs];
in.read(reinterpret_cast<char*>(dof[i]), nDofs * sizeof(DegreeOfFreedom)); in.read(reinterpret_cast<char*>(dof[i]), nDofs * sizeof(DegreeOfFreedom));
if (Mesh::serializedDOFs[dof[i][0]] != NULL) {
DegreeOfFreedom *dofPtr = Mesh::serializedDOFs[dof[i][0]]; // Create index to check if the dofs were alread read from file.
std::pair<DegreeOfFreedom, int> idx = std::make_pair(dof[i][0], pos);
if (Mesh::serializedDOFs[idx] != NULL) {
DegreeOfFreedom *dofPtr = Mesh::serializedDOFs[idx];
delete [] dof[i]; delete [] dof[i];
dof[i] = dofPtr; dof[i] = dofPtr;
} else { } else {
Mesh::serializedDOFs[dof[i][0]] = dof[i]; Mesh::serializedDOFs[idx] = dof[i];
} }
} else { } else {
DegreeOfFreedom index; DegreeOfFreedom index;
in.read(reinterpret_cast<char*>(&index), sizeof(DegreeOfFreedom)); in.read(reinterpret_cast<char*>(&index), sizeof(DegreeOfFreedom));
TEST_EXIT(Mesh::serializedDOFs.find(index) != Mesh::serializedDOFs.end())
std::pair<DegreeOfFreedom, int> idx = std::make_pair(index, pos);
TEST_EXIT(Mesh::serializedDOFs.find(idx) != Mesh::serializedDOFs.end())
("This should never happen!\n"); ("This should never happen!\n");
dof[i] = Mesh::serializedDOFs[index]; dof[i] = Mesh::serializedDOFs[idx];
// std::cout << "i = " << index << " " << Mesh::serializedDOFs[index] << " " << Mesh::serializedDOFs[index][0] << std::endl;
} }
} else { } else {
dof[i] = NULL; dof[i] = NULL;
...@@ -501,8 +513,6 @@ namespace AMDiS { ...@@ -501,8 +513,6 @@ namespace AMDiS {
// read index // read index
in.read(reinterpret_cast<char*>(&index), sizeof(int)); in.read(reinterpret_cast<char*>(&index), sizeof(int));
// std::cout << "index = " << index << std::endl;
// read mark // read mark
in.read(reinterpret_cast<char*>(&mark), sizeof(signed char)); in.read(reinterpret_cast<char*>(&mark), sizeof(signed char));
...@@ -527,11 +537,11 @@ namespace AMDiS { ...@@ -527,11 +537,11 @@ namespace AMDiS {
if (typeName != "NULL") { if (typeName != "NULL") {
elementData = CreatorMap<ElementData>::getCreator(typeName)->create(); elementData = CreatorMap<ElementData>::getCreator(typeName)->create();
if (elementData) {
if (elementData)
elementData->deserialize(in); elementData->deserialize(in);
} else { else
ERROR_EXIT("unexpected type name\n"); ERROR_EXIT("unexpected type name\n");
}
} else { } else {
elementData = NULL; elementData = NULL;
} }
...@@ -544,9 +554,8 @@ namespace AMDiS { ...@@ -544,9 +554,8 @@ namespace AMDiS {
result += sizeof(Element); result += sizeof(Element);
result += mesh->getNumberOfNodes() * sizeof(DegreeOfFreedom*); result += mesh->getNumberOfNodes() * sizeof(DegreeOfFreedom*);
if (child[0]) { if (child[0])
result += child[0]->calcMemoryUsage() + child[1]->calcMemoryUsage(); result += child[0]->calcMemoryUsage() + child[1]->calcMemoryUsage();
}
return result; return result;
} }
......
...@@ -66,7 +66,7 @@ namespace AMDiS { ...@@ -66,7 +66,7 @@ namespace AMDiS {
Mesh* Mesh::traversePtr = NULL; Mesh* Mesh::traversePtr = NULL;
std::vector<DegreeOfFreedom> Mesh::dof_used; std::vector<DegreeOfFreedom> Mesh::dof_used;
const int Mesh::MAX_DOF = 100; const int Mesh::MAX_DOF = 100;
std::map<DegreeOfFreedom, DegreeOfFreedom*> Mesh::serializedDOFs; std::map<std::pair<DegreeOfFreedom, int>, DegreeOfFreedom*> Mesh::serializedDOFs;
struct delmem { struct delmem {
DegreeOfFreedom* ptr; DegreeOfFreedom* ptr;
...@@ -894,6 +894,39 @@ namespace AMDiS { ...@@ -894,6 +894,39 @@ namespace AMDiS {
return found; return found;
} }
bool Mesh::getDofIndexCoords(DegreeOfFreedom dof,
const FiniteElemSpace* feSpace,
WorldVector<double>& coords)
{
DimVec<double>* baryCoords;
bool found = false;
TraverseStack stack;
Vector<DegreeOfFreedom> dofVec(feSpace->getBasisFcts()->getNumber());
ElInfo *elInfo = stack.traverseFirst(this, -1,
Mesh::CALL_LEAF_EL | Mesh::FILL_COORDS);
while (elInfo) {
feSpace->getBasisFcts()->getLocalIndicesVec(elInfo->getElement(),
feSpace->getAdmin(),
&dofVec);
for (int i = 0; i < feSpace->getBasisFcts()->getNumber(); i++) {
if (dofVec[i] == dof) {
baryCoords = feSpace->getBasisFcts()->getCoords(i);
elInfo->coordToWorld(*baryCoords, coords);
found = true;
break;
}
}
if (found)
break;
elInfo = stack.traverseNext(elInfo);
}
return found;
}
void Mesh::setDiameter(const WorldVector<double>& w) void Mesh::setDiameter(const WorldVector<double>& w)
{ {
diam = w; diam = w;
......
...@@ -502,6 +502,9 @@ namespace AMDiS { ...@@ -502,6 +502,9 @@ namespace AMDiS {
const FiniteElemSpace* feSpace, const FiniteElemSpace* feSpace,
WorldVector<double>& coords); WorldVector<double>& coords);
bool getDofIndexCoords(DegreeOfFreedom dof,
const FiniteElemSpace* feSpace,
WorldVector<double>& coords);
/// Returns FILL_ANY_?D /// Returns FILL_ANY_?D
inline static const Flag& getFillAnyFlag(int dim) inline static const Flag& getFillAnyFlag(int dim)
...@@ -749,8 +752,17 @@ namespace AMDiS { ...@@ -749,8 +752,17 @@ namespace AMDiS {
/// Used by check functions /// Used by check functions
static std::vector<DegreeOfFreedom> dof_used; static std::vector<DegreeOfFreedom> dof_used;
/// /** \brief
static std::map<DegreeOfFreedom, DegreeOfFreedom*> serializedDOFs; * This map is used for serialization and deserialization of mesh elements.
* During the serialization process, all elements are visited and their dof indices
* are written to the file. If a dof index at a position, i.e. vertex, line or face,
* was written to file, the combination of dof index and position is inserted to
* this map. That ensures that the same dof at the same position, but being part of
* another element, is not written twice to the file.
* When a state should be deserialized, the information can be used to construct
* exactly the same dof structure.
*/
static std::map<std::pair<DegreeOfFreedom, int>, DegreeOfFreedom*> serializedDOFs;
/** \brief /** \brief
* Used while mesh refinement. To create new elements * Used while mesh refinement. To create new elements
......
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