Skip to content

Commit

Permalink
Integrate CMeshSolver for mesh deformation based on linear elasticity…
Browse files Browse the repository at this point in the history
… solver
  • Loading branch information
aa-g committed Jun 22, 2021
1 parent 6facf5b commit bb2c030
Show file tree
Hide file tree
Showing 8 changed files with 245 additions and 35 deletions.
1 change: 1 addition & 0 deletions Common/include/geometry/primal_grid/CPrimalGrid.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,7 @@

#include <iostream>
#include <vector>
#include <limits>
#include <cstdlib>

#include "../../CConfig.hpp"
Expand Down
15 changes: 12 additions & 3 deletions SU2_CFD/include/solvers/CMeshSolver.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -129,19 +129,28 @@ class CMeshSolver final : public CFEASolver {
/*!
* \brief Grid deformation using the linear elasticity equations.
* \param[in] geometry - Geometrical definition of the problem.
* \param[in] numerics - Numerics used in the solution.
* \param[in] config - Definition of the particular problem.
*/
void DeformMesh(CGeometry **geometry,
CNumerics **numerics,
CConfig *config) override;

/*!
* \brief Set the stiffness of the mesh.
* \brief Grid deformation using the linear elasticity equations (no multigrid).
* \param[in] geometry - Geometrical definition of the problem.
* \param[in] numerics - Numerics used in the solution.
* \param[in] config - Definition of the particular problem.
*/
void DeformMesh(CGeometry *geometry,
CNumerics **numerics,
CConfig *config) override;
/*!
* \brief Set the stiffness of the mesh.
* \param[in] numerics - Numerics used in the solution.
* \param[in] config - Definition of the particular problem.
*/
void SetMesh_Stiffness(CGeometry **geometry,
CNumerics **numerics,
void SetMesh_Stiffness(CNumerics **numerics,
CConfig *config) override;

/*!
Expand Down
12 changes: 10 additions & 2 deletions SU2_CFD/include/solvers/CSolver.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -4205,8 +4205,16 @@ class CSolver {
* \param[in] config - Definition of the particular problem.
* \param[in] referenceCoord - Determine if the mesh is deformed from the reference or from the current coordinates.
*/
inline virtual void SetMesh_Stiffness(CGeometry **geometry,
CNumerics **numerics,
inline virtual void DeformMesh(CGeometry *geometry,
CNumerics **numerics,
CConfig *config) { }

/*!
* \brief A virtual member.
* \param[in] config - Definition of the particular problem.
* \param[in] referenceCoord - Determine if the mesh is deformed from the reference or from the current coordinates.
*/
inline virtual void SetMesh_Stiffness(CNumerics **numerics,
CConfig *config) { }

/*!
Expand Down
2 changes: 1 addition & 1 deletion SU2_CFD/src/iteration/CIteration.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -163,7 +163,7 @@ void CIteration::SetMesh_Deformation(CGeometry** geometry, CSolver** solver, CNu

/*--- Set the stiffness of each element mesh into the mesh numerics ---*/

solver[MESH_SOL]->SetMesh_Stiffness(geometry, numerics[MESH_SOL], config);
solver[MESH_SOL]->SetMesh_Stiffness(numerics[MESH_SOL], config);

/*--- Deform the volume grid around the new boundary locations ---*/

Expand Down
58 changes: 57 additions & 1 deletion SU2_CFD/src/solvers/CMeshSolver.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -420,7 +420,7 @@ void CMeshSolver::SetWallDistance(CGeometry *geometry, CConfig *config) {
END_SU2_OMP_PARALLEL
}

void CMeshSolver::SetMesh_Stiffness(CGeometry **geometry, CNumerics **numerics, CConfig *config){
void CMeshSolver::SetMesh_Stiffness(CNumerics **numerics, CConfig *config){

if (stiffness_set) return;

Expand Down Expand Up @@ -542,6 +542,62 @@ void CMeshSolver::DeformMesh(CGeometry **geometry, CNumerics **numerics, CConfig

}

void CMeshSolver::DeformMesh(CGeometry *geometry, CNumerics **numerics, CConfig *config){

if (multizone) nodes->Set_BGSSolution_k();

/*--- Capture a few MPI dependencies for AD. ---*/
geometry->InitiateComms(geometry, config, COORDINATES);
geometry->CompleteComms(geometry, config, COORDINATES);

InitiateComms(geometry, config, SOLUTION);
CompleteComms(geometry, config, SOLUTION);

InitiateComms(geometry, config, MESH_DISPLACEMENTS);
CompleteComms(geometry, config, MESH_DISPLACEMENTS);

/*--- Compute the stiffness matrix, no point recording because we clear the residual. ---*/

const bool wasActive = AD::BeginPassive();

Compute_StiffMatrix(geometry, numerics, config);

AD::EndPassive(wasActive);

/*--- Clear residual (loses AD info), we do not want an incremental solution. ---*/
SU2_OMP_PARALLEL {
LinSysRes.SetValZero();
if (time_domain && config->GetFSI_Simulation()) LinSysSol.SetValZero();
}
END_SU2_OMP_PARALLEL

/*--- Impose boundary conditions (all of them are ESSENTIAL BC's - displacements). ---*/
SetBoundaryDisplacements(geometry, config, false);

/*--- Solve the linear system. ---*/
Solve_System(geometry, config);

SU2_OMP_PARALLEL {

/*--- Update the grid coordinates and cell volumes using the solution
of the linear system (usol contains the x, y, z displacements). ---*/
UpdateGridCoord(geometry, config);

/*--- Update the dual grid. ---*/
UpdateDualGrid(geometry, config);

/*--- Check for failed deformation (negative volumes). ---*/
SetMinMaxVolume(geometry, config, true);

/*--- The Grid Velocity is only computed if the problem is time domain ---*/
if (time_domain && !config->GetFSI_Simulation())
ComputeGridVelocity(geometry, config);

}
END_SU2_OMP_PARALLEL

}

void CMeshSolver::UpdateGridCoord(CGeometry *geometry, CConfig *config){

/*--- Update the grid coordinates using the solution of the linear system ---*/
Expand Down
30 changes: 29 additions & 1 deletion SU2_DEF/include/drivers/CDeformationDriver.hpp
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
/*!
/*!
* \file CDeformationDriver.hpp
* \brief Headers of the main subroutines for driving the mesh deformation.
* \author T. Economon, H. Kline, R. Sanchez
Expand Down Expand Up @@ -32,6 +32,7 @@
#include "../../../Common/include/grid_movement/CSurfaceMovement.hpp"
#include "../../../Common/include/grid_movement/CVolumetricMovement.hpp"
#include "../../../SU2_CFD/include/output/COutput.hpp"
#include "../../../SU2_CFD/include/numerics/CNumerics.hpp"
#include "../../../Common/include/geometry/CGeometry.hpp"

/*!
Expand All @@ -56,6 +57,8 @@ class CDeformationDriver {
CGeometry **geometry_container; /*!< \brief Geometrical definition of the problem. */
CSurfaceMovement **surface_movement; /*!< \brief Surface movement classes of the problem. */
CVolumetricMovement **grid_movement; /*!< \brief Volume grid movement classes of the problem. */
CSolver **solver_container;
CNumerics ***numerics_container;
COutput **output_container; /*!< \brief Pointer to the COutput class. */

public:
Expand All @@ -76,6 +79,11 @@ class CDeformationDriver {
*/
void Run();

/*!
* \brief Output the mesh.
*/
void Output();

/*!
* \brief Deallocation routine
*/
Expand All @@ -102,4 +110,24 @@ class CDeformationDriver {
*/
void Output_Preprocessing();

/*!
* \brief Preprocess the mesh solver container.
*/
void Solver_Preprocessing();

/*!
* \brief Preprocess the numerics container.
*/
void Numerics_Preprocessing();

/*!
* \brief Mesh deformation based on linear elasticity solver (CMeshSolver).
*/
void Update();

/*!
* \brief Mesh deformation based on legacy implementation.
*/
void Update_Legacy();

};
Loading

0 comments on commit bb2c030

Please sign in to comment.