hydroframe / ParFlow_PerfTeam

Parflow is an open-source parallel watershed flow model.
http://inside.mines.edu/~rmaxwell/maxwell_software.shtml
Other
0 stars 0 forks source link

Figure out and document the current procedure #18

Closed cathieO closed 5 years ago

cathieO commented 5 years ago

Not just in Richards and NLFunctionEval We need to look in bc pressure package and bc pressure and some other stuff.

Keep Steve in the loop.

cathieO commented 5 years ago

need to find where u_new is being read from -- that is one of the data structures of interest

cathieO commented 5 years ago

From Reed and Steve: Please excuse the brevity of this message it was sent from my iPhone

Begin forwarded message:

From: "Smith, Steve" smith84@llnl.gov Date: June 18, 2019 at 12:08:14 MDT To: Reed Maxwell rmaxwell@mines.edu Cc: Laura - Condon lecondon@email.arizona.edu Subject: Re: adding new BC's in ParFlow

I'm a little lost on why this extra Package layer is in there. Reverse engineering it appears to me that the intent was for Package info to be shared across multiple patches...but it doesn't look like input works that way anymore (ever?). The BC input is specified per patch.

The bc_pressure_package is has an input structure for each of the different bc_pressure types.

BCPressurePackageNewPublicXtra, does the reading into the Type structures. So you need a new Type9 structure for input data for the new BC type. The input Type are internal to the to the C code (not in .h file).

When the BCPressurePackage main method is called it allocates and does some basic setup of the BCPressureType structure the for the BC type. Structure is defined in bc_pressure.h.

problem_bc_pressure.[ch] does the full setup of the structures, allocates vectors needed etc.

Searching for "Type8" and OverlandBC should hit most of the setup parts.

Testing can just be a new problem with the new SeepageFace BC applied? If you know what BC should look like can you just verify pressure is correct along BC?

Steve

From: Reed Maxwell rmaxwell@mines.edu Sent: Tuesday, June 18, 2019 9:06 AM To: Smith, Steve Cc: Laura - Condon Subject: adding new BC's in ParFlow

Hi Steve-

I’ve got a big project this week to standardize and add new BC’s into PF — I’m starting with something that is already hacked in as a modifier to the existing overland flow BC (using a spinup flag) and I want to make this a stand alone BC called SeepageFace. However, I’m really lost in the different modules. I want to add it in NL_FUNCTION_EVAL.c (and I know where) but the other structures for bc’s (problem_bc_pressure, bc_pressure_package) have me lost. Is there a good way to do this? Is there a good way to test that I’ve done this correctly?

thanks Reed

KoenigKrote commented 5 years ago

Boundary Conditions are comprised of three things: struct TypeN, struct BCPressureTypeN, and a #define macro for use in branching on types, where N is just an incrementing number (e.g. Type0 Type1 etc) TypeN is defined in problem_bc_pressure.c and appears to contain the necessary filenames or other values needed to set up the BCStruct data for all timesteps BCPressureTypeN is defined in bc_pressure.h and appears to contain the values necessary to set up the BCStruct data for a particular timestep The #define macro is defined in problem_bc.h and is effectively an enum for switching

Go into each of these files and define your new structs with the appropriate values.

The first step is to enter bc_pressure_package.c:BCPressurePackageNewPublicXtra and near the top of the function, edit the type_na assignment string to include the name of the new boundary condition as it would appear in the TCL script. The rest of this function loops over each patch and switches on their type, setting up all the data for struct TypeN. Add a new case to the bottom of this switch and set up your TypeN struct as appropriate. Store this pointer in public_xtra->data[i] as a void pointer.

Next, enter bc_pressure_package.c:BCPressurePackage and go to the bottom. Similarly add a new case, read out your TypeN struct from public_xtra->data[i] and cast it as appropriate. Assign your new #define macro type into BCPressureDataBCType(bc_pressure_data, i), then assign values into your BCPressureTypeN struct as appropriate. Store this in the bc_pressure_data struct with BCPressureDataIntervalValue(bc_pressure_data, i, interval_number) = (void*)bc_pressure_typeN;

Inside problem_bc_pressure.c:BCPressure go to the bottom of the function and add a new case. Read out your BCPressureTypeN struct from bc_pressure_data with BCPressureDataIntervalValue(bc_pressure_data, ipatch, interval_number) and set up the actual boundary condition values as appropriate (read them from a value, set up vectors, etc).

You should now be able to add a new case when switching on BCStructBCType(bc_struct, ipatch) and use the appropriate values.

KoenigKrote commented 5 years ago

u_new value in nl_function_eval.c:NlFunctionEval is a scalar that is assigned on some computations based on the bc_patch_value inside a BCStructPatchLoop. i.e. It is based on the values read in from the boundary condition patch. EX nl_function_eval.c:890 has u_new being assigned as

u_new = RPMean(value, pp[ip], rpp[ip - 1] * dp[ip - 1], rpp[ip] * dp[ip]);

where value is the bc_patch_value read out in the loop. Or nl_function_eval.c:1006 it is set as

lower_cond = value / sep - 0.25 * dp[ip] * gravity;
// other equations
u_new = RPMean(lower_cond, upper_cond, rpp[ip - sz_p] * dp[ip - sz_p], rpp[ip] * dp[ip]);

It is assigned based on the face of the patch, it is not reassigned within an iteration.

KoenigKrote commented 5 years ago

Refer to PR #26 specifically the top of bc_pressure.h for documentation of adding a new boundary condition using the proposed macro system. https://github.com/hydroframe/ParFlow_PerfTeam/pull/26/files#diff-05f34523efd6f86d386d9e645a13647d

@reedmaxwell @lecondon Requesting a review of this, if the naming scheme is okay and the macro api makes sense and the documentation is coherent.

lecondon commented 5 years ago

Yes we went over the changes in our last call and Reed and I approved the new approach and would like it to be merged back into the main branch so we can implement the new BCs with this approach.

cathieO commented 5 years ago

To wrap this up let's get it into the user manual.