Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Forest Canopy Model #1324

Open
wants to merge 43 commits into
base: main
Choose a base branch
from
Open

Forest Canopy Model #1324

wants to merge 43 commits into from

Conversation

hgopalan
Copy link
Contributor

@hgopalan hgopalan commented Nov 3, 2024

This PR provides a forest canopy model in AMR-Wind. Two kinds of forests are supported: (i) homogeneous forest and (ii) heterogeneous forest using an empirical model for leaf area density.

Forest overlap is allowed and is not checked. It is expected that the users provide accurate inputs and currently no checking is included. The model requires following inputs from the user: (i) tree type (ii) tree center x (iii) tree center y (iv) tree height (v) tree girth preferably at the widest point (vi) tree drag coefficient (vii) tree leaf area index (viii) location of maximum leaf area density for heterogeneous forests.

The model will work with any LES model as the drag forcing due to the turbulence is required only in momentum equation. It is also possible to include a turbulence forcing term in one equation kegs model.

The model will be extended to the one-equation RANS model in a future PR by including the turbulence contribution.

Please check the type of change introduced:

  • Bugfix
  • [X ] 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)
  • [X ] 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
    • [X ] on CPU

Issue Number: #1322

@hgopalan hgopalan added the enhancement New feature or request label Nov 3, 2024
@hgopalan hgopalan linked an issue Nov 3, 2024 that may be closed by this pull request
@hgopalan hgopalan marked this pull request as ready for review November 3, 2024 21:24
@hgopalan
Copy link
Contributor Author

hgopalan commented Nov 4, 2024

Sample result. Top is a heterogeneous tree model while other three are homogeneous.
forest_drag


namespace amr_wind::pde::icns {

/** Adds the forcing term to include the presence of immersed boundary
Copy link
Contributor

Choose a reason for hiding this comment

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

out of date comment

amr-wind/physics/ForestDrag.H Outdated Show resolved Hide resolved
amr-wind/physics/ForestDrag.H Outdated Show resolved Hide resolved
amr-wind/physics/ForestDrag.H Outdated Show resolved Hide resolved
amr-wind/physics/ForestDrag.H Outdated Show resolved Hide resolved
amr-wind/physics/ForestDrag.cpp Outdated Show resolved Hide resolved
amr-wind/physics/ForestDrag.cpp Outdated Show resolved Hide resolved
amr-wind/physics/ForestDrag.cpp Outdated Show resolved Hide resolved
@hgopalan hgopalan changed the base branch from forest_drag to main November 4, 2024 21:05
@marchdf
Copy link
Contributor

marchdf commented Nov 20, 2024

@hgopalan sorry this slipped off my radar. Can you remind me where we are at?

@hgopalan
Copy link
Contributor Author

@hgopalan sorry this slipped off my radar. Can you remind me where we are at?

You wanted to discuss with me about the multiple for loops and may be come up with a better way to do it. Rest of issues are sorted.

@marchdf
Copy link
Contributor

marchdf commented Nov 22, 2024

After chatting with @hgopalan: he will remove the n_cells x n_forest loop with a bounding box for the forest.

The other thing I would recommend is to create a Forest struct that contains all the data for a forest and that can be stored in a vector (device or host). That will simplify the code quite a bit.

struct Forest{
real rad
int type
Box bounding_box
etc
}

// later:
amrex::Vector<Forest> m_forests;

// read the data from file
loop on file lines{
  Forest f;
  f.rad.= value_from_file
  f.type = value_from_file
  f.bouding_box = bx
  forests.push_back(f)
}

// and then a single copy to device
amrex::DeviceVector<Forest> m_d_forests
DeviceCopy blah

@hgopalan
Copy link
Contributor Author

hgopalan commented Nov 23, 2024

Code has been updated with rearrangement. @marchdf I have not added bounding box since I wanted a circular search. Will it be possible to define a cylinder for contains?

@marchdf
Copy link
Contributor

marchdf commented Nov 25, 2024

Just make a bounding box wherein the cylinder fits. It's fine if the bounding box technically has more volume than the cylinder it contains.

amr-wind/physics/ForestDrag.H Outdated Show resolved Hide resolved
amr-wind/physics/ForestDrag.H Outdated Show resolved Hide resolved
amr-wind/physics/ForestDrag.cpp Show resolved Hide resolved
amr-wind/physics/ForestDrag.cpp Outdated Show resolved Hide resolved
amr-wind/physics/ForestDrag.cpp Outdated Show resolved Hide resolved
amr-wind/physics/ForestDrag.cpp Outdated Show resolved Hide resolved
amr-wind/physics/ForestDrag.cpp Outdated Show resolved Hide resolved
amr-wind/physics/ForestDrag.cpp Outdated Show resolved Hide resolved
amr-wind/physics/ForestDrag.cpp Outdated Show resolved Hide resolved
@marchdf
Copy link
Contributor

marchdf commented Nov 27, 2024

@hgopalan confirmed I didn't break anything. While I tidy up a couple other things, could you add a unit test, @hgopalan ? Just add something like you did with test_abl_terrain.cpp. Maybe instead of point probes, just do a field norm on the drag and blank fields?

@marchdf marchdf mentioned this pull request Nov 27, 2024
14 tasks
@marchdf
Copy link
Contributor

marchdf commented Nov 27, 2024

Ok I am done with all my changes. There's a last bit that's bothering me (the if condtion on the type in the lm and area_fraction member functions). But I need to move on to other things.

Tagging some others (@moprak-nrel and @mbkuhn) on the PR review since I am now a major author ;)

Tests pass on CPU and GPU.

@marchdf marchdf enabled auto-merge (squash) November 27, 2024 20:36
Copy link
Contributor

@marchdf marchdf left a comment

Choose a reason for hiding this comment

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

Blocking with a change request until others have been able to look.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Forest Canopy Model
3 participants