@@ -95,6 +95,7 @@ CGradientSmoothingSolver::CGradientSmoothingSolver(CGeometry *geometry, CConfig
9595 LinSysRes.Initialize (nPoint, nPointDomain, 1 , 0.0 );
9696 Jacobian.Initialize (nPoint, nPointDomain, 1 , 1 , false , geometry, config, false , true );
9797 }
98+ visited.resize (geometry->GetnPoint (), false );
9899 }
99100
100101 /* --- vectors needed for projection when working on the complete system ---*/
@@ -201,9 +202,11 @@ void CGradientSmoothingSolver::ApplyGradientSmoothingSurface(CGeometry* geometry
201202 LinSysSol.SetValZero ();
202203 LinSysRes.SetValZero ();
203204 Jacobian.SetValZero ();
205+ std::fill (visited.begin (), visited.end (), false );
204206
205207 /* --- Compute the stiffness matrix for the smoothing operator. ---*/
206208 Compute_Surface_StiffMatrix (geometry, numerics, config, val_marker);
209+ Complete_Surface_StiffMatrix (geometry);
207210
208211 Compute_Surface_Residual (geometry, config, val_marker);
209212
@@ -397,18 +400,12 @@ void CGradientSmoothingSolver::Compute_Surface_StiffMatrix(CGeometry* geometry,
397400 std::array<unsigned long , MAXNNODE_2D> indexVertex;
398401 int EL_KIND = 0 ;
399402 su2double val_Coord, HiHj = 0.0 ;
400- su2activematrix DHiDHj, Jacobian_block, mId_Aux ;
403+ su2activematrix DHiDHj, Jacobian_block;
401404
402405 Jacobian_block.resize (nDim, nDim) = su2double (0.0 );
403- mId_Aux .resize (nDim, nDim) = su2double (0.0 );
404- for (iDim = 0 ; iDim < nDim; iDim++) {
405- mId_Aux [iDim][iDim] = su2double (1.0 );
406- }
407-
408- vector<bool > visited (geometry->GetnPoint (), false );
409406
410407 /* --- Check if the current MPI rank has a part of the marker ---*/
411- if (val_marker!=NOT_AVAILABLE) {
408+ if (val_marker!=BC_TYPE:: NOT_AVAILABLE) {
412409
413410 /* --- Loops over all the elements ---*/
414411 for (iElem = 0 ; iElem < geometry->GetnElem_Bound (val_marker); iElem++) {
@@ -463,13 +460,6 @@ void CGradientSmoothingSolver::Compute_Surface_StiffMatrix(CGeometry* geometry,
463460 }
464461 }
465462
466- /* --- Assembling the stiffness matrix on the design surface means the Jacobian is the identity for nodes inside the domain. ---*/
467- for (iPoint = 0 ; iPoint < geometry->GetnPointDomain (); iPoint++){
468- if (visited[iPoint]==false ) {
469- Jacobian.AddBlock (iPoint, iPoint, mId_Aux );
470- }
471- }
472-
473463}
474464
475465void CGradientSmoothingSolver::Compute_Residual (CGeometry* geometry, const CConfig* config) {
@@ -539,7 +529,7 @@ void CGradientSmoothingSolver::Compute_Surface_Residual(CGeometry* geometry, con
539529 su2double* normal = NULL ;
540530
541531 /* --- Check if the current MPI rank has a part of the marker ---*/
542- if (val_marker!=NOT_AVAILABLE) {
532+ if (val_marker!=BC_TYPE:: NOT_AVAILABLE) {
543533
544534 for (iElem = 0 ; iElem < geometry->GetnElem_Bound (val_marker); iElem++) {
545535
@@ -637,7 +627,7 @@ void CGradientSmoothingSolver::BC_Surface_Dirichlet(const CGeometry* geometry, c
637627 const su2double zeros[MAXNDIM] = {0.0 };
638628
639629 /* --- Check if the current MPI rank has a part of the marker ---*/
640- if (val_marker!=NOT_AVAILABLE) {
630+ if (val_marker!=BC_TYPE:: NOT_AVAILABLE) {
641631 for (iVertex = 0 ; iVertex < geometry->nVertex [val_marker]; iVertex++) {
642632
643633 /* --- Get node index ---*/
@@ -680,17 +670,15 @@ template <typename scalar_type>
680670CSysMatrixVectorProduct<scalar_type> CGradientSmoothingSolver::GetStiffnessMatrixVectorProduct (CGeometry* geometry,
681671 CNumerics* numerics,
682672 const CConfig* config) {
683- bool surf = config->GetSmoothOnSurface ();
684673
685674 /* --- Compute the sparse stiffness matrix ---*/
686- if (surf) {
687- unsigned long dvMarker=NOT_AVAILABLE;
688- for (unsigned int iMarker = 0 ; iMarker < config->GetnMarker_All (); iMarker++) {
689- if ( config->GetMarker_All_DV (iMarker) == YES ) {
690- dvMarker=iMarker;
675+ if (config->GetSmoothOnSurface ()) {
676+ for (unsigned int iMarker = 0 ; iMarker < config->GetnMarker_CfgFile (); iMarker++) {
677+ if (config->GetMarker_All_DV (iMarker) == YES) {
678+ Compute_Surface_StiffMatrix (geometry, numerics, config, iMarker, nDim);
691679 }
692680 }
693- Compute_Surface_StiffMatrix (geometry, numerics, config, dvMarker, nDim );
681+ Complete_Surface_StiffMatrix (geometry);
694682 } else {
695683 Compute_StiffMatrix (geometry, numerics, config);
696684 }
@@ -917,7 +905,7 @@ void CGradientSmoothingSolver::WriteSensitivity(CGeometry* geometry, const CConf
917905
918906 /* --- split between surface and volume first, to avoid mpi ranks with no part of the marker to write back nonphysical solutions in the surface case ---*/
919907 if ( config->GetSmoothOnSurface () ) {
920- if ( val_marker!=NOT_AVAILABLE ) {
908+ if ( val_marker!=BC_TYPE:: NOT_AVAILABLE ) {
921909 for (unsigned long iVertex =0 ; iVertex<geometry->nVertex [val_marker]; iVertex++) {
922910 iPoint = geometry->vertex [val_marker][iVertex]->GetNode ();
923911 normal = geometry->vertex [val_marker][iVertex]->GetNormal ();
@@ -980,23 +968,25 @@ void CGradientSmoothingSolver::Set_VertexEliminationSchedule(CGeometry* geometry
980968 if (config->GetSmoothOnSurface ()) {
981969
982970 /* --- Find Marker_DV if this node has any ---*/
983- unsigned long dvMarker=NOT_AVAILABLE;
971+ unsigned long dvMarker=BC_TYPE:: NOT_AVAILABLE;
984972 for (unsigned short iMarker = 0 ; iMarker < config->GetnMarker_All (); iMarker++) {
985- if (config->GetMarker_All_DV (iMarker) == YES) {
986- dvMarker = iMarker;
987- }
988- }
989-
990- /* --- Surface case:
991- * Fix design boundary border if Dirichlet condition is set and the current rank holds part of it. ---*/
992- if ( config->GetDirichletSurfaceBound () && dvMarker!=NOT_AVAILABLE) {
993- for (iVertex = 0 ; iVertex < geometry->nVertex [dvMarker]; iVertex++) {
994- /* --- Get node index ---*/
995- iPoint = geometry->vertex [dvMarker][iVertex]->GetNode ();
996- if (nodes->GetIsBoundaryPoint (iPoint)) {
997- myPoints.push_back (geometry->nodes ->GetGlobalIndex (iPoint));
973+ // if (MarkerIsDVMarker(iMarker, config)) {
974+ // dvMarker = BC_TYPE::NOT_AVAILABLE;
975+ if (config->GetMarker_All_DV (iMarker) == YES) dvMarker = iMarker;
976+ // }
977+
978+ /* --- Surface case:
979+ * Fix design boundary border if Dirichlet condition is set and the current rank holds part of it. ---*/
980+ if ( config->GetDirichletSurfaceBound () && dvMarker!=BC_TYPE::NOT_AVAILABLE) {
981+ for (iVertex = 0 ; iVertex < geometry->nVertex [dvMarker]; iVertex++) {
982+ /* --- Get node index ---*/
983+ iPoint = geometry->vertex [dvMarker][iVertex]->GetNode ();
984+ if (nodes->GetIsBoundaryPoint (iPoint)) {
985+ myPoints.push_back (geometry->nodes ->GetGlobalIndex (iPoint));
986+ }
998987 }
999988 }
989+
1000990 }
1001991
1002992 } else {
@@ -1024,3 +1014,36 @@ void CGradientSmoothingSolver::Set_VertexEliminationSchedule(CGeometry* geometry
10241014 Jacobian.EnforceSolutionAtNode (iPoint, LinSysSol.GetBlock (iPoint), LinSysRes);
10251015 }
10261016}
1017+
1018+ bool CGradientSmoothingSolver::MarkerIsDVMarker (unsigned short iMarker, const CConfig *config) const {
1019+
1020+ int isLocalDVmarker, isGlobalDVmarker;
1021+ bool isDVmarker=false ;
1022+
1023+ if ( config->GetMarker_All_DV (iMarker) == YES ) {
1024+ isLocalDVmarker = 1 ;
1025+ } else {
1026+ isLocalDVmarker = 0 ;
1027+ }
1028+ SU2_MPI::Allreduce (&isLocalDVmarker, &isGlobalDVmarker, 1 , MPI_UNSIGNED_LONG, MPI_SUM, SU2_MPI::GetComm ());
1029+ if (isGlobalDVmarker >= 1 ) isDVmarker=true ;
1030+
1031+ return isDVmarker;
1032+ }
1033+
1034+ void CGradientSmoothingSolver::Complete_Surface_StiffMatrix (const CGeometry* geometry) {
1035+
1036+ su2activematrix mId_Aux ;
1037+ mId_Aux .resize (nDim, nDim) = su2double (0.0 );
1038+ for (unsigned iDim = 0 ; iDim < nDim; iDim++) {
1039+ mId_Aux [iDim][iDim] = su2double (1.0 );
1040+ }
1041+
1042+ /* --- Assembling the stiffness matrix on the design surface means the Jacobian is the identity for nodes inside the domain. ---*/
1043+ for (unsigned long iPoint = 0 ; iPoint < geometry->GetnPointDomain (); iPoint++){
1044+ if (visited[iPoint]==false ) {
1045+ Jacobian.AddBlock (iPoint, iPoint, mId_Aux );
1046+ }
1047+ }
1048+
1049+ }
0 commit comments