<div dir="ltr">Hi Barry,<div><br></div><div>Several years ago, during the SciDAC-II project, I remember you saying something about how we might be able to use active set methods (with which I am wholly unfamiliar) to impose some constraints that hold the variable set constant over the projected Newton step. We'd then project only onto the allowed variables during the line search, and then after the projected step, determine if we need to switch variables. Since I don't know anything about these methods other than what I just looked at on Wikipedia, I don't know if this makes any sense or not.</div><div><br></div><div>I recall also that one of the reasons we never pushed hard on multigrid solvers was that, for the multiphase problems we were working on for the CO2 sequestration studies, variable-switching would make this a nightmare: different phases might be present at the different grid levels, and thus the meaning of the primary variables would differ between fine and coarse levels! How you prolong coarse grid corrections in that case is... messy. Anybody on petsc-dev have any ideas?</div><div><br></div><div>--Richard</div></div><div class="gmail_extra"><br><div class="gmail_quote">On Fri, Jun 12, 2015 at 8:03 PM, Peter Lichtner <span dir="ltr"><<a href="mailto:peter.lichtner@gmail.com" target="_blank">peter.lichtner@gmail.com</a>></span> wrote:<br><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">Barry: here is an attempt to explain how variable switching works in pflotran (we may need to iterate on this if it's not clear). I will consider as an example the 2-phase, 3-component water-supercritical CO2 system.<br>
<br>
Any grid cell (we use finite volume) can exist in one of three possible states: single-phase pure liquid water (l); single-phase pure supercritical CO2 (g); or two-phase coexistence of water and supercritical CO2 (2ph).<br>
<br>
Each of these states is described by three independent (nonunique) state variables. One possibility is:<br>
<br>
l: (p_l, T, X_CO2^l)<br>
g: (p_g, T, X_CO2^g)<br>
2ph: (p_g, T, s_g)<br>
<br>
where p_l,g = liquid or gas pressure, T = temperature, and s_g = volume fraction of pore space occupied by supercritical CO2.<br>
<br>
Where variable switching comes into play is when a grid cell undergoes a phase change with the following possibilities:<br>
<br>
l -> 2ph<br>
g -> 2ph<br>
2ph -> l<br>
2ph -> g<br>
<br>
Note that we do not include directly l <-> g.<br>
<br>
As a consequence different regions of space have different primary variables the boundaries of which are changing with time along with the state variables.<br>
<br>
Line search is not feasible with the current implementation in petsc.<br>
<br>
After a completed time step or Newton iteration, the stability of the solution in each grid cell must be checked for a change of phase. For example, if the cell is in a 2 phase state, but the solution gives s_g > 1 or s_g < 1, then a phase change occurs from 2ph -> g or 2ph -> l, respectively, and a change of variables is necessary:<br>
<br>
(p_g, T, s_g) -> (p_l, T, X_CO2^l)<br>
<br>
or<br>
<br>
(p_g, T, s_g) -> (p_g, T, X_CO2^g)<br>
<span class="HOEnZb"><font color="#888888"><br>
…Peter<br>
</font></span><div class="HOEnZb"><div class="h5"><br>
> On Jun 12, 2015, at 18:14, Barry Smith <<a href="mailto:bsmith@mcs.anl.gov">bsmith@mcs.anl.gov</a>> wrote:<br>
><br>
><br>
> John,<br>
><br>
> We can provide any Fortran stubs you need but before we do could you please outline to us (in algebraic notation; not in reference to PETSc code) how you plan to handle your "variable switching". That is, what is the problem being solved, what are the constraints, when do you need to switch variables etc?<br>
><br>
> I would say everyone who has tried to do variable switching in PETSc before has failed because we (the PETSc developers) did not help them enough and understand what is needed in the Newton solver. I suspect we need to provide a bit more functionality in PETSc to make variable switching a success and I'd like to understand what that is and add it to the PETSc algorithms. Also if you know of any references that actually explain variable switching in detail, that would be great, all I've found are vague hand-wavy discussions that leave too many important details unexplained.<br>
><br>
> Thanks<br>
><br>
> Barry<br>
><br>
>> On Jun 12, 2015, at 5:54 PM, John O'Sullivan <<a href="mailto:jp.osullivan@auckland.ac.nz">jp.osullivan@auckland.ac.nz</a>> wrote:<br>
>><br>
>> Hi,<br>
>><br>
>> We're working on changing variables during an SNES solve so that we can handle phase changes.<br>
>><br>
>> I'm looking into using SNESSetUpdate but there doesn't seem to be a fortran interface. I get an error:<br>
>><br>
>> Undefined symbols for architecture x86_64:<br>
>> "_snessetupdate_", referenced from:<br>
>> _MAIN__ in phaseChange.o<br>
>><br>
>> I've looked in the interface files and can't find it either. I tried writing one myself but things get a bit too complicated to guess...<br>
>><br>
>> Can an interface be added please?<br>
>><br>
>> Is this the best to do variable switching? If not where would be the right place and are there Fortran interfaces? We will be changing from Pressure, Temperature to Pressure, Saturation etc. But for now I'm just working on a simple example code.<br>
>><br>
>> Cheers<br>
>> John<br>
>> --<br>
>> Dr John O'Sullivan<br>
>> Lecturer<br>
>> Department of Engineering Science<br>
>> University of Auckland, New Zealand<br>
>> email:<br>
>> jp.osullivan at <a href="http://auckland.ac.nz" rel="noreferrer" target="_blank">auckland.ac.nz</a><br>
>><br>
>> tel: +64 (0)9 923 85353<br>
>><br>
><br>
<br>
</div></div></blockquote></div><br></div>