Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

New data structure for multidimensional data (+some bugfixes) #1286

Merged
merged 55 commits into from
May 29, 2021
Merged
Show file tree
Hide file tree
Changes from 43 commits
Commits
Show all changes
55 commits
Select commit Hold shift + click to select a range
89b6700
Fix rough wall treatment for multizone setup
maxaehle May 11, 2021
188869f
removed redundant "virtual"
maxaehle May 12, 2021
f6f62f5
communicate wall roughness with NdFlattener
maxaehle May 12, 2021
5d62fc7
Index shift for K in NdFlattener
maxaehle May 14, 2021
dea3838
corrections
maxaehle May 14, 2021
53e6189
improvements proposed by @pcarruscag
maxaehle May 14, 2021
1b827e5
NdFlattener IndexAccumulator to provide []...[] interface
maxaehle May 14, 2021
fc628c7
SetWallRoughness as template with the [][][] interface
maxaehle May 14, 2021
b433ff6
moved ndflattener.hpp to Common/include/toolboxes
maxaehle May 14, 2021
af1bb01
Unit tests added
maxaehle May 14, 2021
22073ff
documentation of NdFlattener
maxaehle May 15, 2021
16c75e5
correct handling of non-const and const access
maxaehle May 15, 2021
4a1b3d4
operator[] returns reference to Data, and provide .data()
maxaehle May 15, 2021
9284153
IndexAccumulator_Checked added, which also carries size
maxaehle May 15, 2021
f940ff7
Removed get, getNChildren in favor of []...[] interface
maxaehle May 15, 2021
663e9b9
correction, now unit tests are passed
maxaehle May 15, 2021
9020677
NdFlattener documentation improved: refreshing
maxaehle May 15, 2021
80ec291
::Get_Nd_MPI_Env() is inline, not static
maxaehle May 15, 2021
e2a44d1
removed unnecessary ";"
maxaehle May 15, 2021
1bfa060
removed more unused ";"
maxaehle May 15, 2021
706e878
correct spelling in comment
maxaehle May 19, 2021
c6d7346
inherit default values for SetWallDistance
maxaehle May 24, 2021
13cb05d
use default NdFlattener arguments
maxaehle May 24, 2021
f60ca15
Refactoring in ndflattener.hpp
maxaehle May 24, 2021
c70706b
typedef -> using
maxaehle May 24, 2021
efe1c63
continue f60ca15d with _N -> N_
maxaehle May 24, 2021
0b19e6d
IndexAccumulator_Base::conditional -> ::su2conditional
maxaehle May 24, 2021
dfd3686
'Merge' IndexAccumulator_Checked into IndexAccumulator
maxaehle May 24, 2021
b82a065
added functionality to NdFlattener<1>
maxaehle May 24, 2021
26fca77
Reference instead of pointer for gathering initialization/refreshing
maxaehle May 24, 2021
a410d09
nd pointer->ref
maxaehle May 24, 2021
a0fb3d5
const reference in parameter packs
maxaehle May 24, 2021
fe56658
Merge branch 'fix_wallroughness_multizone' into tmp_1
maxaehle May 24, 2021
12890b9
replace parameter pack in IndexAccumulator constructor
maxaehle May 24, 2021
25e58e6
continue f60ca15d
maxaehle May 24, 2021
0cfcf1b
Nd_MPI_Environment in main scope, with constructor
maxaehle May 24, 2021
3a98d59
Look-up for IndexAccumulator is always a const method
maxaehle May 24, 2021
9d13918
get rid of ones and displs by using MPI_Allgather
maxaehle May 24, 2021
ab085f5
use std::vector for Nodes_all_K_as_int, Nodes_all_k_cumulated
maxaehle May 24, 2021
8d88a68
use su2matrix for Nodes_all
maxaehle May 24, 2021
fd29fe9
update comments to reflect 0cfcf1bb
maxaehle May 24, 2021
f376c80
clang-format -i Common/include/toolboxes/ndflattener.hpp
maxaehle May 24, 2021
e1f2f73
manual improvements of code formatting
maxaehle May 24, 2021
d66a0ef
Merge remote-tracking branch 'upstream/develop' into fix_wallroughnes…
pcarruscag May 24, 2021
13c63fa
avoid duplication of default values
pcarruscag May 25, 2021
018b1a8
example of what should not be possible
pcarruscag May 25, 2021
f0e16b0
IndexAccumulator::operator[],data is non-const, added const variants
maxaehle May 25, 2021
722a4dc
Removed forbidden write access in ndflattener_tests.cpp
maxaehle May 25, 2021
e97b0bf
little less duplication in []
pcarruscag May 26, 2021
1244638
error if roughness is set to non-0 value
maxaehle May 27, 2021
b5bd2b1
documentation improved
maxaehle May 27, 2021
340cf8c
further testing of the CI pipeline
maxaehle May 27, 2021
a5d8a62
remove debug stuff
maxaehle May 28, 2021
8372309
correct non-MPI Allgatherv, Alltoallv
maxaehle May 28, 2021
aaf5b8a
include <limits> in CPrimalGrid.hpp
maxaehle May 28, 2021
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 8 additions & 1 deletion Common/include/code_config.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -60,6 +60,13 @@
template<bool condition>
using su2enable_if = typename std::enable_if<condition,bool>::type;

/*--- Compile-time type selection. ---*/
template<bool B, class T, class F> struct su2conditional { typedef T type; };
template<class T, class F> struct su2conditional<false, T, F> { typedef F type; };

template<bool B, class T, class F>
using su2conditional_t = typename su2conditional<B,T,F>::type;

/*--- Detect compilation with OpenMP. ---*/
#if defined(_OPENMP)
#define HAVE_OMP
Expand Down Expand Up @@ -103,7 +110,7 @@ using su2double = codi::RealForward;
using su2double = double;
#endif

/*--- This type can be used for (rare) compatiblity cases or for
/*--- This type can be used for (rare) compatibility cases or for
* computations that are intended to be (always) passive. ---*/
using passivedouble = double;

Expand Down
11 changes: 7 additions & 4 deletions Common/include/fem/fem_geometry_structure.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -1227,11 +1227,14 @@ class CMeshFEM_DG: public CMeshFEM {
void SetWallDistance(su2double val) override;

/*!
* \brief Set the wall distance based on an previously constructed ADT
* \param[in] config - Definition of the particular problem.
* \param[in] WallADT - The ADT to compute the wall distance
* \brief Reduce the wall distance based on an previously constructed ADT.
* \details The ADT might belong to another zone, giving rise to lower wall distances
* than those already stored.
* \param[in] WallADT - The ADT to reduce the wall distance
* \param[in] config - Config of this geometry (not the ADT zone's geometry)
* \param[in] iZone - ignored
*/
void SetWallDistance(const CConfig *config, CADTElemClass* WallADT) override;
void SetWallDistance(CADTElemClass* WallADT, const CConfig* config, unsigned short iZone) override;
};

/*!
Expand Down
13 changes: 8 additions & 5 deletions Common/include/geometry/CGeometry.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -1683,11 +1683,14 @@ class CGeometry {
virtual std::unique_ptr<CADTElemClass> ComputeViscousWallADT(const CConfig *config) const { return nullptr; }

/*!
* \brief Set the wall distance based on an previously constructed ADT
* \param[in] config - Definition of the particular problem.
* \param[in] WallADT - The ADT to compute the wall distance
*/
virtual void SetWallDistance(const CConfig *config, CADTElemClass* WallADT) {}
* \brief Reduce the wall distance based on an previously constructed ADT.
* \details The ADT might belong to another zone, giving rise to lower wall distances
* than those already stored.
* \param[in] WallADT - The ADT to reduce the wall distance
* \param[in] config - Config of this geometry (not the ADT zone's geometry)
* \param[in] iZone - Zone whose markers made the ADT
*/
virtual void SetWallDistance(CADTElemClass* WallADT, const CConfig* config, unsigned short iZone = numeric_limits<unsigned short>::max()) {}

/*!
* \brief Set wall distances a specific value
Expand Down
18 changes: 7 additions & 11 deletions Common/include/geometry/CPhysicalGeometry.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -104,9 +104,6 @@ class CPhysicalGeometry final : public CGeometry {
unsigned long *Elem_ID_BoundTria_Linear{nullptr};
unsigned long *Elem_ID_BoundQuad_Linear{nullptr};

vector<int> GlobalMarkerStorageDispl;
vector<su2double> GlobalRoughness_Height;

su2double Streamwise_Periodic_RefNode[MAXNDIM] = {0}; /*!< \brief Coordinates of the reference node [m] on the receiving periodic marker, for recovered pressure/temperature computation only.*/

public:
Expand Down Expand Up @@ -767,10 +764,14 @@ class CPhysicalGeometry final : public CGeometry {
std::unique_ptr<CADTElemClass> ComputeViscousWallADT(const CConfig *config) const override;

/*!
* \brief Set the wall distance based on an previously constructed ADT
* \param[in] WallADT - The ADT to compute the wall distance
* \brief Reduce the wall distance based on an previously constructed ADT.
* \details The ADT might belong to another zone, giving rise to lower wall distances
* than those already stored.
* \param[in] WallADT - The ADT to reduce the wall distance
* \param[in] config - ignored
* \param[in] iZone - zone whose markers made the ADT
*/
void SetWallDistance(const CConfig *config, CADTElemClass* WallADT) override;
void SetWallDistance(CADTElemClass* WallADT, const CConfig* config, unsigned short iZone) override;

/*!
* \brief Set wall distances a specific value
Expand All @@ -781,11 +782,6 @@ class CPhysicalGeometry final : public CGeometry {
}
}

/*!
* \brief Set roughness values for markers in a global array.
*/
void SetGlobalMarkerRoughness(const CConfig* config);

/*!
* \brief For streamwise periodicity, find & store a unique reference node on the designated periodic inlet.
* \param[in] config - Definition of the particular problem.
Expand Down
41 changes: 39 additions & 2 deletions Common/include/geometry/dual_grid/CPoint.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,7 @@
#include "../../containers/container_decorators.hpp"
#include "../../toolboxes/graph_toolbox.hpp"
#include <vector>
#include "../../toolboxes/ndflattener.hpp"

using namespace std;

Expand Down Expand Up @@ -85,7 +86,14 @@ class CPoint {
su2vector<bool> Agglomerate; /*!< \brief This flag indicates if the element has been agglomerated. */

su2vector<unsigned short> nNeighbor; /*!< \brief Number of neighbors, needed by some numerical methods. */

/*--- Closest element on a viscous wall, and distance to it. ---*/
su2activevector Wall_Distance; /*!< \brief Distance to the nearest wall. */
su2vector<int> ClosestWall_Rank; /*!< \brief Rank of process holding the closest wall element. */
su2vector<unsigned short> ClosestWall_Zone; /*!< \brief Zone index of closest wall element. */
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Alright, I already have problems to understand the basics: Why is the whole WallRoughness thing not a matter of every zone by themselves? I have no real clue of how wall roughness is intended to work but I imagined that in each (fluid-)zone there is an added viscosity (or sth else, idk) added to nodes in a certain vicinity (also as function of wall distance) to a wall with wall roughness. Now I don't know how other zones would influence that. ClosestWall_Rank (and Marker and Elem), sure ... but ClosestWall_Zone, why?
plz help 🏳️

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The code cites

Aupoix, B. and Spalart, P. R., "Extensions of the Spalart-Allmaras Turbulence Model to Account for Wall Roughness,"
International Journal of Heat and Fluid Flow, Vol. 24, 2003, pp. 454-462.
See https://turbmodels.larc.nasa.gov/spalart.html#sarough for detailed explanation.

The TMR page says that you require the " conventional Nikuradse sand roughness scale height" at the wall. In the old implementation each marker is allowed to have its specific roughness, and for integration at one point, the roughness of the closest marker is chosen. As I just wanted to fix the bug and I'm not familiar with the theory, I kept this level of generality.

I encountered the bug in setup with two fluid zones connected by a sliding mesh interface.

The point is that in CPhysicalGeometry::SetWallDistance, the call to WallADT::DetermineNearestElement gives the closest wall marker in the iZone (which is not the zone in which this CPhysicalGeometry lives in, generally). It is therefore wrong to access the wall roughness array of this CPhysicalGeometry with the marker ID that belongs to a different zone. In my case, valgrind reported an invalid read, because there were different numbers of markers in both zones.

Maybe the dependency on the rank is irrelevant, I don't know if all markers have the same marker IDs in all ranks... I don't care ;)

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

They don't. iMarker only makes sense locally and different ranks may have different boundaries.
If you try to do any MPI as part of a boundary condition you will have a bad time.

su2vector<unsigned short> ClosestWall_Marker; /*!< \brief Marker index of closest wall element, for given rank and zone index. */
su2vector<unsigned long> ClosestWall_Elem; /*!< \brief Element index of closest wall element, for givenrank, zone and marker index. */
pcarruscag marked this conversation as resolved.
Show resolved Hide resolved

su2activevector SharpEdge_Distance; /*!< \brief Distance to a sharp edge. */
su2activevector Curvature; /*!< \brief Value of the surface curvature (SU2_GEO). */
su2activevector MaxLength; /*!< \brief The maximum cell-center to cell-center length. */
Expand Down Expand Up @@ -415,8 +423,22 @@ class CPoint {
* \brief Set the value of the distance to the nearest wall.
* \param[in] iPoint - Index of the point.
* \param[in] distance - Value of the distance.
*/
inline void SetWall_Distance(unsigned long iPoint, su2double distance) { Wall_Distance(iPoint) = distance; }
* \param[in] rankID - Rank of process holding the closest wall element.
* \param[in] zoneID - Zone index of closest wall element.
* \param[in] markerID - Marker index of closest wall element.
* \param[in] elemID - Element index of closest wall element.
*/
inline void SetWall_Distance(unsigned long iPoint, su2double distance,
int rankID = -1,
unsigned short zoneID = numeric_limits<unsigned short>::max(),
unsigned short markerID = numeric_limits<unsigned short>::max(),
unsigned long elemID = numeric_limits<unsigned long>::max() ) {
Wall_Distance(iPoint) = distance;
ClosestWall_Rank(iPoint) = rankID;
ClosestWall_Zone(iPoint) = zoneID;
ClosestWall_Marker(iPoint) = markerID;
ClosestWall_Elem(iPoint) = elemID;
}

/*!
* \brief Get the value of the distance to the nearest wall.
Expand Down Expand Up @@ -829,4 +851,19 @@ class CPoint {
*/
void SetIndex(unsigned long iPoint, bool input);

/*!
* \brief Set wall roughnesses according to stored closest wall information.
* \param[in] roughness - Mapping [rank][zone][marker] -> roughness
*/
template<typename Roughness_type>
void SetWallRoughness(Roughness_type const& roughness){
for (unsigned long iPoint=0; iPoint<GlobalIndex.size(); ++iPoint) {
int rankID = ClosestWall_Rank[iPoint];
unsigned short zoneID = ClosestWall_Zone[iPoint];
unsigned short markerID = ClosestWall_Marker[iPoint];
if(rankID != -1){
SetRoughnessHeight(iPoint, roughness[rankID][zoneID][markerID]);
}
}
}
};
Loading