Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 3 additions & 0 deletions Common/src/geometry/CGeometry.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -4243,6 +4243,7 @@ void CGeometry::SetWallVelocity(const CConfig* config, bool print) {

const auto Marker_Tag = config->GetMarker_All_TagBound(iMarker);
const auto jMarker = config->GetMarker_Moving(Marker_Tag);
if (config->GetKind_SurfaceMovement(jMarker) != MOVING_WALL) continue;

su2double xDot[MAXNDIM], Center[MAXNDIM], Omega[MAXNDIM];

Expand Down Expand Up @@ -4315,6 +4316,8 @@ void CGeometry::SetGridVelocity(const CConfig* config) {
nodes->SetGridVel(iPoint, iDim, GridVel);
}
}

if (config->GetSurface_Movement(MOVING_WALL)) SetWallVelocity(config, false);
}

const CGeometry::LDUSparsePattern& CGeometry::GetSparsePattern(ConnectivityType type, unsigned long fillLvl) {
Expand Down
2 changes: 1 addition & 1 deletion SU2_CFD/src/drivers/CDriver.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -2575,7 +2575,7 @@ void CDriver::PreprocessStaticMesh(const CConfig *config, CGeometry** geometry){

if (!fem_solver) {

if (config->GetnMarker_Moving() > 0) {
if (config->GetSurface_Movement(MOVING_WALL)) {

/*--- Fixed wall velocities: set the grid velocities only one time
before the first iteration flow solver. ---*/
Expand Down
24 changes: 20 additions & 4 deletions SU2_CFD/src/solvers/CMeshSolver.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,24 @@
using namespace GeometryToolbox;


namespace {
/*!
* \brief Re-apply prescribed MOVING_WALL velocities on MESH_0 after volume grid velocity
* updates and restrict all grid velocities to coarser multigrid levels.
*/
void ApplyMovingWallAndRestrictGridVel(CGeometry** geometry, const CConfig* config) {
if (config->GetSurface_Movement(MOVING_WALL)) {
BEGIN_SU2_OMP_SAFE_GLOBAL_ACCESS {
geometry[MESH_0]->SetWallVelocity(config, false);
}
END_SU2_OMP_SAFE_GLOBAL_ACCESS
}

for (auto iMGlevel = 1u; iMGlevel <= config->GetnMGLevels(); iMGlevel++)
geometry[iMGlevel]->SetRestricted_GridVelocity(geometry[iMGlevel - 1]);
}
} // namespace

CMeshSolver::CMeshSolver(CGeometry *geometry, CConfig *config) : CFEASolver(LINEAR_SOLVER_MODE::MESH_DEFORM) {
SU2_ZONE_SCOPED

Expand Down Expand Up @@ -609,8 +627,7 @@ void CMeshSolver::ComputeGridVelocity_FromBoundary(CGeometry **geometry, CNumeri
geometry[MESH_0]->nodes->SetGridVel(iPoint, iDim, LinSysSol(iPoint,iDim)*invVelRef);
END_SU2_OMP_FOR

for (auto iMGlevel = 1u; iMGlevel <= config->GetnMGLevels(); iMGlevel++)
geometry[iMGlevel]->SetRestricted_GridVelocity(geometry[iMGlevel-1]);
ApplyMovingWallAndRestrictGridVel(geometry, config);
}
END_SU2_OMP_PARALLEL

Expand Down Expand Up @@ -649,8 +666,7 @@ void CMeshSolver::ComputeGridVelocity(CGeometry **geometry, const CConfig *confi
}
END_SU2_OMP_FOR

for (auto iMGlevel = 1u; iMGlevel <= config->GetnMGLevels(); iMGlevel++)
geometry[iMGlevel]->SetRestricted_GridVelocity(geometry[iMGlevel-1]);
ApplyMovingWallAndRestrictGridVel(geometry, config);

}

Expand Down
64 changes: 64 additions & 0 deletions UnitTests/Common/geometry/CGeometry_test.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -263,3 +263,67 @@ TEST_CASE("Wall-normal edge spacing", "[Geometry]") {
CHECK(GeometryToolbox::WallNormalEdgeLength(2, origin, skewEdge, normal) == Approx(0.5));
CHECK(GeometryToolbox::WallNormalEdgeLength(3, skewEdge, origin, normal) == Approx(0.5));
}

TEST_CASE("Moving wall and deforming surface grid velocities", "[Geometry]") {
UnitQuadTestCase test;
test.SetOption("KIND_VERIFICATION_SOLUTION= NO_VERIFICATION_SOLUTION");
test.SetOption("MESH_FORMAT= RECTANGLE");
test.SetOption("MARKER_HEATFLUX= (y_minus, 0.0, y_plus, 0.0)");
test.SetOption("MARKER_CUSTOM= (x_minus, x_plus)");
test.AddOption("REF_DIMENSIONALIZATION= DIMENSIONAL");
test.AddOption("TIME_DOMAIN= YES");
test.AddOption("TIME_MARCHING= DUAL_TIME_STEPPING-1ST_ORDER");
test.AddOption("TIME_STEP= 0.5");
test.AddOption("TIME_ITER= 2");
test.AddOption("SURFACE_MOVEMENT= MOVING_WALL DEFORMING");
test.AddOption("MARKER_MOVING= (y_plus, y_minus)");
test.AddOption("SURFACE_TRANSLATION_RATE= 10.0 0.0 0.0 0.0 2.0 0.0");
test.InitConfig();
test.InitGeometry();
test.InitSolver();

auto* geom = test.geometry.get();
const auto* cfg = test.config.get();
geom->SetWallVelocity(cfg, false);

auto findMarker = [&](const std::string& tag) {
for (auto m = 0u; m < cfg->GetnMarker_All(); ++m) {
if (cfg->GetMarker_All_TagBound(m) == tag) return m;
}
return static_cast<unsigned int>(cfg->GetnMarker_All());
};
const auto upper = findMarker("y_plus");
const auto lower = findMarker("y_minus");
REQUIRE(upper < cfg->GetnMarker_All());
REQUIRE(lower < cfg->GetnMarker_All());

const su2double expectedVel = 10.0 / cfg->GetVelocity_Ref();
for (auto v = 0ul; v < geom->nVertex[upper]; ++v) {
const auto pt = geom->vertex[upper][v]->GetNode();
CHECK(geom->nodes->GetGridVel(pt)[0] == Approx(expectedVel));
CHECK(geom->nodes->GetGridVel(pt)[1] == Approx(0.0).margin(1e-12));
}
for (auto v = 0ul; v < geom->nVertex[lower]; ++v) {
const auto pt = geom->vertex[lower][v]->GetNode();
CHECK(geom->nodes->GetGridVel(pt)[0] == Approx(0.0).margin(1e-12));
CHECK(geom->nodes->GetGridVel(pt)[1] == Approx(0.0).margin(1e-12));
}

geom->nodes->SetCoord_n();
for (auto v = 0ul; v < geom->nVertex[lower]; ++v) {
const auto pt = geom->vertex[lower][v]->GetNode();
geom->nodes->SetCoord(pt, 1, geom->nodes->GetCoord(pt, 1) + 1.0);
}
geom->SetGridVelocity(cfg);

for (auto v = 0ul; v < geom->nVertex[upper]; ++v) {
const auto pt = geom->vertex[upper][v]->GetNode();
CHECK(geom->nodes->GetGridVel(pt)[0] == Approx(expectedVel));
CHECK(geom->nodes->GetGridVel(pt)[1] == Approx(0.0).margin(1e-12));
}
for (auto v = 0ul; v < geom->nVertex[lower]; ++v) {
const auto pt = geom->vertex[lower][v]->GetNode();
CHECK(geom->nodes->GetGridVel(pt)[1] == Approx(2.0));
}
delete test.solver[MESH_SOL];
}
68 changes: 68 additions & 0 deletions UnitTests/SU2_CFD/solvers/moving_wall_tests.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,8 @@
#include <memory>
#include "../../UnitQuadTestCase.hpp"
#include "../../../SU2_CFD/include/numerics/flow/convection/hllc.hpp"
#include "../../../SU2_CFD/include/numerics/elasticity/CFEALinearElasticity.hpp"
#include "../../../SU2_CFD/include/solvers/CMeshSolver.hpp"
#include "../../../SU2_CFD/include/fluid/CPengRobinson.hpp"

TEST_CASE("Compressible wall projection commutes with a Galilean boost", "[HLLC-wall]") {
Expand Down Expand Up @@ -180,3 +182,69 @@ TEST_CASE("Compressible wall projection commutes with a Galilean boost", "[HLLC-
}
}
}

TEST_CASE("Moving wall velocity is preserved during mesh deformation", "[MovingWall]") {
UnitQuadTestCase test;
test.SetOption("KIND_VERIFICATION_SOLUTION= NO_VERIFICATION_SOLUTION");
test.SetOption("MESH_FORMAT= RECTANGLE");
test.SetOption("MARKER_HEATFLUX= (y_minus, 0.0, y_plus, 0.0)");
test.SetOption("MARKER_CUSTOM= (x_minus, x_plus)");
test.AddOption("REF_DIMENSIONALIZATION= DIMENSIONAL");
test.AddOption("TIME_DOMAIN= YES");
test.AddOption("TIME_MARCHING= DUAL_TIME_STEPPING-1ST_ORDER");
test.AddOption("TIME_STEP= 0.5");
test.AddOption("TIME_ITER= 2");
test.AddOption("SURFACE_MOVEMENT= MOVING_WALL DEFORMING");
test.AddOption("MARKER_MOVING= (y_plus, y_minus)");
test.AddOption("SURFACE_TRANSLATION_RATE= 10.0 0.0 0.0 0.0 0.2 0.0");
test.AddOption("DEFORM_STIFFNESS_TYPE= WALL_DISTANCE");
test.InitConfig();
test.InitGeometry();
test.InitSolver();

auto* geom = test.geometry.get();
auto* cfg = test.config.get();
auto* meshSolver = static_cast<CMeshSolver*>(test.solver[MESH_SOL]);
REQUIRE(meshSolver != nullptr);

std::unique_ptr<CNumerics> meshElast(
new CFEAMeshElasticity(geom->GetnDim(), geom->GetnDim(), geom->GetnElem(), cfg));
std::vector<CNumerics*> meshNum(omp_get_max_threads(), meshElast.get());
CGeometry* meshes[] = {geom};

geom->SetWallVelocity(cfg, false);
cfg->SetTimeIter(1);
meshSolver->GetNodes()->Set_Solution_time_n();
meshSolver->SetMesh_Stiffness(meshNum.data(), cfg);
meshSolver->DeformMesh(meshes, meshNum.data(), cfg);

auto findMarker = [&](const std::string& tag) {
for (auto m = 0u; m < cfg->GetnMarker_All(); ++m) {
if (cfg->GetMarker_All_TagBound(m) == tag) return m;
}
return static_cast<unsigned int>(cfg->GetnMarker_All());
};
const auto upper = findMarker("y_plus");
const auto lower = findMarker("y_minus");
REQUIRE(upper < cfg->GetnMarker_All());
REQUIRE(lower < cfg->GetnMarker_All());

const su2double expectedUpperVel = 10.0 / cfg->GetVelocity_Ref();
const su2double expectedLowerVel = 0.2 / cfg->GetVelocity_Ref();
for (auto v = 0ul; v < geom->nVertex[upper]; ++v) {
const auto pt = geom->vertex[upper][v]->GetNode();
CHECK(geom->nodes->GetGridVel(pt)[0] == Approx(expectedUpperVel));
CHECK(geom->nodes->GetGridVel(pt)[1] == Approx(0.0).margin(1e-12));
}
auto interiorLowerCount = 0u;
for (auto v = 0ul; v < geom->nVertex[lower]; ++v) {
const auto pt = geom->vertex[lower][v]->GetNode();
const auto x = geom->nodes->GetCoord(pt)[0];
if (x > 0.0 && x < 1.0) {
++interiorLowerCount;
CHECK(geom->nodes->GetGridVel(pt)[1] == Approx(expectedLowerVel).margin(1e-8));
}
}
REQUIRE(interiorLowerCount > 0);
delete meshSolver;
}