-
Notifications
You must be signed in to change notification settings - Fork 1
feat: Add energy equation solver with Boussinesq buoyancy coupling #176
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
Merged
Merged
Changes from all commits
Commits
Show all changes
20 commits
Select commit
Hold shift + click to select a range
6b71dc1
feat: Add energy equation solver with Boussinesq buoyancy coupling
shaia 6829103
Remove dead t_new allocation from explicit Euler solver
shaia 603d014
Pass physical time to heat_source_func in energy solver
shaia b1f51a1
Populate max_temperature in solver stats after each step
shaia 7cc828a
Add test for heat_source_func in energy solver
shaia c346a95
Use plain max T (not fabs) and merge into OMP-parallel loop
shaia 4e2b6c4
Replace magic number 81 with named constants in energy disabled test
shaia 2d36f77
Guard OMP/AVX2 backends against unsupported energy params
shaia d29f06f
Validate uniform dz spacing in energy solver for 3D grids
shaia 3e46474
Use cfd_set_error instead of fprintf for NaN detection in energy solver
shaia 7309a50
Guard GPU backends against unsupported energy equation params
shaia 4da24f4
Init max_t from field->T[0] in AVX2 rk2 stats reduction
shaia 872590e
Reuse T_new workspace across energy solver calls
shaia 49fff5f
Fix OOB read in energy solver dz validation loop
shaia c6de2a5
Preserve thermal BCs across apply_boundary_conditions calls
shaia 80a7726
Fix Boussinesq doc: acceleration not force (no rho_0 factor)
shaia 84e7cf4
Allocate T workspace for buoyancy-only coupling (beta!=0, alpha==0)
shaia 3ad6aa5
Add input validation to energy_step_explicit_with_workspace
shaia 6e86c77
Validate uniform dx/dy and use precomputed inverse spacing constants
shaia bac421a
Fix TSan SEGV: match Poisson BC backend to solver backend
shaia File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,68 @@ | ||
| /** | ||
| * @file energy_solver.h | ||
| * @brief Energy equation solver for temperature advection-diffusion | ||
| * | ||
| * Solves the energy equation for incompressible flow: | ||
| * dT/dt + u*nabla(T) = alpha * nabla^2(T) + Q | ||
| * | ||
| * where alpha = k/(rho*cp) is thermal diffusivity and Q is a heat source. | ||
| * | ||
| * Boussinesq buoyancy coupling adds a buoyancy acceleration to the momentum equations: | ||
| * a_buoy = -beta * (T - T_ref) * g | ||
| * | ||
| * The energy equation is solved as a post-step after velocity advancement, | ||
| * using the updated velocity field for advection. | ||
| */ | ||
|
|
||
| #ifndef CFD_ENERGY_SOLVER_H | ||
| #define CFD_ENERGY_SOLVER_H | ||
|
|
||
| #include "cfd/cfd_export.h" | ||
| #include "cfd/core/cfd_status.h" | ||
| #include "cfd/core/grid.h" | ||
| #include "cfd/solvers/navier_stokes_solver.h" | ||
|
|
||
| #ifdef __cplusplus | ||
| extern "C" { | ||
| #endif | ||
|
|
||
| /** | ||
| * Advance the temperature field by one explicit Euler step. | ||
| * | ||
| * Computes: T^{n+1} = T^n + dt * (-u*nabla(T) + alpha*nabla^2(T) + Q) | ||
| * | ||
| * Only active when params->alpha > 0. Returns immediately otherwise. | ||
| * | ||
| * @param field Flow field (T is updated in-place, u/v/w are read-only) | ||
| * @param grid Computational grid | ||
| * @param params Solver parameters (alpha, heat_source_func, dt) | ||
| * @param dt Time step size | ||
| * @param time Current physical time (passed to heat_source_func) | ||
| * @return CFD_SUCCESS, or CFD_ERROR_DIVERGED if NaN detected in T | ||
| */ | ||
| CFD_LIBRARY_EXPORT cfd_status_t energy_step_explicit(flow_field* field, const grid* grid, | ||
| const ns_solver_params_t* params, | ||
| double dt, double time); | ||
|
|
||
| /** | ||
| * Compute Boussinesq buoyancy source terms from the temperature field. | ||
| * | ||
| * Adds buoyancy force: source_{u,v,w} += -beta * (T[idx] - T_ref) * g_{x,y,z} | ||
| * | ||
| * Only active when params->beta != 0. Does nothing otherwise. | ||
| * | ||
| * @param T_local Temperature at the current grid point | ||
| * @param params Solver parameters (beta, T_ref, gravity) | ||
| * @param source_u Output: added u-momentum buoyancy source | ||
| * @param source_v Output: added v-momentum buoyancy source | ||
| * @param source_w Output: added w-momentum buoyancy source | ||
| */ | ||
| CFD_LIBRARY_EXPORT void energy_compute_buoyancy(double T_local, const ns_solver_params_t* params, | ||
| double* source_u, double* source_v, | ||
| double* source_w); | ||
|
|
||
| #ifdef __cplusplus | ||
| } | ||
| #endif | ||
|
|
||
| #endif /* CFD_ENERGY_SOLVER_H */ |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.