Skip to content

Commit

Permalink
fluids: Use enum for mesh transformation flag
Browse files Browse the repository at this point in the history
  • Loading branch information
jrwrigh committed Aug 21, 2023
1 parent f8839eb commit 2526956
Show file tree
Hide file tree
Showing 9 changed files with 37 additions and 21 deletions.
4 changes: 4 additions & 0 deletions examples/fluids/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -160,6 +160,10 @@ The following options are common among all problem types:
- Viewer for the force on each no-slip wall, e.g., `ascii:force.csv:ascii_csv` to write a CSV file.
-

* - `-mesh_transform`
- Transform the mesh, usually for an initial box mesh.
- `none`

* - `-snes_view`
- View PETSc `SNES` nonlinear solver configuration
-
Expand Down
2 changes: 1 addition & 1 deletion examples/fluids/blasius.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ checkpoint_interval: 10
## Linear Settings:
degree: 1
dm_plex_box_faces: 40,60,1
platemesh_modify_mesh: true
mesh_transform: platemesh
platemesh_nDelta: 45

# # Quadratic Settings:
Expand Down
2 changes: 1 addition & 1 deletion examples/fluids/index.md
Original file line number Diff line number Diff line change
Expand Up @@ -813,7 +813,7 @@ flow state. $P_\mathrm{ref}$ is defined via the `-reference_pressure` flag.
### Meshing

The flat plate boundary layer example has custom meshing features to better resolve the flow when using a generated box mesh.
These meshing features modify the nodal layout of the default, equispaced box mesh and are enabled via `-platemesh_modify_mesh true`.
These meshing features modify the nodal layout of the default, equispaced box mesh and are enabled via `-mesh_transform platemesh`.
One of those is tilting the top of the domain, allowing for it to be a outflow boundary condition.
The angle of this tilt is controlled by `-platemesh_top_angle`.

Expand Down
12 changes: 10 additions & 2 deletions examples/fluids/navierstokes.h
Original file line number Diff line number Diff line change
Expand Up @@ -87,13 +87,20 @@ typedef enum {
} TestType;
static const char *const TestTypes[] = {"none", "solver", "turb_spanstats", "diff_filter", "TestType", "TESTTYPE_", NULL};

// Test mode type
// Subgrid-Stress mode type
typedef enum {
SGS_MODEL_NONE = 0,
SGS_MODEL_DATA_DRIVEN = 1,
} SGSModelType;
static const char *const SGSModelTypes[] = {"none", "data_driven", "SGSModelType", "SGS_MODEL_", NULL};

// Mesh transformation type
typedef enum {
MESH_TRANSFORM_NONE = 0,
MESH_TRANSFORM_PLATEMESH = 1,
} MeshTransformType;
static const char *const MeshTransformTypes[] = {"none", "platemesh", "MeshTransformType", "MESH_TRANSFORM_", NULL};

static const char *const DifferentialFilterDampingFunctions[] = {
"none", "van_driest", "mms", "DifferentialFilterDampingFunction", "DIFF_FILTER_DAMP_", NULL};

Expand Down Expand Up @@ -160,7 +167,8 @@ struct AppCtx_private {
// Subgrid Stress Model
SGSModelType sgs_model_type;
// Differential Filtering
PetscBool diff_filter_monitor;
PetscBool diff_filter_monitor;
MeshTransformType mesh_transform_type;
};

// libCEED data struct
Expand Down
27 changes: 13 additions & 14 deletions examples/fluids/problems/blasius.c
Original file line number Diff line number Diff line change
Expand Up @@ -255,7 +255,6 @@ PetscErrorCode NS_BLASIUS(ProblemData *problem, DM dm, void *ctx, SimpleBC bc) {
CeedScalar P0 = 1.01e5; // Pa
PetscInt N = 20; // Number of Chebyshev terms
PetscBool weakT = PETSC_FALSE; // weak density or temperature
PetscBool use_mesh_modification = PETSC_FALSE; // Whether to modify the mesh at all
PetscReal mesh_refine_height = 5.9e-4; // m
PetscReal mesh_growth = 1.08; // [-]
PetscInt mesh_Ndelta = 45; // [-]
Expand All @@ -272,18 +271,18 @@ PetscErrorCode NS_BLASIUS(ProblemData *problem, DM dm, void *ctx, SimpleBC bc) {
PetscCall(PetscOptionsInt("-n_chebyshev", "Number of Chebyshev terms", NULL, N, &N, NULL));
PetscCheck(3 <= N && N <= BLASIUS_MAX_N_CHEBYSHEV, comm, PETSC_ERR_ARG_OUTOFRANGE, "-n_chebyshev %" PetscInt_FMT " must be in range [3, %d]", N,
BLASIUS_MAX_N_CHEBYSHEV);
PetscCall(PetscOptionsBool("-platemesh_modify_mesh", "Whether to modify the mesh based on settings (for box meshes only)", NULL,
use_mesh_modification, &use_mesh_modification, NULL));
PetscCall(PetscOptionsBoundedInt("-platemesh_Ndelta", "Velocity at boundary layer edge", NULL, mesh_Ndelta, &mesh_Ndelta, NULL, 1));
PetscCall(PetscOptionsScalar("-platemesh_refine_height", "Height of boundary layer mesh refinement", NULL, mesh_refine_height, &mesh_refine_height,
NULL));
PetscCall(PetscOptionsScalar("-platemesh_growth", "Geometric growth rate of boundary layer mesh", NULL, mesh_growth, &mesh_growth, NULL));
PetscCall(
PetscOptionsScalar("-platemesh_top_angle", "Geometric top_angle rate of boundary layer mesh", NULL, mesh_top_angle, &mesh_top_angle, NULL));
PetscCall(PetscOptionsString("-platemesh_y_node_locs_path",
"Path to file with y node locations. "
"If empty, will use the algorithmic mesh warping.",
NULL, mesh_ynodes_path, mesh_ynodes_path, sizeof(mesh_ynodes_path), NULL));
if (user->app_ctx->mesh_transform_type == MESH_TRANSFORM_PLATEMESH) {
PetscCall(PetscOptionsBoundedInt("-platemesh_Ndelta", "Velocity at boundary layer edge", NULL, mesh_Ndelta, &mesh_Ndelta, NULL, 1));
PetscCall(PetscOptionsScalar("-platemesh_refine_height", "Height of boundary layer mesh refinement", NULL, mesh_refine_height,
&mesh_refine_height, NULL));
PetscCall(PetscOptionsScalar("-platemesh_growth", "Geometric growth rate of boundary layer mesh", NULL, mesh_growth, &mesh_growth, NULL));
PetscCall(
PetscOptionsScalar("-platemesh_top_angle", "Geometric top_angle rate of boundary layer mesh", NULL, mesh_top_angle, &mesh_top_angle, NULL));
PetscCall(PetscOptionsString("-platemesh_y_node_locs_path",
"Path to file with y node locations. "
"If empty, will use the algorithmic mesh warping.",
NULL, mesh_ynodes_path, mesh_ynodes_path, sizeof(mesh_ynodes_path), NULL));
}
PetscCall(PetscOptionsBool("-stg_use", "Use STG inflow boundary condition", NULL, use_stg, &use_stg, NULL));
PetscOptionsEnd();

Expand All @@ -298,7 +297,7 @@ PetscErrorCode NS_BLASIUS(ProblemData *problem, DM dm, void *ctx, SimpleBC bc) {
U_inf *= meter / second;
delta0 *= meter;

if (use_mesh_modification) {
if (user->app_ctx->mesh_transform_type == MESH_TRANSFORM_PLATEMESH) {
PetscReal *mesh_ynodes = NULL;
PetscInt mesh_nynodes = 0;
if (strcmp(mesh_ynodes_path, "")) PetscCall(GetYNodeLocs(comm, mesh_ynodes_path, &mesh_ynodes, &mesh_nynodes));
Expand Down
5 changes: 5 additions & 0 deletions examples/fluids/src/cloptions.c
Original file line number Diff line number Diff line change
Expand Up @@ -186,6 +186,11 @@ PetscErrorCode ProcessCommandLineOptions(MPI_Comm comm, AppCtx app_ctx, SimpleBC
PetscCall(PetscOptionsBool("-diff_filter_monitor", "Enable differential filtering TSMonitor", NULL, app_ctx->diff_filter_monitor,
&app_ctx->diff_filter_monitor, NULL));

// Mesh Transformation Options
app_ctx->mesh_transform_type = MESH_TRANSFORM_NONE;
PetscCall(PetscOptionsEnum("-mesh_transform", "Mesh transform to perform", NULL, MeshTransformTypes, (PetscEnum)app_ctx->mesh_transform_type,
(PetscEnum *)&app_ctx->mesh_transform_type, NULL));

PetscOptionsEnd();

PetscFunctionReturn(PETSC_SUCCESS);
Expand Down
2 changes: 1 addition & 1 deletion examples/fluids/tests-output/blasius_stgtest.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -8,8 +8,8 @@ ts:
max_steps: 5

dm_plex_box_faces: 3,20,1
mesh_transform: platemesh
platemesh:
modify_mesh: true
Ndelta: 15
growth: 1.3

Expand Down
2 changes: 1 addition & 1 deletion examples/fluids/tests-output/blasius_test.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -8,8 +8,8 @@ ts:
max_steps: 5

dm_plex_box_faces: 3,20,1
mesh_transform: platemesh
platemesh:
modify_mesh: true
Ndelta: 10
growth: 1.2

Expand Down
2 changes: 1 addition & 1 deletion examples/fluids/tests-output/stats_test.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -8,8 +8,8 @@ ts:
max_steps: 10

dm_plex_box_faces: 3,20,2
mesh_transform: platemesh
platemesh:
modify_mesh: true
Ndelta: 15
growth: 1.3

Expand Down

0 comments on commit 2526956

Please sign in to comment.