Skip to content

Commit

Permalink
Generalize terrain initialization so we can read from a file or use a…
Browse files Browse the repository at this point in the history
…nalytical function for any of the terrain types
  • Loading branch information
asalmgren committed Jan 9, 2025
1 parent 0690d5c commit 644e284
Show file tree
Hide file tree
Showing 36 changed files with 1,742 additions and 2,004 deletions.
1 change: 0 additions & 1 deletion CMake/BuildERFExe.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -162,7 +162,6 @@ function(build_erf_lib erf_lib_name)
${SRC_DIR}/SourceTerms/ERF_MoistSetRhs.cpp
${SRC_DIR}/SourceTerms/ERF_NumericalDiffusion.cpp
${SRC_DIR}/SourceTerms/ERF_ForestDrag.cpp
${SRC_DIR}/SourceTerms/ERF_TerrainDrag.cpp
${SRC_DIR}/TimeIntegration/ERF_ComputeTimestep.cpp
${SRC_DIR}/TimeIntegration/ERF_Advance.cpp
${SRC_DIR}/TimeIntegration/ERF_TimeStep.cpp
Expand Down
2 changes: 1 addition & 1 deletion CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -245,7 +245,7 @@ target_link_libraries(erf_api PUBLIC erf_srclib)
add_library(${PROJECT_NAME}::erf_api ALIAS erf_srclib)

# Collect all headers and make them installable with the target
set(ERF_INCLUDES "Source/ERF.H;Source/ERF_Constants.H;Source/WindFarmParametrization/SimpleActuatorDisk/ERF_SimpleAD.H;Source/WindFarmParametrization/EWP/ERF_EWP.H;Source/WindFarmParametrization/Null/ERF_NullWindFarm.H;Source/WindFarmParametrization/ERF_WindFarm.H;Source/WindFarmParametrization/Fitch/ERF_Fitch.H;Source/BoundaryConditions/ERF_PhysBCFunct.H;Source/BoundaryConditions/ERF_MOSTAverage.H;Source/BoundaryConditions/ERF_MOSTRoughness.H;Source/BoundaryConditions/ERF_ABLMost.H;Source/BoundaryConditions/ERF_FillPatcher.H;Source/BoundaryConditions/ERF_MOSTStress.H;Source/BoundaryConditions/ERF_TimeInterpolatedData.H;Source/Utils/ERF_Interpolation.H;Source/Utils/ERF_TileNoZ.H;Source/Utils/ERF_PlaneAverage.H;Source/Utils/ERF_Interpolation_WENO.H;Source/Utils/ERF_DirectionSelector.H;Source/Utils/ERF_ParFunctions.H;Source/Utils/ERF_Wstar.H;Source/Utils/ERF_MicrophysicsUtils.H;Source/Utils/ERF_SatMethods.H;Source/Utils/ERF_Interpolation_1D.H;Source/Utils/ERF_Interpolation_UPW.H;Source/Utils/ERF_TerrainMetrics.H;Source/Utils/ERF_Interpolation_WENO_Z.H;Source/Utils/ERF_Thetav.H;Source/Utils/ERF_WaterVaporSaturation.H;Source/Utils/ERF_Utils.H;Source/Utils/ERF_Orbit.H;Source/Utils/ERF_EOS.H;Source/Utils/ERF_HSEUtils.H;Source/EB/ERF_TerrainIF.H;Source/EB/ERF_EBIF.H;Source/Particles/ERFPC.H;Source/Particles/ERF_ParticleData.H;Source/Prob/ERF_InitDensityHSEDry.H;Source/Prob/ERF_InitRayleighDamping.H;Source/Prob/ERF_InitConstantDensityHSE.H;Source/ERF_ProbCommon.H;Source/ERF_Derive.H;Source/Radiation/ERF_Mam4Constituents.H;Source/Radiation/ERF_Mam4Aero.H;Source/Radiation/ERF_Optics.H;Source/Radiation/ERF_ModalAeroWaterUptake.H;Source/Radiation/ERF_CloudRadProps.H;Source/Radiation/ERF_PhysProp.H;Source/Radiation/ERF_Radiation.H;Source/Radiation/ERF_Albedo.H;Source/Radiation/ERF_Parameterizations.H;Source/Radiation/ERF_RadConstants.H;Source/Radiation/ERF_AeroRadProps.H;Source/Radiation/ERF_M2005EffRadius.H;Source/Radiation/ERF_LinearInterpolate.H;Source/Radiation/ERF_Slingo.H;Source/Radiation/ERF_RRTMGP.H;Source/Radiation/ERF_EbertCurry.H;Source/SourceTerms/ERF_NumericalDiffusion.H;Source/SourceTerms/ERF_SrcHeaders.H;Source/SourceTerms/ERF_ForestDrag.H;Source/SourceTerms/ERF_TerrainDrag.H;Source/IO/ERF_SampleData.H;Source/IO/ERF_NCInterface.H;Source/IO/ERF_NCWpsFile.H;Source/IO/ERF_NCPlotFile.H;Source/IO/ERF_ReadBndryPlanes.H;Source/IO/ERF_WriteBndryPlanes.H;Source/PBL/ERF_MYNNStruct.H;Source/PBL/ERF_PBLModels.H;Source/PBL/ERF_PBLHeight.H;Source/TimeIntegration/ERF_TI_substep_fun.H;Source/TimeIntegration/ERF_TI_slow_headers.H;Source/TimeIntegration/ERF_TI_slow_rhs_fun.H;Source/TimeIntegration/ERF_TI_fast_headers.H;Source/TimeIntegration/ERF_TI_utils.H;Source/TimeIntegration/ERF_MRI.H;Source/TimeIntegration/ERF_TI_no_substep_fun.H;Source/LandSurfaceModel/Null/ERF_NullSurf.H;Source/LandSurfaceModel/ERF_LandSurface.H;Source/LandSurfaceModel/MM5/ERF_MM5.H;Source/LandSurfaceModel/SLM/ERF_SLM.H;Source/ERF_IndexDefines.H;Source/Advection/ERF_AdvectionSrcForMom_N.H;Source/Advection/ERF_AdvectionSrcForScalars.H;Source/Advection/ERF_AdvectionSrcForMom_T.H;Source/Advection/ERF_Advection.H;Source/MultiBlock/ERF_MultiBlockContainer.H;Source/Initialization/ERF_MetgridUtils.H;Source/Diffusion/ERF_EddyViscosity.H;Source/Diffusion/ERF_Diffusion.H;Source/Microphysics/Null/ERF_NullMoistLagrangian.H;Source/Microphysics/Null/ERF_NullMoist.H;Source/Microphysics/ERF_Microphysics.H;Source/Microphysics/ERF_LagrangianMicrophysics.H;Source/Microphysics/ERF_EulerianMicrophysics.H;Source/Microphysics/Kessler/ERF_Kessler.H;Source/Microphysics/SAM/ERF_SAM.H;Source/Microphysics/SatAdj/ERF_SatAdj.H;Source/DataStructs/ERF_InputSpongeData.H;Source/DataStructs/ERF_TurbPertStruct.H;Source/DataStructs/ERF_SpongeStruct.H;Source/DataStructs/ERF_AdvStruct.H;Source/DataStructs/ERF_DataStruct.H;Source/DataStructs/ERF_InputSoundingData.H;Source/DataStructs/ERF_DiffStruct.H;Source/DataStructs/ERF_TurbStruct.H;Source/LinearSolvers/ERF_TerrainPoisson.H;Source/LinearSolvers/ERF_FFTUtils.H")
set(ERF_INCLUDES "Source/ERF.H;Source/ERF_Constants.H;Source/WindFarmParametrization/SimpleActuatorDisk/ERF_SimpleAD.H;Source/WindFarmParametrization/EWP/ERF_EWP.H;Source/WindFarmParametrization/Null/ERF_NullWindFarm.H;Source/WindFarmParametrization/ERF_WindFarm.H;Source/WindFarmParametrization/Fitch/ERF_Fitch.H;Source/BoundaryConditions/ERF_PhysBCFunct.H;Source/BoundaryConditions/ERF_MOSTAverage.H;Source/BoundaryConditions/ERF_MOSTRoughness.H;Source/BoundaryConditions/ERF_ABLMost.H;Source/BoundaryConditions/ERF_FillPatcher.H;Source/BoundaryConditions/ERF_MOSTStress.H;Source/BoundaryConditions/ERF_TimeInterpolatedData.H;Source/Utils/ERF_InitTerrain.H;Source/Utils/ERF_Interpolation.H;Source/Utils/ERF_TileNoZ.H;Source/Utils/ERF_PlaneAverage.H;Source/Utils/ERF_Interpolation_WENO.H;Source/Utils/ERF_DirectionSelector.H;Source/Utils/ERF_ParFunctions.H;Source/Utils/ERF_Wstar.H;Source/Utils/ERF_MicrophysicsUtils.H;Source/Utils/ERF_SatMethods.H;Source/Utils/ERF_Interpolation_1D.H;Source/Utils/ERF_Interpolation_UPW.H;Source/Utils/ERF_TerrainMetrics.H;Source/Utils/ERF_Interpolation_WENO_Z.H;Source/Utils/ERF_Thetav.H;Source/Utils/ERF_WaterVaporSaturation.H;Source/Utils/ERF_Utils.H;Source/Utils/ERF_Orbit.H;Source/Utils/ERF_EOS.H;Source/Utils/ERF_HSEUtils.H;Source/EB/ERF_TerrainIF.H;Source/EB/ERF_EBIF.H;Source/Particles/ERFPC.H;Source/Particles/ERF_ParticleData.H;Source/Prob/ERF_InitDensityHSEDry.H;Source/Prob/ERF_InitRayleighDamping.H;Source/Prob/ERF_InitConstantDensityHSE.H;Source/ERF_ProbCommon.H;Source/ERF_Derive.H;Source/Radiation/ERF_Mam4Constituents.H;Source/Radiation/ERF_Mam4Aero.H;Source/Radiation/ERF_Optics.H;Source/Radiation/ERF_ModalAeroWaterUptake.H;Source/Radiation/ERF_CloudRadProps.H;Source/Radiation/ERF_PhysProp.H;Source/Radiation/ERF_Radiation.H;Source/Radiation/ERF_Albedo.H;Source/Radiation/ERF_Parameterizations.H;Source/Radiation/ERF_RadConstants.H;Source/Radiation/ERF_AeroRadProps.H;Source/Radiation/ERF_M2005EffRadius.H;Source/Radiation/ERF_LinearInterpolate.H;Source/Radiation/ERF_Slingo.H;Source/Radiation/ERF_RRTMGP.H;Source/Radiation/ERF_EbertCurry.H;Source/SourceTerms/ERF_NumericalDiffusion.H;Source/SourceTerms/ERF_SrcHeaders.H;Source/SourceTerms/ERF_ForestDrag.H;Source/IO/ERF_SampleData.H;Source/IO/ERF_NCInterface.H;Source/IO/ERF_NCWpsFile.H;Source/IO/ERF_NCPlotFile.H;Source/IO/ERF_ReadBndryPlanes.H;Source/IO/ERF_WriteBndryPlanes.H;Source/PBL/ERF_MYNNStruct.H;Source/PBL/ERF_PBLModels.H;Source/PBL/ERF_PBLHeight.H;Source/TimeIntegration/ERF_TI_substep_fun.H;Source/TimeIntegration/ERF_TI_slow_headers.H;Source/TimeIntegration/ERF_TI_slow_rhs_fun.H;Source/TimeIntegration/ERF_TI_fast_headers.H;Source/TimeIntegration/ERF_TI_utils.H;Source/TimeIntegration/ERF_MRI.H;Source/TimeIntegration/ERF_TI_no_substep_fun.H;Source/LandSurfaceModel/Null/ERF_NullSurf.H;Source/LandSurfaceModel/ERF_LandSurface.H;Source/LandSurfaceModel/MM5/ERF_MM5.H;Source/LandSurfaceModel/SLM/ERF_SLM.H;Source/ERF_IndexDefines.H;Source/Advection/ERF_AdvectionSrcForMom_N.H;Source/Advection/ERF_AdvectionSrcForScalars.H;Source/Advection/ERF_AdvectionSrcForMom_T.H;Source/Advection/ERF_Advection.H;Source/MultiBlock/ERF_MultiBlockContainer.H;Source/Initialization/ERF_MetgridUtils.H;Source/Diffusion/ERF_EddyViscosity.H;Source/Diffusion/ERF_Diffusion.H;Source/Microphysics/Null/ERF_NullMoistLagrangian.H;Source/Microphysics/Null/ERF_NullMoist.H;Source/Microphysics/ERF_Microphysics.H;Source/Microphysics/ERF_LagrangianMicrophysics.H;Source/Microphysics/ERF_EulerianMicrophysics.H;Source/Microphysics/Kessler/ERF_Kessler.H;Source/Microphysics/SAM/ERF_SAM.H;Source/Microphysics/SatAdj/ERF_SatAdj.H;Source/DataStructs/ERF_InputSpongeData.H;Source/DataStructs/ERF_TurbPertStruct.H;Source/DataStructs/ERF_SpongeStruct.H;Source/DataStructs/ERF_AdvStruct.H;Source/DataStructs/ERF_DataStruct.H;Source/DataStructs/ERF_InputSoundingData.H;Source/DataStructs/ERF_DiffStruct.H;Source/DataStructs/ERF_TurbStruct.H;Source/LinearSolvers/ERF_TerrainPoisson.H;Source/LinearSolvers/ERF_FFTUtils.H")
set_target_properties(
erf_srclib PROPERTIES PUBLIC_HEADER "${ERF_INCLUDES}")

Expand Down
8 changes: 3 additions & 5 deletions Exec/ABL/ERF_Prob.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -66,8 +66,6 @@ Problem::init_custom_pert(
{
const bool use_moisture = (sc.moisture_type != MoistureType::None);

const bool use_terrain = SolverChoice::terrain_type != TerrainType::None;

if (parms.KE_decay_height > 0) {
amrex::Print() << "Initial KE profile (order " << parms.KE_decay_order
<< ") will extend up to " << parms.KE_decay_height
Expand Down Expand Up @@ -102,7 +100,7 @@ Problem::init_custom_pert(
const Real* dx = geomdata.CellSize();
const Real x = prob_lo[0] + (i + 0.5) * dx[0];
const Real y = prob_lo[1] + (j + 0.5) * dx[1];
const Real z = use_terrain ? z_cc(i,j,k) : prob_lo[2] + (k + 0.5) * dx[2];
const Real z = (z_cc) ? z_cc(i,j,k) : prob_lo[2] + (k + 0.5) * dx[2];

// Define a point (xc,yc,zc) at the center of the domain
const Real xc = 0.5 * (prob_lo[0] + prob_hi[0]);
Expand Down Expand Up @@ -151,7 +149,7 @@ Problem::init_custom_pert(
const Real* prob_lo = geomdata.ProbLo();
const Real* dx = geomdata.CellSize();
const Real y = prob_lo[1] + (j + 0.5) * dx[1];
const Real z = use_terrain ? 0.25*( z_nd(i,j ,k) + z_nd(i,j ,k+1)
const Real z = (z_nd) ? 0.25*( z_nd(i,j ,k) + z_nd(i,j ,k+1)
+ z_nd(i,j+1,k) + z_nd(i,j+1,k+1) )
: prob_lo[2] + (k + 0.5) * dx[2];

Expand All @@ -177,7 +175,7 @@ Problem::init_custom_pert(
const Real* prob_lo = geomdata.ProbLo();
const Real* dx = geomdata.CellSize();
const Real x = prob_lo[0] + (i + 0.5) * dx[0];
const Real z = use_terrain ? 0.25*( z_nd(i ,j,k) + z_nd(i ,j,k+1)
const Real z = (z_nd) ? 0.25*( z_nd(i ,j,k) + z_nd(i ,j,k+1)
+ z_nd(i+1,j,k) + z_nd(i+1,j,k+1) )
: prob_lo[2] + (k + 0.5) * dx[2];

Expand Down
Loading

0 comments on commit 644e284

Please sign in to comment.