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

Refactoring of CField struct to include gridindexingtype and interp_method #1673

Draft
wants to merge 2 commits into
base: analyticaladvection_in_jit
Choose a base branch
from

Conversation

erikvansebille
Copy link
Member

@erikvansebille erikvansebille commented Aug 29, 2024

Following #1612, where we need to provide the gridindexingtype on the CField struct for technical reasons, it makes sense to also use it throughout the rest of the C-code. Hence, this PR refactors the code to not require the gridindexingtype and interp_method when calling a Field evaluation in C, but get them from the CField itself

@erikvansebille erikvansebille changed the base branch from master to croco_3D_velocities August 29, 2024 07:28
@erikvansebille erikvansebille changed the base branch from croco_3D_velocities to analyticaladvection_in_jit August 29, 2024 07:29
Copy link

codecov bot commented Aug 29, 2024

Codecov Report

All modified and coverable lines are covered by tests ✅

Additional details and impacted files
@@                     Coverage Diff                     @@
##           analyticaladvection_in_jit    #1673   +/-   ##
===========================================================
  Coverage                       86.22%   86.22%           
===========================================================
  Files                              67       67           
  Lines                           11827    11828    +1     
===========================================================
+ Hits                            10198    10199    +1     
  Misses                           1629     1629           
Flag Coverage Δ
integration-tests 64.85% <100.00%> (+<0.01%) ⬆️
unit-tests 80.62% <100.00%> (+<0.01%) ⬆️

Flags with carried forward coverage won't be shown. Click here to find out more.

Files with missing lines Coverage Δ
parcels/field.py 89.72% <100.00%> (+<0.01%) ⬆️

Comment on lines 1479 to +1491
gridindexingtype_mapping = {"nemo": 0, "mitgcm": 1, "mom5": 2, "pop": 3}
interp_method_mapping = {
"LINEAR": 0,
"NEAREST": 1,
"CGRID_VELOCITY": 2,
"CGRID_TRACER": 3,
"BGRID_VELOCITY": 4,
"BGRID_W_VELOCITY": 5,
"BGRID_TRACER": 6,
"LINEAR_INVDIST_LAND_TRACER": 7,
"PARTIALSLIP": 8,
"FREESLIP": 9,
}
Copy link
Member Author

Choose a reason for hiding this comment

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

This is still a bit ugly, because it mirrors the information from

typedef enum
{
LINEAR=0, NEAREST=1, CGRID_VELOCITY=2, CGRID_TRACER=3, BGRID_VELOCITY=4, BGRID_W_VELOCITY=5, BGRID_TRACER=6, LINEAR_INVDIST_LAND_TRACER=7, PARTIALSLIP=8, FREESLIP=9
} InterpCode;
typedef enum
{
NEMO = 0, MITGCM = 1, MOM5 = 2, POP = 3
} GridIndexingType;

It would be cleaner to either

  1. Use the string here in the CField, instead of an integer. I tried using c_char_p, but that didn't work (yet)
  2. Somehow import the typedefs from index_search.h (above) here
    In any case, I think we want to avoid happing two places where these mappings between strings and integers occur...

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
Status: Backlog
Development

Successfully merging this pull request may close these issues.

1 participant