Skip to content

update master#2499

Merged
pcarruscag merged 448 commits intomasterfrom
develop
May 4, 2025
Merged

update master#2499
pcarruscag merged 448 commits intomasterfrom
develop

Conversation

@pcarruscag
Copy link
Member

No description provided.

pcarruscag and others added 30 commits January 1, 2025 14:57
…o coupled_thermoelasticity

Add nodal temperature integration in Compute_StiffMatrix
[WIP] Coupled solver for thermoelasticity
Fix Non-dimensionalization to translation velocity
pcarruscag and others added 27 commits April 6, 2025 15:43
2D DSMA661 Airfoil Near-Wake V&V case
Fix preaccumulation error, improve recording of RANS solvers
Changing version number to 8.2.0
* \brief Shape function Jacobian (dNi) evaluated at point Xi,Eta.
*/
inline static void ShapeFunctionJacobian(su2double Xi, su2double Eta, su2double dNi[][2]) {
inline static void ShapeFunctionJacobian(const su2double& Xi, const su2double& Eta, su2double dNi[][2]) {

Check notice

Code scanning / CodeQL

No raw arrays in interfaces

Raw arrays should not be used in interfaces. A container class should be used instead.

Copilot Autofix

AI 9 months ago

To fix the issue, replace the raw array parameter su2double dNi[][2] in the ShapeFunctionJacobian method with a safer container class, such as std::array. Specifically:

  1. Use std::array<std::array<su2double, 2>, 4> to represent a 4x2 matrix, as the size of the array is fixed and known at compile time.
  2. Update the method signature to accept the container by reference.
  3. Modify the method implementation to work with the std::array structure instead of raw arrays.

This change ensures type safety, prevents array decay, and makes the code more expressive and maintainable.


Suggested changeset 1
Common/include/geometry/elements/CElement.hpp

Autofix patch

Autofix patch
Run the following command in your local git repository to apply this patch
cat << 'EOF' | git apply
diff --git a/Common/include/geometry/elements/CElement.hpp b/Common/include/geometry/elements/CElement.hpp
--- a/Common/include/geometry/elements/CElement.hpp
+++ b/Common/include/geometry/elements/CElement.hpp
@@ -33,2 +33,3 @@
 #include <vector>
+#include <array>
 
@@ -828,3 +829,3 @@
    */
-  inline static void ShapeFunctionJacobian(const su2double& Xi, const su2double& Eta, su2double dNi[][2]) {
+  inline static void ShapeFunctionJacobian(const su2double& Xi, const su2double& Eta, std::array<std::array<su2double, 2>, 4>& dNi) {
     dNi[0][0] = -0.25 * (1.0 - Eta);
EOF
@@ -33,2 +33,3 @@
#include <vector>
#include <array>

@@ -828,3 +829,3 @@
*/
inline static void ShapeFunctionJacobian(const su2double& Xi, const su2double& Eta, su2double dNi[][2]) {
inline static void ShapeFunctionJacobian(const su2double& Xi, const su2double& Eta, std::array<std::array<su2double, 2>, 4>& dNi) {
dNi[0][0] = -0.25 * (1.0 - Eta);
Copilot is powered by AI and may make mistakes. Always verify output.
Unable to commit as this autofix suggestion is now outdated
"of entries (the number of materials).", CURRENT_FUNCTION);
if (nMaterialThermalExpansion == 0) {
nMaterialThermalExpansion = 1;
MaterialThermalExpansion = new su2double[1]();

Check warning

Code scanning / CodeQL

Resource not released in destructor

Resource MaterialThermalExpansion is acquired by class CConfig but not released anywhere in this class.

Copilot Autofix

AI 9 months ago

Copilot could not generate an autofix suggestion

Copilot could not generate an autofix suggestion for this alert. Try pushing a new commit or if the problem persists contact support.

Comment on lines +148 to +232
switch (nCornerPoints) {
case 2: {
/* Element is a line. Check if the node numbering must be swapped. If so
also the element information must be swapped, because element 0 is to
the left of the face and element 1 to the right. */
if (cornerPoints[1] < cornerPoints[0]) {
std::swap(cornerPoints[0], cornerPoints[1]);
swapElements = true;
}
break;
}

case 3: {
/* Element is a triangle. The vertices are sorted in increasing order.
If the sequence of the new numbering is opposite to the current
numbering, the element information must be exchanged, because
element 0 is to the left of the face and element 1 to the right. */
unsigned long nn[] = {cornerPoints[0], cornerPoints[1], cornerPoints[2]};
unsigned short ind = 0;
if (nn[1] < nn[ind]) ind = 1;
if (nn[2] < nn[ind]) ind = 2;

unsigned short indm1 = ind == 0 ? 2 : ind - 1; // Next lower index.
unsigned short indp1 = ind == 2 ? 0 : ind + 1; // Next upper index.

if (nn[indp1] < nn[indm1]) {
/* The orientation of the triangle remains the same.
Store the new sorted node numbering. */
cornerPoints[0] = nn[ind];
cornerPoints[1] = nn[indp1];
cornerPoints[2] = nn[indm1];
} else {
/* The orientation of the triangle changes. Store the new
sorted node numbering and set swapElements to true. */
cornerPoints[0] = nn[ind];
cornerPoints[1] = nn[indm1];
cornerPoints[2] = nn[indp1];
swapElements = true;
}

break;
}

case 4: {
/* Element is a quadrilateral. The vertices are sorted in increasing order
under the condition neighboring vertices remain neighbors. If the
sequence of the new numbering is opposite to the current
numbering, the element information must be exchanged, because
element 0 is to the left of the face and element 1 to the right. */
unsigned long nn[] = {cornerPoints[0], cornerPoints[1], cornerPoints[2], cornerPoints[3]};
unsigned short ind = 0;
if (nn[1] < nn[ind]) ind = 1;
if (nn[2] < nn[ind]) ind = 2;
if (nn[3] < nn[ind]) ind = 3;

unsigned short indm1 = ind == 0 ? 3 : ind - 1; // Next lower index.
unsigned short indp1 = ind == 3 ? 0 : ind + 1; // Next upper index.
unsigned short indp2 = ind >= 2 ? ind - 2 : ind + 2; // Opposite index.

if (nn[indp1] < nn[indm1]) {
/* The orientation of the quadrilateral remains the same.
Store the new sorted node numbering. */
cornerPoints[0] = nn[ind];
cornerPoints[1] = nn[indp1];
cornerPoints[2] = nn[indp2];
cornerPoints[3] = nn[indm1];
} else {
/* The orientation of the quadrilateral changes. Store the new
sorted node numbering and set swapElements to true. */
cornerPoints[0] = nn[ind];
cornerPoints[1] = nn[indm1];
cornerPoints[2] = nn[indp2];
cornerPoints[3] = nn[indp1];
swapElements = true;
}

break;
}

default: {
std::ostringstream message;
message << "Unknown surface element type with " << nCornerPoints << " corners." << std::endl;
SU2_MPI::Error(message.str(), CURRENT_FUNCTION);
}
}

Check notice

Code scanning / CodeQL

Long switch case

Switch has at least one case that is too long: [4 (35 lines)](1).

Copilot Autofix

AI 9 months ago

To address the issue, we will refactor the logic in the case 4: block into a separate function named ProcessQuadrilateralCase. This function will encapsulate the logic for handling quadrilateral elements, making the switch statement more concise and easier to follow. The function will take the necessary parameters (e.g., cornerPoints, swapElements) and return any modified values or flags.

The changes will involve:

  1. Extracting the logic from case 4: into a new function ProcessQuadrilateralCase.
  2. Replacing the case 4: block with a call to the new function.
  3. Ensuring that the new function has access to all required variables and updates them correctly.

Suggested changeset 1
Common/src/toolboxes/fem/CFaceOfElement.cpp

Autofix patch

Autofix patch
Run the following command in your local git repository to apply this patch
cat << 'EOF' | git apply
diff --git a/Common/src/toolboxes/fem/CFaceOfElement.cpp b/Common/src/toolboxes/fem/CFaceOfElement.cpp
--- a/Common/src/toolboxes/fem/CFaceOfElement.cpp
+++ b/Common/src/toolboxes/fem/CFaceOfElement.cpp
@@ -191,34 +191,3 @@
     case 4: {
-      /* Element is a quadrilateral. The vertices are sorted in increasing order
-         under the condition neighboring vertices remain neighbors. If the
-         sequence of the new numbering is opposite to the current
-         numbering, the element information must be exchanged, because
-         element 0 is to the left of the face and element 1 to the right. */
-      unsigned long nn[] = {cornerPoints[0], cornerPoints[1], cornerPoints[2], cornerPoints[3]};
-      unsigned short ind = 0;
-      if (nn[1] < nn[ind]) ind = 1;
-      if (nn[2] < nn[ind]) ind = 2;
-      if (nn[3] < nn[ind]) ind = 3;
-
-      unsigned short indm1 = ind == 0 ? 3 : ind - 1;        // Next lower index.
-      unsigned short indp1 = ind == 3 ? 0 : ind + 1;        // Next upper index.
-      unsigned short indp2 = ind >= 2 ? ind - 2 : ind + 2;  // Opposite index.
-
-      if (nn[indp1] < nn[indm1]) {
-        /* The orientation of the quadrilateral remains the same.
-           Store the new sorted node numbering. */
-        cornerPoints[0] = nn[ind];
-        cornerPoints[1] = nn[indp1];
-        cornerPoints[2] = nn[indp2];
-        cornerPoints[3] = nn[indm1];
-      } else {
-        /* The orientation of the quadrilateral changes. Store the new
-           sorted node numbering and set swapElements to true. */
-        cornerPoints[0] = nn[ind];
-        cornerPoints[1] = nn[indm1];
-        cornerPoints[2] = nn[indp2];
-        cornerPoints[3] = nn[indp1];
-        swapElements = true;
-      }
-
+      ProcessQuadrilateralCase(cornerPoints, swapElements);
       break;
@@ -242,2 +211,36 @@
   }
+}
+
+void CFaceOfElement::ProcessQuadrilateralCase(unsigned long* cornerPoints, bool& swapElements) {
+  /* Element is a quadrilateral. The vertices are sorted in increasing order
+     under the condition neighboring vertices remain neighbors. If the
+     sequence of the new numbering is opposite to the current
+     numbering, the element information must be exchanged, because
+     element 0 is to the left of the face and element 1 to the right. */
+  unsigned long nn[] = {cornerPoints[0], cornerPoints[1], cornerPoints[2], cornerPoints[3]};
+  unsigned short ind = 0;
+  if (nn[1] < nn[ind]) ind = 1;
+  if (nn[2] < nn[ind]) ind = 2;
+  if (nn[3] < nn[ind]) ind = 3;
+
+  unsigned short indm1 = ind == 0 ? 3 : ind - 1;        // Next lower index.
+  unsigned short indp1 = ind == 3 ? 0 : ind + 1;        // Next upper index.
+  unsigned short indp2 = ind >= 2 ? ind - 2 : ind + 2;  // Opposite index.
+
+  if (nn[indp1] < nn[indm1]) {
+    /* The orientation of the quadrilateral remains the same.
+       Store the new sorted node numbering. */
+    cornerPoints[0] = nn[ind];
+    cornerPoints[1] = nn[indp1];
+    cornerPoints[2] = nn[indp2];
+    cornerPoints[3] = nn[indm1];
+  } else {
+    /* The orientation of the quadrilateral changes. Store the new
+       sorted node numbering and set swapElements to true. */
+    cornerPoints[0] = nn[ind];
+    cornerPoints[1] = nn[indm1];
+    cornerPoints[2] = nn[indp2];
+    cornerPoints[3] = nn[indp1];
+    swapElements = true;
+  }
 }
EOF
Copilot is powered by AI and may make mistakes. Always verify output.
Unable to commit as this autofix suggestion is now outdated
@pcarruscag pcarruscag merged commit 5d71ae2 into master May 4, 2025
56 of 70 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.