From cd3440565ab442b7ecdb180133cffc95dd5f2dd0 Mon Sep 17 00:00:00 2001 From: Thomas Witkowski <thomas.witkowski@gmx.de> Date: Tue, 24 Mar 2009 07:55:41 +0000 Subject: [PATCH] * Nothing important --- AMDiS/src/ElementFileWriter.cc | 37 +-- AMDiS/src/ElementFileWriter.h | 72 ++---- AMDiS/src/FileWriter.h | 10 +- AMDiS/src/Mesh.h | 419 +++++++++---------------------- AMDiS/src/ParMetisPartitioner.cc | 68 +++-- AMDiS/src/ParMetisPartitioner.h | 39 +-- AMDiS/src/ParallelProblem.cc | 18 +- AMDiS/src/ParallelProblem.h | 14 +- AMDiS/src/VtkWriter.h | 16 +- 9 files changed, 236 insertions(+), 457 deletions(-) diff --git a/AMDiS/src/ElementFileWriter.cc b/AMDiS/src/ElementFileWriter.cc index 63b7b61f..68b14e76 100644 --- a/AMDiS/src/ElementFileWriter.cc +++ b/AMDiS/src/ElementFileWriter.cc @@ -8,7 +8,7 @@ namespace AMDiS { ElementFileWriter::ElementFileWriter(const std::string& name_, const FiniteElemSpace *feSpace_, - std::map<int, double> &vec_) + std::map<int, double> &mapvec) : name(name_), tecplotExt(".plt"), amdisMeshDatExt(".elem.mesh"), @@ -23,20 +23,20 @@ namespace AMDiS { timestepNumber(-1), mesh(feSpace_->getMesh()), feSpace(feSpace_), - vec(vec_) + vec(mapvec) { - GET_PARAMETER(0, name + "->output->filename", &filename); - GET_PARAMETER(0, name + "->output->TecPlot format", "%d", - &writeTecPlotFormat); - GET_PARAMETER(0, name + "->output->TecPlot ext", &tecplotExt); - GET_PARAMETER(0, name + "->output->AMDiS format", "%d", &writeAMDiSFormat); - GET_PARAMETER(0, name + "->output->AMDiS mesh-dat ext", &amdisMeshDatExt); - GET_PARAMETER(0, name + "->output->ParaView format", "%d", &writeVtkFormat); - GET_PARAMETER(0, name + "->output->append index", "%d", &appendIndex); - GET_PARAMETER(0, name + "->output->index length", "%d", &indexLength); - GET_PARAMETER(0, name + "->output->index decimals", "%d", &indexDecimals); - GET_PARAMETER(0, name + "->output->write every i-th timestep", "%d", - &tsModulo); + if (name != "") { + GET_PARAMETER(0, name + "->output->filename", &filename); + GET_PARAMETER(0, name + "->output->TecPlot format", "%d", &writeTecPlotFormat); + GET_PARAMETER(0, name + "->output->TecPlot ext", &tecplotExt); + GET_PARAMETER(0, name + "->output->AMDiS format", "%d", &writeAMDiSFormat); + GET_PARAMETER(0, name + "->output->AMDiS mesh-dat ext", &amdisMeshDatExt); + GET_PARAMETER(0, name + "->output->ParaView format", "%d", &writeVtkFormat); + GET_PARAMETER(0, name + "->output->append index", "%d", &appendIndex); + GET_PARAMETER(0, name + "->output->index length", "%d", &indexLength); + GET_PARAMETER(0, name + "->output->index decimals", "%d", &indexDecimals); + GET_PARAMETER(0, name + "->output->write every i-th timestep", "%d", &tsModulo); + } } void ElementFileWriter::writeFiles(AdaptInfo *adaptInfo, bool force, @@ -93,6 +93,15 @@ namespace AMDiS { } } + void ElementFileWriter::writeFile(std::map<int, double> &vec, + const FiniteElemSpace *feSpace, + const std::string& filename) + { + ElementFileWriter efw("", feSpace, vec); + efw.writeVtkValues(filename); + } + + void ElementFileWriter::writeTecPlotValues(const std::string &filename) { FUNCNAME("ElementFileWriter::writeTecPlotValues()"); diff --git a/AMDiS/src/ElementFileWriter.h b/AMDiS/src/ElementFileWriter.h index dd9b1eff..205d48cc 100644 --- a/AMDiS/src/ElementFileWriter.h +++ b/AMDiS/src/ElementFileWriter.h @@ -23,61 +23,46 @@ namespace AMDiS { public: MEMORY_MANAGED(ElementFileWriter); - /** - * Constructor. - */ + /// Constructor. ElementFileWriter(const std::string& name, const FiniteElemSpace *feSpace, std::map<int, double> &vec); - /** - * Implementation of FileWriterInterface::writeFiles(). - */ + /// Implementation of FileWriterInterface::writeFiles(). void writeFiles(AdaptInfo *adaptInfo, bool force, int level = -1, Flag traverseFlag = Mesh::CALL_LEAF_EL, bool (*writeElem)(ElInfo*) = NULL); + /// Simple writing procedure for one element map. + static void writeFile(std::map<int, double> &vec, + const FiniteElemSpace *feSpace, + const std::string& filename); + protected: - /** - * Writes element data in tecplot format. - */ + /// Writes element data in tecplot format. void writeTecPlotValues(const std::string &filename); - /** - * Writes element data in AMDiS format (1 file !). - */ + /// Writes element data in AMDiS format (1 file !). void writeMeshDatValues(const std::string &filename, double time); - /** - * Writes element data in VTK format. - */ + /// Writes element data in VTK format. void writeVtkValues(const std::string &filename); protected: - /** \brief - * Name. - */ + /// Name. std::string name; - /** \brief - * Used filename prefix. - */ + /// Used filename prefix. std::string filename; - /** \brief - * TecPlot file extension. - */ + /// TecPlot file extension. std::string tecplotExt; - /** \brief - * AMDiS mesh-data-file extension. - */ + /// AMDiS mesh-data-file extension. std::string amdisMeshDatExt; - /** \brief - * VTK file extension. - */ + /// VTK file extension. std::string vtkExt; /** \brief @@ -104,38 +89,25 @@ namespace AMDiS { */ int appendIndex; - /** \brief - * Total length of appended time index. - */ + /// Total length of appended time index. int indexLength; - /** \brief - * Number of decimals in time index. - */ + /// Number of decimals in time index. int indexDecimals; - /** \brief - * Timestep modulo: write only every tsModulo-th timestep! - */ + /// Timestep modulo: write only every tsModulo-th timestep! int tsModulo; - /** - */ + /// int timestepNumber; - /** \brief - * Mesh used for output. - */ + /// Mesh used for output. Mesh *mesh; - /** \brief - * fespace used for output. - */ + /// fespace used for output. const FiniteElemSpace *feSpace; - /** \brief - * Vector that stores the solution. - */ + /// Vector that stores the solution. std::map<int, double> vec; }; diff --git a/AMDiS/src/FileWriter.h b/AMDiS/src/FileWriter.h index b33952ed..fc1d28b4 100644 --- a/AMDiS/src/FileWriter.h +++ b/AMDiS/src/FileWriter.h @@ -63,9 +63,9 @@ namespace AMDiS { traverseLevel(-1), traverseFlag(Mesh::CALL_LEAF_EL), writeElement(NULL) - {}; + {} - virtual ~FileWriterInterface() {}; + virtual ~FileWriterInterface() {} /** \brief * Interface. Must be overridden in subclasses. @@ -84,15 +84,15 @@ namespace AMDiS { traverseLevel = level; traverseFlag |= flag; writeElement = writeElem; - }; + } std::string getFilename() { return filename; - }; + } void setFilename(std::string n) { filename = n; - }; + } protected: /** \brief diff --git a/AMDiS/src/Mesh.h b/AMDiS/src/Mesh.h index ad4d3e47..1141f24b 100644 --- a/AMDiS/src/Mesh.h +++ b/AMDiS/src/Mesh.h @@ -86,38 +86,26 @@ namespace AMDiS { public: MEMORY_MANAGED(Mesh); - /** \brief - * Creates a mesh with the given name of dimension dim - */ + /// Creates a mesh with the given name of dimension dim Mesh(const std::string& name, int dim); - /** \brief - * Destructor - */ + /// Destructor virtual ~Mesh(); - /** \brief - * Reads macro triangulation. - */ + /// Reads macro triangulation. void initialize(); - /** \brief - * Assignment operator - */ + /// Assignment operator Mesh& operator=(const Mesh&); /** \name static methods used while mesh traversal * \{ */ - /** \brief - * Used while dof compress - */ + /// Used while dof compress static int newDOFFct1(ElInfo* e); - /** \brief - * Used while dof compress - */ + /// Used while dof compress static int newDOFFct2(ElInfo* e); /** \} */ @@ -135,114 +123,82 @@ namespace AMDiS { return Global::getGeo(p, dim); } - /** \brief - * Returns \ref name of the mesh - */ + /// Returns \ref name of the mesh inline const std::string& getName() const { return name; } - /** \brief - * Returns \ref dim of the mesh - */ + /// Returns \ref dim of the mesh inline int getDim() const { return dim; } - /** \brief - * Returns \ref nDOFEl of the mesh - */ + /// Returns \ref nDOFEl of the mesh inline const int getNumberOfAllDOFs() const { return nDOFEl; } - /** \brief - * Returns \ref nNodeEl of the mesh - */ + /// Returns \ref nNodeEl of the mesh inline const int getNumberOfNodes() const { return nNodeEl; } - /** \brief - * Returns \ref nVertices of the mesh - */ + /// Returns \ref nVertices of the mesh inline const int getNumberOfVertices() const { return nVertices; } - /** \brief - * Returns \ref nEdges of the mesh - */ + /// Returns \ref nEdges of the mesh inline const int getNumberOfEdges() const { return nEdges; } - /** \brief - * Returns \ref nFaces of the mesh - */ + /// Returns \ref nFaces of the mesh inline const int getNumberOfFaces() const { return nFaces; } - /** \brief - * Returns \ref nLeaves of the mesh - */ + /// Returns \ref nLeaves of the mesh inline const int getNumberOfLeaves() const { return nLeaves; } - /** \brief - * Returns \ref nElements of the mesh - */ + /// Returns \ref nElements of the mesh inline const int getNumberOfElements() const { return nElements; } - /** \brief - * Returns \ref maxEdgeNeigh of the mesh - */ + /// Returns \ref maxEdgeNeigh of the mesh inline const int getMaxEdgeNeigh() const { return maxEdgeNeigh; } - /** \brief - * Returns \ref parametric of the mesh - */ + /// Returns \ref parametric of the mesh inline Parametric *getParametric() const { return parametric; } - /** \brief - * Returns \ref diam of the mesh - */ + /// Returns \ref diam of the mesh inline const WorldVector<double>& getDiameter() const { return diam; } - /** \brief - * Returns nDOF[i] of the mesh - */ + /// Returns nDOF[i] of the mesh inline const int getNumberOfDOFs(int i) const { return nDOF[i]; } - /** \brief - * Returns \ref elementPrototype of the mesh - */ + /// Returns \ref elementPrototype of the mesh inline Element* getElementPrototype() { return elementPrototype; } - /** \brief - * Returns \ref leafDataPrototype of the mesh - */ + /// Returns \ref leafDataPrototype of the mesh inline ElementData* getElementDataPrototype() { return elementDataPrototype; } - /** \brief - * Returns node[i] of the mesh - */ + /// Returns node[i] of the mesh inline int getNode(int i) const { return node[i]; } @@ -255,9 +211,7 @@ namespace AMDiS { */ DegreeOfFreedom *getDOF(GeoIndex position); - /** \brief - * Returns *(\ref admin[i]) of the mesh - */ + /// Returns *(\ref admin[i]) of the mesh inline const DOFAdmin& getDOFAdmin(int i) const { return *(admin[i]); } @@ -285,41 +239,28 @@ namespace AMDiS { return macroElements.size(); } - /** \brief - * Returns a DOFAdmin which at least manages vertex DOFs - */ + /// Returns a DOFAdmin which at least manages vertex DOFs const DOFAdmin* getVertexAdmin() const; - /** \brief - * Allocates a array of DOF pointers. The array holds one pointer for - * each node. - */ + /// Allocates a array of DOF pointers. The array holds one pointer for each node. DegreeOfFreedom **createDOFPtrs(); - /** \brief - * Returns \ref preserveCoarseDOFs of the mesh - */ + /// Returns \ref preserveCoarseDOFs of the mesh inline bool queryCoarseDOFs() const { return preserveCoarseDOFs; } - /** \brief - * Returns an iterator to the begin of \ref macroElements - */ + /// Returns an iterator to the begin of \ref macroElements inline std::deque<MacroElement*>::iterator firstMacroElement() { return macroElements.begin(); } - /** \brief - * Returns macroElements[i]. - */ + /// Returns macroElements[i]. inline MacroElement *getMacroElement(int i) { return macroElements[i]; } - /** \brief - * Returns an iterator to the end of \ref macroElements - */ + /// Returns an iterator to the end of \ref macroElements inline std::deque<MacroElement*>::iterator endOfMacroElements() { return macroElements.end(); } @@ -331,132 +272,98 @@ namespace AMDiS { * \{ */ - /** \brief - * Sets \ref name of the mesh - */ + /// Sets \ref name of the mesh inline void setName(const std::string& aName) { name = aName; } - /** \brief - * Sets \ref nVertices of the mesh - */ + /// Sets \ref nVertices of the mesh inline void setNumberOfVertices(int n) { nVertices = n; } - /** \brief - * Sets \ref nFaces of the mesh - */ + /// Sets \ref nFaces of the mesh inline void setNumberOfFaces(int n) { nFaces = n; } - /** \brief - * Increments \ref nVertices by inc - */ + /// Increments \ref nVertices by inc inline void incrementNumberOfVertices(int inc) { nVertices += inc; } - /** \brief - * Sets \ref nEdges of the mesh - */ + /// Sets \ref nEdges of the mesh inline void setNumberOfEdges(int n) { nEdges = n; } - /** \brief - * Increments \ref nEdges by inc - */ + /// Increments \ref nEdges by inc inline void incrementNumberOfEdges(int inc) { nEdges += inc; } - /** \brief - * Increments \ref nFaces by inc - */ + /// Increments \ref nFaces by inc inline void incrementNumberOfFaces(int inc) { nFaces += inc; } - /** \brief - * Sets \ref nLeaves of the mesh - */ + /// Sets \ref nLeaves of the mesh inline void setNumberOfLeaves(int n) { nLeaves = n; } - /** \brief - * Increments \ref nLeaves by inc - */ + /// Increments \ref nLeaves by inc inline void incrementNumberOfLeaves(int inc) { nLeaves += inc; } - /** \brief - * Sets \ref nElements of the mesh - */ + /// Sets \ref nElements of the mesh inline void setNumberOfElements(int n) { nElements = n; } - /** \brief - * Increments \ref nElements by inc - */ + /// Increments \ref nElements by inc inline void incrementNumberOfElements(int inc) { nElements += inc; } - /** \brief - * Sets *\ref diam to w - */ + /// Sets *\ref diam to w void setDiameter(const WorldVector<double>& w); - /** \brief - * Sets (*\ref diam)[i] to d - */ + /// Sets (*\ref diam)[i] to d void setDiameter(int i, double d); - /** \brief - * Sets \ref preserveCoarseDOFs = true - */ + /// Sets \ref preserveCoarseDOFs = true inline void retainCoarseDOFs() { preserveCoarseDOFs = true; } - /** \brief - * Sets \ref preserveCoarseDOFs = b - */ + /// Sets \ref preserveCoarseDOFs = b inline void setPreserveCoarseDOFs(bool b) { preserveCoarseDOFs = b; } - /** \brief - * Sets \ref preserveCoarseDOFs = false - */ + /// Sets \ref preserveCoarseDOFs = false inline void noCoarseDOFs() { preserveCoarseDOFs = false; } - /** \brief - * Sets \ref elementPrototype of the mesh - */ + /// Sets \ref elementPrototype of the mesh inline void setElementPrototype(Element* prototype) { elementPrototype = prototype; } - /** \brief - * Sets \ref elementDataPrototype of the mesh - */ + /// Sets \ref elementDataPrototype of the mesh inline void setElementDataPrototype(ElementData* prototype) { elementDataPrototype = prototype; } + /// inline void setParametric(Parametric *param) { parametric = param; } + /// inline void setMaxEdgeNeigh(int m) { maxEdgeNeigh = m; } @@ -464,34 +371,22 @@ namespace AMDiS { /** \} */ // ========================================================================== - /** \brief - * Creates a new Element by cloning \ref elementPrototype - */ + /// Creates a new Element by cloning \ref elementPrototype Element* createNewElement(Element *parent = NULL); - /** \brief - * Creates a new ElInfo dependent of \ref dim of the mesh - */ + /// Creates a new ElInfo dependent of \ref dim of the mesh ElInfo* createNewElInfo(); - /** \brief - * Frees DOFs at the given position pointed by dof - */ + /// Frees DOFs at the given position pointed by dof void freeDOF(DegreeOfFreedom* dof, GeoIndex position); - /** \brief - * Frees memory for the given element el - */ + /// Frees memory for the given element el void freeElement(Element* el); - /** \brief - * Performs DOF compression for all DOFAdmins (see \ref DOFAdmin::compress) - */ + /// Performs DOF compression for all DOFAdmins (see \ref DOFAdmin::compress) void dofCompress(); - /** \brief - * Adds a DOFAdmin to the mesh - */ + /// Adds a DOFAdmin to the mesh virtual void addDOFAdmin(DOFAdmin *admin); /** \brief @@ -509,26 +404,18 @@ namespace AMDiS { const Flag fillFlag, int (*elFct)(ElInfo*)); - /** \brief - * Clears \ref macroElements - */ + /// Clears \ref macroElements inline void clearMacroElements() { macroElements.clear(); } - /** \brief - * Adds a macro element to the mesh - */ + /// Adds a macro element to the mesh void addMacroElement(MacroElement* me); - /** \brief - * Frees the array of DOF pointers (see \ref createDOFPtrs) - */ + /// Frees the array of DOF pointers (see \ref createDOFPtrs) void freeDOFPtrs(DegreeOfFreedom **ptrs); - /** \brief - * Used by \ref findElementAtPoint. - */ + /// Used by \ref findElementAtPoint. bool findElInfoAtPoint(const WorldVector<double>& xy, ElInfo *el_info, DimVec<double>& bary, @@ -579,9 +466,7 @@ namespace AMDiS { double *sp); - /** \brief - * Returns FILL_ANY_?D - */ + /// Returns FILL_ANY_?D inline static const Flag& getFillAnyFlag(int dim) { switch (dim) { case 1: @@ -599,187 +484,136 @@ namespace AMDiS { } } - // ===== Serializable implementation ===== - + /// Serialize the mesh to a file. void serialize(std::ostream &out); + /// Deserialize a mesh from a file. void deserialize(std::istream &in); - /** \brief - * Returns \ref elementIndex and increments it by 1. - */ + /// Returns \ref elementIndex and increments it by 1. inline int getNextElementIndex() { return elementIndex++; } - /** \brief - * Returns \ref initialized. - */ + /// Returns \ref initialized. inline bool isInitialized() { return initialized; } + /// inline std::map<BoundaryType, VertexVector*>& getPeriodicAssociations() { return periodicAssociations; } + /// bool associated(DegreeOfFreedom dof1, DegreeOfFreedom dof2); + /// bool indirectlyAssociated(DegreeOfFreedom dof1, DegreeOfFreedom dof2); + /// Returns \macroFileInfo inline MacroInfo* getMacroFileInfo() { return macroFileInfo; } + /// void clearMacroFileInfo(); + /// int calcMemoryUsage(); public: - /** \brief - * - */ + /// static const Flag FILL_NOTHING; - /** \brief - * - */ + /// static const Flag FILL_COORDS; - /** \brief - * - */ + /// static const Flag FILL_BOUND; - /** \brief - * - */ + /// static const Flag FILL_NEIGH; - /** \brief - * - */ + /// static const Flag FILL_OPP_COORDS; - /** \brief - * - */ + /// static const Flag FILL_ORIENTATION; - /** \brief - * - */ + /// static const Flag FILL_ADD_ALL; - /** \brief - * - */ + /// static const Flag FILL_ANY_1D; - /** \brief - * - */ + /// static const Flag FILL_ANY_2D; - /** \brief - * - */ + /// static const Flag FILL_ANY_3D; - /** \brief - * - */ + /// static const Flag FILL_DET; - /** \brief - * - */ + /// static const Flag FILL_GRD_LAMBDA; //************************************************************************** // flags for Mesh traversal //************************************************************************** - /** \brief - * - */ + /// static const Flag CALL_EVERY_EL_PREORDER; - /** \brief - * - */ + /// static const Flag CALL_EVERY_EL_INORDER; - /** \brief - * - */ + /// static const Flag CALL_EVERY_EL_POSTORDER; - /** \brief - * - */ + /// static const Flag CALL_LEAF_EL; - /** \brief - * - */ + /// static const Flag CALL_LEAF_EL_LEVEL; - /** \brief - * - */ + /// static const Flag CALL_EL_LEVEL; - /** \brief - * - */ + /// static const Flag CALL_MG_LEVEL; protected: + /// bool findElementAtPointRecursive(ElInfo *elinfo, const DimVec<double>& lambda, int outside, ElInfo *final_el_info); protected: - /** \brief - * maximal number of DOFs at one position - */ + /// maximal number of DOFs at one position static const int MAX_DOF; - /** \brief - * Name of this Mesh - */ + /// Name of this Mesh std::string name; - /** \brief - * Dimension of this Mesh. Doesn't have to be equal to dimension of world. - */ + /// Dimension of this Mesh. Doesn't have to be equal to dimension of world. int dim; - /** \brief - * Number of vertices in this Mesh - */ + /// Number of vertices in this Mesh int nVertices; - /** \brief - * Number of Edges in this Mesh - */ + /// Number of Edges in this Mesh int nEdges; - /** \brief - * Number of leaf elements in this Mesh - */ + /// Number of leaf elements in this Mesh int nLeaves; - /** \brief - * Total number of elements in this Mesh - */ + /// Total number of elements in this Mesh int nElements; - /** \brief - * Number of faces in this Mesh - */ + /// Number of faces in this Mesh int nFaces; /** \brief @@ -789,9 +623,7 @@ namespace AMDiS { */ int maxEdgeNeigh; - /** \brief - * Diameter of the mesh in the DIM_OF_WORLD directions - */ + /// Diameter of the mesh in the DIM_OF_WORLD directions WorldVector<double> diam; /** \brief @@ -809,9 +641,7 @@ namespace AMDiS { */ bool preserveCoarseDOFs; - /** \brief - * Number of all DOFs on a single element - */ + /// Number of all DOFs on a single element int nDOFEl; /** \brief @@ -855,24 +685,16 @@ namespace AMDiS { */ DimVec<int> node; - /** \brief - * list of all DOFAdmins - */ + /// List of all DOFAdmins std::vector<DOFAdmin*> admin; - /** \brief - * List of all MacroElements of this Mesh - */ + /// List of all MacroElements of this Mesh std::deque<MacroElement*> macroElements; - /** \brief - * Needed during DOF compression (\ref DOFAdmin::compress). - */ + /// Needed during DOF compression (\ref DOFAdmin::compress). std::vector<DegreeOfFreedom> newDOF; - /** \brief - * Needed during DOF compression (\ref DOFAdmin::compress). - */ + /// Needed during DOF compression (\ref DOFAdmin::compress). static DOFAdmin *compressAdmin; /** \brief @@ -882,19 +704,13 @@ namespace AMDiS { */ static Mesh* traversePtr; - /** \brief - * Used by compress- and check functions. Number of the current DOFAdmin - */ + /// Used by compress- and check functions. Number of the current DOFAdmin static int iadmin; - /** \brief - * Used by check functions - */ + /// Used by check functions static std::vector<DegreeOfFreedom> dof_used; - /** \brief - * - */ + /// static std::map<DegreeOfFreedom, DegreeOfFreedom*> serializedDOFs; /** \brief @@ -905,25 +721,16 @@ namespace AMDiS { */ Element* elementPrototype; - /** \brief - * Prototype for leaf data. Used for creation of new leaf data while - * refinement. - */ + /// Prototype for leaf data. Used for creation of new leaf data while refinement. ElementData* elementDataPrototype; - /** \brief - * Used for enumeration of all mesh elements - */ + /// Used for enumeration of all mesh elements int elementIndex; - /** \brief - * True if the mesh is already initialized, false otherwise. - */ + /// True if the mesh is already initialized, false otherwise. bool initialized; - /** \brief - * Map of managed periodic vertex associations. - */ + /// Map of managed periodic vertex associations. std::map<BoundaryType, VertexVector*> periodicAssociations; /** \brief @@ -933,9 +740,7 @@ namespace AMDiS { MacroInfo *macroFileInfo; protected: - /** \brief - * for findElement-Fcts - */ + /// for findElement-Fcts DimVec<double> final_lambda; /** \brief diff --git a/AMDiS/src/ParMetisPartitioner.cc b/AMDiS/src/ParMetisPartitioner.cc index 415e6ac6..fab2df99 100644 --- a/AMDiS/src/ParMetisPartitioner.cc +++ b/AMDiS/src/ParMetisPartitioner.cc @@ -13,28 +13,24 @@ namespace AMDiS { ParMetisMesh::ParMetisMesh(Mesh *mesh, MPI::Comm *comm) - : nElements(0), + : dim(mesh->getDim()), + nElements(0), mpiComm(comm) { FUNCNAME("ParMetisMesh::ParMetisMesh()"); int mpiSize = mpiComm->Get_size(); - int nodeCounter = 0; int elementCounter = 0; - - dim_ = mesh->getDim(); int dow = Global::getGeo(WORLD); TraverseStack stack; ElInfo *elInfo = stack.traverseFirst(mesh, -1, Mesh::CALL_EVERY_EL_PREORDER); while (elInfo) { - Element *element = elInfo->getElement(); - // get partition data PartitionElementData *partitionData = dynamic_cast<PartitionElementData*> - (element->getElementData(PARTITION_ED)); + (elInfo->getElement()->getElementData(PARTITION_ED)); if (partitionData && partitionData->getPartitionStatus() == IN && @@ -50,23 +46,23 @@ namespace AMDiS { TEST_EXIT(nElements > 0)("no elements in ParMETIS mesh\n"); // allocate memory - eptr_ = GET_MEMORY(int, nElements + 1); - eind_ = GET_MEMORY(int, nElements * (dim_ + 1)); + eptr = GET_MEMORY(int, nElements + 1); + eind = GET_MEMORY(int, nElements * (dim + 1)); elmdist = GET_MEMORY(int, mpiSize + 1); - elem_p2a_ = GET_MEMORY(int, nElements); + elem_p2a = GET_MEMORY(int, nElements); - if (dim_ == dow) { - xyz_ = GET_MEMORY(float, nElements * dim_); + if (dim == dow) { + xyz = GET_MEMORY(float, nElements * dim); } else { - xyz_ = NULL; + xyz = NULL; } - eptr_[0] = 0; + eptr[0] = 0; - int *ptr_eptr = eptr_ + 1; - int *ptr_eind = eind_; - float *ptr_xyz = xyz_; + int *ptr_eptr = eptr + 1; + int *ptr_eind = eind; + float *ptr_xyz = xyz; // gather element numbers and create elmdist mpiComm->Allgather(&nElements, 1, MPI_INT, elmdist + 1, 1, MPI_INT); @@ -77,7 +73,7 @@ namespace AMDiS { } // traverse mesh and fill distributed ParMETIS data - DimVec<double> bary(dim_, DEFAULT_VALUE, 1.0 / (dim_ + 1)); + DimVec<double> bary(dim, DEFAULT_VALUE, 1.0 / (dim + 1)); WorldVector<double> world; elementCounter = 0; @@ -102,12 +98,12 @@ namespace AMDiS { setAMDiSIndex(elementCounter, index); // write eptr entry - nodeCounter += dim_ + 1; + nodeCounter += dim + 1; *ptr_eptr = nodeCounter; ptr_eptr++; // write eind entries (element nodes) - for (int i = 0; i < dim_ + 1; i++) { + for (int i = 0; i < dim + 1; i++) { *ptr_eind = element->getDOF(i, 0); ptr_eind++; } @@ -115,7 +111,7 @@ namespace AMDiS { // write xyz element coordinates if (ptr_xyz) { elInfo->coordToWorld(bary, world); - for (int i = 0; i < dim_; i++) { + for (int i = 0; i < dim; i++) { *ptr_xyz = static_cast<float>(world[i]); ptr_xyz++; } @@ -129,20 +125,20 @@ namespace AMDiS { ParMetisMesh::~ParMetisMesh() { - if (eptr_) - FREE_MEMORY(eptr_, int, nElements + 1); + if (eptr) + FREE_MEMORY(eptr, int, nElements + 1); - if (eind_) - FREE_MEMORY(eind_, int, nElements * (dim_ + 1)); + if (eind) + FREE_MEMORY(eind, int, nElements * (dim + 1)); if (elmdist) FREE_MEMORY(elmdist, int, mpiComm->Get_size() + 1); - if (xyz_) - FREE_MEMORY(xyz_, float, nElements * dim_); + if (xyz) + FREE_MEMORY(xyz, float, nElements * dim); - if (elem_p2a_) - FREE_MEMORY(elem_p2a_, int, nElements); + if (elem_p2a) + FREE_MEMORY(elem_p2a, int, nElements); } ParMetisGraph::ParMetisGraph(ParMetisMesh *parMetisMesh, @@ -162,15 +158,15 @@ namespace AMDiS { parMetisMesh_->getElementInd(), &numflag, &ncommonnodes, - &xadj_, - &adjncy_, + &xadj, + &adjncy, &tmpComm); } ParMetisGraph::~ParMetisGraph() { - free(xadj_); - free(adjncy_); + free(xadj); + free(adjncy); } @@ -237,7 +233,6 @@ namespace AMDiS { int *wgts = elemWeights ? GET_MEMORY(int, numElements) : NULL; float *floatWgts = elemWeights ? GET_MEMORY(float, numElements) : NULL; float maxWgt = 0.0; - float *ptr_floatWgts = floatWgts; elInfo = stack.traverseFirst(mesh_, -1, Mesh::CALL_EVERY_EL_PREORDER); @@ -386,12 +381,11 @@ namespace AMDiS { int mpiRank = mpiComm->Get_rank(); int mpiSize = mpiComm->Get_size(); - int *numPartitionElements = GET_MEMORY(int, mpiSize); - int *elmdist = parMetisMesh_->getElementDist(); + for (int i = 0; i < mpiSize; i++) { - numPartitionElements[i] = elmdist[i+1] - elmdist[i]; + numPartitionElements[i] = elmdist[i + 1] - elmdist[i]; } // === count number of elements === diff --git a/AMDiS/src/ParMetisPartitioner.h b/AMDiS/src/ParMetisPartitioner.h index ea03fdc2..58758b08 100644 --- a/AMDiS/src/ParMetisPartitioner.h +++ b/AMDiS/src/ParMetisPartitioner.h @@ -51,33 +51,33 @@ namespace AMDiS { ~ParMetisMesh(); inline void setParMetisIndex(int amdisIndex, int parMetisIndex) { - elem_a2p_[amdisIndex] = parMetisIndex + 1; + elem_a2p[amdisIndex] = parMetisIndex + 1; } inline int getParMetisIndex(int amdisIndex) { - int result = elem_a2p_[amdisIndex]; + int result = elem_a2p[amdisIndex]; TEST_EXIT(result > 0)("invalid index\n"); return result - 1; } inline void setAMDiSIndex(int parMetisIndex, int amdisIndex) { - elem_p2a_[parMetisIndex] = amdisIndex; + elem_p2a[parMetisIndex] = amdisIndex; } inline int getAMDiSIndex(int parMetisIndex) { - return elem_p2a_[parMetisIndex]; + return elem_p2a[parMetisIndex]; } inline int *getAMDiSIndices() { - return elem_p2a_; + return elem_p2a; } inline int *getElementPtr() { - return eptr_; + return eptr; } inline int *getElementInd() { - return eind_; + return eind; } inline int *getElementDist() { @@ -85,11 +85,11 @@ namespace AMDiS { } inline int getDim() { - return dim_; + return dim; } inline float *getXYZ() { - return xyz_; + return xyz; } inline int getNumElements() { @@ -97,9 +97,9 @@ namespace AMDiS { } protected: - int *eptr_; + int *eptr; - int *eind_; + int *eind; /* \brief * Array that specifies the distribution of the mesh elements. @@ -111,15 +111,15 @@ namespace AMDiS { */ int *elmdist; - int dim_; + int dim; - float *xyz_; + float *xyz; int nElements; - std::map<int, int> elem_a2p_; + std::map<int, int> elem_a2p; - int *elem_p2a_; + int *elem_p2a; /// The MPI communicator that should be used for mesh partition. MPI::Comm *mpiComm; @@ -138,18 +138,19 @@ namespace AMDiS { ~ParMetisGraph(); inline int *getXAdj() { - return xadj_; + return xadj; } inline int *getAdjncy() { - return adjncy_; + return adjncy; } protected: ParMetisMesh *parMetisMesh_; - int *xadj_; - int *adjncy_; + int *xadj; + + int *adjncy; }; diff --git a/AMDiS/src/ParallelProblem.cc b/AMDiS/src/ParallelProblem.cc index b193297c..69d93c7d 100644 --- a/AMDiS/src/ParallelProblem.cc +++ b/AMDiS/src/ParallelProblem.cc @@ -332,10 +332,10 @@ namespace AMDiS { if (initial) { initial = false; partitioner->fillCoarsePartitionVec(&oldPartitionVec); - partitioner->partition(&elemWeights_, INITIAL); + partitioner->partition(&elemWeights, INITIAL); } else { oldPartitionVec = partitionVec; - partitioner->partition(&elemWeights_, ADAPTIVE_REPART, 100.0 /*0.000001*/); + partitioner->partition(&elemWeights, ADAPTIVE_REPART, 100.0 /*0.000001*/); } partitioner->fillCoarsePartitionVec(&partitionVec); @@ -1050,26 +1050,26 @@ namespace AMDiS { double localWeightSum = 0.0; int elNum = -1; - elemWeights_.clear(); + elemWeights.clear(); TraverseStack stack; ElInfo *elInfo = stack.traverseFirst(mesh, -1, Mesh::CALL_EVERY_EL_PREORDER); - while(elInfo) { + while (elInfo) { Element *element = elInfo->getElement(); // get partition data PartitionElementData *partitionData = dynamic_cast<PartitionElementData*> (element->getElementData(PARTITION_ED)); - if(partitionData && partitionData->getPartitionStatus() == IN) { - if(partitionData->getLevel() == 0) { + if (partitionData && partitionData->getPartitionStatus() == IN) { + if (partitionData->getLevel() == 0) { elNum = element->getIndex(); } TEST_EXIT(elNum != -1)("invalid element number\n"); - if(element->isLeaf()) { - elemWeights_[elNum] += 1.0; + if (element->isLeaf()) { + elemWeights[elNum] += 1.0; localWeightSum += 1.0; } } @@ -1352,7 +1352,9 @@ namespace AMDiS { if (mpiSize > 1) { clock_t partitioningStart = clock(); + // create an initial partitioning of the mesh partitioner->createPartitionData(); + // set the element weights, which are 1 at the very first begin. setElemWeights(adaptInfo); partitionMesh(adaptInfo); diff --git a/AMDiS/src/ParallelProblem.h b/AMDiS/src/ParallelProblem.h index 0bde33ef..581b09cb 100644 --- a/AMDiS/src/ParallelProblem.h +++ b/AMDiS/src/ParallelProblem.h @@ -73,6 +73,7 @@ namespace AMDiS { virtual bool doBuildGlobalSolution(AdaptInfo *adaptInfo) = 0; + /// Set for each element on the partitioning level the number of leaf elements. virtual double setElemWeights(AdaptInfo *adaptInfo) = 0; virtual void partitionMesh(AdaptInfo *adaptInfo) = 0; @@ -223,18 +224,21 @@ namespace AMDiS { virtual bool doBuildGlobalSolution(AdaptInfo *adaptInfo); virtual void partitionMesh(AdaptInfo *adaptInfo); + virtual void refineOverlap(AdaptInfo *adaptInfo); + virtual void createOverlap(AdaptInfo *adaptInfo); + virtual void globalRefineOutOfPartition(AdaptInfo *adaptInfo); + virtual void coarsenOutOfPartition(AdaptInfo *adaptInfo); + virtual void synchronizeMeshes(AdaptInfo *adaptInfo); + virtual double setElemWeights(AdaptInfo *adaptInfo); virtual void globalRefinements(); - /** \brief - * - */ void exchangeRankSolutions(AdaptInfo *adaptInfo, Mesh *workMesh, std::vector<DOFVector<double>*> rankSolutions); @@ -312,8 +316,8 @@ namespace AMDiS { */ std::map<int, int> oldPartitionVec; - /// - std::map<int, double> elemWeights_; + /// Weights for the elements, i.e., the number of leaf elements within this element. + std::map<int, double> elemWeights; /// Stores to every element the set of partitions it corresponds to. std::map<Element*, std::set<int> > elementPartitions_; diff --git a/AMDiS/src/VtkWriter.h b/AMDiS/src/VtkWriter.h index fa8bbbfa..ee362f0b 100644 --- a/AMDiS/src/VtkWriter.h +++ b/AMDiS/src/VtkWriter.h @@ -48,27 +48,19 @@ namespace AMDiS { } - /** \brief - * Writes a ParaView-VTK file. - */ + /// Writes a ParaView-VTK file. int writeFile(const std::string &name); - /** \brief - * May be used to simply write ParaView files. - */ + /// May be used to simply write ParaView files. static void writeFile(DOFVector<double> *values, const std::string &filename); - /** \brief - * Set a compressing method for file output. - */ + /// Set a compressing method for file output. void setCompression(FileCompression c) { compress = c; } - /** \brief - * Adds a new entry to a ParaView animation file. - */ + /// Adds a new entry to a ParaView animation file. int updateAnimationFile(std::string valueFilename, std::vector< std::string > *paraViewAnimationFrames, const std::string &animationFilename); -- GitLab