From 5e754b0400a79e507a786d38f2bbdbdc6d4d099f Mon Sep 17 00:00:00 2001 From: Thomas Witkowski <thomas.witkowski@gmx.de> Date: Wed, 18 Apr 2012 05:18:17 +0000 Subject: [PATCH] Fixed problem for compiling AMDiS in sequentiel mode. --- AMDiS/CMakeLists.txt | 3 +- AMDiS/src/BoundaryObject.cc | 138 +++++++++++++++++++++++++ AMDiS/src/BoundaryObject.h | 127 +++++++++++++++++++++++ AMDiS/src/Line.h | 2 +- AMDiS/src/MeshStructure.h | 30 +++--- AMDiS/src/parallel/InteriorBoundary.cc | 136 ++---------------------- AMDiS/src/parallel/InteriorBoundary.h | 93 +---------------- 7 files changed, 296 insertions(+), 233 deletions(-) create mode 100644 AMDiS/src/BoundaryObject.cc create mode 100644 AMDiS/src/BoundaryObject.h diff --git a/AMDiS/CMakeLists.txt b/AMDiS/CMakeLists.txt index 718c38ee..971e990c 100644 --- a/AMDiS/CMakeLists.txt +++ b/AMDiS/CMakeLists.txt @@ -70,6 +70,7 @@ SET(AMDIS_SRC ${SOURCE_DIR}/AdaptBase.cc ${SOURCE_DIR}/BasisFunction.cc ${SOURCE_DIR}/Boundary.cc ${SOURCE_DIR}/BoundaryManager.cc + ${SOURCE_DIR}/BoundaryObject.cc ${SOURCE_DIR}/Cholesky.cc ${SOURCE_DIR}/CoarseningManager.cc ${SOURCE_DIR}/CoarseningManager1d.cc @@ -166,7 +167,6 @@ SET(AMDIS_SRC ${SOURCE_DIR}/AdaptBase.cc ${SOURCE_DIR}/io/VtkWriter.cc ${SOURCE_DIR}/io/VtkVectorWriter.cc ${SOURCE_DIR}/nonlin/ProblemNonLin.cc - ${SOURCE_DIR}/parallel/InteriorBoundary.cc ${SOURCE_DIR}/time/RosenbrockAdaptInstationary.cc ${SOURCE_DIR}/time/RosenbrockMethod.cc ${SOURCE_DIR}/time/RosenbrockStationary.cc @@ -225,6 +225,7 @@ if(ENABLE_PARALLEL_DOMAIN) ${SOURCE_DIR}/parallel/DofComm.cc ${SOURCE_DIR}/parallel/CheckerPartitioner.cc ${SOURCE_DIR}/parallel/ElementObjectDatabase.cc + ${SOURCE_DIR}/parallel/InteriorBoundary.cc ${SOURCE_DIR}/parallel/MeshDistributor.cc ${SOURCE_DIR}/parallel/MeshLevelData.cc ${SOURCE_DIR}/parallel/MeshManipulation.cc diff --git a/AMDiS/src/BoundaryObject.cc b/AMDiS/src/BoundaryObject.cc new file mode 100644 index 00000000..435fc002 --- /dev/null +++ b/AMDiS/src/BoundaryObject.cc @@ -0,0 +1,138 @@ +// +// Software License for AMDiS +// +// Copyright (c) 2010 Dresden University of Technology +// All rights reserved. +// Authors: Simon Vey, Thomas Witkowski et al. +// +// This file is part of AMDiS +// +// See also license.opensource.txt in the distribution. + + +#include "BoundaryObject.h" +#include "Mesh.h" +#include "FiniteElemSpace.h" +#include "BasisFunction.h" + +namespace AMDiS { + + BoundaryObject::BoundaryObject() + : elType(0), + reverseMode(false), + excludedSubstructures(0) + {} + + + BoundaryObject::BoundaryObject(Element *e, + int eType, + GeoIndex sObj, + int iObj, + bool rMode) + : el(e), + elIndex(e->getIndex()), + elType(eType), + subObj(sObj), + ithObj(iObj), + reverseMode(rMode), + excludedSubstructures(0) + {} + + + bool BoundaryObject::computeReverseMode(BoundaryObject &obj0, + BoundaryObject &obj1, + const FiniteElemSpace *feSpace, + BoundaryType boundary) + { + FUNCNAME("BoundaryObject::computeReverseMode()"); + + bool reverseMode = false; + + switch (feSpace->getMesh()->getDim()) { + case 2: + reverseMode = true; + break; + + case 3: + TEST_EXIT_DBG(obj1.elType == 0) + ("Only 3D macro elements with level 0 are supported. This element has level %d!\n", + obj1.elType); + + + if (obj0.subObj == EDGE) { + int el0_v0 = obj0.el->getVertexOfEdge(obj0.ithObj, 0); + int el0_v1 = obj0.el->getVertexOfEdge(obj0.ithObj, 1); + int el1_v0 = obj0.el->getVertexOfEdge(obj1.ithObj, 0); + int el1_v1 = obj0.el->getVertexOfEdge(obj1.ithObj, 1); + + const BasisFunction *basFcts = feSpace->getBasisFcts(); + int nBasFcts = basFcts->getNumber(); + std::vector<DegreeOfFreedom> localDofs0(nBasFcts), localDofs1(nBasFcts); + basFcts->getLocalIndices(obj0.el, feSpace->getAdmin(), localDofs0); + basFcts->getLocalIndices(obj1.el, feSpace->getAdmin(), localDofs1); + + Mesh *mesh = feSpace->getMesh(); + + if (mesh->isPeriodicAssociation(boundary) == false) { + TEST_EXIT_DBG(localDofs0[el0_v0] == localDofs1[el1_v0] || + localDofs0[el0_v0] == localDofs1[el1_v1]) + ("This should not happen!\n"); + TEST_EXIT_DBG(localDofs0[el0_v1] == localDofs1[el1_v0] || + localDofs0[el0_v1] == localDofs1[el1_v1]) + ("This should not happen!\n"); + + if (localDofs0[el0_v0] != localDofs1[el1_v0]) + reverseMode = true; + } else { + if (mesh->associated(localDofs0[el0_v0], localDofs1[el1_v0]) == false) + reverseMode = true; + } + } + + if (obj0.subObj == FACE && obj0.ithObj != 1) { + const BasisFunction *basFcts = feSpace->getBasisFcts(); + int nBasFcts = basFcts->getNumber(); + std::vector<DegreeOfFreedom> localDofs0(nBasFcts), localDofs1(nBasFcts); + basFcts->getLocalIndices(obj0.el, feSpace->getAdmin(), localDofs0); + basFcts->getLocalIndices(obj1.el, feSpace->getAdmin(), localDofs1); + + if (obj0.ithObj == 2 || obj0.ithObj == 3) + reverseMode = (localDofs0[0] != localDofs1[0]); + + if (obj0.ithObj == 0) + reverseMode = (localDofs0[1] != localDofs1[1]); + } + break; + + default: + ERROR_EXIT("This should not happen!\n"); + } + + return reverseMode; + } + + + bool BoundaryObject::operator==(const BoundaryObject& other) const + { + return (other.elIndex == elIndex && + other.subObj == subObj && + other.ithObj == ithObj); + } + + + bool BoundaryObject::operator!=(const BoundaryObject& other) const + { + return (other.elIndex != elIndex || + other.subObj != subObj || + other.ithObj != ithObj); + } + + + bool AtomicBoundary::operator==(const AtomicBoundary& other) const + { + return (rankObj == other.rankObj && + neighObj == other.neighObj && + type == other.type); + } + +} diff --git a/AMDiS/src/BoundaryObject.h b/AMDiS/src/BoundaryObject.h new file mode 100644 index 00000000..11d7ceda --- /dev/null +++ b/AMDiS/src/BoundaryObject.h @@ -0,0 +1,127 @@ +// ============================================================================ +// == == +// == AMDiS - Adaptive multidimensional simulations == +// == == +// == http://www.amdis-fem.org == +// == == +// ============================================================================ +// +// Software License for AMDiS +// +// Copyright (c) 2010 Dresden University of Technology +// All rights reserved. +// Authors: Simon Vey, Thomas Witkowski et al. +// +// This file is part of AMDiS +// +// See also license.opensource.txt in the distribution. + + + +/** \file BoundaryObject.h */ + +#ifndef AMDIS_BOUNDARY_OBJECT_H +#define AMDIS_BOUNDARY_OBJECT_H + +#include <vector> + +#include "MacroElement.h" +#include "Element.h" +#include "Boundary.h" + +namespace AMDiS { + + using namespace std; + + typedef vector<pair<GeoIndex, int> > ExcludeList; + + /// Defines the geometrical objects that forms the boundary; + struct BoundaryObject { + + BoundaryObject(); + + BoundaryObject(Element *e, + int eType, + GeoIndex sObj, + int iObj, + bool rMode = false); + + static bool computeReverseMode(BoundaryObject &obj0, + BoundaryObject &obj1, + const FiniteElemSpace *feSpace, + BoundaryType boundary); + + bool operator==(const BoundaryObject& other) const; + + bool operator!=(const BoundaryObject& other) const; + + /// The macro element to which the boundary element corresponds to. + Element* el; + + /// Index of the macro element. + int elIndex; + + /// Element type index, only used in 3d. + int elType; + + /** \brief + * Defines the geometrical object at the boundary. It must be "a part" of the + * macro element \ref el, i.e., either 1 (a vertex), 2 (an edge) or 3 + * (a face). + */ + GeoIndex subObj; + + /** \brief + * Defines which of vertex, edge or face of the macro element is part of the + * boundary. + * + * Example: If the macro element is a triangle, than \ref subObj may be either + * 1 (vertex) or 2 (edge). Assume its the last one. So this variable defines + * which of the three possible edges of the triangle is at the interior + * boundary. + */ + int ithObj; + + bool reverseMode; + + /** \brief + * In many situations it may be necessary to exclude some parts of the + * element to be part of the boundary. In 3d, when a face is part of the + * boundary, an edge or an vertex may be exludeded. In 2d only vertices may + * be exluded to be part of an edge boundary. This list contains pairs of + * exludeded structures. The first component of every pair denotes if it is + * a vertex or an edge, and the second component denotes the local index of + * the structure. + */ + ExcludeList excludedSubstructures; + }; + + + + /** \brief + * Defines one atomic part of the boundary, i.e., two boundary objects where + * the boundary goes through. + */ + struct AtomicBoundary { + AtomicBoundary() + : type(INTERIOR) + {} + + bool operator==(const AtomicBoundary& other) const; + + /// The rank's part of the boundary. + BoundaryObject rankObj; + + /// The object on the other side of the boundary. + BoundaryObject neighObj; + + /// Integer flag that is used to distinguish between different types of + /// boundaries. Till now it is used only for periodic boundaries, which are + /// also handles as interior boundaries. + BoundaryType type; + }; + + +} + +#endif diff --git a/AMDiS/src/Line.h b/AMDiS/src/Line.h index 661db9f7..484024a6 100644 --- a/AMDiS/src/Line.h +++ b/AMDiS/src/Line.h @@ -24,7 +24,7 @@ #define AMDIS_LINE_H #include "Element.h" -#include "parallel/InteriorBoundary.h" +#include "BoundaryObject.h" namespace AMDiS { diff --git a/AMDiS/src/MeshStructure.h b/AMDiS/src/MeshStructure.h index c9b86f3e..77593db4 100644 --- a/AMDiS/src/MeshStructure.h +++ b/AMDiS/src/MeshStructure.h @@ -28,7 +28,7 @@ #include "AMDiS_fwd.h" #include "Global.h" -#include "parallel/InteriorBoundary.h" +#include "BoundaryObject.h" namespace AMDiS { @@ -46,6 +46,7 @@ namespace AMDiS { void clear(); + /** \brief * Creates a mesh structure code from a mesh object by traversing it in * preorder. @@ -96,10 +97,8 @@ namespace AMDiS { return (currentCode & 1) == 0; } - /** \brief - * Merges a mesh structure code with its own mesh structure code. The result - * overwrites the own mesh structure code. - */ + /// Merges a mesh structure code with its own mesh structure code. The result + /// overwrites the own mesh structure code. void merge(MeshStructure *struc) { MeshStructure temp(*this); @@ -109,14 +108,14 @@ namespace AMDiS { /** \brief * Fits a given mesh to the mesh structure code. * - * \param debugMode In debugMode, the whole mesh is fitted to the mesh structure - * code. Otherwise, the mesh is fitted only on the partition - * of the current process. + * \param debugMode In debugMode, the whole mesh is fitted to the mesh + * structure code. Otherwise, the mesh is fitted only on + * the partition of the current process. * \param macroElIndex If the mesh structure code represents only one macro * element, this can be denoted here by its index. In this - * case, only the corresponding macro element will be fitted - * to the code. Otherwise, this variable is negative and the - * whole mesh will be adapted. + * case, only the corresponding macro element will be + * fitted to the code. Otherwise, this variable is + * negative and the whole mesh will be adapted. */ void fitMeshToStructure(Mesh *mesh, RefinementManager *manager, @@ -187,7 +186,11 @@ namespace AMDiS { /// Insert a new element to the structure code. Is used by the init function. void insertElement(bool isLeaf); - void addAlongSide(Element *el, GeoIndex subObj, int ithObj, int elType, bool reverseOrder); + void addAlongSide(Element *el, + GeoIndex subObj, + int ithObj, + int elType, + bool reverseOrder); /// Merges two mesh structure codes to one structure code. void merge(MeshStructure *structure1, @@ -208,7 +211,8 @@ namespace AMDiS { int nElements; - /// If true, some output is printed to screen during mesh structure code generation. + /// If true, some output is printed to screen during mesh structure + /// code generation. bool debugMode; static const int structureSize; diff --git a/AMDiS/src/parallel/InteriorBoundary.cc b/AMDiS/src/parallel/InteriorBoundary.cc index bd776e17..f3e694a4 100644 --- a/AMDiS/src/parallel/InteriorBoundary.cc +++ b/AMDiS/src/parallel/InteriorBoundary.cc @@ -10,7 +10,7 @@ // See also license.opensource.txt in the distribution. -#include "InteriorBoundary.h" +#include "parallel/InteriorBoundary.h" #include "FiniteElemSpace.h" #include "BasisFunction.h" #include "Serializer.h" @@ -18,125 +18,6 @@ namespace AMDiS { - BoundaryObject::BoundaryObject() - : elType(0), - reverseMode(false), - excludedSubstructures(0) - {} - - - BoundaryObject::BoundaryObject(Element *e, - int eType, - GeoIndex sObj, - int iObj, - bool rMode) - : el(e), - elIndex(e->getIndex()), - elType(eType), - subObj(sObj), - ithObj(iObj), - reverseMode(rMode), - excludedSubstructures(0) - {} - - - bool BoundaryObject::computeReverseMode(BoundaryObject &obj0, - BoundaryObject &obj1, - const FiniteElemSpace *feSpace, - BoundaryType boundary) - { - FUNCNAME("BoundaryObject::computeReverseMode()"); - - bool reverseMode = false; - - switch (feSpace->getMesh()->getDim()) { - case 2: - reverseMode = true; - break; - - case 3: - TEST_EXIT_DBG(obj1.elType == 0) - ("Only 3D macro elements with level 0 are supported. This element has level %d!\n", - obj1.elType); - - - if (obj0.subObj == EDGE) { - int el0_v0 = obj0.el->getVertexOfEdge(obj0.ithObj, 0); - int el0_v1 = obj0.el->getVertexOfEdge(obj0.ithObj, 1); - int el1_v0 = obj0.el->getVertexOfEdge(obj1.ithObj, 0); - int el1_v1 = obj0.el->getVertexOfEdge(obj1.ithObj, 1); - - const BasisFunction *basFcts = feSpace->getBasisFcts(); - int nBasFcts = basFcts->getNumber(); - std::vector<DegreeOfFreedom> localDofs0(nBasFcts), localDofs1(nBasFcts); - basFcts->getLocalIndices(obj0.el, feSpace->getAdmin(), localDofs0); - basFcts->getLocalIndices(obj1.el, feSpace->getAdmin(), localDofs1); - - Mesh *mesh = feSpace->getMesh(); - - if (mesh->isPeriodicAssociation(boundary) == false) { - TEST_EXIT_DBG(localDofs0[el0_v0] == localDofs1[el1_v0] || - localDofs0[el0_v0] == localDofs1[el1_v1]) - ("This should not happen!\n"); - TEST_EXIT_DBG(localDofs0[el0_v1] == localDofs1[el1_v0] || - localDofs0[el0_v1] == localDofs1[el1_v1]) - ("This should not happen!\n"); - - if (localDofs0[el0_v0] != localDofs1[el1_v0]) - reverseMode = true; - } else { - if (mesh->associated(localDofs0[el0_v0], localDofs1[el1_v0]) == false) - reverseMode = true; - } - } - - if (obj0.subObj == FACE && obj0.ithObj != 1) { - const BasisFunction *basFcts = feSpace->getBasisFcts(); - int nBasFcts = basFcts->getNumber(); - std::vector<DegreeOfFreedom> localDofs0(nBasFcts), localDofs1(nBasFcts); - basFcts->getLocalIndices(obj0.el, feSpace->getAdmin(), localDofs0); - basFcts->getLocalIndices(obj1.el, feSpace->getAdmin(), localDofs1); - - if (obj0.ithObj == 2 || obj0.ithObj == 3) - reverseMode = (localDofs0[0] != localDofs1[0]); - - if (obj0.ithObj == 0) - reverseMode = (localDofs0[1] != localDofs1[1]); - } - break; - - default: - ERROR_EXIT("This should not happen!\n"); - } - - return reverseMode; - } - - - bool BoundaryObject::operator==(const BoundaryObject& other) const - { - return (other.elIndex == elIndex && - other.subObj == subObj && - other.ithObj == ithObj); - } - - - bool BoundaryObject::operator!=(const BoundaryObject& other) const - { - return (other.elIndex != elIndex || - other.subObj != subObj || - other.ithObj != ithObj); - } - - - bool AtomicBoundary::operator==(const AtomicBoundary& other) const - { - return (rankObj == other.rankObj && - neighObj == other.neighObj && - type == other.type); - } - - AtomicBoundary& InteriorBoundary::getNewAtomic(int rank) { boundary[rank].resize(boundary[rank].size() + 1); @@ -176,7 +57,8 @@ namespace AMDiS { int mSize = boundary.size(); SerUtil::serialize(out, mSize); - for (RankToBoundMap::iterator it = boundary.begin(); it != boundary.end(); ++it) { + for (RankToBoundMap::iterator it = boundary.begin(); + it != boundary.end(); ++it) { int rank = it->first; int boundSize = it->second.size(); SerUtil::serialize(out, rank); @@ -246,9 +128,9 @@ namespace AMDiS { bound.rankObj.el = elIndexMap[bound.rankObj.elIndex]; - // For the case of periodic interior boundaries, a rank may have an boundary - // with itself. In this case, also the pointer to the neighbour object must - // be set correctly. + // For the case of periodic interior boundaries, a rank may have an + // boundary with itself. In this case, also the pointer to the neighbour + // object must be set correctly. if (elIndexMap.count(bound.neighObj.elIndex)) bound.neighObj.el = elIndexMap[bound.neighObj.elIndex]; else @@ -258,7 +140,8 @@ namespace AMDiS { } - void InteriorBoundary::serializeExcludeList(std::ostream &out, ExcludeList &list) + void InteriorBoundary::serializeExcludeList(std::ostream &out, + ExcludeList &list) { int size = list.size(); SerUtil::serialize(out, size); @@ -269,7 +152,8 @@ namespace AMDiS { } - void InteriorBoundary::deserializeExcludeList(std::istream &in, ExcludeList &list) + void InteriorBoundary::deserializeExcludeList(std::istream &in, + ExcludeList &list) { int size = 0; SerUtil::deserialize(in, size); diff --git a/AMDiS/src/parallel/InteriorBoundary.h b/AMDiS/src/parallel/InteriorBoundary.h index dc04842f..2bf154f3 100644 --- a/AMDiS/src/parallel/InteriorBoundary.h +++ b/AMDiS/src/parallel/InteriorBoundary.h @@ -27,104 +27,13 @@ #include <map> #include "AMDiS_fwd.h" -#include "MacroElement.h" -#include "Element.h" -#include "Boundary.h" +#include "BoundaryObject.h" #include "parallel/MeshLevelData.h" namespace AMDiS { using namespace std; - typedef vector<pair<GeoIndex, int> > ExcludeList; - - /// Defines the geometrical objects that forms the boundary; - struct BoundaryObject { - - BoundaryObject(); - - BoundaryObject(Element *e, - int eType, - GeoIndex sObj, - int iObj, - bool rMode = false); - - static bool computeReverseMode(BoundaryObject &obj0, - BoundaryObject &obj1, - const FiniteElemSpace *feSpace, - BoundaryType boundary); - - bool operator==(const BoundaryObject& other) const; - - bool operator!=(const BoundaryObject& other) const; - - /// The macro element to which the boundary element corresponds to. - Element* el; - - /// Index of the macro element. - int elIndex; - - /// Element type index, only used in 3d. - int elType; - - /** \brief - * Defines the geometrical object at the boundary. It must be "a part" of the - * macro element \ref el, i.e., either 1 (a vertex), 2 (an edge) or 3 (a face). - */ - GeoIndex subObj; - - /** \brief - * Defines which of vertex, edge or face of the macro element is part of the - * boundary. - * - * Example: If the macro element is a triangle, than \ref subObj may be either - * 1 (vertex) or 2 (edge). Assume its the last one. So this variable defines - * which of the three possible edges of the triangle is at the interior - * boundary. - */ - int ithObj; - - bool reverseMode; - - /** \brief - * In many situations it may be necessary to exclude some parts of the - * element to be part of the boundary. In 3d, when a face is part of the - * boundary, an edge or an vertex may be exludeded. In 2d only vertices may - * be exluded to be part of an edge boundary. This list contains pairs of - * exludeded structures. The first component of every pair denotes if it is - * a vertex or an edge, and the second component denotes the local index of - * the structure. - */ - ExcludeList excludedSubstructures; - }; - - - - /** \brief - * Defines one atomic part of the boundary, i.e., two boundary objects where the - * boundary goes through. - */ - struct AtomicBoundary { - AtomicBoundary() - : type(INTERIOR) - {} - - bool operator==(const AtomicBoundary& other) const; - - /// The rank's part of the boundary. - BoundaryObject rankObj; - - /// The object on the other side of the boundary. - BoundaryObject neighObj; - - /// Integer flag that is used to distinguish between different types of - /// boundaries. Till now it is used only for periodic boundaries, which are also - /// handles as interior boundaries. - BoundaryType type; - }; - - - /** \brief * Defines the interior boundary, i.e. a bound within the domain. It is used for * the classical domain decomposition parallelization. -- GitLab