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"
AR_FLAGS="cru"
# A C compiler.
LTCC="/usr/lib/openmpi/1.2.7-gcc//bin/mpicc"
LTCC="gcc"
# LTCC compiler flags.
LTCFLAGS="-g -O2"
# A language-specific compiler.
CC="/usr/lib/openmpi/1.2.7-gcc//bin/mpicc"
CC="gcc"
# Is the compiler the GNU C compiler?
with_gcc=yes
......@@ -174,7 +174,7 @@ dlopen_self=unknown
dlopen_self_static=unknown
# Compiler flag to prevent dynamic linking.
link_static_flag=""
link_static_flag="-static"
# Compiler flag to turn off builtin functions.
no_builtin_flag=" -fno-builtin"
......@@ -6801,13 +6801,13 @@ AR="ar"
AR_FLAGS="cru"
# A C compiler.
LTCC="/usr/lib/openmpi/1.2.7-gcc//bin/mpicc"
LTCC="gcc"
# LTCC compiler flags.
LTCFLAGS="-g -O2"
# A language-specific compiler.
CC="/usr/lib/openmpi/1.2.7-gcc//bin/mpiCC"
CC="g++"
# Is the compiler the GNU C compiler?
with_gcc=yes
......@@ -6893,7 +6893,7 @@ dlopen_self=unknown
dlopen_self_static=unknown
# Compiler flag to prevent dynamic linking.
link_static_flag=""
link_static_flag="-static"
# Compiler flag to turn off builtin functions.
no_builtin_flag=" -fno-builtin"
......@@ -6960,11 +6960,11 @@ predeps=""
# Dependencies to place after the objects being linked to create a
# 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
# 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.
deplibs_check_method="pass_all"
......@@ -7109,7 +7109,7 @@ AR="ar"
AR_FLAGS="cru"
# A C compiler.
LTCC="/usr/lib/openmpi/1.2.7-gcc//bin/mpicc"
LTCC="gcc"
# LTCC compiler flags.
LTCFLAGS="-g -O2"
......
......@@ -79,7 +79,7 @@ namespace AMDiS {
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
// may be refinemed in a way, such that there is no new vertex on the
......@@ -113,6 +113,7 @@ namespace AMDiS {
// -------
//
// nb el
//
// 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
// level neighbour.
......@@ -178,10 +179,21 @@ namespace AMDiS {
break;
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
// possible. If an error occurs in this line, please check AMDiS
// revision <= 476 at the same position.
ERROR_EXIT("Should not happen!\n");
// ERROR_EXIT("Should not happen!\n");
break;
default:
......
......@@ -156,14 +156,16 @@ namespace AMDiS {
if (ndof > 0) {
for (int i = 0; i < mesh->getGeo(position); i++) {
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];
for (int k = 0; k < ndof; k++)
el->dof[j][k] = dof[j][k];
Mesh::serializedDOFs[dof[j][0]] = el->dof[j];
Mesh::serializedDOFs[idx] = el->dof[j];
} else {
el->dof[j] = Mesh::serializedDOFs[dof[j][0]];
el->dof[j] = Mesh::serializedDOFs[idx];
}
} else {
el->dof[j] = NULL;
......@@ -175,12 +177,10 @@ namespace AMDiS {
/* =========== And clone the children ============= */
if (child[0]) {
if (child[0])
el->child[0] = child[0]->cloneWithDOFs();
}
if (child[1]) {
if (child[1])
el->child[1] = child[1]->cloneWithDOFs();
}
return el;
}
......@@ -264,7 +264,7 @@ namespace AMDiS {
int edges = mesh->getGeo(EDGE);
int faces = mesh->getGeo(FACE);
if ((nd = admin->getNumberOfDOFs(VERTEX))) {
if (nd = admin->getNumberOfDOFs(VERTEX)) {
nd0 = admin->getNumberOfPreDOFs(VERTEX);
n0 = admin->getMesh()->getNode(VERTEX);
for (i = 0; i < vertices; i++) {
......@@ -273,7 +273,7 @@ namespace AMDiS {
}
if (mesh->getDim() > 1) {
if ((nd = admin->getNumberOfDOFs(EDGE))) {
if (nd = admin->getNumberOfDOFs(EDGE)) {
nd0 = admin->getNumberOfPreDOFs(EDGE);
n0 = admin->getMesh()->getNode(EDGE);
for (i = 0; i < edges; i++) {
......@@ -283,7 +283,7 @@ namespace AMDiS {
}
if (mesh->getDim() == 3) {
if ((nd = admin->getNumberOfDOFs(FACE))) {
if (nd = admin->getNumberOfDOFs(FACE)) {
nd0 = admin->getNumberOfPreDOFs(FACE);
n0 = admin->getMesh()->getNode(FACE);
for (i = 0; i < faces; i++) {
......@@ -292,10 +292,11 @@ namespace AMDiS {
}
}
if ((nd = admin->getNumberOfDOFs(CENTER))) {
if (nd = admin->getNumberOfDOFs(CENTER)) {
nd0 = admin->getNumberOfPreDOFs(CENTER);
n0 = admin->getMesh()->getNode(CENTER);
i = 0; /* only one center */
// only one center
i = 0;
CHANGE_DOFS_2(this);
}
}
......@@ -389,18 +390,26 @@ namespace AMDiS {
if (ndof > 0) {
for (int i = 0; i < mesh->getGeo(position); i++) {
if (dof[j] != NULL) {
if (Mesh::serializedDOFs[dof[j][0]] == NULL) {
Mesh::serializedDOFs[dof[j][0]] = dof[j];
// Create index to check if the dofs were already written.
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*>(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 {
int minusOne = -1;
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 {
int zero = 0;
out.write(reinterpret_cast<const char*>(&zero), sizeof(int));
out.write(reinterpret_cast<const char*>(&pos), sizeof(int));
}
j++;
}
......@@ -466,32 +475,35 @@ namespace AMDiS {
dof = new DegreeOfFreedom*[nodes];
// std::cout << "-- n = " << nodes << std::endl;
for (int i = 0; i < nodes; i++) {
int nDofs;
int nDofs, pos;
in.read(reinterpret_cast<char*>(&nDofs), sizeof(int));
// std::cout << "d = " << nDofs << std::endl;
in.read(reinterpret_cast<char*>(&pos), sizeof(int));
if (nDofs) {
if (nDofs != -1) {
dof[i] = new DegreeOfFreedom[nDofs];
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];
dof[i] = dofPtr;
} else {
Mesh::serializedDOFs[dof[i][0]] = dof[i];
Mesh::serializedDOFs[idx] = dof[i];
}
} else {
DegreeOfFreedom index;
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");
dof[i] = Mesh::serializedDOFs[index];
// std::cout << "i = " << index << " " << Mesh::serializedDOFs[index] << " " << Mesh::serializedDOFs[index][0] << std::endl;
dof[i] = Mesh::serializedDOFs[idx];
}
} else {
dof[i] = NULL;
......@@ -501,8 +513,6 @@ namespace AMDiS {
// read index
in.read(reinterpret_cast<char*>(&index), sizeof(int));
// std::cout << "index = " << index << std::endl;
// read mark
in.read(reinterpret_cast<char*>(&mark), sizeof(signed char));
......@@ -527,11 +537,11 @@ namespace AMDiS {
if (typeName != "NULL") {
elementData = CreatorMap<ElementData>::getCreator(typeName)->create();
if (elementData) {
if (elementData)
elementData->deserialize(in);
} else {
ERROR_EXIT("unexpected type name\n");
}
else
ERROR_EXIT("unexpected type name\n");
} else {
elementData = NULL;
}
......@@ -544,9 +554,8 @@ namespace AMDiS {
result += sizeof(Element);
result += mesh->getNumberOfNodes() * sizeof(DegreeOfFreedom*);
if (child[0]) {
result += child[0]->calcMemoryUsage() + child[1]->calcMemoryUsage();
}
if (child[0])
result += child[0]->calcMemoryUsage() + child[1]->calcMemoryUsage();
return result;
}
......
......@@ -66,7 +66,7 @@ namespace AMDiS {
Mesh* Mesh::traversePtr = NULL;
std::vector<DegreeOfFreedom> Mesh::dof_used;
const int Mesh::MAX_DOF = 100;
std::map<DegreeOfFreedom, DegreeOfFreedom*> Mesh::serializedDOFs;
std::map<std::pair<DegreeOfFreedom, int>, DegreeOfFreedom*> Mesh::serializedDOFs;
struct delmem {
DegreeOfFreedom* ptr;
......@@ -894,6 +894,39 @@ namespace AMDiS {
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)
{
diam = w;
......
......@@ -502,6 +502,9 @@ namespace AMDiS {
const FiniteElemSpace* feSpace,
WorldVector<double>& coords);
bool getDofIndexCoords(DegreeOfFreedom dof,
const FiniteElemSpace* feSpace,
WorldVector<double>& coords);
/// Returns FILL_ANY_?D
inline static const Flag& getFillAnyFlag(int dim)
......@@ -749,8 +752,17 @@ namespace AMDiS {
/// Used by check functions
static std::vector<DegreeOfFreedom> dof_used;
///
static std::map<DegreeOfFreedom, DegreeOfFreedom*> serializedDOFs;
/** \brief
* 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
* 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