nasa / cape

Computational Aerosciences Productivity & Execution
Other
21 stars 9 forks source link

Modifying MAPBC Files #27

Closed rbreslavsky closed 9 months ago

rbreslavsky commented 9 months ago

I'm attempting to modify a case's mapbc from the default value specified in pyfun.json.

In trying to do this via a case function, modifying the value of Mesh / BCFile does not result in the copying of the desired mapbc to the case folder. This seems to work fine for grids (Mesh / MeshFile). Is this a bug, or am I doing something wrong?

nasa-ddalle commented 9 months ago

So you have something like ...

"Mesh": {
    "BCFile": "inputs/bc/mymapbcfile.mapbc"
}

and then it doesn't seem to read mymapbcfile.mapbc? That seems strange; it's working for me in both branches.

I have a slight suspicion that what's happening is that CAPE is modifying your file before writing it in the case file in such a way that it looks exactly like your previous template. In general pyfun never copies .mapbc files directly but rather reads them and then writes its own version. Usually this just affects spacing, but there a couple of changes that can get made to your file behind the scenes, and those might be getting in your way. The only one that I can think of are changing "SurfBC" surfaces' boundary condition to 7011 or 7021. If you want to manually override this number, you can set a "SurfBC" in the "RunMatrix" definitions. For example

"RunMatrix": {
    "Keys": ["mach", "CT"],
    "Definitions": {
        "CT": {
            "Type": "SurfCT",
            "Value": "float",
            "SurfBC": 1234    // instead of 7011
        }
    }
}

Depending on what we figure out CAPE is doing wrong, you might be able to use a hook. The API function cntl.opts.get_MapBCFile() should point you to the correct (original) file, which you could then just copy directly into a case folder if needed.

rbreslavsky commented 9 months ago

It does read mymapbcfile.mapbc if specified in pyfun.json, but not if I specify or define it in a case function hook.

nasa-ddalle commented 9 months ago

Oh! I missed that detail. Yes, that's definitely true. Since you're writing a case function hook anyway, you should be able to just call

cntl.opts["Mesh"]["BCFile"] = "mymapbcfile.json"
cntl.ReadMapBC()

I suspect you're already doing the first, and hopefully the second should help. This does point to another problem using the CAPE 1.1 @map, @expr for Mesh > BCFile that I should fix, but I think you should be able to proceed for now w/o a CAPE update.

rbreslavsky commented 9 months ago

Thanks Derek, that seems to work!