Skip to content

Damping refactor and enhancement - #2008

Draft
mbkuhn wants to merge 32 commits into
kynema:mainfrom
mbkuhn:damping_refactor
Draft

Damping refactor and enhancement#2008
mbkuhn wants to merge 32 commits into
kynema:mainfrom
mbkuhn:damping_refactor

Conversation

@mbkuhn

@mbkuhn mbkuhn commented Jul 23, 2026

Copy link
Copy Markdown
Contributor

Summary

The near-boundary damping implementation in TerrainDrag + DragForcing is awkward and did not align well with the other kinds of damping in the code (e.g., RayleighDamping, TemperatureFreeAtmosphereForcing). This PR provides a better, more generalized approach to damping fields in a simulation. The damping coefficient is set up through the Physics class Damping Layer, and the damping is applied through a source term DampingLayerSource. There is a unified set of inputs, and any field (that has a governing equation) can be damped in a region adjacent to any boundary, with each boundary allowed to have a different target of the damping. There are several options for the setup of the damping coefficient field and for the damping target.

Pull request type

Please check the type of change introduced:

  • Bugfix
  • Feature
  • Code style update (formatting, renaming)
  • Refactoring (no functional changes, no api changes)
  • Build related changes
  • Documentation content changes
  • Other (please describe):

Checklist

The following is included:

  • new unit-test(s)
  • new regression test(s)
  • documentation for new capability

This PR was tested by running:

  • the unit tests
    • on GPU
    • on CPU
  • the regression tests
    • on GPU
    • on CPU

Additional background

Issue Number:

Comment thread src/equation_systems/source_terms/DampingLayerSource.H Fixed
@mbkuhn mbkuhn changed the title Damping refactor Damping refactor and enhancement Aug 10, 2026
Comment thread test/test_files/abl_damping_layer_source/abl_damping_layer_source.inp Outdated
@mbkuhn

mbkuhn commented Aug 13, 2026

Copy link
Copy Markdown
Contributor Author

@rthedin @mchurchf I incorporated two things from our discussion: the specification of the vertical dimensions of the damping zone and the format for specifying which components get damped. I think the other parts of our discussion are best saved for other PRs. Should be ready to try out now!

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

This PR introduces a generalized near-boundary damping capability by adding a DampingLayer physics module to generate damping-coefficient fields and a DampingLayerSource source term to relax supported PDE fields toward configurable targets, replacing/avoiding the prior awkward coupling in terrain-drag damping.

Changes:

  • Added DampingLayer physics for constructing per-boundary damping coefficient fields for arbitrary solved fields.
  • Added DampingLayerSource source term supporting constant/profile/function/field targets with optional per-component damping masks.
  • Updated legacy TerrainDrag damping handling and added unit/regression tests plus Sphinx input documentation.

Reviewed changes

Copilot reviewed 22 out of 22 changed files in this pull request and generated 6 comments.

Show a summary per file
File Description
unit_tests/physics/test_damping_layer.cpp Adds unit tests for blending/damping math helpers.
unit_tests/physics/CMakeLists.txt Registers new physics unit test source.
unit_tests/equation_systems/test_damping_layer_source.cpp Adds unit tests for target-type parsing and traits.
unit_tests/equation_systems/CMakeLists.txt Registers new equation-system unit test source.
unit_tests/CMakeLists.txt Adds physics unit-test subdirectory.
test/test_files/abl_damping_layer_source/abl_damping_layer_source.inp Adds regression input covering multiple DampingLayer/Source configurations.
test/CMakeLists.txt Registers new regression test.
src/physics/TerrainDragDamping.H Extracts legacy terrain damping computation into a reusable helper.
src/physics/TerrainDrag.H Makes terrain damping field optional (pointer) for legacy inputs.
src/physics/TerrainDrag.cpp Declares/initializes terrain damping field only when legacy inputs exist; calls extracted helper.
src/physics/DampingLayer.H Declares DampingLayer API and device-side damping/blending math utilities.
src/physics/DampingLayer.cpp Implements parsing and construction of damping coefficient fields.
src/physics/CMakeLists.txt Adds DampingLayer compilation unit to physics library.
src/equation_systems/source_terms/DampingLayerSource.H Introduces generic damping source-term implementation and configuration parsing.
src/equation_systems/source_terms/DampingLayerSource.cpp Explicit template instantiations for supported PDE source types.
src/equation_systems/source_terms/CMakeLists.txt Adds new source-terms compilation unit to the library.
src/equation_systems/CMakeLists.txt Adds top-level source_terms subdirectory to equation-systems build.
docs/sphinx/user/inputs.rst Adds DampingLayer inputs page to user docs toctree.
docs/sphinx/user/inputs_Temperature_Sources.rst Documents how to configure DampingLayerSource for temperature.
docs/sphinx/user/inputs_Momentum_Sources.rst Documents how to configure DampingLayerSource for momentum.
docs/sphinx/user/inputs_incflo.rst Adds DampingLayer to the list of available physics modules.
docs/sphinx/user/inputs_DampingLayer.rst Adds full documentation for DampingLayer and DampingLayerSource parameters.

💡 Add a code-review agent skill or configure MCP servers for context-aware, tailored reviews. Learn more in the docs.

Comment on lines +244 to +256
const amrex::Real distance_from_zhi =
prob_hi[2] - z;
const amrex::Real vertical_thickness =
prob_hi[2] - min_height;
const amrex::Real vertical_blending_fraction =
vertical_blending_thickness / distance_from_zhi;
const amrex::Real vertical_damping_coeff =
damping_calc(
distance_from_zhi, vertical_thickness,
vertical_blending_fraction,
vertical_blending_function_type);
damping_coeff =
std::min(damping_coeff, vertical_damping_coeff);
Comment on lines +19 to +20
AMREX_GPU_HOST_DEVICE AMREX_FORCE_INLINE BlendingFunctionType
string_to_blending_function_type(const std::string& op_str)
Comment on lines +67 to +79
const amrex::Real length_full_damp =
layer_thickness * (1.0_rt - blending_fraction);
const amrex::Real blend_position_nondim =
(distance_from_boundary - length_full_damp) /
(layer_thickness * blending_fraction);
if (blend_position_nondim <= 0.0_rt) {
return 1.0_rt;
}
if (blend_position_nondim <= 1.0_rt) {
return blending_function(blend_position_nondim, function_type);
}
return 0.0_rt;
}
Comment on lines +27 to +28
AMREX_GPU_HOST_DEVICE AMREX_FORCE_INLINE TargetType
string_to_target_type(const std::string& target_type_str)
Comment on lines +202 to +203

if (target_type == TargetType::Constant) {
problo[1] + ((j + 0.5_rt) * dx[1]);
const amrex::Real z =
problo[2] + ((k + 0.5_rt) * dx[2]);

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants