-
Notifications
You must be signed in to change notification settings - Fork 238
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
Account for the Darcy Velocity and/or the Fluid Velocity when Determining Outflow Boundaries #6075
base: main
Are you sure you want to change the base?
Conversation
Thanks for the quick review @tjhei! I've added another if statement which accounts for the fluid velocity used by the melt transport model when determining whether a boundary is an outflow boundary |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thank you for taking a stab at this!
I think this goes in the right direction. But I think it would be good to have a test case that shows that this actually works (one with darcy flow where the solid flows in and the melt flow out, for example).
source/simulator/helper_functions.cc
Outdated
} | ||
|
||
// ... and change the boundary id of any outflow boundary faces. | ||
if (integrated_flow > 0) | ||
if (integrated_solid_flow > 0 || integrated_darcy_flow > 0 || integrated_fluid_flow > 0) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I know you said you wanted to split this into 2 PRs and this will be changed later when you actually take into account the different field types. But I think like this, it might break some models. Because now, if melt flows out, and solid flows in, you would not set boundary conditions. But you need boundary conditions when material flows in (otherwise, what temperature/composition will the inflowing material have?) So at the very least only change it to an outflow boundary if all fields flow out (which is a bit tricky with how you've set up the integrated_flow variables right now).
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This makes sense! I've changed this so that they all need to be outflowing to update the cell.
b52900a
to
f0ca161
Compare
Thanks @jdannberg for the review, I'll add a test case in a separate commit soon! |
f0ca161
to
85d4b31
Compare
source/simulator/helper_functions.cc
Outdated
if (parameters.include_melt_transport) | ||
integrated_fluid_flow = 0; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
these two lines seem redundant.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I do this because by default (no melt transport) integrated_fluid_flow = std::numeric_limits<double>::max()
so that the if statement at line 2400 still works in solid only models. If there is melt though, then I need to set integrated_fluid_flow = 0
otherwise line 2388:
integrated_fluid_flow += (face_current_fluid_velocity_values[q] * fe_face_values.normal_vector(q)) *
fe_face_values.JxW(q);
will always be infinity. This was the only way I could think to get around this issue, but if you have a better approach that would be great!
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The same is done for when a field is advected using the darcy advection method at line 2352
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Oh, I see. I would put that into the initialization directly then by using a ternary (?) operator.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Ah yes! That will make this look much cleaner
85d4b31
to
6d4a813
Compare
@jdannberg @tjhei John (@naliboff) and I just talked about what this PR is now doing given that the condition for flagging a cell as an outflow cell requires outflow of all three velocities and we're wondering if we should just scrap this PR and jump right into making it composition dependent. The issue that this PR was trying to address was that in a model with two-phases the solid phase could be inflowing while the fluid phase is outflowing, this is why I had initially implemented line 2388 as an OR condition and not an AND condition. Since it is an AND condition now (to not violate the boundary condition for the solid as it inflows), the original issue that this PR is trying to address is no longer solved. Additionally, in the rare case where the solid is outflowing and the fluid is inflowing, the cell will not be flagged as outflow because both phases are not outflowing, which is an issue that wasn't present prior to this PR. Am I missing something that makes what I'm currently trying to do still valuable? If not, I will close this PR and work on a composition dependent implementation. |
I think it makes sense to directly go to implementing this in dependence of the compositional field type. But I think you can just work from what you have here. The only changes that would be required are (1) add an input parameter to the replace_outflow_boundary_ids function that tells the function if it computes boundary ids for the temperature or compositional field, and which field, |
71bacb3
to
65e611b
Compare
@jdannberg Here's my initial go at making this composition dependent. I wasn't sure if I needed to make |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think this should work!
There's one case (porosity in the case of melt transport) which I think does not work correctly right now (see other comments), but I think in general this should now apply the different velocities correctly at the boundary. You also do not need to change restore_outflow_boundary_ids
because that just resets the values to what they were originally.
Did you already check the tests to see if the results look right? Because it would make sense that some tests are different now (since you changed the functionality).
65e611b
to
3eb4ac6
Compare
Thanks for the review @jdannberg! The tests are failing because the boundary_ids are exceeding 128, working on fixing this bug now but hopefully after that is fixed this is good to go! |
3eb4ac6
to
4cac542
Compare
Think I fixed it! |
While trying to come up with a test I ran into an issue with the case where
gets called (specifically A similar error happens for the same test if porosity is not advected with the I'm not sure what to make of this, as for the fluid velocity case this all happening in functions that I didn't modify in this PR. The only connection between what I changed and the fluid velocity case is through the variable |
I think I don't yet understand what exactly the problem is you're describing. The line Does your input file crash if you run it on ASPECT main? Or is the crash actually related to the changes you made? |
@jdannberg Yes sorry for not including more background detail on this. My first instinct was, as you pointed out could be an issue, was that I was trying to use the material model inputs before they were initialized and so were set to 0. For the Darcy velocity case, this error does only happens on this branch, and does not happen on main. For the fluid velocity case it happens on both main and on my branch. It isn't surprising that this doesn't happen for the Darcy velocity case on main though, because the line I think I'm just now figuring out why this is happening. The test Of course I could probably circumnavigate this by using |
366ebc9
to
8e298f4
Compare
@jdannberg I got around the issue by properly setting the initial adiabatic conditions! Now the tests are not crashing, but they are producing some behaviour that is really bizarre. For both cases, the test simulates a blob of porosity in the middle of the model which flows up to outflow through the top boundary. At the top boundary, there is a solid field called For the fluid velocity case, when the blob hits the top boundary the porosity starts to increase across the whole domain and the model crashes. This is what happens to the For the Darcy velocity case though, this seems to be ok. I'm not exactly sure what is causing the fluid velocity case to crash. The model hangs when run in debug mode, and terminates with an MPI error in release mode. |
8e298f4
to
c2f6a2c
Compare
c2f6a2c
to
59be152
Compare
59be152
to
c0b5596
Compare
For the first problem with the pressure and temperature: Are you saying you need to set the adiabatic conditions to a function, and if you use initial profile, it does not work? If that’s the case, we have many places in the material models where we check if For the blob: That does seem strange. And I would say, even for the Darcy velocity, it does not seem right. It looks like there is a small blue line at the top of the box, so the outflow boundary conditions are not actually recognized correctly and porosity is still set to zero at the boundary (whereas at the bottom boundary, porosity along the boundary is the same as what it is in the interior). For the fluid velocity case: where does it hang in debug mode? Can you run it in a debugger and figure out the line? And it looks like you’ve set up the model to not have melting or freezing, so it really just advects the porosity field? Is there anything else that is weird about the model (pressure, temperature, etc.)? Does it also look like that and crash on main or is it related to the boundary conditions? And at least the boundary condition part might work for the porosity? It is set to zero along parts of the upper and the whole lower boundary, but not where the blob reached the boundary. |
@jdannberg Thanks for following up on this! For the first problem, yes even on the main branch if I do not define an For the darcy flow case, you are right I didn't notice that there is a thin blue line along the top boundary where the For the fluid velocity case, I wasn't able to found out an exact line unfortunately, but I was
Unfortunately I haven't been able to make much of this error message... I found the error message in the dealii source code but as the error message points out I didn't find it very helpful. If you've encountered this before or have any ideas on how to proceed I would really appreciate it. Also, here is the stacktrace in case that might be helpful:
|
Oh, I see. So everything works fine with the adiabatic conditions as long as you set the adiabatic surface temperature. That's good to hear. For the fluid velocity case, for me it worked with a high resolution everywhere:
I am still not sure what the problem is, and it would be good to figure that out, but you could try if your current file also crashes on main, and if so, then at least you know it does not have anything to do with your implementation. Since I had simplified a few more things, I am attaching my input file here. I also still see the porosity increasing in the box at the end even though I don't think any fluid flows in and there are no reactions. That still seems quite wrong, but at the moment I can't see where that comes from. Looking at the output, for the fluid flow case the boundary conditions seem correct for the porosity (for the solid_phase field it is hard to tell, because the value at the outflow boundary is the same as the initial condition).
Yes, I think that makes sense and gives you an idea where to search for the bug. |
@jdannberg I'm pretty confident I've figured out what is going on with these tests. First, when I increase the resolution of the fluid velocity test, the behaviour does drastically improve, and the behaviour of the test using the functionality implemented in this PR relative to the On the main branch, because the top boundary is strictly an inflow boundary, the For the Darcy velocity test, the issue is that the Darcy velocity depends on the If I define the porosity to be uniform everywhere and create an additional field which is advected with the The first pair of screenshots shows how when using the main branch the The second pair of screenshots shows the behaviour on this branch, where these issues are not present. The composition effectively outflows through the top boundary and avoids blowing up later in the model. While I'm confident that this is why the Darcy velocity test was not working, the solution of defining a homogeneous |
Currently, the
replace_outflow_boundary_ids
function only uses the solid velocity to determine if a boundary should be flagged as an outflow boundary. This PR updates thereplace_outflow_boundary_ids
function to account for the darcy velocity when using thedarcy field
compositional field advection method.Based on a conversation with @jdannberg this will also need to be extended to account for the fluid velocity when simulating melt transport, but I figured I would open the PR with what I have first to make sure that the implementation looks good and then add the other case afterwards.
This PR addresses the last point in Issue #4748.