33#include "../../../Common/include/parallelization/omp_structure.hpp"
34#include "../../../Common/include/toolboxes/geometry_toolbox.hpp"
60template <
size_t nDim,
class FieldType,
class GradientType>
63 const size_t varBegin,
const size_t varEnd,
const int idxVel, GradientType& gradient) {
67 constexpr size_t OMP_MAX_CHUNK = 512;
72 static constexpr size_t MAXNVAR = 20;
77 for (
size_t iPoint = 0; iPoint < nPointDomain; ++iPoint) {
78 auto nodes = geometry.
nodes;
85 for (
size_t iVar = varBegin; iVar < varEnd; ++iVar)
AD::SetPreaccIn(field(iPoint, iVar));
89 for (
size_t iVar = varBegin; iVar < varEnd; ++iVar)
90 for (
size_t iDim = 0; iDim < nDim; ++iDim) gradient(iPoint, iVar, iDim) = 0.0;
94 su2double halfOnVol = 0.5 / (nodes->GetVolume(iPoint) + nodes->GetPeriodicVolume(iPoint));
98 for (
size_t iNeigh = 0; iNeigh < nodes->GetnPoint(iPoint); ++iNeigh) {
99 size_t iEdge = nodes->GetEdge(iPoint, iNeigh);
100 size_t jPoint = nodes->GetPoint(iPoint, iNeigh);
105 su2double dir = (iPoint < jPoint) ? 1.0 : -1.0;
111 for (
size_t iVar = varBegin; iVar < varEnd; ++iVar) {
113 su2double flux = weight * (field(iPoint, iVar) + field(jPoint, iVar));
115 for (
size_t iDim = 0; iDim < nDim; ++iDim) gradient(iPoint, iVar, iDim) += flux * area[iDim];
119 for (
size_t iVar = varBegin; iVar < varEnd; ++iVar)
120 for (
size_t iDim = 0; iDim < nDim; ++iDim)
AD::SetPreaccOut(gradient(iPoint, iVar, iDim));
129 for (
size_t iMarker = 0; iMarker < geometry.
GetnMarker(); ++iMarker) {
137 for (
size_t iVertex = 0; iVertex < geometry.
GetnVertex(iMarker); ++iVertex) {
138 size_t iPoint = geometry.
vertex[iMarker][iVertex]->
GetNode();
139 auto nodes = geometry.
nodes;
143 if (!nodes->GetDomain(iPoint))
continue;
148 for (
size_t iVar = varBegin; iVar < varEnd; iVar++)
149 flux[iVar] = field(iPoint,iVar) / volume;
151 for (
size_t iVar = varBegin; iVar < varEnd; iVar++) {
152 for (
size_t iDim = 0; iDim < nDim; iDim++) {
153 gradient(iPoint, iVar, iDim) -= flux[iVar] * area[iDim];
164 correctGradientsSymmetry<nDim>(geometry, config, varBegin, varEnd, idxVel, gradient);
168 if (solver ==
nullptr)
return;
190template <
class FieldType,
class GradientType>
193 const size_t varBegin,
const size_t varEnd,
const int idxVel, GradientType& gradient) {
196 detail::computeGradientsGreenGauss<2>(solver, kindMpiComm, kindPeriodicComm, geometry, config, field, varBegin,
197 varEnd, idxVel, gradient);
200 detail::computeGradientsGreenGauss<3>(solver, kindMpiComm, kindPeriodicComm, geometry, config, field, varBegin,
201 varEnd, idxVel, gradient);
static void Error(const std::string &ErrorMsg, const std::string &FunctionName)
Definition mpi_structure.cpp:131
Main class for defining the problem; basically this class reads the configuration file,...
Definition CConfig.hpp:64
unsigned short GetnMarker_Periodic(void) const
Get the total number of periodic markers.
Definition CConfig.hpp:3309
unsigned short GetMarker_All_KindBC(unsigned short val_marker) const
Get the kind of boundary for each marker.
Definition CConfig.hpp:3556
void GetNormal(unsigned long iEdge, T &normal) const
Copy the the normal vector of a face.
Definition CEdge.hpp:161
Parent class for defining the geometry of the problem (complete geometry, multigrid agglomerated geom...
Definition CGeometry.hpp:75
unsigned long GetnVertex(unsigned short val_marker) const
Get number of vertices.
Definition CGeometry.hpp:637
CPoint * nodes
Node vector (dual grid information).
Definition CGeometry.hpp:253
CVertex *** vertex
Boundary Vertex vector (dual grid information).
Definition CGeometry.hpp:255
unsigned long GetnPointDomain() const
Get number of real points (that belong to the domain).
Definition CGeometry.hpp:593
unsigned short GetnDim() const
Get number of coordinates.
Definition CGeometry.hpp:575
unsigned short GetnMarker() const
Get number of markers.
Definition CGeometry.hpp:623
CEdge * edges
Edge vector (dual grid information).
Definition CGeometry.hpp:254
su2double & GetVolume(unsigned long iPoint)
Get area or volume of the control volume.
Definition CPoint.hpp:557
Definition CSolver.hpp:71
void InitiatePeriodicComms(CGeometry *geometry, const CConfig *config, unsigned short val_periodic_index, unsigned short commType)
Routine to load a solver quantity into the data structures for MPI periodic communication and to laun...
Definition CSolver.cpp:368
void CompleteComms(CGeometry *geometry, const CConfig *config, MPI_QUANTITIES commType)
Routine to complete the set of non-blocking communications launched by InitiateComms() and unpacking ...
Definition CSolver.cpp:1724
void CompletePeriodicComms(CGeometry *geometry, const CConfig *config, unsigned short val_periodic_index, unsigned short commType)
Routine to complete the set of non-blocking periodic communications launched by InitiatePeriodicComms...
Definition CSolver.cpp:1113
void InitiateComms(CGeometry *geometry, const CConfig *config, MPI_QUANTITIES commType)
Routine to load a solver quantity into the data structures for MPI point-to-point communication and t...
Definition CSolver.cpp:1563
void GetNormal(su2double *val_normal) const override
Copy the the normal vector of a face.
Definition CVertex.hpp:94
unsigned long GetNode() const
Get the node of the vertex.
Definition CVertex.hpp:70
passivedouble su2double
Definition code_config.hpp:181
Implements the symmetry boundary conditions for the gradient computations.
void computeGradientsGreenGauss(CSolver *solver, MPI_QUANTITIES kindMpiComm, PERIODIC_QUANTITIES kindPeriodicComm, CGeometry &geometry, const CConfig &config, const FieldType &field, const size_t varBegin, const size_t varEnd, const int idxVel, GradientType &gradient)
Compute the gradient of a field using the Green-Gauss theorem.
Definition computeGradientsGreenGauss.hpp:61
void computeGradientsGreenGauss(CSolver *solver, MPI_QUANTITIES kindMpiComm, PERIODIC_QUANTITIES kindPeriodicComm, CGeometry &geometry, const CConfig &config, const FieldType &field, const size_t varBegin, const size_t varEnd, const int idxVel, GradientType &gradient)
Instantiations for 2D and 3D.
Definition computeGradientsGreenGauss.hpp:191
#define CURRENT_FUNCTION
Definition mpi_structure.hpp:59
void StartPreacc()
Starts a new preaccumulation section and sets the input variables.
Definition ad_structure.hpp:215
void EndPreacc()
Ends a preaccumulation section and computes the local Jacobi matrix of a code section using the varia...
Definition ad_structure.hpp:243
void SetPreaccOut(Ts &&... data)
Sets the scalar outputs of a preaccumulation section.
Definition ad_structure.hpp:222
void SetPreaccIn(Ts &&... data)
Sets the scalar inputs of a preaccumulation section.
Definition ad_structure.hpp:186
Definition computeGradientsGreenGauss.hpp:37
constexpr int omp_get_num_threads()
Number of threads in current team.
Definition omp_structure.hpp:75
#define END_SU2_OMP_FOR
Definition omp_structure.hpp:158
constexpr int omp_get_max_threads()
Maximum number of threads available.
Definition omp_structure.hpp:70
size_t computeStaticChunkSize(size_t totalWork, size_t numThreads, size_t maxChunkSize)
Compute a chunk size based on totalWork and number of threads such that all threads get the same numb...
Definition omp_structure.hpp:223
#define SU2_OMP_FOR_DYN(CHUNK)
Definition omp_structure.hpp:150
#define SU2_OMP_FOR_STAT(CHUNK)
Definition omp_structure.hpp:151
@ INTERNAL_BOUNDARY
Internal Boundary definition.
Definition option_structure.hpp:1840
@ NEARFIELD_BOUNDARY
Near-Field boundary definition.
Definition option_structure.hpp:1821
@ PERIODIC_BOUNDARY
Periodic boundary definition.
Definition option_structure.hpp:1820
PERIODIC_QUANTITIES
Vertex-based quantities exchanged during periodic marker communications.
Definition option_structure.hpp:2843
MPI_QUANTITIES
Vertex-based quantities exchanged in MPI point-to-point communications.
Definition option_structure.hpp:2873