<div dir="ltr">Thanks! will give that a try!<div>df</div></div><div class="gmail_extra"><br><div class="gmail_quote">On Mon, Nov 20, 2017 at 11:23 AM, Matthew Knepley <span dir="ltr"><<a href="mailto:knepley@gmail.com" target="_blank">knepley@gmail.com</a>></span> wrote:<br><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex"><div dir="ltr"><div class="gmail_extra"><div class="gmail_quote"><span class="">On Mon, Nov 20, 2017 at 12:20 PM, David Fuentes <span dir="ltr"><<a href="mailto:fuentesdt@gmail.com" target="_blank">fuentesdt@gmail.com</a>></span> wrote:<br><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex"><div dir="ltr">Thanks for the quick reply. Indeed it does work like this. I have added a location dependence on the boundary to differentiate the two. However, when my mesh moves then the BC will be applied incorrectly. </div></blockquote><div><br></div></span><div>I don't think you should have to do that. You can call AddBoundary twice. Once with a function with the first branch and marker value 3, and the next with the second branch and marker value 2. Does<br></div><div>that make sense?</div><div><br></div><div>  Thanks,</div><div><br></div><div>     Matt</div><div><div class="h5"><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex"><div dir="ltr"><div>







<p class="m_-6884419750981380993m_-2462315501270164214gmail-p1"><b>//<span class="m_-6884419750981380993m_-2462315501270164214gmail-Apple-converted-space">  </span>PetscFEIntegrateBdResidual_Bas<wbr>ic DMPlexComputeBdResidual_Intern<wbr>al</b><span class="m_-6884419750981380993m_-2462315501270164214gmail-s1"><b> </b></span></p>
<p class="m_-6884419750981380993m_-2462315501270164214gmail-p2"><span class="m_-6884419750981380993m_-2462315501270164214gmail-s2"><b>static</b></span><b> </b><span class="m_-6884419750981380993m_-2462315501270164214gmail-s2"><b>void</b></span><b> f0_bd_u(PetscInt dim, PetscInt Nf, PetscInt NfAux,</b></p>
<p class="m_-6884419750981380993m_-2462315501270164214gmail-p2"><b>                    </b><span class="m_-6884419750981380993m_-2462315501270164214gmail-s2"><b>const</b></span><b> PetscInt uOff[], </b><span class="m_-6884419750981380993m_-2462315501270164214gmail-s2"><b>const</b></span><b> PetscInt uOff_x[], </b><span class="m_-6884419750981380993m_-2462315501270164214gmail-s2"><b>const</b></span><b> PetscScalar u[], </b><span class="m_-6884419750981380993m_-2462315501270164214gmail-s2"><b>const</b></span><b> PetscScalar u_t[], </b><span class="m_-6884419750981380993m_-2462315501270164214gmail-s2"><b>const</b></span><b> PetscScalar u_x[],</b></p>
<p class="m_-6884419750981380993m_-2462315501270164214gmail-p2"><b>                    </b><span class="m_-6884419750981380993m_-2462315501270164214gmail-s2"><b>const</b></span><b> PetscInt aOff[], </b><span class="m_-6884419750981380993m_-2462315501270164214gmail-s2"><b>const</b></span><b> PetscInt aOff_x[], </b><span class="m_-6884419750981380993m_-2462315501270164214gmail-s2"><b>const</b></span><b> PetscScalar a[], </b><span class="m_-6884419750981380993m_-2462315501270164214gmail-s2"><b>const</b></span><b> PetscScalar a_t[], </b><span class="m_-6884419750981380993m_-2462315501270164214gmail-s2"><b>const</b></span><b> PetscScalar a_x[],</b></p>
<p class="m_-6884419750981380993m_-2462315501270164214gmail-p2"><b><span class="m_-6884419750981380993m_-2462315501270164214gmail-Apple-converted-space">                    </span>PetscReal t, </b><span class="m_-6884419750981380993m_-2462315501270164214gmail-s2"><b>const</b></span><b> PetscReal x[], </b><span class="m_-6884419750981380993m_-2462315501270164214gmail-s2"><b>const</b></span><b> PetscReal n[], PetscInt numConstants, </b><span class="m_-6884419750981380993m_-2462315501270164214gmail-s2"><b>const</b></span><b> PetscScalar constants[], PetscScalar f0[])</b></p>
<p class="m_-6884419750981380993m_-2462315501270164214gmail-p2"><b>{<span class="m_-6884419750981380993m_-2462315501270164214gmail-Apple-converted-space"> </span></b></p>
<p class="m_-6884419750981380993m_-2462315501270164214gmail-p2"><b><span class="m_-6884419750981380993m_-2462315501270164214gmail-Apple-converted-space">  </span>PetscInt d;</b></p>
<p class="m_-6884419750981380993m_-2462315501270164214gmail-p2"><b>  </b><span class="m_-6884419750981380993m_-2462315501270164214gmail-s2"><b>double</b></span><b> radius = </b><span class="m_-6884419750981380993m_-2462315501270164214gmail-s3"><b>0.0</b></span><b>;</b></p>
<p class="m_-6884419750981380993m_-2462315501270164214gmail-p2"><b>  </b><span class="m_-6884419750981380993m_-2462315501270164214gmail-s2"><b>const</b></span><b> </b><span class="m_-6884419750981380993m_-2462315501270164214gmail-s2"><b>double</b></span><b><span class="m_-6884419750981380993m_-2462315501270164214gmail-Apple-converted-space">  </span>zthresh = (</b><span class="m_-6884419750981380993m_-2462315501270164214gmail-s3"><b>3.</b></span><b> - </b><span class="m_-6884419750981380993m_-2462315501270164214gmail-s3"><b>4.5</b></span><b>/</b><span class="m_-6884419750981380993m_-2462315501270164214gmail-s3"><b>2.</b></span><b>)*</b><span class="m_-6884419750981380993m_-2462315501270164214gmail-s3"><b>.01</b></span><b>; </b><span class="m_-6884419750981380993m_-2462315501270164214gmail-s4"><b>// [m]</b></span></p>
<p class="m_-6884419750981380993m_-2462315501270164214gmail-p2"><b>  </b><span class="m_-6884419750981380993m_-2462315501270164214gmail-s5"><b>for</b></span><b> (d = </b><span class="m_-6884419750981380993m_-2462315501270164214gmail-s3"><b>0</b></span><b>; d < </b><span class="m_-6884419750981380993m_-2462315501270164214gmail-s3"><b>2</b></span><b>; ++d) radius += x[d]*x[d];</b></p>
<p class="m_-6884419750981380993m_-2462315501270164214gmail-p2"><b><span class="m_-6884419750981380993m_-2462315501270164214gmail-Apple-converted-space">  </span>radius = sqrt(radius);<span class="m_-6884419750981380993m_-2462315501270164214gmail-Apple-converted-space"> </span></b></p>
<p class="m_-6884419750981380993m_-2462315501270164214gmail-p2"><b>  </b><span class="m_-6884419750981380993m_-2462315501270164214gmail-s5"><b>if</b></span><b> ( radius > </b><span class="m_-6884419750981380993m_-2462315501270164214gmail-s3"><b>.001</b></span><b>/</b><span class="m_-6884419750981380993m_-2462315501270164214gmail-s3"><b>2.</b></span><b><span class="m_-6884419750981380993m_-2462315501270164214gmail-Apple-converted-space">  </span>)<span class="m_-6884419750981380993m_-2462315501270164214gmail-Apple-converted-space"> </span></b></p>
<p class="m_-6884419750981380993m_-2462315501270164214gmail-p2"><b><span class="m_-6884419750981380993m_-2462315501270164214gmail-Apple-converted-space">    </span>{f0[</b><span class="m_-6884419750981380993m_-2462315501270164214gmail-s3"><b>0</b></span><b>] =<span class="m_-6884419750981380993m_-2462315501270164214gmail-Apple-converted-space">  </span>constants[</b><span class="m_-6884419750981380993m_-2462315501270164214gmail-s3"><b>2</b></span><b>] * u[</b><span class="m_-6884419750981380993m_-2462315501270164214gmail-s3"><b>0</b></span><b>];}</b></p>
<p class="m_-6884419750981380993m_-2462315501270164214gmail-p2"><b>  </b><span class="m_-6884419750981380993m_-2462315501270164214gmail-s5"><b>else</b></span><b>   </b></p>
<p class="m_-6884419750981380993m_-2462315501270164214gmail-p2"><b><span class="m_-6884419750981380993m_-2462315501270164214gmail-Apple-converted-space">    </span>{</b></p>
<p class="m_-6884419750981380993m_-2462315501270164214gmail-p2"><b><span class="m_-6884419750981380993m_-2462315501270164214gmail-Apple-converted-space">     </span>f0[</b><span class="m_-6884419750981380993m_-2462315501270164214gmail-s3"><b>0</b></span><b>] = -constants[</b><span class="m_-6884419750981380993m_-2462315501270164214gmail-s3"><b>3</b></span><b>] <span class="m_-6884419750981380993m_-2462315501270164214gmail-Apple-converted-space">      </span>;<span class="m_-6884419750981380993m_-2462315501270164214gmail-Apple-converted-space"> </span></b></p>
<p class="m_-6884419750981380993m_-2462315501270164214gmail-p2"><b><span class="m_-6884419750981380993m_-2462315501270164214gmail-Apple-converted-space">    </span>}</b></p>
<p class="m_-6884419750981380993m_-2462315501270164214gmail-p2"><b>}<span class="m_-6884419750981380993m_-2462315501270164214gmail-Apple-converted-space"> </span></b></p></div><div><br></div></div><div class="gmail_extra"><br><div class="gmail_quote">On Mon, Nov 20, 2017 at 11:02 AM, Matthew Knepley <span dir="ltr"><<a href="mailto:knepley@gmail.com" target="_blank">knepley@gmail.com</a>></span> wrote:<br><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex"><div dir="ltr"><div class="gmail_extra"><div><div class="m_-6884419750981380993m_-2462315501270164214h5"><div class="gmail_quote">On Mon, Nov 20, 2017 at 11:46 AM, David Fuentes <span dir="ltr"><<a href="mailto:fuentesdt@gmail.com" target="_blank">fuentesdt@gmail.com</a>></span> wrote:<br><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex"><div dir="ltr">







<p class="m_-6884419750981380993m_-2462315501270164214m_3437437877740401020m_802134873794636337gmail-p1"><b>Is there a way to pass the boundary set id to the function pointers for the residual evaluation on the boundary ?</b><br><b></b></p><p class="m_-6884419750981380993m_-2462315501270164214m_3437437877740401020m_802134873794636337gmail-p1"><b></b></p>
<p class="m_-6884419750981380993m_-2462315501270164214m_3437437877740401020m_802134873794636337gmail-p2"><b><a href="https://bitbucket.org/petsc/petsc/src/d89bd21cf2b5366df29efb6006298d2bc22fb509/src/dm/dt/interface/dtfe.c?at=master&fileviewer=file-view-default#dtfe.c-4245" target="_blank">https://bitbucket.org/petsc/pe<wbr>tsc/src/d89bd21cf2b5366df29efb<wbr>6006298d2bc22fb509/src/dm/dt/i<wbr>nterface/dtfe.c?at=master&file<wbr>viewer=file-view-default#dtfe.<wbr>c-4245</a></b></p>
<p class="m_-6884419750981380993m_-2462315501270164214m_3437437877740401020m_802134873794636337gmail-p1"><b>I want to pass the boundary condition/constraint ID (ids):<span class="m_-6884419750981380993m_-2462315501270164214m_3437437877740401020m_802134873794636337gmail-Apple-converted-space">  </span>PetscErrorCode PetscDSAddBoundary(PetscDS ds, DMBoundaryConditionType type, const char name[], const char labelname[], PetscInt field, PetscInt numcomps, const PetscInt *comps, void (*bcFunc)(void), PetscInt numids, const PetscInt *ids, void *ctx)</b><br><b></b></p>
<p class="m_-6884419750981380993m_-2462315501270164214m_3437437877740401020m_802134873794636337gmail-p2"><b>to the functions for the residual evaluation on the boundary.</b></p>
<p class="m_-6884419750981380993m_-2462315501270164214m_3437437877740401020m_802134873794636337gmail-p1"><b></b><br></p>
<p class="m_-6884419750981380993m_-2462315501270164214m_3437437877740401020m_802134873794636337gmail-p2"><b>For example, I have two side sets in an exodus file. I want to implement Neumann boundary conditions on side set = 2 and Mixed/Cauchy BC on side set = 3. Or similarly use different</b></p>
<p class="m_-6884419750981380993m_-2462315501270164214m_3437437877740401020m_802134873794636337gmail-p2"><b>gmsh BC tags for Neumann/Mixed BC.</b></p></div>
</blockquote></div></div></div>I am not completely against this, but let me respond with my rationale first. What I thought you would do, is call AddBoundary() twice. Once with the</div><div class="gmail_extra">Neumann function and value 2, and once with the Cauchy function and value 3. Does that not work in your situation?</div><div class="gmail_extra"><br></div><div class="gmail_extra">Also, I am refectoring this right now because a DS object can only take a single boundary integral point function (which is a pain for inhomogeneous Neumann),</div><div class="gmail_extra">so I welcome input.</div><div class="gmail_extra"><br></div><div class="gmail_extra">  Thanks,</div><div class="gmail_extra"><br></div><div class="gmail_extra">    Matt<span class="m_-6884419750981380993HOEnZb"><font color="#888888"><span class="m_-6884419750981380993m_-2462315501270164214HOEnZb"><font color="#888888"><br clear="all"><div><br></div>-- <br><div class="m_-6884419750981380993m_-2462315501270164214m_3437437877740401020gmail_signature" data-smartmail="gmail_signature"><div dir="ltr"><div><div dir="ltr"><div>What most experimenters take for granted before they begin their experiments is infinitely more interesting than any results to which their experiments lead.<br>-- Norbert Wiener</div><div><br></div><div><a href="http://www.caam.rice.edu/~mk51/" target="_blank">https://www.cse.buffalo.edu/~k<wbr>nepley/</a><br></div></div></div></div></div>
</font></span></font></span></div></div>
</blockquote></div><br></div>
</blockquote></div></div></div><div><div class="h5"><br><br clear="all"><div><br></div>-- <br><div class="m_-6884419750981380993gmail_signature" data-smartmail="gmail_signature"><div dir="ltr"><div><div dir="ltr"><div>What most experimenters take for granted before they begin their experiments is infinitely more interesting than any results to which their experiments lead.<br>-- Norbert Wiener</div><div><br></div><div><a href="http://www.caam.rice.edu/~mk51/" target="_blank">https://www.cse.buffalo.edu/~<wbr>knepley/</a><br></div></div></div></div></div>
</div></div></div></div>
</blockquote></div><br></div>