Skip to content

Commit 53207ab

Browse files
committed
Replaced the C-style cast by static_cast
1 parent 6a659d7 commit 53207ab

13 files changed

Lines changed: 113 additions & 113 deletions

Common/src/fem/fem_geometry_structure.cpp

Lines changed: 18 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -267,14 +267,14 @@ CMeshFEM::CMeshFEM(CGeometry* geometry, CConfig* config) {
267267
map<int, int> rankToIndCommBuf;
268268
for (int i = 0; i < size; ++i) {
269269
if (sendToRank[i]) {
270-
int ind = (int)rankToIndCommBuf.size();
270+
int ind = static_cast<int>(rankToIndCommBuf.size());
271271
rankToIndCommBuf[i] = ind;
272272
}
273273
}
274274

275275
/*--- Definition of the communication buffers, used to send the element data
276276
to the correct ranks. ---*/
277-
int nRankSend = (int)rankToIndCommBuf.size();
277+
int nRankSend = static_cast<int>(rankToIndCommBuf.size());
278278
vector<vector<short> > shortSendBuf(nRankSend, vector<short>(0));
279279
vector<vector<long> > longSendBuf(nRankSend, vector<long>(0));
280280
vector<vector<su2double> > doubleSendBuf(nRankSend, vector<su2double>(0));
@@ -294,7 +294,7 @@ CMeshFEM::CMeshFEM(CGeometry* geometry, CConfig* config) {
294294

295295
/*--- Loop over the local elements to fill the communication buffers with element data. ---*/
296296
for (unsigned long i = 0; i < geometry->GetnElem(); ++i) {
297-
int ind = (int)geometry->elem[i]->GetColor();
297+
int ind = static_cast<int>(geometry->elem[i]->GetColor());
298298
map<int, int>::const_iterator MI = rankToIndCommBuf.find(ind);
299299
ind = MI->second;
300300

@@ -385,7 +385,7 @@ CMeshFEM::CMeshFEM(CGeometry* geometry, CConfig* config) {
385385
/* Determine to which rank this boundary element must be sent.
386386
That is the same as its corresponding domain element.
387387
Update the corresponding index in longSendBuf. */
388-
int ind = (int)geometry->elem[elemID]->GetColor();
388+
int ind = static_cast<int>(geometry->elem[elemID]->GetColor());
389389
const auto MI = rankToIndCommBuf.find(ind);
390390
ind = MI->second;
391391

@@ -566,8 +566,8 @@ CMeshFEM::CMeshFEM(CGeometry* geometry, CConfig* config) {
566566
the elements with constant and non-constant Jacobians are
567567
considered the same. */
568568
if (JacConstant) {
569-
const auto orderExactStraight = (unsigned short)ceil(nPolySol * config->GetQuadrature_Factor_Straight());
570-
const auto orderExactCurved = (unsigned short)ceil(nPolySol * config->GetQuadrature_Factor_Curved());
569+
const auto orderExactStraight = static_cast<unsigned short>(ceil(nPolySol * config->GetQuadrature_Factor_Straight()));
570+
const auto orderExactCurved = static_cast<unsigned short>(ceil(nPolySol * config->GetQuadrature_Factor_Curved()));
571571
if (orderExactStraight == orderExactCurved) JacConstant = false;
572572
}
573573

@@ -691,14 +691,14 @@ CMeshFEM::CMeshFEM(CGeometry* geometry, CConfig* config) {
691691
rankToIndCommBuf.clear();
692692
for (int i = 0; i < size; ++i) {
693693
if (sendToRank[i]) {
694-
int ind = (int)rankToIndCommBuf.size();
694+
int ind = static_cast<int>(rankToIndCommBuf.size());
695695
rankToIndCommBuf[i] = ind;
696696
}
697697
}
698698

699699
/* Resize the first index of the long send buffers for the communication of
700700
the halo data. */
701-
nRankSend = (int)rankToIndCommBuf.size();
701+
nRankSend = static_cast<int>(rankToIndCommBuf.size());
702702
longSendBuf.resize(nRankSend);
703703

704704
/* Determine the number of ranks, from which this rank will receive elements. */
@@ -717,7 +717,7 @@ CMeshFEM::CMeshFEM(CGeometry* geometry, CConfig* config) {
717717
if (*low > haloElements[i].long0) --ind;
718718

719719
/* Convert this rank to the index in the send buffer. */
720-
MI = rankToIndCommBuf.find((int)ind);
720+
MI = rankToIndCommBuf.find(static_cast<int>(ind));
721721
ind = MI->second;
722722

723723
/* Store the global element ID and the periodic index in the long buffer.
@@ -911,12 +911,12 @@ CMeshFEM::CMeshFEM(CGeometry* geometry, CConfig* config) {
911911
for (int i = 0; i < size; ++i) {
912912
if (nHaloElemPerRank[i + 1] > nHaloElemPerRank[i]) {
913913
sendToRank[i] = 1;
914-
int ind = (int)rankToIndCommBuf.size();
914+
int ind = static_cast<int>(rankToIndCommBuf.size());
915915
rankToIndCommBuf[i] = ind;
916916
}
917917
}
918918

919-
nRankSend = (int)rankToIndCommBuf.size();
919+
nRankSend = static_cast<int>(rankToIndCommBuf.size());
920920

921921
/* Store the value of nRankSend for later use. */
922922
const int nRankSendHaloInfo = nRankSend;
@@ -1179,7 +1179,7 @@ CMeshFEM::CMeshFEM(CGeometry* geometry, CConfig* config) {
11791179
/*--- Create the graph of local elements. The halo elements are ignored. ---*/
11801180
vector<vector<unsigned long> > neighElem(nVolElemOwned, vector<unsigned long>(0));
11811181

1182-
nRankRecv = (int)longRecvBuf.size();
1182+
nRankRecv = static_cast<int>(longRecvBuf.size());
11831183
for (int i = 0; i < nRankRecv; ++i) {
11841184
unsigned long indL = 1, indS = 0;
11851185
for (long j = 0; j < longRecvBuf[i][0]; ++j) {
@@ -1452,7 +1452,7 @@ CMeshFEM::CMeshFEM(CGeometry* geometry, CConfig* config) {
14521452
/*--- Resize the first index of the send buffers to nRankRecv, because this
14531453
number of messages must be sent back to the sending ranks with halo
14541454
information. ---*/
1455-
nRankRecv = (int)longSecondRecvBuf.size();
1455+
nRankRecv = static_cast<int>(longSecondRecvBuf.size());
14561456
shortSendBuf.resize(nRankRecv);
14571457
longSendBuf.resize(nRankRecv);
14581458
doubleSendBuf.resize(nRankRecv);
@@ -2455,12 +2455,12 @@ void CMeshFEM_DG::CreateFaces(CConfig* config) {
24552455
is set to false. Hence it is only needed to carry out this check for faces
24562456
with a constant Jacobian. This is done to reduce the number of standard elements. */
24572457
if (thisFace.JacFaceIsConsideredConstant) {
2458-
auto orderExactStraight = (unsigned short)ceil(thisFace.nPolyGrid0 * config->GetQuadrature_Factor_Straight());
2459-
auto orderExactCurved = (unsigned short)ceil(thisFace.nPolyGrid0 * config->GetQuadrature_Factor_Curved());
2458+
auto orderExactStraight = static_cast<unsigned short>(ceil(thisFace.nPolyGrid0 * config->GetQuadrature_Factor_Straight()));
2459+
auto orderExactCurved = static_cast<unsigned short>(ceil(thisFace.nPolyGrid0 * config->GetQuadrature_Factor_Curved()));
24602460

24612461
if (orderExactStraight == orderExactCurved) {
2462-
orderExactStraight = (unsigned short)ceil(thisFace.nPolySol0 * config->GetQuadrature_Factor_Straight());
2463-
orderExactCurved = (unsigned short)ceil(thisFace.nPolySol0 * config->GetQuadrature_Factor_Curved());
2462+
orderExactStraight = static_cast<unsigned short>(ceil(thisFace.nPolySol0 * config->GetQuadrature_Factor_Straight()));
2463+
orderExactCurved = static_cast<unsigned short>(ceil(thisFace.nPolySol0 * config->GetQuadrature_Factor_Curved()));
24642464
if (orderExactStraight == orderExactCurved) thisFace.JacFaceIsConsideredConstant = false;
24652465
}
24662466
}
@@ -3159,7 +3159,7 @@ void CMeshFEM_DG::SetSendReceive(const CConfig* config) {
31593159
map<int, int> rankToIndRecvBuf;
31603160
for (int i = 0; i < size; ++i) {
31613161
if (recvFromRank[i]) {
3162-
int ind = (int)rankToIndRecvBuf.size();
3162+
int ind = static_cast<int>(rankToIndRecvBuf.size());
31633163
rankToIndRecvBuf[i] = ind;
31643164
}
31653165
}

Common/src/fem/fem_standard_element.cpp

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -186,9 +186,9 @@ CFEMStandardElementBase::CFEMStandardElementBase(unsigned short val_VTK_Type, un
186186
orderExact = val_orderExact;
187187
} else {
188188
if (constJacobian)
189-
orderExact = (unsigned short)ceil(val_nPoly * config->GetQuadrature_Factor_Straight());
189+
orderExact = static_cast<unsigned short>(ceil(val_nPoly * config->GetQuadrature_Factor_Straight()));
190190
else
191-
orderExact = (unsigned short)ceil(val_nPoly * config->GetQuadrature_Factor_Curved());
191+
orderExact = static_cast<unsigned short>(ceil(val_nPoly * config->GetQuadrature_Factor_Curved()));
192192
}
193193

194194
/*--- Determine the integration points. This depends on the element type. ---*/
@@ -903,7 +903,7 @@ void CFEMStandardElementBase::SubConnForPlottingLine(const unsigned short nPoly,
903903
/*--- Determine the local subconnectivity of the line element used for plotting
904904
purposes. This is rather trivial, because the line element is subdivided
905905
into nPoly linear line elements. ---*/
906-
unsigned short nnPoly = max(nPoly, (unsigned short)1);
906+
unsigned short nnPoly = max(nPoly, static_cast<unsigned short>(1));
907907
for (unsigned short i = 0; i < nnPoly; ++i) {
908908
subConn.push_back(i);
909909
subConn.push_back(i + 1);
@@ -916,7 +916,7 @@ void CFEMStandardElementBase::SubConnForPlottingQuadrilateral(const unsigned sho
916916
plotting purposes. Note that the connectivity of the linear subelements
917917
obey the VTK connectivity rule of a quadrilateral, which is different
918918
from the connectivity for the high order quadrilateral. ---*/
919-
unsigned short nnPoly = max(nPoly, (unsigned short)1);
919+
unsigned short nnPoly = max(nPoly, static_cast<unsigned short>(1));
920920
for (unsigned short j = 0; j < nnPoly; ++j) {
921921
unsigned short jj = j * (nnPoly + 1);
922922
for (unsigned short i = 0; i < nnPoly; ++i) {

Common/src/fem/geometry_structure_fem_part.cpp

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -609,15 +609,15 @@ void CPhysicalGeometry::SetColorFEMGrid_Parallel(CConfig* config) {
609609
the points that occur in the faces of localFacesComm. ---*/
610610
vector<unsigned long> facePointsProc(size + 1, 0);
611611
unsigned long total_point_accounted = 0;
612-
for (unsigned long i = 1; i <= (unsigned long)size; ++i) {
612+
for (unsigned long i = 1; i <= static_cast<unsigned long>(size); ++i) {
613613
facePointsProc[i] = maxPointID / size;
614614
total_point_accounted += facePointsProc[i];
615615
}
616616

617617
unsigned long rem_point = maxPointID - total_point_accounted;
618618
for (unsigned long i = 1; i <= rem_point; ++i) ++facePointsProc[i];
619619

620-
for (unsigned long i = 0; i < (unsigned long)size; ++i) facePointsProc[i + 1] += facePointsProc[i];
620+
for (unsigned long i = 0; i < static_cast<unsigned long>(size); ++i) facePointsProc[i + 1] += facePointsProc[i];
621621

622622
/*--- Determine the number of faces that has to be sent to each rank.
623623
Note that the rank is stored in elemID1, such that the search
@@ -637,7 +637,7 @@ void CPhysicalGeometry::SetColorFEMGrid_Parallel(CConfig* config) {
637637
vector<unsigned long> sendBufFace(9 * nFacesLocComm);
638638
vector<unsigned long> counter(size);
639639
counter[0] = 0;
640-
for (unsigned long i = 1; i < (unsigned long)size; ++i) counter[i] = counter[i - 1] + 9 * nFacesComm[i - 1];
640+
for (unsigned long i = 1; i < static_cast<unsigned long>(size); ++i) counter[i] = counter[i - 1] + 9 * nFacesComm[i - 1];
641641

642642
for (unsigned long i = 0; i < nFacesLocComm; ++i) {
643643
unsigned long rankFace = localFacesComm[i].elemID1;
@@ -657,7 +657,7 @@ void CPhysicalGeometry::SetColorFEMGrid_Parallel(CConfig* config) {
657657

658658
/*--- Determine the number of ranks from which I receive a message. */
659659
unsigned long nMessSend = 0;
660-
for (unsigned long i = 0; i < (unsigned long)size; ++i) {
660+
for (unsigned long i = 0; i < static_cast<unsigned long>(size); ++i) {
661661
if (nFacesComm[i]) {
662662
counter[i] = 1;
663663
++nMessSend;
@@ -674,7 +674,7 @@ void CPhysicalGeometry::SetColorFEMGrid_Parallel(CConfig* config) {
674674

675675
nMessSend = 0;
676676
unsigned long indSend = 0;
677-
for (unsigned long i = 0; i < (unsigned long)size; ++i) {
677+
for (unsigned long i = 0; i < static_cast<unsigned long>(size); ++i) {
678678
if (nFacesComm[i]) {
679679
unsigned long count = 9 * nFacesComm[i];
680680
SU2_MPI::Isend(&sendBufFace[indSend], count, MPI_UNSIGNED_LONG, i, i, SU2_MPI::GetComm(), &commReqs[nMessSend]);
@@ -792,7 +792,7 @@ void CPhysicalGeometry::SetColorFEMGrid_Parallel(CConfig* config) {
792792

793793
sizeMess /= 9;
794794
unsigned long jj = 0;
795-
for (unsigned long j = 0; j < (unsigned long)sizeMess; ++j, jj += 9) {
795+
for (unsigned long j = 0; j < static_cast<unsigned long>(sizeMess); ++j, jj += 9) {
796796
CFaceOfElement thisFace;
797797
thisFace.nCornerPoints = recvBuf[jj];
798798
thisFace.cornerPoints[0] = recvBuf[jj + 1];
@@ -2240,7 +2240,7 @@ void CPhysicalGeometry::DetermineDonorElementsWallFunctions(CConfig* config) {
22402240
carried out for each rank and store them in such a way that the info can
22412241
be used directly in Allgatherv. */
22422242
vector<int> recvCounts(size), displs(size);
2243-
int nLocalSearchPoints = (int)markerIDGlobalSearch.size();
2243+
int nLocalSearchPoints = static_cast<int>(markerIDGlobalSearch.size());
22442244

22452245
SU2_MPI::Allgather(&nLocalSearchPoints, 1, MPI_INT, recvCounts.data(), 1, MPI_INT, SU2_MPI::GetComm());
22462246
displs[0] = 0;

Common/src/geometry/CGeometry.cpp

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -183,8 +183,8 @@ void CGeometry::PreprocessP2PComms(CGeometry* geometry, CConfig* config) {
183183
/*--- If we have not visited this element yet, increment our
184184
number of elements that must be sent to a particular proc. ---*/
185185

186-
if ((nPoint_Flag[iRank] != (int)iMarker)) {
187-
nPoint_Flag[iRank] = (int)iMarker;
186+
if ((nPoint_Flag[iRank] != static_cast<int>(iMarker))) {
187+
nPoint_Flag[iRank] = static_cast<int>(iMarker);
188188
nPoint_Send_All[iRank + 1] += nVertexS;
189189
}
190190
}
@@ -819,13 +819,13 @@ void CGeometry::PreprocessPeriodicComms(CGeometry* geometry, CConfig* config) {
819819
/*--- Get the rank that holds the matching periodic point
820820
on the other marker in the periodic pair. ---*/
821821

822-
iRank = (int)geometry->vertex[iMarker][iVertex]->GetDonorProcessor();
822+
iRank = static_cast<int>(geometry->vertex[iMarker][iVertex]->GetDonorProcessor());
823823

824824
/*--- If we have not visited this point last, increment our
825825
number of points that must be sent to a particular proc. ---*/
826826

827-
if ((nPoint_Flag[iRank] != (int)iPoint)) {
828-
nPoint_Flag[iRank] = (int)iPoint;
827+
if ((nPoint_Flag[iRank] != static_cast<int>(iPoint))) {
828+
nPoint_Flag[iRank] = static_cast<int>(iPoint);
829829
nPoint_Send_All[iRank + 1] += 1;
830830
}
831831
}
@@ -962,7 +962,7 @@ void CGeometry::PreprocessPeriodicComms(CGeometry* geometry, CConfig* config) {
962962
/*--- Get the rank that holds the matching periodic point
963963
on the other marker in the periodic pair. ---*/
964964

965-
iRank = (int)geometry->vertex[iMarker][iVertex]->GetDonorProcessor();
965+
iRank = static_cast<int>(geometry->vertex[iMarker][iVertex]->GetDonorProcessor());
966966

967967
/*--- If the rank for the current periodic point matches the
968968
rank of the current send message, then store the local point
@@ -971,11 +971,11 @@ void CGeometry::PreprocessPeriodicComms(CGeometry* geometry, CConfig* config) {
971971

972972
if (iRank == Neighbors_PeriodicSend[iSend]) {
973973
Local_Point_PeriodicSend[ii] = iPoint;
974-
Local_Marker_PeriodicSend[ii] = (unsigned long)iMarker;
974+
Local_Marker_PeriodicSend[ii] = static_cast<unsigned long>(iMarker);
975975
jj = ii * nPackets;
976976
idSend[jj] = geometry->vertex[iMarker][iVertex]->GetDonorPoint();
977977
jj++;
978-
idSend[jj] = (unsigned long)iPeriodic;
978+
idSend[jj] = static_cast<unsigned long>(iPeriodic);
979979
ii++;
980980
}
981981
}

0 commit comments

Comments
 (0)