Add centered pressure gradient implimentation#8
Add centered pressure gradient implimentation#8sbrus89 wants to merge 159 commits intoomega/developfrom
Conversation
xylar
left a comment
There was a problem hiding this comment.
@sbrus89, a few comments. The main ones in terms of needing to discuss them relate to how the product of
| parallelFor( | ||
| "compute-interface-values", {NCellsAll, NVertLayers + 1}, | ||
| KOKKOS_LAMBDA(I4 ICell, I4 KInterface) { | ||
| if (KInterface == 0) { |
There was a problem hiding this comment.
As we discussed, we need hierarchical parallelism here and this should be MinLayerCell or whatever the proper variable is, rather than 0.
There was a problem hiding this comment.
Yes, I'll take care of swapping out for hierachical parallelism.
| // AbsSalinityInterface(ICell, KInterface) = | ||
| // AbsSalinity(ICell, KInterface); | ||
| SpecVolInterface(ICell, KInterface) = SpecVol(ICell, KInterface); | ||
| } else if (KInterface == NVertLayers + 1) { |
There was a problem hiding this comment.
Similarly, this should have hierarchical parallelism and use MaxLayerCell or similar.
| const I4 ICell1 = CellsOnEdge(IEdge, 1); | ||
| const Real InvDcEdge = 1.0_Real / DcEdge(IEdge); | ||
|
|
||
| for (int KVec = 0; KVec < VecLength; ++KVec) { |
There was a problem hiding this comment.
This needs to be over something like MinLayerEdgeBot to MaxLayerEdgeTop with hierarchical parallelism.
| (PressureInterface(ICell1, K) * SpecVolInterface(ICell1, K) + | ||
| PressureInterface(ICell0, K) * SpecVolInterface(ICell0, K)); |
There was a problem hiding this comment.
Let's chat about it but I think we want the PAlpha product to be averaged both to cell centers and to layer interfaces.
There was a problem hiding this comment.
Check out my latest commit and let me know what you think. The new averaging appeared to lower errors in my hydrostatic test.
…t#7866) This is changing code that is widely used and has been unchanged for a very long time, so I'm adding a lot of reviewers. Feel free to add more. I stumbled across this code when trying to debug a weird eamxx failure: I observed the following symtoms: If you look at components/elm/src/main/reweightMod.F90, you'll see the line SHR_ASSERT(bounds%level == BOUNDS_LEVEL_CLUMP, errMsg(__FILE__, __LINE__)) which causes this error: 1: free(): invalid pointer ... 0: #8 0x4c7e3ab in __shr_log_mod_MOD_shr_log_errmsg 0: at /pscratch/sd/a/acmetest/E3SM/share/util/shr_log_mod.F90:78 0: E3SM-Project#9 0x914149 in __reweightmod_MOD_reweight_wrapup 0: at /pscratch/sd/a/acmetest/E3SM/components/elm/src/main/reweightMod.F90:48 0: E3SM-Project#10 0x17bda7d in __dynsubgriddrivermod_MOD_dynsubgrid_wrapup_weight_changes 0: at /pscratch/sd/a/acmetest/E3SM/components/elm/src/dyn_subgrid/dynSubgridDriverMod.F90:403 0: E3SM-Project#11 0x17bf256 in __dynsubgriddrivermod_MOD_dynsubgrid_init._omp_fn.0 0: at /pscratch/sd/a/acmetest/E3SM/components/elm/src/dyn_subgrid/dynSubgridDriverMod.F90:150 I thought this was because the SHR_ASSERT was failing, but that's not the case (both bounds%level and BOUNDS_LEVEL_CLUMP are always 2). If I just comment this SHR_ASSERT out entirely, the test PASSES! The lowest line of code that triggers the free(): invalid pointer error is: shr_log_errMsg = 'ERROR in '//trim(file)//' at line '//toString(line) What I think is happening is that there is some memory corruption that is causing the freeing of the allocation done by toString to fail. So, this PR kind of sweeps that issue under the rug, but I do think it's better not to do dynamic allocations if you don't have to. The test PASSes with the changes in this PR. [BFB]
|
@sbrus89, your last few commits look reasonable to me. I would remove the commented-out loops after the switch to hierarchical parallelism eventually but it's okay to keep them for now while you make sure things are working as expected. It's getting cumbersome to review here because your local omega/develop is out of date, so let's just got ahead and make the PR to Omega. |
|
|
||
| // compute specific volume from EOS | ||
| VCoord->computePressure(LayerThick, SurfacePressure); | ||
| DefEos->computeSpecVol(Temp, Salinity, PressureMid); |
There was a problem hiding this comment.
This is probably not where we want to be computing the specific volume in the long run, right? We would want to compute it somewhere external in the time step and just make it available here? I guess that's what Hyun is working on?
There was a problem hiding this comment.
Right, I realized I need to add this call in Tendencies as well.
| Real Rho0 = 1026.0_Real; | ||
| Real Gravity = 9.80616_Real; |
There was a problem hiding this comment.
This is not the right Gravity. We should use the value from GlobalConstants.h, which comes from here:
https://github.com/E3SM-Project/Omega/blob/develop/share/util_cxx/pcd_const.h#L28
| const I4 ICell0 = CellsOnEdge(IEdge, 0); | ||
| const I4 ICell1 = CellsOnEdge(IEdge, 1); | ||
| const Real InvDcEdge = 1.0_Real / DcEdge(IEdge); | ||
| Real Rho0 = 1026.0_Real; |
There was a problem hiding this comment.
This isn't used and should be removed.
Surface flux terms, body forces and pressure terms were all getting multiplied by $\rho_0$, leading to incorrect dimensions and inconsistency with the rest of the derivation.
…1-equations
Fixes to Omega v1 Governing Equations
This pull request updates the documentation in OmegaV1GoverningEqns.md to improve the consistency, clarity, and correctness of the mathematical notation used in the derivation of the governing equations. The changes primarily remove unnecessary factors of \rho_0 from several equations, clarify the definition and notation for surface forces, and correct integration limits and variable usage for consistency.
Mathematical and Notational Corrections:
* Removed unnecessary factors of \rho_0 from the pseudo-height mass, tracer, and momentum conservation equations, as well as from their layer-averaged and Reynolds-averaged forms, to ensure dimensionally consistent and simplified expressions.
* Clarified the definition of the surface force (traction vector) as \tau = \sigma \cdot {\bf n} and distinguished the horizontal component \tau_\perp in the momentum equation, improving the physical interpretation and accuracy of boundary force terms.
Consistency and Integration Limit Corrections:
* Corrected integration limits and variable usage in the layer and Reynolds-averaged tracer equations to ensure consistency with the rest of the document and the intended physical meaning.
* Updated several equations to use consistent notation for averages, fluctuations, and layer integrals, improving readability and reducing the risk of confusion.
Use accessor functions to get state variables
Drop unused Rho0
No description provided.