Skip to content

Commit c725fc1

Browse files
authored
Merge pull request #2443 from su2code/feature_hom_cleanup_partitioning
Clean up the partitioner for the FEM solver.
2 parents 5db56f9 + 23c3d09 commit c725fc1

25 files changed

+1631
-1363
lines changed

Common/include/fem/fem_geometry_structure.hpp

Lines changed: 2 additions & 144 deletions
Original file line numberDiff line numberDiff line change
@@ -32,152 +32,10 @@
3232
#include "fem_standard_element.hpp"
3333
#include "../wall_model.hpp"
3434
#include "../linear_algebra/blas_structure.hpp"
35+
#include "../toolboxes/fem/CFaceOfElement.hpp"
3536

3637
using namespace std;
3738

38-
/*!
39-
* \class CLong3T
40-
* \brief Help class used to store three longs as one entity.
41-
* \version 8.1.0 "Harrier"
42-
*/
43-
struct CLong3T {
44-
long long0 = 0; /*!< \brief First long to store in this class. */
45-
long long1 = 0; /*!< \brief Second long to store in this class. */
46-
long long2 = 0; /*!< \brief Third long to store in this class. */
47-
48-
CLong3T() = default;
49-
50-
CLong3T(const long a, const long b, const long c) {
51-
long0 = a;
52-
long1 = b;
53-
long2 = c;
54-
}
55-
56-
bool operator<(const CLong3T& other) const;
57-
};
58-
59-
/*!
60-
* \class CReorderElements
61-
* \brief Class, used to reorder the owned elements after the partitioning.
62-
* \author E. van der Weide
63-
* \version 8.1.0 "Harrier"
64-
*/
65-
class CReorderElements {
66-
private:
67-
unsigned long globalElemID; /*!< \brief Global element ID of the element. */
68-
unsigned short timeLevel; /*!< \brief Time level of the element. Only relevant
69-
for time accurate local time stepping. */
70-
bool commSolution; /*!< \brief Whether or not the solution must be
71-
communicated to other ranks. */
72-
unsigned short elemType; /*!< \brief Short hand for the element type, Which
73-
stored info of the VTK_Type, polynomial
74-
degree of the solution and whether or
75-
not the Jacobian is constant. */
76-
public:
77-
/*!
78-
* \brief Constructor of the class, set the member variables to the arguments.
79-
*/
80-
CReorderElements(const unsigned long val_GlobalElemID, const unsigned short val_TimeLevel,
81-
const bool val_CommSolution, const unsigned short val_VTK_Type, const unsigned short val_nPolySol,
82-
const bool val_JacConstant);
83-
84-
/*!
85-
* \brief Default constructor of the class. Disabled.
86-
*/
87-
CReorderElements(void) = delete;
88-
89-
/*!
90-
* \brief Less than operator of the class. Needed for the sorting.
91-
*/
92-
bool operator<(const CReorderElements& other) const;
93-
94-
/*!
95-
* \brief Function to make available the variable commSolution.
96-
* \return Whether or not the solution of the element must be communicated.
97-
*/
98-
inline bool GetCommSolution(void) const { return commSolution; }
99-
100-
/*!
101-
* \brief Function to make available the element type of the element.
102-
* \return The value of elemType, which stores the VTK type, polynomial degree
103-
and whether or not the Jacobian is constant.
104-
*/
105-
inline unsigned short GetElemType(void) const { return elemType; }
106-
107-
/*!
108-
* \brief Function to make available the global element ID.
109-
* \return The global element ID of the element.
110-
*/
111-
inline unsigned long GetGlobalElemID(void) const { return globalElemID; }
112-
113-
/*!
114-
* \brief Function to make available the time level.
115-
* \return The time level of the element.
116-
*/
117-
inline unsigned short GetTimeLevel(void) const { return timeLevel; }
118-
119-
/*!
120-
* \brief Function, which sets the value of commSolution.
121-
* \param[in] val_CommSolution - value to which commSolution must be set.
122-
*/
123-
inline void SetCommSolution(const bool val_CommSolution) { commSolution = val_CommSolution; }
124-
};
125-
126-
/*!
127-
* \class CSortFaces
128-
* \brief Functor, used for a different sorting of the faces than the < operator
129-
* of CFaceOfElement.
130-
* \author E. van der Weide
131-
* \version 8.1.0 "Harrier"
132-
*/
133-
class CVolumeElementFEM; // Forward declaration to avoid problems.
134-
class CSortFaces {
135-
private:
136-
unsigned long nVolElemOwned; /*!< \brief Number of locally owned volume elements. */
137-
unsigned long nVolElemTot; /*!< \brief Total number of local volume elements . */
138-
139-
const CVolumeElementFEM* volElem; /*!< \brief The locally stored volume elements. */
140-
141-
public:
142-
/*!
143-
* \brief Constructor of the class. Set the values of the member variables.
144-
*/
145-
CSortFaces(unsigned long val_nVolElemOwned, unsigned long val_nVolElemTot, const CVolumeElementFEM* val_volElem) {
146-
nVolElemOwned = val_nVolElemOwned;
147-
nVolElemTot = val_nVolElemTot;
148-
volElem = val_volElem;
149-
}
150-
151-
/*!
152-
* \brief Default constructor of the class. Disabled.
153-
*/
154-
CSortFaces(void) = delete;
155-
156-
/*!
157-
* \brief Operator used for the comparison.
158-
* \param[in] f0 - First face in the comparison.
159-
* \param[in] f1 - Second face in the comparison.
160-
*/
161-
bool operator()(const CFaceOfElement& f0, const CFaceOfElement& f1);
162-
};
163-
164-
/*!
165-
* \class CSortBoundaryFaces
166-
* \brief Functor, used for a different sorting of the faces than the < operator
167-
* of CSurfaceElementFEM.
168-
* \author E. van der Weide
169-
* \version 8.1.0 "Harrier"
170-
*/
171-
struct CSurfaceElementFEM; // Forward declaration to avoid problems.
172-
struct CSortBoundaryFaces {
173-
/*!
174-
* \brief Operator used for the comparison.
175-
* \param[in] f0 - First boundary face in the comparison.
176-
* \param[in] f1 - Second boundary face in the comparison.
177-
*/
178-
bool operator()(const CSurfaceElementFEM& f0, const CSurfaceElementFEM& f1);
179-
};
180-
18139
/*!
18240
* \class CVolumeElementFEM
18341
* \brief Class to store a volume element for the FEM solver.
@@ -271,7 +129,7 @@ class CVolumeElementFEM {
271129

272130
/*!
273131
* \class CPointFEM
274-
* \brief Class to a point for the FEM solver.
132+
* \brief Class to store a point for the FEM solver.
275133
* \author E. van der Weide
276134
* \version 8.1.0 "Harrier"
277135
*/

Common/include/fem/fem_standard_element.hpp

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -990,7 +990,7 @@ class CFEMStandardElement : public CFEMStandardElementBase {
990990
type. This information is used to determine a well balanced partition.
991991
* \param[in] config - Object, which contains the input parameters.
992992
*/
993-
su2double WorkEstimateMetis(CConfig* config);
993+
passivedouble WorkEstimateMetis(CConfig* config);
994994

995995
private:
996996
/*!
@@ -1420,7 +1420,7 @@ class CFEMStandardInternalFace : public CFEMStandardElementBase {
14201420
type. This information is used to determine a well balanced partition.
14211421
* \param[in] config - Object, which contains the input parameters.
14221422
*/
1423-
su2double WorkEstimateMetis(CConfig* config);
1423+
passivedouble WorkEstimateMetis(CConfig* config);
14241424

14251425
private:
14261426
/*!
@@ -1636,7 +1636,7 @@ class CFEMStandardBoundaryFace : public CFEMStandardElementBase {
16361636
type. This information is used to determine a well balanced partition.
16371637
* \param[in] config - Object, which contains the input parameters.
16381638
*/
1639-
su2double WorkEstimateMetis(CConfig* config);
1639+
passivedouble WorkEstimateMetis(CConfig* config);
16401640

16411641
/*!
16421642
* \brief Function, which estimates the additional amount of work for an element
@@ -1645,7 +1645,7 @@ class CFEMStandardBoundaryFace : public CFEMStandardElementBase {
16451645
* \param[in] config - Object, which contains the input parameters.
16461646
* \param[in] nPointsWF - Number of points to discretize the wall model.
16471647
*/
1648-
su2double WorkEstimateMetisWallFunctions(CConfig* config, const unsigned short nPointsWF);
1648+
passivedouble WorkEstimateMetisWallFunctions(CConfig* config, const unsigned short nPointsWF);
16491649

16501650
private:
16511651
/*!

Common/include/geometry/CGeometry.hpp

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -60,7 +60,6 @@ extern "C" {
6060
#include "dual_grid/CTurboVertex.hpp"
6161

6262
#include "../CConfig.hpp"
63-
#include "../fem/geometry_structure_fem_part.hpp"
6463
#include "../toolboxes/graph_toolbox.hpp"
6564
#include "../adt/CADTElemClass.hpp"
6665

Common/include/geometry/CPhysicalGeometry.hpp

Lines changed: 69 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -30,6 +30,8 @@
3030
#include "CGeometry.hpp"
3131
#include "meshreader/CMeshReaderBase.hpp"
3232
#include "../containers/C2DContainer.hpp"
33+
#include "../toolboxes/classes_multiple_integers.hpp"
34+
#include "../toolboxes/fem/CFaceOfElement.hpp"
3335

3436
/*!
3537
* \class CPhysicalGeometry
@@ -497,6 +499,34 @@ class CPhysicalGeometry final : public CGeometry {
497499
*/
498500
void SetColorFEMGrid_Parallel(CConfig* config) override;
499501

502+
/*!
503+
* \brief Determine the donor elements for the boundary elements on viscous
504+
wall boundaries when wall functions are used.
505+
* \param[in] config - Definition of the particular problem.
506+
*/
507+
void DetermineDonorElementsWallFunctions(CConfig* config);
508+
509+
#ifdef HAVE_MPI
510+
#ifdef HAVE_PARMETIS
511+
/*!
512+
* \brief Function, which converts the input the format for ParMETIS and calls
513+
* ParMETIS to determine the actual colors of the elements.
514+
* \param[in] adjacency - Adjacency information of the elements.
515+
* \param[in] vwgt - Weights of the vertices of the graph, which are the elements.
516+
* \param[in] adjwgt - Weights of the adjacencies of the graph.
517+
*/
518+
void DetermineFEMColorsViaParMETIS(vector<vector<unsigned long> >& adjacency, vector<passivedouble>& vwgt,
519+
vector<vector<passivedouble> >& adjwgt);
520+
#endif
521+
#endif
522+
523+
/*!
524+
* \brief Determine whether or not the Jacobians of the elements and faces
525+
are constant and a length scale of the elements.
526+
* \param[in] config - Definition of the particular problem.
527+
*/
528+
void DetermineFEMConstantJacobiansAndLenScale(CConfig* config);
529+
500530
/*!
501531
* \brief Compute the weights of the FEM graph for ParMETIS.
502532
* \param[in] config - Definition of the particular problem.
@@ -507,24 +537,44 @@ class CPhysicalGeometry final : public CGeometry {
507537
* \param[out] vwgt - Weights of the vertices of the graph, i.e. the elements.
508538
* \param[out] adjwgt - Weights of the edges of the graph.
509539
*/
510-
void ComputeFEMGraphWeights(CConfig* config, const vector<CFaceOfElement>& localFaces,
511-
const vector<vector<unsigned long> >& adjacency,
512-
const map<unsigned long, CUnsignedShort2T>& mapExternalElemIDToTimeLevel,
513-
vector<su2double>& vwgt, vector<vector<su2double> >& adjwgt);
540+
void DetermineFEMGraphWeights(CConfig* config, const vector<CFaceOfElement>& localFaces,
541+
const vector<vector<unsigned long> >& adjacency,
542+
const map<unsigned long, CUnsignedShort2T>& mapExternalElemIDToTimeLevel,
543+
vector<passivedouble>& vwgt, vector<vector<passivedouble> >& adjwgt);
514544

515545
/*!
516-
* \brief Determine the donor elements for the boundary elements on viscous
517-
wall boundaries when wall functions are used.
518-
* \param[in] config - Definition of the particular problem.
546+
* \brief Function, which determines the adjacency information of the graph
547+
* representation of the grid.
548+
* \param[in] localFaces - Vector containing the local matching faces of the FEM grid.
549+
* \param[out] adjacency - Vector of vectors to store the adjacency.
519550
*/
520-
void DetermineDonorElementsWallFunctions(CConfig* config);
551+
void DetermineGraphAdjacency(const vector<CFaceOfElement>& localFaces, vector<vector<unsigned long> >& adjacency);
521552

522553
/*!
523-
* \brief Determine whether or not the Jacobians of the elements and faces
524-
are constant and a length scale of the elements.
525-
* \param[in] config - Definition of the particular problem.
554+
* \brief Function, which determines the matching faces of a FEM grid.
555+
* \param[in] config - Definition of the particular problem.
556+
* \param[out] localFaces - Vector containing the local faces of the FEM grid.
557+
* On output the matching faces are stored as one face.
526558
*/
527-
void DetermineFEMConstantJacobiansAndLenScale(CConfig* config);
559+
void DetermineMatchingFacesFEMGrid(const CConfig* config, vector<CFaceOfElement>& localFaces);
560+
561+
/*!
562+
* \brief Function, which determines the non-matching faces of a FEM grid.
563+
* \param[in] config - Definition of the particular problem.
564+
* \param[in,out] localMatchingFaces - Vector containing the local faces of the FEM grid.
565+
* On output the non-matching faces are removed.
566+
*/
567+
void DetermineNonMatchingFacesFEMGrid(const CConfig* config, vector<CFaceOfElement>& localMatchingFaces);
568+
569+
/*!
570+
* \brief Function, which determines the owner of the internal faces, i.e. which element
571+
* is responsible for computing the fluxes through the face.
572+
* \param[in] localFaces - Vector, which contains the element faces of this rank.
573+
* \param[out] mapExternalElemIDToTimeLevel - Map from the external element ID's to their time level and number of
574+
* DOFs.
575+
*/
576+
void DetermineOwnershipInternalFaces(vector<CFaceOfElement>& localFaces,
577+
map<unsigned long, CUnsignedShort2T>& mapExternalElemIDToTimeLevel);
528578

529579
/*!
530580
* \brief Determine the neighboring information for periodic faces of a FEM grid.
@@ -543,6 +593,13 @@ class CPhysicalGeometry final : public CGeometry {
543593
void DetermineTimeLevelElements(CConfig* config, const vector<CFaceOfElement>& localFaces,
544594
map<unsigned long, CUnsignedShort2T>& mapExternalElemIDToTimeLevel);
545595

596+
/*!
597+
* \brief Function, which stores the information of the local matching faces in the
598+
* data structures of the local elements.
599+
* \param[in] localFaces - Vector, which contains the internal matching faces of this rank.
600+
*/
601+
void StoreFaceInfoInLocalElements(const vector<CFaceOfElement>& localFaces);
602+
546603
/*!
547604
* \brief Compute 3 grid quality metrics: orthogonality angle, dual cell aspect ratio, and dual cell volume ratio.
548605
* \param[in] config - Definition of the particular problem.

Common/include/geometry/meshreader/CMeshReaderBase.hpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -32,7 +32,7 @@
3232
#include <string.h>
3333

3434
#include "../primal_grid/CPrimalGridFEM.hpp"
35-
#include "../../fem/geometry_structure_fem_part.hpp"
35+
#include "../../toolboxes/fem/CFaceOfElement.hpp"
3636
#include "../../parallelization/mpi_structure.hpp"
3737
#include "../../CConfig.hpp"
3838

Common/include/linear_algebra/blas_structure.hpp

Lines changed: 1 addition & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -29,11 +29,6 @@
2929

3030
#pragma once
3131

32-
/* LIBXSMM include files, if supported. */
33-
#ifdef HAVE_LIBXSMM
34-
#include "libxsmm.h"
35-
#endif
36-
3732
class CConfig;
3833

3934
/*!
@@ -494,8 +489,7 @@ class CBlasStructure {
494489
}
495490

496491
private:
497-
#if !(defined(HAVE_LIBXSMM) || defined(HAVE_BLAS) || defined(HAVE_MKL)) || \
498-
(defined(CODI_REVERSE_TYPE) || defined(CODI_FORWARD_TYPE))
492+
#if !(defined(HAVE_BLAS) || defined(HAVE_MKL)) || (defined(CODI_REVERSE_TYPE) || defined(CODI_FORWARD_TYPE))
499493
/* Blocking parameters for the outer kernel. We multiply mc x kc blocks of
500494
the matrix A with kc x nc panels of the matrix B (this approach is referred
501495
to as `gebp` in the literature). */

0 commit comments

Comments
 (0)