Skip to content

Commit 813ff06

Browse files
committed
option to consider only the surface of a reference geometry
1 parent 286e3c2 commit 813ff06

7 files changed

Lines changed: 38 additions & 34 deletions

File tree

Common/include/CConfig.hpp

Lines changed: 8 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -849,7 +849,7 @@ class CConfig {
849849
su2double Knowles_B, /*!< \brief Knowles material model constant B. */
850850
Knowles_N; /*!< \brief Knowles material model constant N. */
851851
bool DE_Effects; /*!< Application of DE effects to FE analysis */
852-
bool RefGeom; /*!< Read a reference geometry for optimization purposes. */
852+
bool RefGeom, RefGeomSurf; /*!< Read a reference geometry for optimization purposes. */
853853
unsigned long refNodeID; /*!< \brief Global ID for the reference node (optimization). */
854854
string RefGeom_FEMFileName; /*!< \brief File name for reference geometry. */
855855
unsigned short RefGeom_FileFormat; /*!< \brief Mesh input format. */
@@ -2045,11 +2045,15 @@ class CConfig {
20452045
su2double GetRefNode_Penalty(void) const { return RefNode_Penalty; }
20462046

20472047
/*!
2048-
* \brief Decide whether it's necessary to read a reference geometry.
2049-
* \return <code>TRUE</code> if it's necessary to read a reference geometry, <code>FALSE</code> otherwise.
2050-
*/
2048+
* \brief Decide whether it's necessary to read a reference geometry.
2049+
*/
20512050
bool GetRefGeom(void) const { return RefGeom; }
20522051

2052+
/*!
2053+
* \brief Consider only the surface of the reference geometry.
2054+
*/
2055+
bool GetRefGeomSurf(void) const { return RefGeomSurf; }
2056+
20532057
/*!
20542058
* \brief Get the name of the file with the reference geometry of the structural problem.
20552059
* \return Name of the file with the reference geometry of the structural problem.

Common/src/CConfig.cpp

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2237,10 +2237,12 @@ void CConfig::SetConfig_Options() {
22372237
addBoolOption("REFERENCE_GEOMETRY", RefGeom, false);
22382238
/*!\brief REFERENCE_GEOMETRY_PENALTY\n DESCRIPTION: Penalty weight value for the objective function \ingroup Config*/
22392239
addDoubleOption("REFERENCE_GEOMETRY_PENALTY", RefGeom_Penalty, 1E6);
2240-
/*!\brief SOLUTION_FLOW_FILENAME \n DESCRIPTION: Restart structure input file (the file output under the filename set by RESTART_FLOW_FILENAME) \n Default: solution_flow.dat \ingroup Config */
2240+
/*!\brief REFERENCE_GEOMETRY_FILENAME \n DESCRIPTION: Reference geometry filename \n Default: reference_geometry.dat \ingroup Config */
22412241
addStringOption("REFERENCE_GEOMETRY_FILENAME", RefGeom_FEMFileName, string("reference_geometry.dat"));
2242-
/*!\brief MESH_FORMAT \n DESCRIPTION: Mesh input file format \n OPTIONS: see \link Input_Map \endlink \n DEFAULT: SU2 \ingroup Config*/
2242+
/*!\brief REFERENCE_GEOMETRY_FORMAT \n DESCRIPTION: Reference geometry format \n DEFAULT: SU2 \ingroup Config*/
22432243
addEnumOption("REFERENCE_GEOMETRY_FORMAT", RefGeom_FileFormat, Input_Ref_Map, SU2_REF);
2244+
/*!\brief REFERENCE_GEOMETRY_SURFACE\n DESCRIPTION: If true consider only the surfaces where loads are applied. \ingroup Config*/
2245+
addBoolOption("REFERENCE_GEOMETRY_SURFACE", RefGeomSurf, false);
22442246

22452247
/*!\brief TOTAL_DV_PENALTY\n DESCRIPTION: Penalty weight value to maintain the total sum of DV constant \ingroup Config*/
22462248
addDoubleOption("TOTAL_DV_PENALTY", DV_Penalty, 0);

SU2_CFD/include/variables/CFEAVariable.hpp

Lines changed: 1 addition & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -367,14 +367,7 @@ class CFEAVariable : public CVariable {
367367
/*!
368368
* \brief Get the pointer to the reference geometry
369369
*/
370-
inline su2double *GetReference_Geometry(unsigned long iPoint) final { return Reference_Geometry[iPoint]; }
371-
372-
/*!
373-
* \brief Get the value of the reference geometry for the coordinate iVar
374-
*/
375-
inline su2double GetReference_Geometry(unsigned long iPoint, unsigned long iVar) const final {
376-
return Reference_Geometry(iPoint,iVar);
377-
}
370+
inline const su2double* GetReference_Geometry(unsigned long iPoint) const final { return Reference_Geometry[iPoint]; }
378371

379372
/*!
380373
* \brief Register the variables in the solution time_n array as input/output variable.

SU2_CFD/include/variables/CVariable.hpp

Lines changed: 1 addition & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -2308,7 +2308,7 @@ class CVariable {
23082308
/*!
23092309
* \brief A virtual member.
23102310
*/
2311-
inline virtual su2double *GetReference_Geometry(unsigned long iPoint) {return nullptr; }
2311+
inline virtual const su2double* GetReference_Geometry(unsigned long iPoint) const { return nullptr; }
23122312

23132313
/*!
23142314
* \brief A virtual member.
@@ -2325,11 +2325,6 @@ class CVariable {
23252325
*/
23262326
inline virtual su2double GetPrestretch(unsigned long iPoint, unsigned long iVar) const { return 0.0; }
23272327

2328-
/*!
2329-
* \brief A virtual member.
2330-
*/
2331-
inline virtual su2double GetReference_Geometry(unsigned long iPoint, unsigned long iVar) const { return 0.0; }
2332-
23332328
/*!
23342329
* \brief A virtual member. Get the value of the undeformed coordinates.
23352330
* \param[in] iDim - Index of Mesh_Coord[nDim]

SU2_CFD/src/solvers/CFEASolver.cpp

Lines changed: 19 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -2986,19 +2986,25 @@ void CFEASolver::Compute_OFRefGeom(CGeometry *geometry, const CConfig *config){
29862986
{
29872987
su2double obj_fun_local = 0.0;
29882988

2989-
SU2_OMP_FOR_STAT(omp_chunk_size)
2990-
for (unsigned long iPoint = 0; iPoint < nPointDomain; iPoint++) {
2991-
2992-
for (unsigned short iVar = 0; iVar < nVar; iVar++) {
2993-
2994-
/*--- Retrieve the value of the reference geometry ---*/
2995-
su2double reference_geometry = nodes->GetReference_Geometry(iPoint,iVar);
2996-
2997-
/*--- Retrieve the value of the current solution ---*/
2998-
su2double current_solution = nodes->GetSolution(iPoint,iVar);
2999-
3000-
/*--- The objective function is the sum of the difference between solution and difference, squared ---*/
3001-
obj_fun_local += pow(current_solution - reference_geometry, 2);
2989+
if (!config->GetRefGeomSurf()) {
2990+
SU2_OMP_FOR_STAT(omp_chunk_size)
2991+
for (unsigned long iPoint = 0; iPoint < nPointDomain; iPoint++) {
2992+
obj_fun_local += SquaredDistance(nVar, nodes->GetReference_Geometry(iPoint), nodes->GetSolution(iPoint));
2993+
}
2994+
}
2995+
else {
2996+
for (unsigned short iMarker = 0; iMarker < config->GetnMarker_All(); iMarker++) {
2997+
if ((config->GetMarker_All_KindBC(iMarker) == LOAD_BOUNDARY) ||
2998+
(config->GetMarker_All_KindBC(iMarker) == LOAD_DIR_BOUNDARY) ||
2999+
(config->GetMarker_All_KindBC(iMarker) == FLOWLOAD_BOUNDARY)) {
3000+
SU2_OMP_FOR_STAT(OMP_MIN_SIZE)
3001+
for (unsigned long iVertex = 0; iVertex < geometry->GetnVertex(iMarker); ++iVertex) {
3002+
auto iPoint = geometry->vertex[iMarker][iVertex]->GetNode();
3003+
3004+
if (geometry->nodes->GetDomain(iPoint))
3005+
obj_fun_local += SquaredDistance(nVar, nodes->GetReference_Geometry(iPoint), nodes->GetSolution(iPoint));
3006+
}
3007+
}
30023008
}
30033009
}
30043010
atomicAdd(obj_fun_local, objective_function);

TestCases/disc_adj_fea/configAD_fem.cfg

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@
44
% Author: R.Sanchez %
55
% Institution: Imperial College London %
66
% Date: 2017.11.29 %
7-
% File Version 7.1.0 "Blackbird" %
7+
% File Version 7.1.0 "Blackbird" %
88
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
99

1010
SOLVER= ELASTICITY
@@ -22,6 +22,8 @@ REFERENCE_GEOMETRY = YES
2222
REFERENCE_GEOMETRY_FILENAME = reference_geometry.dat
2323
REFERENCE_GEOMETRY_FORMAT = SU2
2424
REFERENCE_GEOMETRY_PENALTY = 1E6
25+
% Consider only the surface
26+
REFERENCE_GEOMETRY_SURFACE = NO
2527

2628
READ_BINARY_RESTART=NO
2729

TestCases/disc_adj_fsi/configFEA.cfg

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,8 @@ ELECTRIC_FIELD_MOD = 20E5
2424
REFERENCE_GEOMETRY = YES
2525
REFERENCE_GEOMETRY_FILENAME = reference_geometry.dat
2626
REFERENCE_GEOMETRY_FORMAT = SU2
27+
% Consider only the surface
28+
REFERENCE_GEOMETRY_SURFACE = NO
2729

2830
READ_BINARY_RESTART=NO
2931

0 commit comments

Comments
 (0)