From 34ae13e0c80d36b8f234c8dce413a1026584da41 Mon Sep 17 00:00:00 2001 From: Tim Brooks <41971846+timryanb@users.noreply.github.com> Date: Tue, 23 Sep 2025 13:13:23 +0000 Subject: [PATCH 1/5] Update clang-format version in workflow configuration to 22 --- .github/workflows/clang-format-check.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/clang-format-check.yml b/.github/workflows/clang-format-check.yml index 874c7c908..ba2c7cdd0 100644 --- a/.github/workflows/clang-format-check.yml +++ b/.github/workflows/clang-format-check.yml @@ -19,6 +19,6 @@ jobs: - name: Run clang-format style check for C/C++ programs. uses: jidicula/clang-format-action@v4.15.0 with: - clang-format-version: '13' + clang-format-version: '22' check-path: ${{ matrix.path }} fallback-style: 'Google' From 124aa12965bd036128419bc5d6a76b95c42e9851 Mon Sep 17 00:00:00 2001 From: Tim Brooks <41971846+timryanb@users.noreply.github.com> Date: Tue, 23 Sep 2025 13:15:47 +0000 Subject: [PATCH 2/5] Downgrade clang-format version in workflow configuration to 20 --- .github/workflows/clang-format-check.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/clang-format-check.yml b/.github/workflows/clang-format-check.yml index ba2c7cdd0..8b53dd94c 100644 --- a/.github/workflows/clang-format-check.yml +++ b/.github/workflows/clang-format-check.yml @@ -19,6 +19,6 @@ jobs: - name: Run clang-format style check for C/C++ programs. uses: jidicula/clang-format-action@v4.15.0 with: - clang-format-version: '22' + clang-format-version: '20' check-path: ${{ matrix.path }} fallback-style: 'Google' From 4fadc1010a1acf774eb66a575e03f81ba9820f89 Mon Sep 17 00:00:00 2001 From: Tim Brooks <41971846+timryanb@users.noreply.github.com> Date: Tue, 23 Sep 2025 13:27:20 +0000 Subject: [PATCH 3/5] format fix --- src/TACSAssembler.h | 80 +++++++++---------- src/TACSCreator.cpp | 6 +- src/TacsUtilities.cpp | 29 +++---- src/constitutive/TACSGaussianProcessModel.h | 14 ++-- .../direct/TACS3DCoupledThermoElement.h | 77 +++++++++--------- .../direct/TACS3DCoupledThermoTraction.h | 39 ++++----- src/elements/direct/ThermoElements.h | 4 +- src/io/TACSFH5.h | 24 +++--- 8 files changed, 134 insertions(+), 139 deletions(-) diff --git a/src/TACSAssembler.h b/src/TACSAssembler.h index 037018247..11f6ba5d6 100644 --- a/src/TACSAssembler.h +++ b/src/TACSAssembler.h @@ -59,18 +59,18 @@ class TACSAssembler; collective on the tacs_comm communicator. */ class TACSAssembler : public TACSObject { - public: +public: // There are always 3 coordinates (even for 2D problems) static const int TACS_SPATIAL_DIM = 3; enum OrderingType { - NATURAL_ORDER, // Natural ordering - RCM_ORDER, // Reverse Cuthill Mackee ordering - AMD_ORDER, // Approximate minimum degree - ND_ORDER, // Nested disection - TACS_AMD_ORDER, // Interface variables ordered last + NATURAL_ORDER, // Natural ordering + RCM_ORDER, // Reverse Cuthill Mackee ordering + AMD_ORDER, // Approximate minimum degree + ND_ORDER, // Nested disection + TACS_AMD_ORDER, // Interface variables ordered last MULTICOLOR_ORDER - }; // Multicolor via greedy algorithm + }; // Multicolor via greedy algorithm enum MatrixOrderingType { ADDITIVE_SCHWARZ, APPROXIMATE_SCHUR, @@ -321,7 +321,7 @@ class TACSAssembler : public TACSObject { void computeLocalNodeToNodeCSR(int **_rowp, int **_cols, int nodiag = 0); void computeNodeToElementCSR(int **_nodeElem, int **_nodeElemIndex); - private: +private: // Get the number of design variable numbers // ----------------------------------------- int getNumDesignVars(); @@ -362,15 +362,15 @@ class TACSAssembler : public TACSObject { int *item, TacsScalar *temp, MatrixOrientation matOr); - TACSNodeMap *nodeMap; // Variable ownership map - TACSBcMap *bcMap; // Boundary condition data - TACSBcMap *bcInitMap; // Initial boundary condition data - TACSBVecDistribute *extDist; // Distribute the vector - TACSBVecIndices *extDistIndices; // The tacsVarNum indices - TACSBVecDepNodes *depNodes; // Dependent variable information - TACSNodeMap *designNodeMap; // Distribution of design variables - TACSBVecDistribute *designExtDist; // Distribute the design variables - TACSBVecDepNodes *designDepNodes; // Dependent design variable information + TACSNodeMap *nodeMap; // Variable ownership map + TACSBcMap *bcMap; // Boundary condition data + TACSBcMap *bcInitMap; // Initial boundary condition data + TACSBVecDistribute *extDist; // Distribute the vector + TACSBVecIndices *extDistIndices; // The tacsVarNum indices + TACSBVecDepNodes *depNodes; // Dependent variable information + TACSNodeMap *designNodeMap; // Distribution of design variables + TACSBVecDistribute *designExtDist; // Distribute the design variables + TACSBVecDepNodes *designDepNodes; // Dependent design variable information // Reordering information TACSBVecIndices *newNodeIndices; @@ -390,24 +390,24 @@ class TACSAssembler : public TACSObject { int meshInitializedFlag; // Information about the variables and elements - int varsPerNode; // number of variables per node - int numElements; // number of elements - int numNodes; // number of nodes referenced by this process - int numOwnedNodes; // number of nodes owned by this processor - int numExtNodes; // number of extneral nodes - int numDependentNodes; // number of dependent nodes - int numMultiplierNodes; // number of multiplier nodes/elements - int designVarsPerNode; // number of design variables at each design "node" + int varsPerNode; // number of variables per node + int numElements; // number of elements + int numNodes; // number of nodes referenced by this process + int numOwnedNodes; // number of nodes owned by this processor + int numExtNodes; // number of extneral nodes + int numDependentNodes; // number of dependent nodes + int numMultiplierNodes; // number of multiplier nodes/elements + int designVarsPerNode; // number of design variables at each design "node" // Maximum element information - int maxElementDesignVars; // maximum number of design variable - int maxElementNodes; // maximum number of ind. and dep. element nodes - int maxElementSize; // maximum number of variables for any element - int maxElementIndepNodes; // maximum number of independent nodes + int maxElementDesignVars; // maximum number of design variable + int maxElementNodes; // maximum number of ind. and dep. element nodes + int maxElementSize; // maximum number of variables for any element + int maxElementIndepNodes; // maximum number of independent nodes // Node numbers that are referred to from this processor - int *tacsExtNodeNums; // node numbers associated with TACS - int extNodeOffset; // Offset into the external nodes + int *tacsExtNodeNums; // node numbers associated with TACS + int extNodeOffset; // Offset into the external nodes // Variables that define the CSR data structure to // store the element -> node information @@ -427,8 +427,8 @@ class TACSAssembler : public TACSObject { TACSBVec *xptVec; // Memory for the element residuals and variables - TacsScalar *elementData; // Space for element residuals/matrices - int *elementIData; // Space for element index data + TacsScalar *elementData; // Space for element residuals/matrices + int *elementIData; // Space for element index data // Memory for the design variables and inddex data TacsScalar *elementSensData; @@ -454,7 +454,7 @@ class TACSAssembler : public TACSObject { // relatively easy, while design-variable dependent info is // much more challenging! class TACSAssemblerPthreadInfo { - public: + public: TACSAssemblerPthreadInfo() { assembler = NULL; res = NULL; @@ -494,21 +494,21 @@ class TACSAssembler : public TACSObject { TACSFunction::EvaluationType ftype; int numDesignVars; - TacsScalar *fdvSens; // df/dx + TacsScalar *fdvSens; // df/dx TACSBVec **fXptSens; // Information for adjoint-dR/dx products int numAdjoints; TACSBVec **adjoints; - } * tacsPInfo; + } *tacsPInfo; // The pthread data required to pthread tacs operations - int numCompletedElements; // Keep track of how much work has been done - TACSThreadInfo *thread_info; // The pthread object + int numCompletedElements; // Keep track of how much work has been done + TACSThreadInfo *thread_info; // The pthread object // The thread objects pthread_t threads[TACSThreadInfo::TACS_MAX_NUM_THREADS]; - pthread_mutex_t tacs_mutex; // The mutex for coordinating assembly ops. + pthread_mutex_t tacs_mutex; // The mutex for coordinating assembly ops. // The name of the TACSAssembler object static const char *tacsName; @@ -590,4 +590,4 @@ inline void TACSAssembler::addMatValues(TACSMat *A, const int elemNum, } } -#endif // TACS_ASSEMBLER_H +#endif // TACS_ASSEMBLER_H diff --git a/src/TACSCreator.cpp b/src/TACSCreator.cpp index 7cbde1910..34a5fa769 100644 --- a/src/TACSCreator.cpp +++ b/src/TACSCreator.cpp @@ -23,7 +23,7 @@ static void extend_int_array(int **array, int old_len, int new_len) { int *temp = new int[new_len]; memcpy(temp, *array, sizeof(int) * old_len); - delete[] * array; + delete[] *array; *array = temp; } @@ -1085,7 +1085,7 @@ void TACSCreator::partitionMesh(int split_size, const int *part) { // Add the elements - minus the diagonal entry for (int j = 0; j < row_size; j++) { - if (row[j] != i) { // Not the diagonal + if (row[j] != i) { // Not the diagonal elem_conn[elem_conn_size] = row[j]; elem_conn_size++; } @@ -1102,7 +1102,7 @@ void TACSCreator::partitionMesh(int split_size, const int *part) { // Partition the mesh using METIS. if (split_size > 1) { - int ncon = 1; // "It should be at least 1"?? + int ncon = 1; // "It should be at least 1"?? // Set the default options int options[METIS_NOPTIONS]; diff --git a/src/TacsUtilities.cpp b/src/TacsUtilities.cpp index 811178593..a185312cc 100644 --- a/src/TacsUtilities.cpp +++ b/src/TacsUtilities.cpp @@ -77,11 +77,12 @@ int TacsUniqueSort(int len, int *array) { // Sort the array qsort(array, len, sizeof(int), TacsIntegerComparator); - int i = 0; // The location from which to take the entires - int j = 0; // The location to place the entries + int i = 0; // The location from which to take the entires + int j = 0; // The location to place the entries // Remove the negative entries - while (i < len && array[i] < 0) i++; + while (i < len && array[i] < 0) + i++; for (; i < len; i++, j++) { while ((i < len - 1) && (array[i] == array[i + 1])) { @@ -123,7 +124,7 @@ int TacsMergeSortedArrays(int na, int *a, int nb, const int *b) { } } - int len = na + nb - ndup; // End of the array + int len = na + nb - ndup; // End of the array int end = len - 1; j = nb - 1; @@ -135,7 +136,7 @@ int TacsMergeSortedArrays(int na, int *a, int nb, const int *b) { } else if (b[j] > a[i]) { a[end] = b[j]; end--, j--; - } else { // b[j] == a[i] + } else { // b[j] == a[i] a[end] = a[i]; end--, j--, i--; } @@ -166,7 +167,7 @@ int TacsFindInterval(int index, int len, const int intv[]) { } else if (index < intv[0]) { return -1; } else if (index > intv[len - 1]) { - return len - 1; // The number of intervals is equal to len-1 + return len - 1; // The number of intervals is equal to len-1 } int low = 0; @@ -177,9 +178,9 @@ int TacsFindInterval(int index, int len, const int intv[]) { // intv[low] <= index < intv[high] while (low != high) { - if (index < intv[low + 1]) { // Check the low interval + if (index < intv[low + 1]) { // Check the low interval return low; - } else if (intv[high - 1] <= index) { // Check the high interval + } else if (intv[high - 1] <= index) { // Check the high interval return high - 1; } @@ -218,9 +219,9 @@ void TacsMatchIntervals(int mpiSize, const int ownerRange[], int nvars, // First check the lower bound if (ownerRange[n] <= vars[0]) { ext_ptr[n] = 0; - } else if (ownerRange[n] > vars[nvars - 1]) { // No more variables + } else if (ownerRange[n] > vars[nvars - 1]) { // No more variables ext_ptr[n] = nvars; - } else { // Determine the interval using a binary search + } else { // Determine the interval using a binary search int low = 0; int high = nvars - 1; int mid = low + (int)((high - low) / 2); @@ -253,7 +254,7 @@ void TacsExtendArray(int **_array, int oldlen, int newlen) { int *oldarray = *_array; int *newarray = new int[newlen]; memcpy(newarray, oldarray, oldlen * sizeof(int)); - delete[] * _array; + delete[] *_array; *_array = newarray; } @@ -264,7 +265,7 @@ void TacsExtendArray(TacsScalar **_array, int oldlen, int newlen) { TacsScalar *oldarray = *_array; TacsScalar *newarray = new TacsScalar[newlen]; memcpy(newarray, oldarray, oldlen * sizeof(TacsScalar)); - delete[] * _array; + delete[] *_array; *_array = newarray; } @@ -323,8 +324,8 @@ void TacsSortAndUniquifyCSR(int nvars, int *rowp, int *cols, int remove_diag) { static int TacsComputeRCMLevSetOrder(const int nvars, const int *rowp, const int *cols, int *rcm_vars, int *levset, int root) { - int start = 0; // The start of the current level - int end = 0; // The end of the current level + int start = 0; // The start of the current level + int end = 0; // The end of the current level // Set all the new variable numbers to -1 for (int k = 0; k < nvars; k++) { diff --git a/src/constitutive/TACSGaussianProcessModel.h b/src/constitutive/TACSGaussianProcessModel.h index 6cc4fdf75..486ac1bd9 100644 --- a/src/constitutive/TACSGaussianProcessModel.h +++ b/src/constitutive/TACSGaussianProcessModel.h @@ -25,7 +25,7 @@ buckling constraints of stiffened panels. // ============================================================================= class TACSGaussianProcessModel : public TACSObject { - public: +public: TACSGaussianProcessModel(int n_train, int n_param, bool affine, const TacsScalar Xtrain[], const TacsScalar alpha[], const TacsScalar theta[]); @@ -132,7 +132,7 @@ class TACSGaussianProcessModel : public TACSObject { */ static TacsScalar test_soft_relu(TacsScalar epsilon) { TacsScalar x = 1.0, - rho = 1.0; // very low rho for smoother function for deriv test + rho = 1.0; // very low rho for smoother function for deriv test TacsScalar f0 = soft_relu(x - epsilon, rho); TacsScalar f2 = soft_relu(x + epsilon, rho); TacsScalar centDiff = (f2 - f0) / 2.0 / epsilon; @@ -176,7 +176,7 @@ class TACSGaussianProcessModel : public TACSObject { */ static TacsScalar test_soft_abs(TacsScalar epsilon) { TacsScalar x = 1.0, - rho = 1.0; // very low rho for smoother function for deriv test + rho = 1.0; // very low rho for smoother function for deriv test TacsScalar f0 = soft_abs(x - epsilon, rho); TacsScalar f2 = soft_abs(x + epsilon, rho); TacsScalar centDiff = (f2 - f0) / 2.0 / epsilon; @@ -212,7 +212,7 @@ class TACSGaussianProcessModel : public TACSObject { virtual TacsScalar kernel(const TacsScalar *Xtest, const TacsScalar *Xtrain) = 0; - protected: +protected: /** * @brief backpropagate derivatives of the kernel function to the Xtest input * (this is a virtual function here in the base class) @@ -235,7 +235,7 @@ class TACSGaussianProcessModel : public TACSObject { // zeta1, rho02, xi2, gamma2, delta2, zeta2, ..., zetaN] TacsScalar *Xtrain; TacsScalar *alpha; - TacsScalar *theta; // hyperparameters + TacsScalar *theta; // hyperparameters // not using this ks anymore though.. it's a trained hyperparameter, so fixed TacsScalar ks; @@ -243,7 +243,7 @@ class TACSGaussianProcessModel : public TACSObject { }; class TACSBucklingGaussianProcessModel : public TACSGaussianProcessModel { - public: +public: TACSBucklingGaussianProcessModel(int n_train, bool affine, const TacsScalar Xtrain[], const TacsScalar alpha[], @@ -274,7 +274,7 @@ class TACSBucklingGaussianProcessModel : public TACSGaussianProcessModel { */ TacsScalar kernel(const TacsScalar *Xtest, const TacsScalar *Xtrain) override; - protected: +protected: /** * @brief backpropagate derivatives of the kernel function to the Xtest input * for AxialGP diff --git a/src/elements/direct/TACS3DCoupledThermoElement.h b/src/elements/direct/TACS3DCoupledThermoElement.h index 1ce1bac74..fdc75f98b 100644 --- a/src/elements/direct/TACS3DCoupledThermoElement.h +++ b/src/elements/direct/TACS3DCoupledThermoElement.h @@ -24,14 +24,13 @@ cost of the element computations is consumed in the inner product of the B-matrix with the constitutive matrix. */ -template -class TACS3DCoupledThermoElement : public ThermoSolid { - public: +template class TACS3DCoupledThermoElement : public ThermoSolid { +public: // Define some constants for this element type - static const int NUM_DISPS = 4; // u, v, w, dT + static const int NUM_DISPS = 4; // u, v, w, dT static const int NUM_STRESSES = 6; static const int NUM_EXTRAS = 4; - static const int NUM_VARIABLES = 4 * NUM_NODES; // + static const int NUM_VARIABLES = 4 * NUM_NODES; // TACS3DCoupledThermoElement(CoupledThermoSolidStiffness *_stiff, ElementBehaviorType type, int _component); @@ -190,11 +189,11 @@ class TACS3DCoupledThermoElement : public ThermoSolid { const TacsScalar scale, const TacsScalar strainSens[], const TacsScalar Xpts[], const TacsScalar vars[]); - protected: +protected: ElementBehaviorType strain_type; CoupledThermoSolidStiffness *stiff; - private: +private: static const char *dispNames[NUM_DISPS]; static const char *stressNames[NUM_STRESSES]; static const char *strainNames[NUM_STRESSES]; @@ -291,8 +290,7 @@ int TACS3DCoupledThermoElement::numStresses() { return NUM_STRESSES; } -template -int TACS3DCoupledThermoElement::numNodes() { +template int TACS3DCoupledThermoElement::numNodes() { return NUM_NODES; } @@ -530,17 +528,17 @@ void TACS3DCoupledThermoElement::getDisplGradientSens( } // Compute the displacement gradient: Ud = Ua*J - Ud[0] = Ua[0] * J[0] + Ua[1] * J[3] + Ua[2] * J[6]; // u,x - Ud[3] = Ua[3] * J[0] + Ua[4] * J[3] + Ua[5] * J[6]; // v,x - Ud[6] = Ua[6] * J[0] + Ua[7] * J[3] + Ua[8] * J[6]; // w,x + Ud[0] = Ua[0] * J[0] + Ua[1] * J[3] + Ua[2] * J[6]; // u,x + Ud[3] = Ua[3] * J[0] + Ua[4] * J[3] + Ua[5] * J[6]; // v,x + Ud[6] = Ua[6] * J[0] + Ua[7] * J[3] + Ua[8] * J[6]; // w,x - Ud[1] = Ua[0] * J[1] + Ua[1] * J[4] + Ua[2] * J[7]; // u,y - Ud[4] = Ua[3] * J[1] + Ua[4] * J[4] + Ua[5] * J[7]; // v,y - Ud[7] = Ua[6] * J[1] + Ua[7] * J[4] + Ua[8] * J[7]; // w,y + Ud[1] = Ua[0] * J[1] + Ua[1] * J[4] + Ua[2] * J[7]; // u,y + Ud[4] = Ua[3] * J[1] + Ua[4] * J[4] + Ua[5] * J[7]; // v,y + Ud[7] = Ua[6] * J[1] + Ua[7] * J[4] + Ua[8] * J[7]; // w,y - Ud[2] = Ua[0] * J[2] + Ua[1] * J[5] + Ua[2] * J[8]; // u,z - Ud[5] = Ua[3] * J[2] + Ua[4] * J[5] + Ua[5] * J[8]; // v,z - Ud[8] = Ua[6] * J[2] + Ua[7] * J[5] + Ua[8] * J[8]; // w,z + Ud[2] = Ua[0] * J[2] + Ua[1] * J[5] + Ua[2] * J[8]; // u,z + Ud[5] = Ua[3] * J[2] + Ua[4] * J[5] + Ua[5] * J[8]; // v,z + Ud[8] = Ua[6] * J[2] + Ua[7] * J[5] + Ua[8] * J[8]; // w,z // Compute the derivative of the displacement gradient UdSens[0] = Ua[0] * JSens[0] + Ua[1] * JSens[3] + Ua[2] * JSens[6]; @@ -751,7 +749,7 @@ void TACS3DCoupledThermoElement::getBmatTemp( Na++; Nb++; Nc++; - } // end for int i = 0; i < NUM_NODES + } // end for int i = 0; i < NUM_NODES } } @@ -1383,8 +1381,8 @@ void TACS3DCoupledThermoElement::addResidual( b += 3; } - } // end if conduction - } // end for int n = 0; n < numGauss + } // end if conduction + } // end for int n = 0; n < numGauss } /* Get the Jacobian of the governing equations- the exact Jacobian of the @@ -1464,11 +1462,11 @@ void TACS3DCoupledThermoElement::addJacobian( alpha * h * (bi[0] * bs[0] + bi[1] * bs[1] + bi[2] * bs[2] + bi[3] * bs[3] + bi[4] * bs[4] + bi[5] * bs[5]); - } // end for int ii = 0; ii < 2 - } // end for int i = 0; i < NUM_NODES - } // end for int jj = 0; jj < 3 - } // end for int j = 0; j < NUM_NODES - } // end if alpha != 0.0 + } // end for int ii = 0; ii < 2 + } // end for int i = 0; i < NUM_NODES + } // end for int jj = 0; jj < 3 + } // end for int j = 0; j < NUM_NODES + } // end if alpha != 0.0 // ---------------------------------------------------------------- if (gamma != 0.0) { // Get value of the mass/area at this point @@ -1484,7 +1482,7 @@ void TACS3DCoupledThermoElement::addJacobian( mat[4 * i + 2 + (4 * j + 2) * NUM_VARIABLES] += scale * N[i] * N[j]; } } - } // end if (gamma != 0.0) + } // end if (gamma != 0.0) // --------------------------------------------------------------- // Add contribution of heat transfer to the Jacobian // Add heat conduction to the bottom right of the Jacobian [H] @@ -1526,7 +1524,7 @@ void TACS3DCoupledThermoElement::addJacobian( for (int j = 0; j < NUM_NODES; j++) { for (int jj = 3; jj < 4; jj++) { // Compute the product of Dtemp*Btemp [3xNUM_NODES] at the given point - TacsScalar bs[3]; // column of B + TacsScalar bs[3]; // column of B stiff->calculateConduction(pt, bj, bs); bj += 3; for (int i = 0; i < NUM_NODES; i++) { @@ -1534,12 +1532,12 @@ void TACS3DCoupledThermoElement::addJacobian( const TacsScalar *bi = &B[3 * i]; mat[NUM_VARIABLES * (4 * j + jj) + (4 * i + ii)] += alpha * h * (bi[0] * bs[0] + bi[1] * bs[1] + bi[2] * bs[2]); - } // end for int ii = 3; ii < 4 - } // end for int i = 0; i < NUM_NODES - } // end for int jj = 3; jj < 4 - } // end for int j = 0; j < NUM_NODES - } // end if conduction - } // end for int n = 0; n < numGauss + } // end for int ii = 3; ii < 4 + } // end for int i = 0; i < NUM_NODES + } // end for int jj = 3; jj < 4 + } // end for int j = 0; j < NUM_NODES + } // end if conduction + } // end for int n = 0; n < numGauss } /* @@ -1667,7 +1665,7 @@ void TACS3DCoupledThermoElement::addAdjResProduct( // Compute the term alpha*psi_t^{T}*B^{T}*dC/dx*B*T (contribution // of heat transfer model) stiff->addConductionDVSens(pt, strain, scale * h, bpsi, dvSens, dvLen); - } // end for int n = 0; n < numGauss + } // end for int n = 0; n < numGauss } /* @@ -1923,7 +1921,7 @@ void TACS3DCoupledThermoElement::addMatDVSensInnerProduct( // Compute the term alpha*psi_t^{T}*B^{T}*dC/dx*B*phi_t (contribution // of heat transfer model) stiff->addConductionDVSens(pt, bphi, scale * h, bpsi, dvSens, dvLen); - } // for int n = 0; n < numGauss + } // for int n = 0; n < numGauss } else if (matType == MASS_MATRIX) { // The shape functions associated with the element double N[NUM_NODES]; @@ -2058,8 +2056,9 @@ void TACS3DCoupledThermoElement::getMatType( Xpts: the element nodes */ template -TacsScalar TACS3DCoupledThermoElement::getDetJacobian( - const double pt[], const TacsScalar Xpts[]) { +TacsScalar +TACS3DCoupledThermoElement::getDetJacobian(const double pt[], + const TacsScalar Xpts[]) { // Compute the element shape functions double N[NUM_NODES]; double Na[NUM_NODES], Nb[NUM_NODES], Nc[NUM_NODES]; @@ -2444,4 +2443,4 @@ void TACS3DCoupledThermoElement::addBTSVSens( b += 3; } } -#endif // TACS_3D_COUPLED_THERMO_ELEMENT_H +#endif // TACS_3D_COUPLED_THERMO_ELEMENT_H diff --git a/src/elements/direct/TACS3DCoupledThermoTraction.h b/src/elements/direct/TACS3DCoupledThermoTraction.h index 9ef7ff5df..b7104c09b 100644 --- a/src/elements/direct/TACS3DCoupledThermoTraction.h +++ b/src/elements/direct/TACS3DCoupledThermoTraction.h @@ -8,9 +8,8 @@ /* The surface traction class for 3D elements */ -template -class TACS3DThermoTraction : public TACSElement { - public: +template class TACS3DThermoTraction : public TACSElement { +public: static const int NUM_NODES = order * order * order; static const int U_NEGATIVE = 0; @@ -235,7 +234,7 @@ class TACS3DThermoTraction : public TACSElement { const TacsScalar vars[], const TacsScalar dvars[], const TacsScalar ddvars[]) {} - private: +private: int surface; TacsScalar tx[order * order]; TacsScalar ty[order * order]; @@ -247,9 +246,8 @@ class TACS3DThermoTraction : public TACSElement { /* The surface heat flux class for 3D elements */ -template -class TACS3DHeatFluxTraction : public TACSElement { - public: +template class TACS3DHeatFluxTraction : public TACSElement { +public: static const int NUM_NODES = order * order * order; static const int U_NEGATIVE = 0; @@ -472,7 +470,7 @@ class TACS3DHeatFluxTraction : public TACSElement { const TacsScalar vars[], const TacsScalar dvars[], const TacsScalar ddvars[]) {} - private: +private: // Set the base point and direction // -------------------------------- void initBaseDir(int surface) { @@ -509,9 +507,8 @@ class TACS3DHeatFluxTraction : public TACSElement { The surface heat source/sink class for 3D elements; treat it like a body force */ -template -class TACS3DHeatSourceSink : public TACSElement { - public: +template class TACS3DHeatSourceSink : public TACSElement { +public: static const int NUM_NODES = order * order * order; static const int U_NEGATIVE = 0; @@ -543,7 +540,7 @@ class TACS3DHeatSourceSink : public TACSElement { numGauss = FElibrary::getGaussPtsWts(order, &gaussPts, &gaussWts); } // Get the number of displacements/nodes - int numDisplacements() { return 4; } // u,v,w,dT + int numDisplacements() { return 4; } // u,v,w,dT void getShapeFunctions(const double pt[], double N[], double Na[], double Nb[], double Nc[]) { double na[order], nb[order], nc[order]; @@ -620,7 +617,7 @@ class TACS3DHeatSourceSink : public TACSElement { const TacsScalar vars[], const TacsScalar dvars[], const TacsScalar ddvars[]) {} - private: +private: // Information on the heat source/sink TacsScalar Q[NUM_NODES]; // The Gauss quadrature scheme @@ -633,9 +630,8 @@ class TACS3DHeatSourceSink : public TACSElement { /* The surface pressure traction class for 3D elements */ -template -class TACS3DThermoPressureTraction : public TACSElement { - public: +template class TACS3DThermoPressureTraction : public TACSElement { +public: static const int NUM_NODES = order * order * order; static const int U_NEGATIVE = 0; @@ -830,7 +826,7 @@ class TACS3DThermoPressureTraction : public TACSElement { const TacsScalar vars[], const TacsScalar dvars[], const TacsScalar ddvars[]) {} - private: +private: int surface; TacsScalar pressure; @@ -841,9 +837,8 @@ class TACS3DThermoPressureTraction : public TACSElement { /* The surface normal heat flux class for 3D elements */ -template -class TACS3DNormalHeatFluxTraction : public TACSElement { - public: +template class TACS3DNormalHeatFluxTraction : public TACSElement { +public: static const int NUM_NODES = order * order * order; static const int U_NEGATIVE = 0; @@ -1027,7 +1022,7 @@ class TACS3DNormalHeatFluxTraction : public TACSElement { const TacsScalar vars[], const TacsScalar dvars[], const TacsScalar ddvars[]) {} - private: +private: // Set the base point and direction // -------------------------------- void initBaseDir(int surface) { @@ -1058,4 +1053,4 @@ class TACS3DNormalHeatFluxTraction : public TACSElement { double dir1[3], dir2[3], base[3]; }; -#endif // TACS_3D_COUPLED_THERMO_TRACTION_H +#endif // TACS_3D_COUPLED_THERMO_TRACTION_H diff --git a/src/elements/direct/ThermoElements.h b/src/elements/direct/ThermoElements.h index 7aaa4e2d3..0c3f07b3f 100644 --- a/src/elements/direct/ThermoElements.h +++ b/src/elements/direct/ThermoElements.h @@ -3,7 +3,7 @@ #include "TACSElement.h" class ThermoQuad : public TACSElement { - public: +public: ThermoQuad(int component) : TACSElement(component){}; virtual void getShapeFunctions(const double pt[], double N[]) = 0; virtual void getShapeFunctions(const double pt[], double N[], double Na[], @@ -25,7 +25,7 @@ class ThermoQuad : public TACSElement { }; class ThermoSolid : public TACSElement { - public: +public: ThermoSolid(int component) : TACSElement(component){}; virtual void getShapeFunctions(const double pt[], double N[]) = 0; virtual void getShapeFunctions(const double pt[], double N[], double Na[], diff --git a/src/io/TACSFH5.h b/src/io/TACSFH5.h index e34c7b738..5fcd7998f 100644 --- a/src/io/TACSFH5.h +++ b/src/io/TACSFH5.h @@ -27,7 +27,7 @@ */ class TACSFH5File : public TACSObject { - public: +public: // Data types accepted by FH5: Note that float comes last // for backwards compatibility enum FH5DataType { FH5_INT = 0, FH5_DOUBLE = 1, FH5_FLOAT = 2 }; @@ -58,10 +58,10 @@ class TACSFH5File : public TACSObject { int getZoneData(const char **zone_name, const char **var_names, FH5DataType *_dtype, int *dim1, int *dim2, void **data); - private: +private: // Store information about the location of the data within the file class FH5FileInfo { - public: + public: FH5FileInfo() { zone_name = NULL; next = NULL; @@ -84,23 +84,23 @@ class TACSFH5File : public TACSObject { int dim1, dim2; size_t data_offset; FH5FileInfo *next; - } * root, *tip, *current; + } *root, *tip, *current; // Scan the file and record the header information int scanFH5File(); void deleteFH5FileInfo(); - int num_comp; // The number of components - char **comp_names; // The component names + int num_comp; // The number of components + char **comp_names; // The component names - int file_for_writing; // Is this file for writing? - MPI_Comm comm; // The communicator over which the - MPI_File fp; // The MPI file pointer - MPI_Offset file_offset; // The offset into the file - MPI_Offset file_end; // The offset at the end of the file + int file_for_writing; // Is this file for writing? + MPI_Comm comm; // The communicator over which the + MPI_File fp; // The MPI file pointer + MPI_Offset file_offset; // The offset into the file + MPI_Offset file_end; // The offset at the end of the file // Serial file containing the FE solution FILE *rfp; }; -#endif // FH5_INCLUDE_H +#endif // FH5_INCLUDE_H From 1ba644c739e20a1de3bbd85b7f9da78959a471f9 Mon Sep 17 00:00:00 2001 From: Tim Brooks <41971846+timryanb@users.noreply.github.com> Date: Tue, 23 Sep 2025 13:38:41 +0000 Subject: [PATCH 4/5] formatting --- src/TACSAssembler.h | 342 +++++++++--------- src/TACSCreator.cpp | 142 ++++---- src/TacsUtilities.cpp | 137 ++++--- src/constitutive/TACSGaussianProcessModel.h | 50 +-- .../direct/TACS2DCoupledThermoElement.h | 88 ++--- .../direct/TACS3DCoupledThermoElement.h | 147 ++++---- .../direct/TACS3DCoupledThermoTraction.h | 51 +-- src/elements/direct/ThermoElements.h | 8 +- src/io/TACSFH5.h | 50 +-- 9 files changed, 510 insertions(+), 505 deletions(-) diff --git a/src/TACSAssembler.h b/src/TACSAssembler.h index 11f6ba5d6..8e4c93cf2 100644 --- a/src/TACSAssembler.h +++ b/src/TACSAssembler.h @@ -59,18 +59,18 @@ class TACSAssembler; collective on the tacs_comm communicator. */ class TACSAssembler : public TACSObject { -public: + public: // There are always 3 coordinates (even for 2D problems) static const int TACS_SPATIAL_DIM = 3; enum OrderingType { - NATURAL_ORDER, // Natural ordering - RCM_ORDER, // Reverse Cuthill Mackee ordering - AMD_ORDER, // Approximate minimum degree - ND_ORDER, // Nested disection - TACS_AMD_ORDER, // Interface variables ordered last + NATURAL_ORDER, // Natural ordering + RCM_ORDER, // Reverse Cuthill Mackee ordering + AMD_ORDER, // Approximate minimum degree + ND_ORDER, // Nested disection + TACS_AMD_ORDER, // Interface variables ordered last MULTICOLOR_ORDER - }; // Multicolor via greedy algorithm + }; // Multicolor via greedy algorithm enum MatrixOrderingType { ADDITIVE_SCHWARZ, APPROXIMATE_SCHUR, @@ -86,34 +86,34 @@ class TACSAssembler : public TACSObject { // Set the connectivity in TACS // ---------------------------- - int setElementConnectivity(const int *ptr, const int *conn); - void getElementConnectivity(const int **ptr, const int **conn); - int setElements(TACSElement **_elements); - int setDependentNodes(const int *_depNodeIndex, const int *_depNodeToTacs, - const double *_depNodeWeights); + int setElementConnectivity(const int* ptr, const int* conn); + void getElementConnectivity(const int** ptr, const int** conn); + int setElements(TACSElement** _elements); + int setDependentNodes(const int* _depNodeIndex, const int* _depNodeToTacs, + const double* _depNodeWeights); - void getAverageStresses(ElementType elem_type, TacsScalar *avgStresses, + void getAverageStresses(ElementType elem_type, TacsScalar* avgStresses, int compNum); void setComplexStepGmatrix(bool flag); // Set additional information about the design vector // -------------------------------------------------- void setDesignNodeMap(int _designVarsPerNode, - TACSNodeMap *_designVarMap = NULL); - int setDesignDependentNodes(int numDepDesignVars, const int *_depNodePtr, - const int *_depNodes, - const double *_depNodeWeights); + TACSNodeMap* _designVarMap = NULL); + int setDesignDependentNodes(int numDepDesignVars, const int* _depNodePtr, + const int* _depNodes, + const double* _depNodeWeights); // Associate a Dirichlet boundary condition with the given variables // ----------------------------------------------------------------- - void addBCs(int nnodes, const int *nodes, int nbcs = -1, - const int *vars = NULL, const TacsScalar *vals = NULL); - void addInitBCs(int nnodes, const int *nodes, int nbcs = -1, - const int *vars = NULL, const TacsScalar *vals = NULL); + void addBCs(int nnodes, const int* nodes, int nbcs = -1, + const int* vars = NULL, const TacsScalar* vals = NULL); + void addInitBCs(int nnodes, const int* nodes, int nbcs = -1, + const int* vars = NULL, const TacsScalar* vals = NULL); // Set Dirichlet BC values at nodes where BCs are imposed // ------------------------------------------------------ - void setBCValuesFromVec(TACSBVec *vec); + void setBCValuesFromVec(TACSBVec* vec); // Reorder the unknowns according to the specified reordering // ---------------------------------------------------------- @@ -122,9 +122,9 @@ class TACSAssembler : public TACSObject { // Functions for retrieving the reordering // --------------------------------------- int isReordered(); - void getReordering(int *oldToNew); - void reorderVec(TACSBVec *vec); - void reorderNodes(int num_nodes, int *nodes); + void getReordering(int* oldToNew); + void reorderVec(TACSBVec* vec); + void reorderNodes(int num_nodes, int* nodes); // Initialize the mesh // ------------------- @@ -133,19 +133,19 @@ class TACSAssembler : public TACSObject { // Return important information about the TACSAssembler object // ----------------------------------------------------------- MPI_Comm getMPIComm(); - TACSThreadInfo *getThreadInfo(); + TACSThreadInfo* getThreadInfo(); int getVarsPerNode(); int getDesignVarsPerNode(); int getNumNodes(); int getNumDependentNodes(); int getNumOwnedNodes(); int getNumElements(); - TACSNodeMap *getNodeMap(); - TACSNodeMap *getDesignNodeMap(); - TACSBcMap *getBcMap(); - TACSBcMap *getInitBcMap(); - TACSBVecDistribute *getBVecDistribute(); - TACSBVecDepNodes *getBVecDepNodes(); + TACSNodeMap* getNodeMap(); + TACSNodeMap* getDesignNodeMap(); + TACSBcMap* getBcMap(); + TACSBcMap* getInitBcMap(); + TACSBVecDistribute* getBVecDistribute(); + TACSBVecDepNodes* getBVecDepNodes(); // Get the maximum sizes // --------------------- @@ -155,15 +155,15 @@ class TACSAssembler : public TACSObject { // Set auxiliary elements into the TACSAssembler object // ---------------------------------------------------- - void setAuxElements(TACSAuxElements *aux_elems); - TACSAuxElements *getAuxElements(); + void setAuxElements(TACSAuxElements* aux_elems); + TACSAuxElements* getAuxElements(); // Set the nodes in TACS // --------------------- - TACSBVec *createNodeVec(); - void setNodes(TACSBVec *X); - void getNodes(TACSBVec *X); - void getNodes(TACSBVec **X); + TACSBVec* createNodeVec(); + void setNodes(TACSBVec* X); + void getNodes(TACSBVec* X); + void getNodes(TACSBVec** X); // Check for the elements for non-positive determinants // ---------------------------------------------------- @@ -176,15 +176,15 @@ class TACSAssembler : public TACSObject { // Create vectors // -------------- - TACSBVec *createVec(); + TACSBVec* createVec(); // Shortcut to apply boundary conditions - void applyBCs(TACSVec *vec); - void applyBCs(TACSMat *mat); - void applyTransposeBCs(TACSMat *mat); + void applyBCs(TACSVec* vec); + void applyBCs(TACSMat* mat); + void applyTransposeBCs(TACSMat* mat); // Set the Dirichlet boundary conditions to the state vector - void setBCs(TACSVec *vec); + void setBCs(TACSVec* vec); // Methods for manipulating internal variable values // ------------------------------------------------- @@ -194,115 +194,115 @@ class TACSAssembler : public TACSObject { // Methods for setting/getting variables // ------------------------------------- - void setVariables(TACSBVec *q, TACSBVec *qdot = NULL, TACSBVec *qddot = NULL); - void getVariables(TACSBVec *q, TACSBVec *qdot = NULL, TACSBVec *qddot = NULL); - void getVariables(TACSBVec **q, TACSBVec **qdot = NULL, - TACSBVec **qddot = NULL); - void copyVariables(TACSBVec *q, TACSBVec *qdot = NULL, - TACSBVec *qddot = NULL); + void setVariables(TACSBVec* q, TACSBVec* qdot = NULL, TACSBVec* qddot = NULL); + void getVariables(TACSBVec* q, TACSBVec* qdot = NULL, TACSBVec* qddot = NULL); + void getVariables(TACSBVec** q, TACSBVec** qdot = NULL, + TACSBVec** qddot = NULL); + void copyVariables(TACSBVec* q, TACSBVec* qdot = NULL, + TACSBVec* qddot = NULL); // Create the matrices that can be used for analysis // ------------------------------------------------- - TACSParallelMat *createMat(); - TACSSchurMat *createSchurMat(OrderingType order_type = TACS_AMD_ORDER); - TACSSerialPivotMat *createSerialMat(); + TACSParallelMat* createMat(); + TACSSchurMat* createSchurMat(OrderingType order_type = TACS_AMD_ORDER); + TACSSerialPivotMat* createSerialMat(); // Retrieve or set the initial conditions for the simulation // -------------------------------------------------- - void getInitConditions(TACSBVec *vars, TACSBVec *dvars, TACSBVec *ddvars); - void setInitConditions(TACSBVec *vars, TACSBVec *dvars, TACSBVec *ddvars); + void getInitConditions(TACSBVec* vars, TACSBVec* dvars, TACSBVec* ddvars); + void setInitConditions(TACSBVec* vars, TACSBVec* dvars, TACSBVec* ddvars); // Evaluate the kinetic and potential energy // ----------------------------------------- - void evalEnergies(TacsScalar *Te, TacsScalar *Pe); + void evalEnergies(TacsScalar* Te, TacsScalar* Pe); // Residual and Jacobian assembly // ------------------------------ - void assembleRes(TACSBVec *residual, const TacsScalar lambda = 1.0); + void assembleRes(TACSBVec* residual, const TacsScalar lambda = 1.0); void assembleJacobian(TacsScalar alpha, TacsScalar beta, TacsScalar gamma, - TACSBVec *residual, TACSMat *A, + TACSBVec* residual, TACSMat* A, MatrixOrientation matOr = TACS_MAT_NORMAL, const TacsScalar lambda = 1.0); - void assembleMatType(ElementMatrixType matType, TACSMat *A, + void assembleMatType(ElementMatrixType matType, TACSMat* A, MatrixOrientation matOr = TACS_MAT_NORMAL, const TacsScalar lambda = 1.0); void assembleMatCombo(ElementMatrixType matTypes[], TacsScalar scale[], - int nmats, TACSMat *A, + int nmats, TACSMat* A, MatrixOrientation matOr = TACS_MAT_NORMAL, const TacsScalar lambda = 1.0); void addJacobianVecProduct(TacsScalar scale, TacsScalar alpha, - TacsScalar beta, TacsScalar gamma, TACSBVec *x, - TACSBVec *y, + TacsScalar beta, TacsScalar gamma, TACSBVec* x, + TACSBVec* y, MatrixOrientation matOr = TACS_MAT_NORMAL, const TacsScalar lambda = 1.0); // Assemble data for and compute matrix-free matrix-vector products // ---------------------------------------------------------------- - void getMatrixFreeDataSize(ElementMatrixType matType, int *_data_size, - int *_temp_size); + void getMatrixFreeDataSize(ElementMatrixType matType, int* _data_size, + int* _temp_size); void assembleMatrixFreeData(ElementMatrixType matType, TacsScalar alpha, TacsScalar beta, TacsScalar gamma, TacsScalar data[]); void addMatrixFreeVecProduct(ElementMatrixType matType, const TacsScalar data[], TacsScalar temp[], - TACSBVec *x, TACSBVec *y, + TACSBVec* x, TACSBVec* y, MatrixOrientation matOr = TACS_MAT_NORMAL, const TacsScalar lambda = 1.0); // Design variable handling // ------------------------ - TACSBVec *createDesignVec(); - void getDesignVars(TACSBVec *dvs); - void setDesignVars(TACSBVec *dvs); - void getDesignVarRange(TACSBVec *lb, TACSBVec *ub); + TACSBVec* createDesignVec(); + void getDesignVars(TACSBVec* dvs); + void setDesignVars(TACSBVec* dvs); + void getDesignVarRange(TACSBVec* lb, TACSBVec* ub); // Function and sensitivity evaluation // ----------------------------------- - void evalFunctions(int numFuncs, TACSFunction **funcs, TacsScalar *funcVals); + void evalFunctions(int numFuncs, TACSFunction** funcs, TacsScalar* funcVals); // Steady or unsteady derivative evaluation // ---------------------------------------- - void addDVSens(TacsScalar coef, int numFuncs, TACSFunction **funcs, - TACSBVec **dfdx); + void addDVSens(TacsScalar coef, int numFuncs, TACSFunction** funcs, + TACSBVec** dfdx); void addSVSens(TacsScalar alpha, TacsScalar beta, TacsScalar gamma, - int numFuncs, TACSFunction **funcs, TACSBVec **dfdu); + int numFuncs, TACSFunction** funcs, TACSBVec** dfdu); void addAdjointResProducts(TacsScalar scale, int numAdjoints, - TACSBVec **adjoint, TACSBVec **dfdx, + TACSBVec** adjoint, TACSBVec** dfdx, const TacsScalar lambda = 1.0); - void addXptSens(TacsScalar coef, int numFuncs, TACSFunction **funcs, - TACSBVec **dfdXpts); + void addXptSens(TacsScalar coef, int numFuncs, TACSFunction** funcs, + TACSBVec** dfdXpts); void addAdjointResXptSensProducts(TacsScalar scale, int numAdjoints, - TACSBVec **adjoint, TACSBVec **dfdXpts, + TACSBVec** adjoint, TACSBVec** dfdXpts, const TacsScalar lambda = 1.0); // Advanced function interface - for time integration // -------------------------------------------------- void integrateFunctions(TacsScalar tcoef, TACSFunction::EvaluationType ftype, - int numFuncs, TACSFunction **funcs); + int numFuncs, TACSFunction** funcs); // Add the derivatives of inner products // ------------------------------------- void addMatDVSensInnerProduct(TacsScalar scale, ElementMatrixType matType, - TACSBVec *psi, TACSBVec *phi, TACSBVec *dfdx); + TACSBVec* psi, TACSBVec* phi, TACSBVec* dfdx); void addMatXptSensInnerProduct(TacsScalar scale, ElementMatrixType matType, - TACSBVec *psi, TACSBVec *phi, - TACSBVec *dfdXpts); - void evalMatSVSensInnerProduct(ElementMatrixType matType, TACSBVec *psi, - TACSBVec *phi, TACSBVec *res); + TACSBVec* psi, TACSBVec* phi, + TACSBVec* dfdXpts); + void evalMatSVSensInnerProduct(ElementMatrixType matType, TACSBVec* psi, + TACSBVec* phi, TACSBVec* res); // Return elements and node numbers // -------------------------------- - TACSElement **getElements(); - TACSElement *getElement(int elem, TacsScalar *Xpts = NULL, - TacsScalar *vars = NULL, TacsScalar *dvars = NULL, - TacsScalar *ddvars = NULL); - TACSElement *getElement(int elem, int *len, const int **nodes); + TACSElement** getElements(); + TACSElement* getElement(int elem, TacsScalar* Xpts = NULL, + TacsScalar* vars = NULL, TacsScalar* dvars = NULL, + TacsScalar* ddvars = NULL); + TACSElement* getElement(int elem, int* len, const int** nodes); // Test the given element, constitutive or function class // ------------------------------------------------------ void testElement(int elemNum, int print_level, double dh = 1e-6, double rtol = 1e-8, double atol = 1e-1); - void testFunction(TACSFunction *func, double dh); + void testFunction(TACSFunction* func, double dh); // Set the number of threads to work with // -------------------------------------- @@ -311,72 +311,72 @@ class TACSAssembler : public TACSObject { // Get information about the output files; For use by TACSToFH5 // ------------------------------------------------------------ int getNumComponents(); - void getElementOutputData(ElementType elem_type, int write_flag, int *len, - int *nvals, TacsScalar **data); + void getElementOutputData(ElementType elem_type, int write_flag, int* len, + int* nvals, TacsScalar** data); // Functions for ordering the variables // ------------------------------------ int getLocalNodeNum(int node); int getGlobalNodeNum(int node); - void computeLocalNodeToNodeCSR(int **_rowp, int **_cols, int nodiag = 0); - void computeNodeToElementCSR(int **_nodeElem, int **_nodeElemIndex); + void computeLocalNodeToNodeCSR(int** _rowp, int** _cols, int nodiag = 0); + void computeNodeToElementCSR(int** _nodeElem, int** _nodeElemIndex); -private: + private: // Get the number of design variable numbers // ----------------------------------------- int getNumDesignVars(); // Get pointers to the start-locations within the data array // --------------------------------------------------------- - void getDataPointers(TacsScalar *data, TacsScalar **v1, TacsScalar **v2, - TacsScalar **v3, TacsScalar **v4, TacsScalar **x1, - TacsScalar **x2, TacsScalar **weights, TacsScalar **mat); + void getDataPointers(TacsScalar* data, TacsScalar** v1, TacsScalar** v2, + TacsScalar** v3, TacsScalar** v4, TacsScalar** x1, + TacsScalar** x2, TacsScalar** weights, TacsScalar** mat); // Functions that are used to perform reordering // --------------------------------------------- int computeExtNodes(); - int computeCouplingNodes(int **_couplingNodes, int **_extPtr = NULL, - int **_extCount = NULL, int **_recvPtr = NULL, - int **_recvCount = NULL, int **_recvNodes = NULL); - int computeCouplingElements(int **_celems); + int computeCouplingNodes(int** _couplingNodes, int** _extPtr = NULL, + int** _extCount = NULL, int** _recvPtr = NULL, + int** _recvCount = NULL, int** _recvNodes = NULL); + int computeCouplingElements(int** _celems); // Functions for ordering the variables // ------------------------------------ - void computeLocalNodeToNodeCSR(int **_rowp, int **_cols, int nrnodes, - const int *rnodes, int nodiag); + void computeLocalNodeToNodeCSR(int** _rowp, int** _cols, int nrnodes, + const int* rnodes, int nodiag); // Compute the connectivity of the multiplier information - void computeMultiplierConn(int *_num_multipliers, int **_multipliers, - int **_indep_ptr, int **_indep_nodes); + void computeMultiplierConn(int* _num_multipliers, int** _multipliers, + int** _indep_ptr, int** _indep_nodes); // Compute the reordering for a local matrix // ----------------------------------------- - void computeMatReordering(OrderingType order_type, int nvars, int *rowp, - int *cols, int *perm, int *new_vars); + void computeMatReordering(OrderingType order_type, int nvars, int* rowp, + int* cols, int* perm, int* new_vars); // Scatter the boundary conditions on external nodes - void scatterExternalBCs(TACSBcMap *bcs); + void scatterExternalBCs(TACSBcMap* bcs); // Add values into the matrix - inline void addMatValues(TACSMat *A, const int elemNum, const TacsScalar *mat, - int *item, TacsScalar *temp, + inline void addMatValues(TACSMat* A, const int elemNum, const TacsScalar* mat, + int* item, TacsScalar* temp, MatrixOrientation matOr); - TACSNodeMap *nodeMap; // Variable ownership map - TACSBcMap *bcMap; // Boundary condition data - TACSBcMap *bcInitMap; // Initial boundary condition data - TACSBVecDistribute *extDist; // Distribute the vector - TACSBVecIndices *extDistIndices; // The tacsVarNum indices - TACSBVecDepNodes *depNodes; // Dependent variable information - TACSNodeMap *designNodeMap; // Distribution of design variables - TACSBVecDistribute *designExtDist; // Distribute the design variables - TACSBVecDepNodes *designDepNodes; // Dependent design variable information + TACSNodeMap* nodeMap; // Variable ownership map + TACSBcMap* bcMap; // Boundary condition data + TACSBcMap* bcInitMap; // Initial boundary condition data + TACSBVecDistribute* extDist; // Distribute the vector + TACSBVecIndices* extDistIndices; // The tacsVarNum indices + TACSBVecDepNodes* depNodes; // Dependent variable information + TACSNodeMap* designNodeMap; // Distribution of design variables + TACSBVecDistribute* designExtDist; // Distribute the design variables + TACSBVecDepNodes* designDepNodes; // Dependent design variable information // Reordering information - TACSBVecIndices *newNodeIndices; + TACSBVecIndices* newNodeIndices; // Additional information information for the TACSParallel class - TACSBVecIndices *parMatIndices; + TACSBVecIndices* parMatIndices; // Additional ordering information for the TACSSchurMat class // These are created once - all subsequent calls use this data. @@ -390,49 +390,49 @@ class TACSAssembler : public TACSObject { int meshInitializedFlag; // Information about the variables and elements - int varsPerNode; // number of variables per node - int numElements; // number of elements - int numNodes; // number of nodes referenced by this process - int numOwnedNodes; // number of nodes owned by this processor - int numExtNodes; // number of extneral nodes - int numDependentNodes; // number of dependent nodes - int numMultiplierNodes; // number of multiplier nodes/elements - int designVarsPerNode; // number of design variables at each design "node" + int varsPerNode; // number of variables per node + int numElements; // number of elements + int numNodes; // number of nodes referenced by this process + int numOwnedNodes; // number of nodes owned by this processor + int numExtNodes; // number of extneral nodes + int numDependentNodes; // number of dependent nodes + int numMultiplierNodes; // number of multiplier nodes/elements + int designVarsPerNode; // number of design variables at each design "node" // Maximum element information - int maxElementDesignVars; // maximum number of design variable - int maxElementNodes; // maximum number of ind. and dep. element nodes - int maxElementSize; // maximum number of variables for any element - int maxElementIndepNodes; // maximum number of independent nodes + int maxElementDesignVars; // maximum number of design variable + int maxElementNodes; // maximum number of ind. and dep. element nodes + int maxElementSize; // maximum number of variables for any element + int maxElementIndepNodes; // maximum number of independent nodes // Node numbers that are referred to from this processor - int *tacsExtNodeNums; // node numbers associated with TACS - int extNodeOffset; // Offset into the external nodes + int* tacsExtNodeNums; // node numbers associated with TACS + int extNodeOffset; // Offset into the external nodes // Variables that define the CSR data structure to // store the element -> node information - int *elementNodeIndex; - int *elementTacsNodes; + int* elementNodeIndex; + int* elementTacsNodes; // The local list of elements - TACSElement **elements; + TACSElement** elements; // The auxiliary element class - TACSAuxElements *auxElements; + TACSAuxElements* auxElements; // The variables, velocities and accelerations TACSBVec *varsVec, *dvarsVec, *ddvarsVec; // Memory for the node locations - TACSBVec *xptVec; + TACSBVec* xptVec; // Memory for the element residuals and variables - TacsScalar *elementData; // Space for element residuals/matrices - int *elementIData; // Space for element index data + TacsScalar* elementData; // Space for element residuals/matrices + int* elementIData; // Space for element index data // Memory for the design variables and inddex data - TacsScalar *elementSensData; - int *elementSensIData; + TacsScalar* elementSensData; + int* elementSensIData; // Memory for the initial condition vectors TACSBVec *vars0, *dvars0, *ddvars0; @@ -444,17 +444,17 @@ class TACSAssembler : public TACSObject { // The static member functions that are used to p-thread TACSAssembler // operations... These are the most time-consuming operations. - static void schedPthreadJob(TACSAssembler *tacs, int *index, int total_size); - static void *assembleRes_thread(void *t); - static void *assembleJacobian_thread(void *t); - static void *assembleMatType_thread(void *t); + static void schedPthreadJob(TACSAssembler* tacs, int* index, int total_size); + static void* assembleRes_thread(void* t); + static void* assembleJacobian_thread(void* t); + static void* assembleMatType_thread(void* t); // Class to store specific information about the threaded // operations to perform. Note that assembly operations are // relatively easy, while design-variable dependent info is // much more challenging! class TACSAssemblerPthreadInfo { - public: + public: TACSAssemblerPthreadInfo() { assembler = NULL; res = NULL; @@ -476,13 +476,13 @@ class TACSAssembler : public TACSObject { // The data required to perform most of the matrix // assembly. - TACSAssembler *assembler; + TACSAssembler* assembler; // Information for residual assembly - TACSBVec *res; + TACSBVec* res; // Information for matrix assembly - TACSMat *mat; + TACSMat* mat; TacsScalar alpha, beta, gamma, lambda; ElementMatrixType matType; MatrixOrientation matOr; @@ -490,28 +490,28 @@ class TACSAssembler : public TACSObject { // Information required for the computation of f or df/dx double coef; int numFuncs; - TACSFunction **functions; + TACSFunction** functions; TACSFunction::EvaluationType ftype; int numDesignVars; - TacsScalar *fdvSens; // df/dx - TACSBVec **fXptSens; + TacsScalar* fdvSens; // df/dx + TACSBVec** fXptSens; // Information for adjoint-dR/dx products int numAdjoints; - TACSBVec **adjoints; - } *tacsPInfo; + TACSBVec** adjoints; + }* tacsPInfo; // The pthread data required to pthread tacs operations - int numCompletedElements; // Keep track of how much work has been done - TACSThreadInfo *thread_info; // The pthread object + int numCompletedElements; // Keep track of how much work has been done + TACSThreadInfo* thread_info; // The pthread object // The thread objects pthread_t threads[TACSThreadInfo::TACS_MAX_NUM_THREADS]; - pthread_mutex_t tacs_mutex; // The mutex for coordinating assembly ops. + pthread_mutex_t tacs_mutex; // The mutex for coordinating assembly ops. // The name of the TACSAssembler object - static const char *tacsName; + static const char* tacsName; }; /* @@ -534,9 +534,9 @@ class TACSAssembler : public TACSObject { input/output: A: the matrix to which the element-matrix is added */ -inline void TACSAssembler::addMatValues(TACSMat *A, const int elemNum, - const TacsScalar *mat, int *itemp, - TacsScalar *temp, +inline void TACSAssembler::addMatValues(TACSMat* A, const int elemNum, + const TacsScalar* mat, int* itemp, + TacsScalar* temp, MatrixOrientation matOr) { int start = elementNodeIndex[elemNum]; int end = elementNodeIndex[elemNum + 1]; @@ -544,7 +544,7 @@ inline void TACSAssembler::addMatValues(TACSMat *A, const int elemNum, int nvars = varsPerNode * nnodes; // Add the element values to the matrix - const int *nodeNums = &elementTacsNodes[start]; + const int* nodeNums = &elementTacsNodes[start]; if (matOr == TACS_MAT_NORMAL && numDependentNodes == 0) { // If we have no dependent nodes, then we don't need to do @@ -553,17 +553,17 @@ inline void TACSAssembler::addMatValues(TACSMat *A, const int elemNum, } else { // If we have dependent nodes, then we have to figure out what // the weighting matrix is and add then add the element matrix - const int *depNodePtr = NULL; - const int *depNodeConn = NULL; - const double *depNodeWeights = NULL; + const int* depNodePtr = NULL; + const int* depNodeConn = NULL; + const double* depNodeWeights = NULL; if (depNodes) { depNodes->getDepNodes(&depNodePtr, &depNodeConn, &depNodeWeights); } // Set pointers to the temporary arrays - int *varp = &itemp[0]; - int *vars = &itemp[nnodes + 1]; - TacsScalar *weights = temp; + int* varp = &itemp[0]; + int* vars = &itemp[nnodes + 1]; + TacsScalar* weights = temp; varp[0] = 0; for (int i = 0, k = 0; i < nnodes; i++) { @@ -590,4 +590,4 @@ inline void TACSAssembler::addMatValues(TACSMat *A, const int elemNum, } } -#endif // TACS_ASSEMBLER_H +#endif // TACS_ASSEMBLER_H diff --git a/src/TACSCreator.cpp b/src/TACSCreator.cpp index 34a5fa769..38d42570c 100644 --- a/src/TACSCreator.cpp +++ b/src/TACSCreator.cpp @@ -20,8 +20,8 @@ /* Extend an integer array */ -static void extend_int_array(int **array, int old_len, int new_len) { - int *temp = new int[new_len]; +static void extend_int_array(int** array, int old_len, int new_len) { + int* temp = new int[new_len]; memcpy(temp, *array, sizeof(int) * old_len); delete[] *array; *array = temp; @@ -32,15 +32,15 @@ static void extend_int_array(int **array, int old_len, int new_len) { arg_sort_list[list[i]] is in ascending order */ -static const int *arg_sort_list = NULL; +static const int* arg_sort_list = NULL; -static int compare_arg_sort(const void *a, const void *b) { - const int aval = arg_sort_list[*(int *)a]; - const int bval = arg_sort_list[*(int *)b]; +static int compare_arg_sort(const void* a, const void* b) { + const int aval = arg_sort_list[*(int*)a]; + const int bval = arg_sort_list[*(int*)b]; // Break ties using the index of the list if (aval == bval) { - return *(const int *)(a) - *(const int *)(b); + return *(const int*)(a) - *(const int*)(b); } return aval - bval; @@ -179,9 +179,9 @@ TACSCreator::~TACSCreator() { @param _num_elements The number of */ void TACSCreator::setGlobalConnectivity(int _num_nodes, int _num_elements, - const int *_elem_node_ptr, - const int *_elem_node_conn, - const int *_elem_id_nums) { + const int* _elem_node_ptr, + const int* _elem_node_conn, + const int* _elem_id_nums) { num_elements = _num_elements; num_nodes = _num_nodes; @@ -202,9 +202,9 @@ void TACSCreator::setGlobalConnectivity(int _num_nodes, int _num_elements, /* Set the dependent node information */ -void TACSCreator::setDependentNodes(int num_dep_nodes, const int *_dep_node_ptr, - const int *_dep_node_conn, - const double *_dep_node_weights) { +void TACSCreator::setDependentNodes(int num_dep_nodes, const int* _dep_node_ptr, + const int* _dep_node_conn, + const double* _dep_node_weights) { // Set the number of dependent nodes num_dependent_nodes = num_dep_nodes; @@ -223,9 +223,9 @@ void TACSCreator::setDependentNodes(int num_dep_nodes, const int *_dep_node_ptr, /* Set the boundary condition data */ -void TACSCreator::setBoundaryConditions(int _num_bcs, const int *_bc_nodes, - const int *_bc_ptr, const int *_bc_vars, - const TacsScalar *_bc_vals) { +void TACSCreator::setBoundaryConditions(int _num_bcs, const int* _bc_nodes, + const int* _bc_ptr, const int* _bc_vars, + const TacsScalar* _bc_vals) { // Set the number of boundary conditions and the node numbers // to which they correspond num_bcs = _num_bcs; @@ -273,10 +273,10 @@ void TACSCreator::setBoundaryConditions(int _num_bcs, const int *_bc_nodes, /* Set the elements with an array indexed by element id */ -void TACSCreator::setElements(int _num_elem_ids, TACSElement **_elements) { +void TACSCreator::setElements(int _num_elem_ids, TACSElement** _elements) { num_elem_ids = _num_elem_ids; - elements = new TACSElement *[num_elem_ids]; - memcpy(elements, _elements, num_elem_ids * sizeof(TACSElement *)); + elements = new TACSElement*[num_elem_ids]; + memcpy(elements, _elements, num_elem_ids * sizeof(TACSElement*)); for (int i = 0; i < num_elem_ids; i++) { if (elements[i]) { elements[i]->incref(); @@ -287,14 +287,14 @@ void TACSCreator::setElements(int _num_elem_ids, TACSElement **_elements) { /* Set the element creator callback function */ -void TACSCreator::setElementCreator(TACSElement *(*func)(int, int)) { +void TACSCreator::setElementCreator(TACSElement* (*func)(int, int)) { element_creator = func; } /* Set the nodal locations */ -void TACSCreator::setNodes(const TacsScalar *_Xpts) { +void TACSCreator::setNodes(const TacsScalar* _Xpts) { Xpts = new TacsScalar[3 * num_nodes]; memcpy(Xpts, _Xpts, 3 * num_nodes * sizeof(TacsScalar)); } @@ -313,7 +313,7 @@ void TACSCreator::setReorderingType( /* Get the new node numbers */ -int TACSCreator::getNodeNums(const int **_new_nodes) { +int TACSCreator::getNodeNums(const int** _new_nodes) { *_new_nodes = new_nodes; return num_nodes; } @@ -321,7 +321,7 @@ int TACSCreator::getNodeNums(const int **_new_nodes) { /* Get the element partition */ -int TACSCreator::getElementPartition(const int **_partition) { +int TACSCreator::getElementPartition(const int** _partition) { if (_partition) { *_partition = partition; } @@ -331,14 +331,14 @@ int TACSCreator::getElementPartition(const int **_partition) { /* Get the number of nodes owned by each processor */ -void TACSCreator::getNumOwnedNodes(int **_owned_nodes) { +void TACSCreator::getNumOwnedNodes(int** _owned_nodes) { *_owned_nodes = owned_nodes; } /* Get the number of elements owned by each processor */ -void TACSCreator::getNumOwnedElements(int **_owned_elements) { +void TACSCreator::getNumOwnedElements(int** _owned_elements) { *_owned_elements = owned_elements; } @@ -346,25 +346,25 @@ void TACSCreator::getNumOwnedElements(int **_owned_elements) { Input the node numbers on the root processor in the original order, and get out the distributed node numbers on the final mesh */ -void TACSCreator::getAssemblerNodeNums(TACSAssembler *assembler, +void TACSCreator::getAssemblerNodeNums(TACSAssembler* assembler, int num_orig_nodes, - const int *_orig_nodes, - int *num_dist_nodes, int **_tacs_nodes) { + const int* _orig_nodes, + int* num_dist_nodes, int** _tacs_nodes) { // Figure out how to distribute the nodes int size, rank; MPI_Comm_size(comm, &size); MPI_Comm_rank(comm, &rank); // The array of original nodes - only relevant on the root proc - int *orig_nodes = NULL; - int *ext_ptr = NULL; + int* orig_nodes = NULL; + int* ext_ptr = NULL; // The array of new node numbers - int *tacs_nodes = NULL; + int* tacs_nodes = NULL; // Get the variable map from TACSAssembler - TACSNodeMap *nodeMap = assembler->getNodeMap(); - const int *owner_range = NULL; + TACSNodeMap* nodeMap = assembler->getNodeMap(); + const int* owner_range = NULL; nodeMap->getOwnerRange(&owner_range); if (rank == root_rank) { @@ -433,7 +433,7 @@ void TACSCreator::getAssemblerNodeNums(TACSAssembler *assembler, This code partitions the mesh, calls for the elements to be allocated and returns a valid instance of the TACSAssembler object. */ -TACSAssembler *TACSCreator::createTACS() { +TACSAssembler* TACSCreator::createTACS() { int size, rank; MPI_Comm_size(comm, &size); MPI_Comm_rank(comm, &rank); @@ -458,20 +458,20 @@ TACSAssembler *TACSCreator::createTACS() { // Allocate space for the portion of the element connectivity on // this processor - int *local_elem_node_ptr = new int[num_owned_elements + 1]; - int *local_elem_node_conn = NULL; + int* local_elem_node_ptr = new int[num_owned_elements + 1]; + int* local_elem_node_conn = NULL; // This will be used later to determine which elements belong to // which domain within the finite-element mesh local_elem_id_nums = new int[num_owned_elements]; // Loacal nodal information - TacsScalar *Xpts_local = NULL; + TacsScalar* Xpts_local = NULL; // Local dependent node information - int *local_dep_node_ptr = NULL; - int *local_dep_node_conn = NULL; - double *local_dep_node_weights = NULL; + int* local_dep_node_ptr = NULL; + int* local_dep_node_conn = NULL; + double* local_dep_node_weights = NULL; // For each processor, send the information to the owner if (rank == root_rank) { @@ -483,14 +483,14 @@ TACSAssembler *TACSCreator::createTACS() { // Find the inverse mapping between the new and old node // numbers so that it's faster to access - int *inv_new_nodes = new int[num_nodes]; + int* inv_new_nodes = new int[num_nodes]; for (int i = 0; i < num_nodes; i++) { inv_new_nodes[new_nodes[i]] = i; } // Set up the element partition so that it is sorted so that // we can quickly find the elements associated with a processor - int *elem_part = new int[num_elements]; + int* elem_part = new int[num_elements]; for (int k = 0; k < num_elements; k++) { elem_part[k] = k; } @@ -502,7 +502,7 @@ TACSAssembler *TACSCreator::createTACS() { // Determine a sorted ordering of the new dependent nodes // that can be used to map depedent nodes to process owners - int *dep_nodes_part = NULL; + int* dep_nodes_part = NULL; if (num_dependent_nodes > 0) { dep_nodes_part = new int[num_dependent_nodes]; for (int k = 0; k < num_dependent_nodes; k++) { @@ -513,20 +513,20 @@ TACSAssembler *TACSCreator::createTACS() { // Compute the local CSR data structure on this process // Use an upper bound for the memory requirements int max_conn_size = elem_node_ptr[num_elements]; - int *dep_nodes = new int[num_dependent_nodes]; - int *dep_node_flags = new int[num_dependent_nodes]; - int *inv_dep_nodes = new int[num_dependent_nodes]; + int* dep_nodes = new int[num_dependent_nodes]; + int* dep_node_flags = new int[num_dependent_nodes]; + int* inv_dep_nodes = new int[num_dependent_nodes]; // The local element connectivity - int *elem_ptr = new int[num_elements + 1]; - int *elem_conn = new int[max_conn_size]; - int *elem_ids = new int[num_elements]; - TacsScalar *xpts = new TacsScalar[3 * num_nodes]; + int* elem_ptr = new int[num_elements + 1]; + int* elem_conn = new int[max_conn_size]; + int* elem_ids = new int[num_elements]; + TacsScalar* xpts = new TacsScalar[3 * num_nodes]; // Allocate space for the locally-reduced dependent node data - int *dep_ptr = NULL; - int *dep_conn = NULL; - double *dep_weights = NULL; + int* dep_ptr = NULL; + int* dep_conn = NULL; + double* dep_weights = NULL; if (num_dependent_nodes > 0) { dep_ptr = new int[num_dependent_nodes + 1]; dep_conn = new int[dep_node_ptr[num_dependent_nodes]]; @@ -785,7 +785,7 @@ TACSAssembler *TACSCreator::createTACS() { MPI_Bcast(bc_vals, bc_ptr[num_bcs], TACS_MPI_TYPE, root_rank, comm); } - TACSAssembler *tacs = + TACSAssembler* tacs = new TACSAssembler(comm, vars_per_node, num_owned_nodes, num_owned_elements, num_local_dep_nodes); @@ -800,7 +800,7 @@ TACSAssembler *TACSCreator::createTACS() { // Add the elements if (elements) { - TACSElement **elems = new TACSElement *[num_owned_elements]; + TACSElement** elems = new TACSElement*[num_owned_elements]; for (int k = 0; k < num_owned_elements; k++) { elems[k] = elements[local_elem_id_nums[k]]; if (!elems[k]) { @@ -816,7 +816,7 @@ TACSAssembler *TACSCreator::createTACS() { tacs->setElements(elems); delete[] elems; } else if (element_creator) { - TACSElement **elems = new TACSElement *[num_owned_elements]; + TACSElement** elems = new TACSElement*[num_owned_elements]; for (int k = 0; k < num_owned_elements; k++) { elems[k] = element_creator(k, local_elem_id_nums[k]); if (!elems[k]) { @@ -838,8 +838,8 @@ TACSAssembler *TACSCreator::createTACS() { } // Allocate the arrays to store the variable values - int *bvars = new int[vars_per_node]; - TacsScalar *bvals = new TacsScalar[vars_per_node]; + int* bvars = new int[vars_per_node]; + TacsScalar* bvals = new TacsScalar[vars_per_node]; // Set the boundary conditions for (int k = 0; k < num_bcs; k++) { @@ -883,11 +883,11 @@ TACSAssembler *TACSCreator::createTACS() { tacs->initialize(); // Create the new node vector - TACSBVec *X = tacs->createNodeVec(); + TACSBVec* X = tacs->createNodeVec(); X->incref(); // Copy the node locations to the vector - TacsScalar *Xpt_vals; + TacsScalar* Xpt_vals; X->getArray(&Xpt_vals); memcpy(Xpt_vals, Xpts_local, 3 * num_owned_nodes * sizeof(TacsScalar)); @@ -920,7 +920,7 @@ TACSAssembler *TACSCreator::createTACS() { split_size: the number of segments in the partition part: (optional) the specified partition */ -void TACSCreator::partitionMesh(int split_size, const int *part) { +void TACSCreator::partitionMesh(int split_size, const int* part) { int rank; MPI_Comm_rank(comm, &rank); if (rank != root_rank) { @@ -981,7 +981,7 @@ void TACSCreator::partitionMesh(int split_size, const int *part) { // Compute the node to element CSR data structure for both // the indepedent and dependent nodes - int *node_elem_ptr = new int[num_nodes + 1]; + int* node_elem_ptr = new int[num_nodes + 1]; memset(node_elem_ptr, 0, (num_nodes + 1) * sizeof(int)); for (int i = 0; i < num_elements; i++) { @@ -999,7 +999,7 @@ void TACSCreator::partitionMesh(int split_size, const int *part) { for (int i = 0; i < num_nodes; i++) { node_elem_ptr[i + 1] += node_elem_ptr[i]; } - int *node_elem_conn = new int[node_elem_ptr[num_nodes]]; + int* node_elem_conn = new int[node_elem_ptr[num_nodes]]; // Fill in the entries of the node->element data structure for (int i = 0; i < num_elements; i++) { @@ -1024,7 +1024,7 @@ void TACSCreator::partitionMesh(int split_size, const int *part) { // set of maksed elements. For this to work within METIS, we have // to remove the diagonal contribution so that there is no // self-reference in the graph. - int *elem_ptr = new int[num_elements + 1]; + int* elem_ptr = new int[num_elements + 1]; elem_ptr[0] = 0; // Information to keep track of how big the data structure is @@ -1033,10 +1033,10 @@ void TACSCreator::partitionMesh(int split_size, const int *part) { // Estimate the maximum size of the connectivity data const int ROW_SIZE_EST = 27; int max_elem_conn_size = ROW_SIZE_EST * num_elements; - int *elem_conn = new int[max_elem_conn_size]; + int* elem_conn = new int[max_elem_conn_size]; // Assemble things one row at a time - int *row = new int[num_elements + 1]; + int* row = new int[num_elements + 1]; for (int i = 0; i < num_elements; i++) { // Set the size of the new row in the data structure to zero @@ -1085,7 +1085,7 @@ void TACSCreator::partitionMesh(int split_size, const int *part) { // Add the elements - minus the diagonal entry for (int j = 0; j < row_size; j++) { - if (row[j] != i) { // Not the diagonal + if (row[j] != i) { // Not the diagonal elem_conn[elem_conn_size] = row[j]; elem_conn_size++; } @@ -1102,7 +1102,7 @@ void TACSCreator::partitionMesh(int split_size, const int *part) { // Partition the mesh using METIS. if (split_size > 1) { - int ncon = 1; // "It should be at least 1"?? + int ncon = 1; // "It should be at least 1"?? // Set the default options int options[METIS_NOPTIONS]; @@ -1182,7 +1182,7 @@ void TACSCreator::partitionMesh(int split_size, const int *part) { // Find the offset to the ordering of the nodes for each partition // such that split_offset[i] is the first node number for // the i-th processor - int *split_offset = new int[split_size]; + int* split_offset = new int[split_size]; split_offset[0] = 0; for (int k = 1; k < split_size; k++) { split_offset[k] = split_offset[k - 1] + owned_nodes[k - 1]; @@ -1212,7 +1212,7 @@ void TACSCreator::partitionMesh(int split_size, const int *part) { Retrieve the element numbers on each processor corresponding to the given component numbers. */ -int TACSCreator::getElementIdNums(int num_ids, int ids[], int **elem_nums) { +int TACSCreator::getElementIdNums(int num_ids, int ids[], int** elem_nums) { int rank; MPI_Comm_rank(comm, &rank); if (!local_elem_id_nums) { @@ -1227,7 +1227,7 @@ int TACSCreator::getElementIdNums(int num_ids, int ids[], int **elem_nums) { // Sort the component numbers on input num_ids = TacsUniqueSort(num_ids, ids); - int *all_elems = new int[num_owned_elements]; + int* all_elems = new int[num_owned_elements]; int elem_size = 0; for (int k = 0; k < num_owned_elements; k++) { if (TacsSearchArray(local_elem_id_nums[k], num_ids, ids)) { diff --git a/src/TacsUtilities.cpp b/src/TacsUtilities.cpp index a185312cc..6296a31cb 100644 --- a/src/TacsUtilities.cpp +++ b/src/TacsUtilities.cpp @@ -17,11 +17,11 @@ #include #include -int TacsIntegerComparator(const void *a, const void *b) { - return (*(int *)a - *(int *)b); +int TacsIntegerComparator(const void* a, const void* b) { + return (*(int*)a - *(int*)b); } -int TacsSort(int len, int *array) { +int TacsSort(int len, int* array) { qsort(array, len, sizeof(int), TacsIntegerComparator); return len; } @@ -29,14 +29,14 @@ int TacsSort(int len, int *array) { /* Data and comparison function for the argsort */ -static const TacsScalar *tacs_arg_sort_list = NULL; +static const TacsScalar* tacs_arg_sort_list = NULL; -static int TacsCompareArgSort(const void *a, const void *b) { - if (TacsRealPart(tacs_arg_sort_list[*(int *)a]) < - TacsRealPart(tacs_arg_sort_list[*(int *)b])) { +static int TacsCompareArgSort(const void* a, const void* b) { + if (TacsRealPart(tacs_arg_sort_list[*(int*)a]) < + TacsRealPart(tacs_arg_sort_list[*(int*)b])) { return -1; - } else if (TacsRealPart(tacs_arg_sort_list[*(int *)a]) > - TacsRealPart(tacs_arg_sort_list[*(int *)b])) { + } else if (TacsRealPart(tacs_arg_sort_list[*(int*)a]) > + TacsRealPart(tacs_arg_sort_list[*(int*)b])) { return 1; } return 0; @@ -45,7 +45,7 @@ static int TacsCompareArgSort(const void *a, const void *b) { /* Sort the values by argument */ -int TacsArgSort(int len, const TacsScalar *values, int *array) { +int TacsArgSort(int len, const TacsScalar* values, int* array) { for (int i = 0; i < len; i++) { array[i] = i; } @@ -73,16 +73,15 @@ int TacsArgSort(int len, const TacsScalar *values, int *array) { returns: the size of the unique list <= len */ -int TacsUniqueSort(int len, int *array) { +int TacsUniqueSort(int len, int* array) { // Sort the array qsort(array, len, sizeof(int), TacsIntegerComparator); - int i = 0; // The location from which to take the entires - int j = 0; // The location to place the entries + int i = 0; // The location from which to take the entires + int j = 0; // The location to place the entries // Remove the negative entries - while (i < len && array[i] < 0) - i++; + while (i < len && array[i] < 0) i++; for (; i < len; i++, j++) { while ((i < len - 1) && (array[i] == array[i + 1])) { @@ -108,7 +107,7 @@ int TacsUniqueSort(int len, int *array) { 2. Run through the list backwards placing elements into a[] when appropriate. */ -int TacsMergeSortedArrays(int na, int *a, int nb, const int *b) { +int TacsMergeSortedArrays(int na, int* a, int nb, const int* b) { int ndup = 0; int j = 0, i = 0; @@ -124,7 +123,7 @@ int TacsMergeSortedArrays(int na, int *a, int nb, const int *b) { } } - int len = na + nb - ndup; // End of the array + int len = na + nb - ndup; // End of the array int end = len - 1; j = nb - 1; @@ -136,7 +135,7 @@ int TacsMergeSortedArrays(int na, int *a, int nb, const int *b) { } else if (b[j] > a[i]) { a[end] = b[j]; end--, j--; - } else { // b[j] == a[i] + } else { // b[j] == a[i] a[end] = a[i]; end--, j--, i--; } @@ -167,7 +166,7 @@ int TacsFindInterval(int index, int len, const int intv[]) { } else if (index < intv[0]) { return -1; } else if (index > intv[len - 1]) { - return len - 1; // The number of intervals is equal to len-1 + return len - 1; // The number of intervals is equal to len-1 } int low = 0; @@ -178,9 +177,9 @@ int TacsFindInterval(int index, int len, const int intv[]) { // intv[low] <= index < intv[high] while (low != high) { - if (index < intv[low + 1]) { // Check the low interval + if (index < intv[low + 1]) { // Check the low interval return low; - } else if (intv[high - 1] <= index) { // Check the high interval + } else if (intv[high - 1] <= index) { // Check the high interval return high - 1; } @@ -219,9 +218,9 @@ void TacsMatchIntervals(int mpiSize, const int ownerRange[], int nvars, // First check the lower bound if (ownerRange[n] <= vars[0]) { ext_ptr[n] = 0; - } else if (ownerRange[n] > vars[nvars - 1]) { // No more variables + } else if (ownerRange[n] > vars[nvars - 1]) { // No more variables ext_ptr[n] = nvars; - } else { // Determine the interval using a binary search + } else { // Determine the interval using a binary search int low = 0; int high = nvars - 1; int mid = low + (int)((high - low) / 2); @@ -250,9 +249,9 @@ void TacsMatchIntervals(int mpiSize, const int ownerRange[], int nvars, /*! Extend the length of an integer array to a new length of array */ -void TacsExtendArray(int **_array, int oldlen, int newlen) { - int *oldarray = *_array; - int *newarray = new int[newlen]; +void TacsExtendArray(int** _array, int oldlen, int newlen) { + int* oldarray = *_array; + int* newarray = new int[newlen]; memcpy(newarray, oldarray, oldlen * sizeof(int)); delete[] *_array; *_array = newarray; @@ -261,9 +260,9 @@ void TacsExtendArray(int **_array, int oldlen, int newlen) { /* Extend the length of a TacsScalar array to a new length */ -void TacsExtendArray(TacsScalar **_array, int oldlen, int newlen) { - TacsScalar *oldarray = *_array; - TacsScalar *newarray = new TacsScalar[newlen]; +void TacsExtendArray(TacsScalar** _array, int oldlen, int newlen) { + TacsScalar* oldarray = *_array; + TacsScalar* newarray = new TacsScalar[newlen]; memcpy(newarray, oldarray, oldlen * sizeof(TacsScalar)); delete[] *_array; *_array = newarray; @@ -278,7 +277,7 @@ void TacsExtendArray(TacsScalar **_array, int oldlen, int newlen) { values if required and skip the diagonal. Note that the copy may be overlapping so memcpy cannot be used. */ -void TacsSortAndUniquifyCSR(int nvars, int *rowp, int *cols, int remove_diag) { +void TacsSortAndUniquifyCSR(int nvars, int* rowp, int* cols, int remove_diag) { // Uniquify each column of the array int old_start = 0; int new_start = 0; @@ -321,11 +320,11 @@ void TacsSortAndUniquifyCSR(int nvars, int *rowp, int *cols, int remove_diag) { Here levset is a unique, 0 to nvars array containing the level sets */ -static int TacsComputeRCMLevSetOrder(const int nvars, const int *rowp, - const int *cols, int *rcm_vars, - int *levset, int root) { - int start = 0; // The start of the current level - int end = 0; // The end of the current level +static int TacsComputeRCMLevSetOrder(const int nvars, const int* rowp, + const int* cols, int* rcm_vars, + int* levset, int root) { + int start = 0; // The start of the current level + int end = 0; // The end of the current level // Set all the new variable numbers to -1 for (int k = 0; k < nvars; k++) { @@ -404,13 +403,13 @@ static int TacsComputeRCMLevSetOrder(const int nvars, const int *rowp, The number of variables ordered in this pass of the RCM reordering */ -int TacsComputeRCMOrder(const int nvars, const int *rowp, const int *cols, - int *rcm_vars, int root, int n_rcm_iters) { +int TacsComputeRCMOrder(const int nvars, const int* rowp, const int* cols, + int* rcm_vars, int root, int n_rcm_iters) { if (n_rcm_iters < 1) { n_rcm_iters = 1; } - int *levset = new int[nvars]; + int* levset = new int[nvars]; int rvars = 0; for (int k = 0; k < n_rcm_iters; k++) { rvars = @@ -428,10 +427,10 @@ int TacsComputeRCMOrder(const int nvars, const int *rowp, const int *cols, /* Multicolor code for a single process using a greedy algorithm */ -int TacsComputeSerialMultiColor(const int nvars, const int *rowp, - const int *cols, int *colors, int *new_vars) { +int TacsComputeSerialMultiColor(const int nvars, const int* rowp, + const int* cols, int* colors, int* new_vars) { // Allocate a temporary array to store the - int *tmp = new int[nvars + 1]; + int* tmp = new int[nvars + 1]; for (int i = 0; i < nvars; i++) { tmp[i] = -1; colors[i] = -1; @@ -546,8 +545,8 @@ TACSIndexHash::TACSIndexHash(int approx_size, int _increment_size) { } // Allocate the table and set the entries - table = new HashEntry *[table_size]; - memset(table, 0, table_size * sizeof(HashEntry *)); + table = new HashEntry*[table_size]; + memset(table, 0, table_size * sizeof(HashEntry*)); // Allocate the memory nodes mem = new MemNode(); @@ -561,7 +560,7 @@ TACSIndexHash::TACSIndexHash(int approx_size, int _increment_size) { TACSIndexHash::~TACSIndexHash() { while (mem_root) { delete[] mem_root->array; - MemNode *temp = mem_root; + MemNode* temp = mem_root; mem_root = mem_root->next; delete temp; } @@ -588,7 +587,7 @@ int TACSIndexHash::addEntry(int i) { if (table[index]) { // Loop until finding the location where to insert the entry - HashEntry *ptr = table[index]; + HashEntry* ptr = table[index]; while (ptr) { // If the entry already exists, don't add it if (ptr->i == i) { @@ -646,16 +645,16 @@ int TACSIndexHash::addEntry(int i) { /* Convert the hash table to an array */ -void TACSIndexHash::toArray(int *_size, int **_array) { +void TACSIndexHash::toArray(int* _size, int** _array) { if (_size) { *_size = num_entries; } if (_array) { - int *array = new int[num_entries]; + int* array = new int[num_entries]; int i = 0; // Reset the locations for all the - MemNode *node = mem_root; + MemNode* node = mem_root; while (node) { for (int k = 0; k < node->current; k++, i++) { array[i] = node->array[k].i; @@ -668,22 +667,22 @@ void TACSIndexHash::toArray(int *_size, int **_array) { void TACSIndexHash::reset(int new_table_size) { // Allocate the entries for the new table - HashEntry **new_table = new HashEntry *[new_table_size]; - memset(new_table, 0, new_table_size * sizeof(HashEntry *)); + HashEntry** new_table = new HashEntry*[new_table_size]; + memset(new_table, 0, new_table_size * sizeof(HashEntry*)); // Reset the locations for all the - MemNode *node = mem_root; + MemNode* node = mem_root; while (node) { for (int k = 0; k < node->current; k++) { // Reset the new entries - HashEntry *entry = &node->array[k]; + HashEntry* entry = &node->array[k]; entry->next = NULL; uint32_t index = TACSIndexHashFunction(entry->i); index = index % new_table_size; if (new_table[index]) { - HashEntry *ptr = new_table[index]; + HashEntry* ptr = new_table[index]; while (ptr->next) { ptr = ptr->next; } @@ -730,8 +729,8 @@ TACSMatrixHash::TACSMatrixHash(int approx_num_nonzero, int _increment_size) { } // Allocate the table and set the entries - table = new HashEntry *[table_size]; - memset(table, 0, table_size * sizeof(HashEntry *)); + table = new HashEntry*[table_size]; + memset(table, 0, table_size * sizeof(HashEntry*)); // Allocate the memory nodes mem = new MemNode(); @@ -745,7 +744,7 @@ TACSMatrixHash::TACSMatrixHash(int approx_num_nonzero, int _increment_size) { TACSMatrixHash::~TACSMatrixHash() { while (mem_root) { delete[] mem_root->array; - MemNode *temp = mem_root; + MemNode* temp = mem_root; mem_root = mem_root->next; delete temp; } @@ -773,7 +772,7 @@ int TACSMatrixHash::addEntry(int i, int j) { if (table[index]) { // Loop until finding the location where to insert the entry - HashEntry *ptr = table[index]; + HashEntry* ptr = table[index]; while (ptr) { // If the entry already exists, don't add it if (ptr->i == i && ptr->j == j) { @@ -831,13 +830,13 @@ int TACSMatrixHash::addEntry(int i, int j) { /* Convert the hash table to a non-zero CSR pattern */ -void TACSMatrixHash::tocsr(int *_nrows, int **_rows, int **_rowp, int **_cols) { +void TACSMatrixHash::tocsr(int* _nrows, int** _rows, int** _rowp, int** _cols) { // Add in all the rows - TACSIndexHash *row_hash = new TACSIndexHash(1 << 13); + TACSIndexHash* row_hash = new TACSIndexHash(1 << 13); row_hash->incref(); // Find a unique list of rows - MemNode *node = mem_root; + MemNode* node = mem_root; while (node) { for (int k = 0; k < node->current; k++) { row_hash->addEntry(node->array[k].i); @@ -854,14 +853,14 @@ void TACSMatrixHash::tocsr(int *_nrows, int **_rows, int **_rowp, int **_cols) { TacsUniqueSort(nrows, rows); // Allocate space for the row pointer array - int *rowp = new int[nrows + 1]; + int* rowp = new int[nrows + 1]; memset(rowp, 0, (nrows + 1) * sizeof(int)); node = mem_root; while (node) { for (int k = 0; k < node->current; k++) { int row = node->array[k].i; - int *item = TacsSearchArray(row, nrows, rows); + int* item = TacsSearchArray(row, nrows, rows); if (item) { int index = item - rows; node->array[k].i = index; @@ -884,7 +883,7 @@ void TACSMatrixHash::tocsr(int *_nrows, int **_rows, int **_rowp, int **_cols) { } // Allocate space to store the column indices - int *cols = new int[num_entries]; + int* cols = new int[num_entries]; node = mem_root; while (node) { @@ -935,22 +934,22 @@ void TACSMatrixHash::tocsr(int *_nrows, int **_rows, int **_rowp, int **_cols) { void TACSMatrixHash::reset(int new_table_size) { // Allocate the entries for the new table - HashEntry **new_table = new HashEntry *[new_table_size]; - memset(new_table, 0, new_table_size * sizeof(HashEntry *)); + HashEntry** new_table = new HashEntry*[new_table_size]; + memset(new_table, 0, new_table_size * sizeof(HashEntry*)); // Reset the locations for all the - MemNode *node = mem_root; + MemNode* node = mem_root; while (node) { for (int k = 0; k < node->current; k++) { // Reset the new entries - HashEntry *entry = &node->array[k]; + HashEntry* entry = &node->array[k]; entry->next = NULL; uint32_t index = TACSMatIntegerPairHash(entry->i, entry->j); index = index % new_table_size; if (new_table[index]) { - HashEntry *ptr = new_table[index]; + HashEntry* ptr = new_table[index]; while (ptr->next) { ptr = ptr->next; } @@ -1013,7 +1012,7 @@ TacsScalar ksAggregationSens(const TacsScalar f[], const int numVals, TacsScalar ksAggregationSensProduct(const TacsScalar f[], const int numVals, const int numVars, const double ksWeight, - TacsScalar **dfdx, TacsScalar dKSdx[]) { + TacsScalar** dfdx, TacsScalar dKSdx[]) { TacsScalar maxVal = f[0]; for (int ii = 1; ii < numVals; ii++) { if (TacsRealPart(f[ii]) > TacsRealPart(maxVal)) { diff --git a/src/constitutive/TACSGaussianProcessModel.h b/src/constitutive/TACSGaussianProcessModel.h index 486ac1bd9..1b00f5086 100644 --- a/src/constitutive/TACSGaussianProcessModel.h +++ b/src/constitutive/TACSGaussianProcessModel.h @@ -25,7 +25,7 @@ buckling constraints of stiffened panels. // ============================================================================= class TACSGaussianProcessModel : public TACSObject { -public: + public: TACSGaussianProcessModel(int n_train, int n_param, bool affine, const TacsScalar Xtrain[], const TacsScalar alpha[], const TacsScalar theta[]); @@ -44,7 +44,7 @@ class TACSGaussianProcessModel : public TACSObject { * @param Xtest the 1-tensor test data inputs [param1, param2, param3, param4] * @return the predicted scalar test data Ytest */ - TacsScalar predictMeanTestData(const TacsScalar *Xtest); + TacsScalar predictMeanTestData(const TacsScalar* Xtest); /** * @brief backpropagate derivatives df/dYtest to df/dXtest for @@ -55,8 +55,8 @@ class TACSGaussianProcessModel : public TACSObject { * @return the derivative df/dXtest as a 1-tensor */ TacsScalar predictMeanTestDataSens(const TacsScalar Ysens, - const TacsScalar *Xtest, - TacsScalar *Xtestsens); + const TacsScalar* Xtest, + TacsScalar* Xtestsens); // TESTING SCRIPTS // --------------- @@ -132,7 +132,7 @@ class TACSGaussianProcessModel : public TACSObject { */ static TacsScalar test_soft_relu(TacsScalar epsilon) { TacsScalar x = 1.0, - rho = 1.0; // very low rho for smoother function for deriv test + rho = 1.0; // very low rho for smoother function for deriv test TacsScalar f0 = soft_relu(x - epsilon, rho); TacsScalar f2 = soft_relu(x + epsilon, rho); TacsScalar centDiff = (f2 - f0) / 2.0 / epsilon; @@ -176,7 +176,7 @@ class TACSGaussianProcessModel : public TACSObject { */ static TacsScalar test_soft_abs(TacsScalar epsilon) { TacsScalar x = 1.0, - rho = 1.0; // very low rho for smoother function for deriv test + rho = 1.0; // very low rho for smoother function for deriv test TacsScalar f0 = soft_abs(x - epsilon, rho); TacsScalar f2 = soft_abs(x + epsilon, rho); TacsScalar centDiff = (f2 - f0) / 2.0 / epsilon; @@ -193,10 +193,10 @@ class TACSGaussianProcessModel : public TACSObject { int getNparam() { return n_param; }; TacsScalar getKS() { return ks; }; void setKS(TacsScalar ks) { this->ks = ks; }; - void setAlpha(TacsScalar *alpha) { this->alpha = alpha; }; - void setTheta(TacsScalar *theta) { this->theta = theta; }; - void getTrainingData(TacsScalar *Xtrain) { Xtrain = this->Xtrain; }; - void getTheta(TacsScalar *theta) { theta = this->theta; }; + void setAlpha(TacsScalar* alpha) { this->alpha = alpha; }; + void setTheta(TacsScalar* theta) { this->theta = theta; }; + void getTrainingData(TacsScalar* Xtrain) { Xtrain = this->Xtrain; }; + void getTheta(TacsScalar* theta) { theta = this->theta; }; // virtual functions for the kernel definition and its sensitivity @@ -209,10 +209,10 @@ class TACSGaussianProcessModel : public TACSObject { * @return the kernel value k(Xtest,Xtrain) which gives correlation between * these two points from our model */ - virtual TacsScalar kernel(const TacsScalar *Xtest, - const TacsScalar *Xtrain) = 0; + virtual TacsScalar kernel(const TacsScalar* Xtest, + const TacsScalar* Xtrain) = 0; -protected: + protected: /** * @brief backpropagate derivatives of the kernel function to the Xtest input * (this is a virtual function here in the base class) @@ -222,8 +222,8 @@ class TACSGaussianProcessModel : public TACSObject { * @param Xtrain the training data point, rank 1-tensor of length n_param * @return the derivatives of the Xtest input df/dXtest through the kernel */ - virtual void kernelSens(const TacsScalar ksens, const TacsScalar *Xtest, - const TacsScalar *Xtrain, TacsScalar *Xtestsens) = 0; + virtual void kernelSens(const TacsScalar ksens, const TacsScalar* Xtest, + const TacsScalar* Xtrain, TacsScalar* Xtestsens) = 0; int n_train; int n_param; @@ -233,9 +233,9 @@ class TACSGaussianProcessModel : public TACSObject { // if each point of Xtrain has data [rho0, xi, gamma, delta, zeta] with // n_Train=5 then the entries are basically [rho01, xi1, gamma1, delta1, // zeta1, rho02, xi2, gamma2, delta2, zeta2, ..., zetaN] - TacsScalar *Xtrain; - TacsScalar *alpha; - TacsScalar *theta; // hyperparameters + TacsScalar* Xtrain; + TacsScalar* alpha; + TacsScalar* theta; // hyperparameters // not using this ks anymore though.. it's a trained hyperparameter, so fixed TacsScalar ks; @@ -243,14 +243,14 @@ class TACSGaussianProcessModel : public TACSObject { }; class TACSBucklingGaussianProcessModel : public TACSGaussianProcessModel { -public: + public: TACSBucklingGaussianProcessModel(int n_train, bool affine, const TacsScalar Xtrain[], const TacsScalar alpha[], const TacsScalar theta[]) : TACSGaussianProcessModel(n_train, N_PARAM, affine, Xtrain, alpha, - theta){}; - ~TACSBucklingGaussianProcessModel(){}; + theta) {}; + ~TACSBucklingGaussianProcessModel() {}; /** * @brief test the backpropagation of the kernel() method and its sens routine @@ -272,9 +272,9 @@ class TACSBucklingGaussianProcessModel : public TACSGaussianProcessModel { * @return the kernel value k(Xtest,Xtrain) which gives correlation between * these two points from our model */ - TacsScalar kernel(const TacsScalar *Xtest, const TacsScalar *Xtrain) override; + TacsScalar kernel(const TacsScalar* Xtest, const TacsScalar* Xtrain) override; -protected: + protected: /** * @brief backpropagate derivatives of the kernel function to the Xtest input * for AxialGP @@ -284,8 +284,8 @@ class TACSBucklingGaussianProcessModel : public TACSGaussianProcessModel { * @param Xtrain the training data point, rank 1-tensor of length 4 * @return the derivatives of the Xtest input df/dXtest through the kernel */ - void kernelSens(const TacsScalar ksens, const TacsScalar *Xtest, - const TacsScalar *Xtrain, TacsScalar *Xtestsens) override; + void kernelSens(const TacsScalar ksens, const TacsScalar* Xtest, + const TacsScalar* Xtrain, TacsScalar* Xtestsens) override; // there are 4 parameters [log(xi), log(rho_0), log(1+gamma), log(zeta)] for // the axial model diff --git a/src/elements/direct/TACS2DCoupledThermoElement.h b/src/elements/direct/TACS2DCoupledThermoElement.h index d9b999d1b..f9838ff52 100644 --- a/src/elements/direct/TACS2DCoupledThermoElement.h +++ b/src/elements/direct/TACS2DCoupledThermoElement.h @@ -32,7 +32,7 @@ class TACS2DCoupledThermoElement : public ThermoQuad { static const int NUM_EXTRAS = 4; static const int NUM_VARIABLES = 3 * NUM_NODES; // u, v, dT - TACS2DCoupledThermoElement(CoupledThermoPlaneStressStiffness *_stiff, + TACS2DCoupledThermoElement(CoupledThermoPlaneStressStiffness* _stiff, ElementBehaviorType type, int _component); ~TACS2DCoupledThermoElement(); @@ -84,10 +84,10 @@ class TACS2DCoupledThermoElement : public ThermoQuad { // Get the variable information // ---------------------------- - const char *displacementName(int i); - const char *stressName(int i); - const char *strainName(int i); - const char *extraName(int i); + const char* displacementName(int i); + const char* stressName(int i); + const char* strainName(int i); + const char* extraName(int i); int numDisplacements(); int numStresses(); int numNodes(); @@ -97,7 +97,7 @@ class TACS2DCoupledThermoElement : public ThermoQuad { // Compute the kinetic and potential energy within the element // ----------------------------------------------------------- - void computeEnergies(double time, TacsScalar *_Te, TacsScalar *_Pe, + void computeEnergies(double time, TacsScalar* _Te, TacsScalar* _Pe, const TacsScalar Xpts[], const TacsScalar vars[], const TacsScalar dvars[]); @@ -135,12 +135,12 @@ class TACS2DCoupledThermoElement : public ThermoQuad { // Functions for evaluating global functionals of interest // ------------------------------------------------------- - CoupledThermoPlaneStressStiffness *getConstitutive() { return stiff; } + CoupledThermoPlaneStressStiffness* getConstitutive() { return stiff; } // Evaluate the determinant of the Jacobian and its derivative // ----------------------------------------------------------- - TacsScalar getDetJacobian(const double *pt, const TacsScalar Xpts[]); - TacsScalar getDetJacobianXptSens(TacsScalar *sh, const double *pt, + TacsScalar getDetJacobian(const double* pt, const TacsScalar Xpts[]); + TacsScalar getDetJacobianXptSens(TacsScalar* sh, const double* pt, const TacsScalar Xpts[]); // Compute the point-wise strain and its derivative @@ -168,13 +168,13 @@ class TACS2DCoupledThermoElement : public ThermoQuad { protected: ElementBehaviorType strain_type; - CoupledThermoPlaneStressStiffness *stiff; + CoupledThermoPlaneStressStiffness* stiff; private: - static const char *dispNames[NUM_DISPS]; - static const char *stressNames[NUM_STRESSES]; - static const char *strainNames[NUM_STRESSES]; - static const char *extraNames[NUM_EXTRAS]; + static const char* dispNames[NUM_DISPS]; + static const char* stressNames[NUM_STRESSES]; + static const char* strainNames[NUM_STRESSES]; + static const char* extraNames[NUM_EXTRAS]; int conduction, convection, radiation; }; /* @@ -182,7 +182,7 @@ class TACS2DCoupledThermoElement : public ThermoQuad { */ template TACS2DCoupledThermoElement::TACS2DCoupledThermoElement( - CoupledThermoPlaneStressStiffness *_stiff, ElementBehaviorType type, + CoupledThermoPlaneStressStiffness* _stiff, ElementBehaviorType type, int component) : ThermoQuad(component) { strain_type = type; @@ -203,33 +203,33 @@ TACS2DCoupledThermoElement::~TACS2DCoupledThermoElement() { and stresses */ template -const char *TACS2DCoupledThermoElement::dispNames[] = {"u", "v", +const char* TACS2DCoupledThermoElement::dispNames[] = {"u", "v", "dT"}; template -const char *TACS2DCoupledThermoElement::stressNames[] = { +const char* TACS2DCoupledThermoElement::stressNames[] = { "sxx", "syy", "sxy"}; template -const char *TACS2DCoupledThermoElement::strainNames[] = { +const char* TACS2DCoupledThermoElement::strainNames[] = { "exx", "eyy", "exy"}; template -const char *TACS2DCoupledThermoElement::extraNames[] = { +const char* TACS2DCoupledThermoElement::extraNames[] = { "lambda", "buckling", "dv1", "dv2"}; /* Get the names of the displacements/stress etc. */ template -const char *TACS2DCoupledThermoElement::displacementName(int i) { +const char* TACS2DCoupledThermoElement::displacementName(int i) { if (i >= 0 && i < NUM_DISPS) { return dispNames[i]; } return NULL; } template -const char *TACS2DCoupledThermoElement::stressName(int i) { +const char* TACS2DCoupledThermoElement::stressName(int i) { if (i >= 0 && i < NUM_STRESSES) { return stressNames[i]; } @@ -237,7 +237,7 @@ const char *TACS2DCoupledThermoElement::stressName(int i) { } template -const char *TACS2DCoupledThermoElement::strainName(int i) { +const char* TACS2DCoupledThermoElement::strainName(int i) { if (i >= 0 && i < NUM_STRESSES) { return strainNames[i]; } @@ -245,7 +245,7 @@ const char *TACS2DCoupledThermoElement::strainName(int i) { } template -const char *TACS2DCoupledThermoElement::extraName(int i) { +const char* TACS2DCoupledThermoElement::extraName(int i) { if (i >= 0 && i < NUM_EXTRAS) { return extraNames[i]; } @@ -809,7 +809,7 @@ void TACS2DCoupledThermoElement::addStrainXptSens( */ template void TACS2DCoupledThermoElement::computeEnergies( - double time, TacsScalar *_Te, TacsScalar *_Pe, const TacsScalar Xpts[], + double time, TacsScalar* _Te, TacsScalar* _Pe, const TacsScalar Xpts[], const TacsScalar vars[], const TacsScalar dvars[]) { // Compute the kinetic and potential energy TacsScalar Te = 0.0, Pe = 0.0; @@ -910,7 +910,7 @@ void TACS2DCoupledThermoElement::computeEnergies( */ template void TACS2DCoupledThermoElement::addResidual( - double time, TacsScalar *res, const TacsScalar Xpts[], + double time, TacsScalar* res, const TacsScalar Xpts[], const TacsScalar vars[], const TacsScalar dvars[], const TacsScalar ddvars[]) { // The shape functions associated with the element @@ -951,7 +951,7 @@ void TACS2DCoupledThermoElement::addResidual( // Get the derivative of the strain with respect to the nodal // displacements getBmat(B, J, Na, Nb, vars); - TacsScalar *b = B; + TacsScalar* b = B; // Input into corresponding residual position for (int i = 0; i < NUM_NODES; i++) { // Contribution to u @@ -1025,7 +1025,7 @@ void TACS2DCoupledThermoElement::addResidual( b += 2; } } // end if conduction - } // end for int n = 0; n < numGauss + } // end for int n = 0; n < numGauss } /* Add the Jacobian of the governing equations - the exact Jacobian of @@ -1085,7 +1085,7 @@ void TACS2DCoupledThermoElement::addJacobian( // displacements getBmat(B, J, Na, Nb, vars); // Fill-in the upper portion of the matrix - TacsScalar *bj = B; + TacsScalar* bj = B; for (int j = 0; j < NUM_NODES; j++) { for (int jj = 0; jj < 2; jj++) { // Compute the product of D*B at the given point @@ -1094,14 +1094,14 @@ void TACS2DCoupledThermoElement::addJacobian( bj += NUM_STRESSES; for (int i = 0; i < NUM_NODES; i++) { for (int ii = 0; ii < 2; ii++) { - const TacsScalar *bi = &B[3 * (2 * i + ii)]; + const TacsScalar* bi = &B[3 * (2 * i + ii)]; mat[NUM_VARIABLES * (3 * j + jj) + (3 * i + ii)] += alpha * h * (bi[0] * bs[0] + bi[1] * bs[1] + bi[2] * bs[2]); } // end for int ii = 0; ii < 2 - } // end for int i = 0; i < NUM_NODES - } // end for int ii = 0; ii < 2 - } // end for int j = 0; j < NUM_NODES - } // end if alpha != 0.0 + } // end for int i = 0; i < NUM_NODES + } // end for int ii = 0; ii < 2 + } // end for int j = 0; j < NUM_NODES + } // end if alpha != 0.0 // ---------------------------------------------------------------- if (gamma != 0.0) { // Get value of the mass/area at this point @@ -1129,7 +1129,7 @@ void TACS2DCoupledThermoElement::addJacobian( TacsScalar phi[] = {1.0, 1.0, 0.0}; // Get B [NUM_STRESSESx2*NUM_NODES]; getBmat(B, J, Na, Nb, vars); - TacsScalar *bj = B; + TacsScalar* bj = B; // Compute the vector D*phi*aT [NUM_STRESSESx1] stiff->calculateThermal(pt, phi, s); // Compute the vector B^{T}*D*phi*aT [2xNUM_NODESx1] @@ -1160,15 +1160,15 @@ void TACS2DCoupledThermoElement::addJacobian( bj += 2; for (int i = 0; i < NUM_NODES; i++) { for (int ii = 2; ii < 3; ii++) { - const TacsScalar *bi = &B[2 * i]; + const TacsScalar* bi = &B[2 * i]; mat[NUM_VARIABLES * (3 * j + jj) + (3 * i + ii)] += alpha * h * (bi[0] * bs[0] + bi[1] * bs[1]); } // end for int ii = 2; ii < 3 - } // end for int i = 0; i < NUM_NODES - } // end for int jj = 2; jj < 3 + } // end for int i = 0; i < NUM_NODES + } // end for int jj = 2; jj < 3 } } // end if conduction - } // end for int n = 0; n < numGauss + } // end for int n = 0; n < numGauss } /* Add the product of the adjoint vector times the derivative of the @@ -1240,8 +1240,8 @@ void TACS2DCoupledThermoElement::addAdjResProduct( TacsScalar bpsi[NUM_STRESSES]; memset(bpsi, 0, NUM_STRESSES * sizeof(TacsScalar)); - TacsScalar *b = B; - TacsScalar *ps = psi_u; + TacsScalar* b = B; + TacsScalar* ps = psi_u; for (int i = 0; i < 2 * NUM_NODES; i++) { bpsi[0] += ps[0] * b[0]; bpsi[1] += ps[0] * b[1]; @@ -1460,7 +1460,7 @@ TacsScalar TACS2DCoupledThermoElement::getDetJacobian( */ template TacsScalar TACS2DCoupledThermoElement::getDetJacobianXptSens( - TacsScalar *hXptSens, const double *pt, const TacsScalar Xpts[]) { + TacsScalar* hXptSens, const double* pt, const TacsScalar Xpts[]) { // Compute the element shape functions double N[NUM_NODES]; double Na[NUM_NODES], Nb[NUM_NODES]; @@ -1606,7 +1606,7 @@ void TACS2DCoupledThermoElement::addStrainSVSens( // Get the derivative of the strain with respect to the nodal // displacements getBmat(B, J, Na, Nb, vars); - TacsScalar *b = B; + TacsScalar* b = B; for (int i = 0; i < NUM_NODES; i++) { strainSVSens[3 * i] += scale * @@ -1664,7 +1664,7 @@ void TACS2DCoupledThermoElement::addEffStrainSVSens( getBmat(B, J, Na, Nb, vars); // -------------------------------------------------- - TacsScalar *b = B; + TacsScalar* b = B; for (int i = 0; i < NUM_NODES; i++) { // Derivative wrt u strainSVSens[3 * i] += @@ -1801,7 +1801,7 @@ void TACS2DCoupledThermoElement::addBTSVSens( // Get the derivative of the strain with respect to the nodal // displacements getBmatTemp(B, J, Na, Nb, vars); - TacsScalar *b = B; + TacsScalar* b = B; for (int i = 0; i < NUM_NODES; i++) { strainSVSens[3 * i + 2] += scale * (strainSens[0] * b[0] + strainSens[1] * b[1]); diff --git a/src/elements/direct/TACS3DCoupledThermoElement.h b/src/elements/direct/TACS3DCoupledThermoElement.h index fdc75f98b..d58c375d7 100644 --- a/src/elements/direct/TACS3DCoupledThermoElement.h +++ b/src/elements/direct/TACS3DCoupledThermoElement.h @@ -24,15 +24,16 @@ cost of the element computations is consumed in the inner product of the B-matrix with the constitutive matrix. */ -template class TACS3DCoupledThermoElement : public ThermoSolid { -public: +template +class TACS3DCoupledThermoElement : public ThermoSolid { + public: // Define some constants for this element type - static const int NUM_DISPS = 4; // u, v, w, dT + static const int NUM_DISPS = 4; // u, v, w, dT static const int NUM_STRESSES = 6; static const int NUM_EXTRAS = 4; - static const int NUM_VARIABLES = 4 * NUM_NODES; // + static const int NUM_VARIABLES = 4 * NUM_NODES; // - TACS3DCoupledThermoElement(CoupledThermoSolidStiffness *_stiff, + TACS3DCoupledThermoElement(CoupledThermoSolidStiffness* _stiff, ElementBehaviorType type, int _component); ~TACS3DCoupledThermoElement(); @@ -93,10 +94,10 @@ template class TACS3DCoupledThermoElement : public ThermoSolid { // Get the variable information // ---------------------------- - const char *displacementName(int i); - const char *stressName(int i); - const char *strainName(int i); - const char *extraName(int i); + const char* displacementName(int i); + const char* stressName(int i); + const char* strainName(int i); + const char* extraName(int i); int numDisplacements(); int numStresses(); int numNodes(); @@ -106,7 +107,7 @@ template class TACS3DCoupledThermoElement : public ThermoSolid { // Compute the kinetic and potential energy within the element // ----------------------------------------------------------- - void computeEnergies(double time, TacsScalar *_Te, TacsScalar *_Pe, + void computeEnergies(double time, TacsScalar* _Te, TacsScalar* _Pe, const TacsScalar Xpts[], const TacsScalar vars[], const TacsScalar dvars[]); @@ -159,7 +160,7 @@ template class TACS3DCoupledThermoElement : public ThermoSolid { // Functions for evaluating global functionals of interest // ------------------------------------------------------- - TACSConstitutive *getConstitutive() { return stiff; } + TACSConstitutive* getConstitutive() { return stiff; } // Evaluate the determinant of the Jacobian and its derivative // ----------------------------------------------------------- @@ -189,15 +190,15 @@ template class TACS3DCoupledThermoElement : public ThermoSolid { const TacsScalar scale, const TacsScalar strainSens[], const TacsScalar Xpts[], const TacsScalar vars[]); -protected: + protected: ElementBehaviorType strain_type; - CoupledThermoSolidStiffness *stiff; + CoupledThermoSolidStiffness* stiff; -private: - static const char *dispNames[NUM_DISPS]; - static const char *stressNames[NUM_STRESSES]; - static const char *strainNames[NUM_STRESSES]; - static const char *extraNames[NUM_EXTRAS]; + private: + static const char* dispNames[NUM_DISPS]; + static const char* stressNames[NUM_STRESSES]; + static const char* strainNames[NUM_STRESSES]; + static const char* extraNames[NUM_EXTRAS]; int conduction, convection, radiation; }; @@ -206,7 +207,7 @@ template class TACS3DCoupledThermoElement : public ThermoSolid { */ template TACS3DCoupledThermoElement::TACS3DCoupledThermoElement( - CoupledThermoSolidStiffness *_stiff, ElementBehaviorType type, + CoupledThermoSolidStiffness* _stiff, ElementBehaviorType type, int component) : ThermoSolid(component) { strain_type = type; @@ -227,26 +228,26 @@ TACS3DCoupledThermoElement::~TACS3DCoupledThermoElement() { and stresses */ template -const char *TACS3DCoupledThermoElement::dispNames[] = {"u", "v", "w", +const char* TACS3DCoupledThermoElement::dispNames[] = {"u", "v", "w", "dT"}; template -const char *TACS3DCoupledThermoElement::stressNames[] = { +const char* TACS3DCoupledThermoElement::stressNames[] = { "sxx", "syy", "szz", "syz", "sxz", "sxy"}; template -const char *TACS3DCoupledThermoElement::strainNames[] = { +const char* TACS3DCoupledThermoElement::strainNames[] = { "exx", "eyy", "ezz", "eyz", "exz", "exy"}; template -const char *TACS3DCoupledThermoElement::extraNames[] = { +const char* TACS3DCoupledThermoElement::extraNames[] = { "lambda", "buckling", "dv1", "dv2"}; /* Get the names of the displacements/stress etc. */ template -const char *TACS3DCoupledThermoElement::displacementName(int i) { +const char* TACS3DCoupledThermoElement::displacementName(int i) { if (i >= 0 && i < NUM_DISPS) { return dispNames[i]; } @@ -254,7 +255,7 @@ const char *TACS3DCoupledThermoElement::displacementName(int i) { } template -const char *TACS3DCoupledThermoElement::stressName(int i) { +const char* TACS3DCoupledThermoElement::stressName(int i) { if (i >= 0 && i < NUM_STRESSES) { return stressNames[i]; } @@ -262,7 +263,7 @@ const char *TACS3DCoupledThermoElement::stressName(int i) { } template -const char *TACS3DCoupledThermoElement::strainName(int i) { +const char* TACS3DCoupledThermoElement::strainName(int i) { if (i >= 0 && i < NUM_STRESSES) { return strainNames[i]; } @@ -270,7 +271,7 @@ const char *TACS3DCoupledThermoElement::strainName(int i) { } template -const char *TACS3DCoupledThermoElement::extraName(int i) { +const char* TACS3DCoupledThermoElement::extraName(int i) { if (i >= 0 && i < NUM_EXTRAS) { return extraNames[i]; } @@ -290,7 +291,8 @@ int TACS3DCoupledThermoElement::numStresses() { return NUM_STRESSES; } -template int TACS3DCoupledThermoElement::numNodes() { +template +int TACS3DCoupledThermoElement::numNodes() { return NUM_NODES; } @@ -528,17 +530,17 @@ void TACS3DCoupledThermoElement::getDisplGradientSens( } // Compute the displacement gradient: Ud = Ua*J - Ud[0] = Ua[0] * J[0] + Ua[1] * J[3] + Ua[2] * J[6]; // u,x - Ud[3] = Ua[3] * J[0] + Ua[4] * J[3] + Ua[5] * J[6]; // v,x - Ud[6] = Ua[6] * J[0] + Ua[7] * J[3] + Ua[8] * J[6]; // w,x + Ud[0] = Ua[0] * J[0] + Ua[1] * J[3] + Ua[2] * J[6]; // u,x + Ud[3] = Ua[3] * J[0] + Ua[4] * J[3] + Ua[5] * J[6]; // v,x + Ud[6] = Ua[6] * J[0] + Ua[7] * J[3] + Ua[8] * J[6]; // w,x - Ud[1] = Ua[0] * J[1] + Ua[1] * J[4] + Ua[2] * J[7]; // u,y - Ud[4] = Ua[3] * J[1] + Ua[4] * J[4] + Ua[5] * J[7]; // v,y - Ud[7] = Ua[6] * J[1] + Ua[7] * J[4] + Ua[8] * J[7]; // w,y + Ud[1] = Ua[0] * J[1] + Ua[1] * J[4] + Ua[2] * J[7]; // u,y + Ud[4] = Ua[3] * J[1] + Ua[4] * J[4] + Ua[5] * J[7]; // v,y + Ud[7] = Ua[6] * J[1] + Ua[7] * J[4] + Ua[8] * J[7]; // w,y - Ud[2] = Ua[0] * J[2] + Ua[1] * J[5] + Ua[2] * J[8]; // u,z - Ud[5] = Ua[3] * J[2] + Ua[4] * J[5] + Ua[5] * J[8]; // v,z - Ud[8] = Ua[6] * J[2] + Ua[7] * J[5] + Ua[8] * J[8]; // w,z + Ud[2] = Ua[0] * J[2] + Ua[1] * J[5] + Ua[2] * J[8]; // u,z + Ud[5] = Ua[3] * J[2] + Ua[4] * J[5] + Ua[5] * J[8]; // v,z + Ud[8] = Ua[6] * J[2] + Ua[7] * J[5] + Ua[8] * J[8]; // w,z // Compute the derivative of the displacement gradient UdSens[0] = Ua[0] * JSens[0] + Ua[1] * JSens[3] + Ua[2] * JSens[6]; @@ -749,7 +751,7 @@ void TACS3DCoupledThermoElement::getBmatTemp( Na++; Nb++; Nc++; - } // end for int i = 0; i < NUM_NODES + } // end for int i = 0; i < NUM_NODES } } @@ -1146,7 +1148,7 @@ void TACS3DCoupledThermoElement::addStrainXptSens( */ template void TACS3DCoupledThermoElement::computeEnergies( - double time, TacsScalar *_Te, TacsScalar *_Pe, const TacsScalar Xpts[], + double time, TacsScalar* _Te, TacsScalar* _Pe, const TacsScalar Xpts[], const TacsScalar vars[], const TacsScalar dvars[]) { // Compute the kinetic and potential energy TacsScalar Te = 0.0, Pe = 0.0; @@ -1295,7 +1297,7 @@ void TACS3DCoupledThermoElement::addResidual( // displacements getBmat(B, J, Na, Nb, Nc, vars); - TacsScalar *b = B; + TacsScalar* b = B; for (int i = 0; i < NUM_NODES; i++) { // Contribution to u res[4 * i] += @@ -1381,8 +1383,8 @@ void TACS3DCoupledThermoElement::addResidual( b += 3; } - } // end if conduction - } // end for int n = 0; n < numGauss + } // end if conduction + } // end for int n = 0; n < numGauss } /* Get the Jacobian of the governing equations- the exact Jacobian of the @@ -1448,7 +1450,7 @@ void TACS3DCoupledThermoElement::addJacobian( getBmat(B, J, Na, Nb, Nc, vars); // Fill-in the lower portion of the matrix - TacsScalar *bj = B; + TacsScalar* bj = B; for (int j = 0; j < NUM_NODES; j++) { for (int jj = 0; jj < 3; jj++) { // Compute the product of D*B at the given point @@ -1457,16 +1459,16 @@ void TACS3DCoupledThermoElement::addJacobian( bj += NUM_STRESSES; for (int i = 0; i < NUM_NODES; i++) { for (int ii = 0; ii < 3; ii++) { - const TacsScalar *bi = &B[NUM_STRESSES * (3 * i + ii)]; + const TacsScalar* bi = &B[NUM_STRESSES * (3 * i + ii)]; mat[NUM_VARIABLES * (4 * j + jj) + (4 * i + ii)] += alpha * h * (bi[0] * bs[0] + bi[1] * bs[1] + bi[2] * bs[2] + bi[3] * bs[3] + bi[4] * bs[4] + bi[5] * bs[5]); - } // end for int ii = 0; ii < 2 - } // end for int i = 0; i < NUM_NODES - } // end for int jj = 0; jj < 3 - } // end for int j = 0; j < NUM_NODES - } // end if alpha != 0.0 + } // end for int ii = 0; ii < 2 + } // end for int i = 0; i < NUM_NODES + } // end for int jj = 0; jj < 3 + } // end for int j = 0; j < NUM_NODES + } // end if alpha != 0.0 // ---------------------------------------------------------------- if (gamma != 0.0) { // Get value of the mass/area at this point @@ -1482,7 +1484,7 @@ void TACS3DCoupledThermoElement::addJacobian( mat[4 * i + 2 + (4 * j + 2) * NUM_VARIABLES] += scale * N[i] * N[j]; } } - } // end if (gamma != 0.0) + } // end if (gamma != 0.0) // --------------------------------------------------------------- // Add contribution of heat transfer to the Jacobian // Add heat conduction to the bottom right of the Jacobian [H] @@ -1497,7 +1499,7 @@ void TACS3DCoupledThermoElement::addJacobian( TacsScalar phi[] = {1.0, 1.0, 1.0, 0.0, 0.0, 0.0}; // Get B [NUM_STRESSESx3*NUM_NODES]; getBmat(B, J, Na, Nb, Nc, vars); - TacsScalar *bj = B; + TacsScalar* bj = B; // Compute the vector D*phi*aT [NUM_STRESSESx1] stiff->calculateThermal(pt, phi, s); // Compute the vector B^{T}*D*phi*aT [3xNUM_NODESx1] @@ -1524,20 +1526,20 @@ void TACS3DCoupledThermoElement::addJacobian( for (int j = 0; j < NUM_NODES; j++) { for (int jj = 3; jj < 4; jj++) { // Compute the product of Dtemp*Btemp [3xNUM_NODES] at the given point - TacsScalar bs[3]; // column of B + TacsScalar bs[3]; // column of B stiff->calculateConduction(pt, bj, bs); bj += 3; for (int i = 0; i < NUM_NODES; i++) { for (int ii = 3; ii < 4; ii++) { - const TacsScalar *bi = &B[3 * i]; + const TacsScalar* bi = &B[3 * i]; mat[NUM_VARIABLES * (4 * j + jj) + (4 * i + ii)] += alpha * h * (bi[0] * bs[0] + bi[1] * bs[1] + bi[2] * bs[2]); - } // end for int ii = 3; ii < 4 - } // end for int i = 0; i < NUM_NODES - } // end for int jj = 3; jj < 4 - } // end for int j = 0; j < NUM_NODES - } // end if conduction - } // end for int n = 0; n < numGauss + } // end for int ii = 3; ii < 4 + } // end for int i = 0; i < NUM_NODES + } // end for int jj = 3; jj < 4 + } // end for int j = 0; j < NUM_NODES + } // end if conduction + } // end for int n = 0; n < numGauss } /* @@ -1613,8 +1615,8 @@ void TACS3DCoupledThermoElement::addAdjResProduct( TacsScalar bpsi[NUM_STRESSES]; memset(bpsi, 0, NUM_STRESSES * sizeof(TacsScalar)); - TacsScalar *b = B; - const TacsScalar *ps = psi_u; + TacsScalar* b = B; + const TacsScalar* ps = psi_u; for (int i = 0; i < 3 * NUM_NODES; i++) { bpsi[0] += ps[0] * b[0]; bpsi[1] += ps[0] * b[1]; @@ -1665,7 +1667,7 @@ void TACS3DCoupledThermoElement::addAdjResProduct( // Compute the term alpha*psi_t^{T}*B^{T}*dC/dx*B*T (contribution // of heat transfer model) stiff->addConductionDVSens(pt, strain, scale * h, bpsi, dvSens, dvLen); - } // end for int n = 0; n < numGauss + } // end for int n = 0; n < numGauss } /* @@ -1857,7 +1859,7 @@ void TACS3DCoupledThermoElement::addMatDVSensInnerProduct( memset(bpsi, 0, NUM_STRESSES * sizeof(TacsScalar)); memset(bphi, 0, NUM_STRESSES * sizeof(TacsScalar)); - TacsScalar *b = B; + TacsScalar* b = B; const TacsScalar *ps = psi_u, *ph = phi_u; for (int i = 0; i < NUM_VARIABLES; i++) { bpsi[0] += ps[0] * b[0]; @@ -1921,7 +1923,7 @@ void TACS3DCoupledThermoElement::addMatDVSensInnerProduct( // Compute the term alpha*psi_t^{T}*B^{T}*dC/dx*B*phi_t (contribution // of heat transfer model) stiff->addConductionDVSens(pt, bphi, scale * h, bpsi, dvSens, dvLen); - } // for int n = 0; n < numGauss + } // for int n = 0; n < numGauss } else if (matType == MASS_MATRIX) { // The shape functions associated with the element double N[NUM_NODES]; @@ -1950,7 +1952,7 @@ void TACS3DCoupledThermoElement::addMatDVSensInnerProduct( upsi[0] = upsi[1] = upsi[2] = 0.0; uphi[0] = uphi[1] = uphi[2] = 0.0; - double *ns = N; + double* ns = N; const TacsScalar *ps = psi, *ph = phi; for (int i = 0; i < NUM_NODES; i++) { upsi[0] += ns[0] * ps[0]; @@ -2056,9 +2058,8 @@ void TACS3DCoupledThermoElement::getMatType( Xpts: the element nodes */ template -TacsScalar -TACS3DCoupledThermoElement::getDetJacobian(const double pt[], - const TacsScalar Xpts[]) { +TacsScalar TACS3DCoupledThermoElement::getDetJacobian( + const double pt[], const TacsScalar Xpts[]) { // Compute the element shape functions double N[NUM_NODES]; double Na[NUM_NODES], Nb[NUM_NODES], Nc[NUM_NODES]; @@ -2087,7 +2088,7 @@ TACS3DCoupledThermoElement::getDetJacobian(const double pt[], */ template TacsScalar TACS3DCoupledThermoElement::getDetJacobianXptSens( - TacsScalar *hXptSens, const double pt[], const TacsScalar Xpts[]) { + TacsScalar* hXptSens, const double pt[], const TacsScalar Xpts[]) { // Compute the element shape functions double N[NUM_NODES]; double Na[NUM_NODES], Nb[NUM_NODES], Nc[NUM_NODES]; @@ -2233,7 +2234,7 @@ void TACS3DCoupledThermoElement::addStrainSVSens( // displacements getBmat(B, J, Na, Nb, Nc, vars); - TacsScalar *b = B; + TacsScalar* b = B; for (int i = 0; i < NUM_NODES; i++) { sens[4 * i] += scale * (strainSens[0] * b[0] + strainSens[1] * b[1] + strainSens[2] * b[2] + strainSens[3] * b[3] + @@ -2295,7 +2296,7 @@ void TACS3DCoupledThermoElement::addEffStrainSVSens( // displacements getBmat(B, J, Na, Nb, Nc, vars); - TacsScalar *b = B; + TacsScalar* b = B; for (int i = 0; i < NUM_NODES; i++) { // Derivative wrt u sens[4 * i] += scale * (strainSens[0] * b[0] + strainSens[1] * b[1] + @@ -2436,11 +2437,11 @@ void TACS3DCoupledThermoElement::addBTSVSens( // displacements getBmatTemp(B, J, Na, Nb, Nc, vars); - TacsScalar *b = B; + TacsScalar* b = B; for (int i = 0; i < NUM_NODES; i++) { sens[4 * i + 3] += scale * (strainSens[0] * b[0] + strainSens[1] * b[1] + strainSens[2] * b[2]); b += 3; } } -#endif // TACS_3D_COUPLED_THERMO_ELEMENT_H +#endif // TACS_3D_COUPLED_THERMO_ELEMENT_H diff --git a/src/elements/direct/TACS3DCoupledThermoTraction.h b/src/elements/direct/TACS3DCoupledThermoTraction.h index b7104c09b..4054d9a1f 100644 --- a/src/elements/direct/TACS3DCoupledThermoTraction.h +++ b/src/elements/direct/TACS3DCoupledThermoTraction.h @@ -8,8 +8,9 @@ /* The surface traction class for 3D elements */ -template class TACS3DThermoTraction : public TACSElement { -public: +template +class TACS3DThermoTraction : public TACSElement { + public: static const int NUM_NODES = order * order * order; static const int U_NEGATIVE = 0; @@ -74,7 +75,7 @@ template class TACS3DThermoTraction : public TACSElement { // Compute the kinetic and potential energy within the element // ----------------------------------------------------------- - void computeEnergies(double time, TacsScalar *Te, TacsScalar *Pe, + void computeEnergies(double time, TacsScalar* Te, TacsScalar* Pe, const TacsScalar Xpts[], const TacsScalar vars[], const TacsScalar dvars[]) { *Te = 0.0, *Pe = 0.0; @@ -234,7 +235,7 @@ template class TACS3DThermoTraction : public TACSElement { const TacsScalar vars[], const TacsScalar dvars[], const TacsScalar ddvars[]) {} -private: + private: int surface; TacsScalar tx[order * order]; TacsScalar ty[order * order]; @@ -246,8 +247,9 @@ template class TACS3DThermoTraction : public TACSElement { /* The surface heat flux class for 3D elements */ -template class TACS3DHeatFluxTraction : public TACSElement { -public: +template +class TACS3DHeatFluxTraction : public TACSElement { + public: static const int NUM_NODES = order * order * order; static const int U_NEGATIVE = 0; @@ -313,7 +315,7 @@ template class TACS3DHeatFluxTraction : public TACSElement { // Compute the kinetic and potential energy within the element // ----------------------------------------------------------- - void computeEnergies(double time, TacsScalar *Te, TacsScalar *Pe, + void computeEnergies(double time, TacsScalar* Te, TacsScalar* Pe, const TacsScalar Xpts[], const TacsScalar vars[], const TacsScalar dvars[]) { *Te = 0.0, *Pe = 0.0; @@ -366,7 +368,7 @@ template class TACS3DHeatFluxTraction : public TACSElement { FElibrary::lagrangeSFKnots(nc, dnc, pt[2], knots, order); // Calcualte the Jacobian at the current point - const TacsScalar *x = Xpts; + const TacsScalar* x = Xpts; TacsScalar Xd[9] = {0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0}; for (int k = 0; k < order; k++) { @@ -470,7 +472,7 @@ template class TACS3DHeatFluxTraction : public TACSElement { const TacsScalar vars[], const TacsScalar dvars[], const TacsScalar ddvars[]) {} -private: + private: // Set the base point and direction // -------------------------------- void initBaseDir(int surface) { @@ -507,8 +509,9 @@ template class TACS3DHeatFluxTraction : public TACSElement { The surface heat source/sink class for 3D elements; treat it like a body force */ -template class TACS3DHeatSourceSink : public TACSElement { -public: +template +class TACS3DHeatSourceSink : public TACSElement { + public: static const int NUM_NODES = order * order * order; static const int U_NEGATIVE = 0; @@ -540,7 +543,7 @@ template class TACS3DHeatSourceSink : public TACSElement { numGauss = FElibrary::getGaussPtsWts(order, &gaussPts, &gaussWts); } // Get the number of displacements/nodes - int numDisplacements() { return 4; } // u,v,w,dT + int numDisplacements() { return 4; } // u,v,w,dT void getShapeFunctions(const double pt[], double N[], double Na[], double Nb[], double Nc[]) { double na[order], nb[order], nc[order]; @@ -617,7 +620,7 @@ template class TACS3DHeatSourceSink : public TACSElement { const TacsScalar vars[], const TacsScalar dvars[], const TacsScalar ddvars[]) {} -private: + private: // Information on the heat source/sink TacsScalar Q[NUM_NODES]; // The Gauss quadrature scheme @@ -630,8 +633,9 @@ template class TACS3DHeatSourceSink : public TACSElement { /* The surface pressure traction class for 3D elements */ -template class TACS3DThermoPressureTraction : public TACSElement { -public: +template +class TACS3DThermoPressureTraction : public TACSElement { + public: static const int NUM_NODES = order * order * order; static const int U_NEGATIVE = 0; @@ -669,7 +673,7 @@ template class TACS3DThermoPressureTraction : public TACSElement { // Compute the kinetic and potential energy within the element // ----------------------------------------------------------- - void computeEnergies(double time, TacsScalar *Te, TacsScalar *Pe, + void computeEnergies(double time, TacsScalar* Te, TacsScalar* Pe, const TacsScalar Xpts[], const TacsScalar vars[], const TacsScalar dvars[]) { *Te = 0.0, *Pe = 0.0; @@ -826,7 +830,7 @@ template class TACS3DThermoPressureTraction : public TACSElement { const TacsScalar vars[], const TacsScalar dvars[], const TacsScalar ddvars[]) {} -private: + private: int surface; TacsScalar pressure; @@ -837,8 +841,9 @@ template class TACS3DThermoPressureTraction : public TACSElement { /* The surface normal heat flux class for 3D elements */ -template class TACS3DNormalHeatFluxTraction : public TACSElement { -public: +template +class TACS3DNormalHeatFluxTraction : public TACSElement { + public: static const int NUM_NODES = order * order * order; static const int U_NEGATIVE = 0; @@ -877,7 +882,7 @@ template class TACS3DNormalHeatFluxTraction : public TACSElement { // Compute the kinetic and potential energy within the element // ----------------------------------------------------------- - void computeEnergies(double time, TacsScalar *Te, TacsScalar *Pe, + void computeEnergies(double time, TacsScalar* Te, TacsScalar* Pe, const TacsScalar Xpts[], const TacsScalar vars[], const TacsScalar dvars[]) { *Te = 0.0, *Pe = 0.0; @@ -930,7 +935,7 @@ template class TACS3DNormalHeatFluxTraction : public TACSElement { FElibrary::lagrangeSFKnots(nc, dnc, pt[2], knots, order); // Calcualte the Jacobian at the current point - const TacsScalar *x = Xpts; + const TacsScalar* x = Xpts; TacsScalar Xd[9] = {0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0}; for (int k = 0; k < order; k++) { @@ -1022,7 +1027,7 @@ template class TACS3DNormalHeatFluxTraction : public TACSElement { const TacsScalar vars[], const TacsScalar dvars[], const TacsScalar ddvars[]) {} -private: + private: // Set the base point and direction // -------------------------------- void initBaseDir(int surface) { @@ -1053,4 +1058,4 @@ template class TACS3DNormalHeatFluxTraction : public TACSElement { double dir1[3], dir2[3], base[3]; }; -#endif // TACS_3D_COUPLED_THERMO_TRACTION_H +#endif // TACS_3D_COUPLED_THERMO_TRACTION_H diff --git a/src/elements/direct/ThermoElements.h b/src/elements/direct/ThermoElements.h index 0c3f07b3f..8c3415d1c 100644 --- a/src/elements/direct/ThermoElements.h +++ b/src/elements/direct/ThermoElements.h @@ -3,8 +3,8 @@ #include "TACSElement.h" class ThermoQuad : public TACSElement { -public: - ThermoQuad(int component) : TACSElement(component){}; + public: + ThermoQuad(int component) : TACSElement(component) {}; virtual void getShapeFunctions(const double pt[], double N[]) = 0; virtual void getShapeFunctions(const double pt[], double N[], double Na[], double Nb[]) = 0; @@ -25,8 +25,8 @@ class ThermoQuad : public TACSElement { }; class ThermoSolid : public TACSElement { -public: - ThermoSolid(int component) : TACSElement(component){}; + public: + ThermoSolid(int component) : TACSElement(component) {}; virtual void getShapeFunctions(const double pt[], double N[]) = 0; virtual void getShapeFunctions(const double pt[], double N[], double Na[], double Nb[], double Nc[]) = 0; diff --git a/src/io/TACSFH5.h b/src/io/TACSFH5.h index 5fcd7998f..e1d95a7ef 100644 --- a/src/io/TACSFH5.h +++ b/src/io/TACSFH5.h @@ -27,7 +27,7 @@ */ class TACSFH5File : public TACSObject { -public: + public: // Data types accepted by FH5: Note that float comes last // for backwards compatibility enum FH5DataType { FH5_INT = 0, FH5_DOUBLE = 1, FH5_FLOAT = 2 }; @@ -37,31 +37,31 @@ class TACSFH5File : public TACSObject { ~TACSFH5File(); // Create an output file - int createFile(const char *file_name, int num_components, - char **component_names); - int writeZoneData(char *zone_name, char *var_names, FH5DataType data_name, - int dim1, int dim2, void *data, int *dim1_range = NULL); + int createFile(const char* file_name, int num_components, + char** component_names); + int writeZoneData(char* zone_name, char* var_names, FH5DataType data_name, + int dim1, int dim2, void* data, int* dim1_range = NULL); void close(); // Open a file for reading input - int openFile(const char *file_name); + int openFile(const char* file_name); // Retrieve the component names int getNumComponents(); - char *getComponentName(int comp); + char* getComponentName(int comp); // Retrieve zone data void firstZone(); int nextZone(); - int getZoneInfo(const char **zone_name, const char **var_names, - FH5DataType *_dtype, int *dim1, int *dim2); - int getZoneData(const char **zone_name, const char **var_names, - FH5DataType *_dtype, int *dim1, int *dim2, void **data); + int getZoneInfo(const char** zone_name, const char** var_names, + FH5DataType* _dtype, int* dim1, int* dim2); + int getZoneData(const char** zone_name, const char** var_names, + FH5DataType* _dtype, int* dim1, int* dim2, void** data); -private: + private: // Store information about the location of the data within the file class FH5FileInfo { - public: + public: FH5FileInfo() { zone_name = NULL; next = NULL; @@ -79,28 +79,28 @@ class TACSFH5File : public TACSObject { } } int dtype; - char *zone_name; - char *var_names; + char* zone_name; + char* var_names; int dim1, dim2; size_t data_offset; - FH5FileInfo *next; + FH5FileInfo* next; } *root, *tip, *current; // Scan the file and record the header information int scanFH5File(); void deleteFH5FileInfo(); - int num_comp; // The number of components - char **comp_names; // The component names + int num_comp; // The number of components + char** comp_names; // The component names - int file_for_writing; // Is this file for writing? - MPI_Comm comm; // The communicator over which the - MPI_File fp; // The MPI file pointer - MPI_Offset file_offset; // The offset into the file - MPI_Offset file_end; // The offset at the end of the file + int file_for_writing; // Is this file for writing? + MPI_Comm comm; // The communicator over which the + MPI_File fp; // The MPI file pointer + MPI_Offset file_offset; // The offset into the file + MPI_Offset file_end; // The offset at the end of the file // Serial file containing the FE solution - FILE *rfp; + FILE* rfp; }; -#endif // FH5_INCLUDE_H +#endif // FH5_INCLUDE_H From 05e1c63266c8ec8ee9cbee0debf7892443fc1a85 Mon Sep 17 00:00:00 2001 From: Tim Brooks <41971846+timryanb@users.noreply.github.com> Date: Tue, 23 Sep 2025 13:55:21 +0000 Subject: [PATCH 5/5] Update README.md to specify clang-format and Black versions used for formatting checks --- README.md | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/README.md b/README.md index 7b80d36af..2d726f322 100644 --- a/README.md +++ b/README.md @@ -129,11 +129,11 @@ Testflo can be run by calling the following command from TACS' root directory: testflo ./tests ``` 3. Add unit/integration tests that include coverage for any features that have been added to TACS' test [library](https://github.com/smdogroup/tacs/tree/master/tests). -4. Run formatting checks on any modified C++ source/header code using [clang-format](https://clang.llvm.org/docs/ClangFormat.html). +4. Run formatting checks on any modified C++ source/header code using [clang-format](https://clang.llvm.org/docs/ClangFormat.html). We use version 20 with a Google format style. ``` clang-format --style=Google -i filename.cpp ``` -5. Run formatting checks on any modified Python code using [Black](https://black.readthedocs.io/en/stable/). +5. Run formatting checks on any modified Python code using [Black](https://black.readthedocs.io/en/stable/). We use version 24. ``` python -m black filename.py ```