<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><br></div><div>
<p class="gmail-p1"><b>//<span class="gmail-Apple-converted-space"> </span>PetscFEIntegrateBdResidual_Basic DMPlexComputeBdResidual_Internal</b><span class="gmail-s1"><b> </b></span></p>
<p class="gmail-p2"><span class="gmail-s2"><b>static</b></span><b> </b><span class="gmail-s2"><b>void</b></span><b> f0_bd_u(PetscInt dim, PetscInt Nf, PetscInt NfAux,</b></p>
<p class="gmail-p2"><b> </b><span class="gmail-s2"><b>const</b></span><b> PetscInt uOff[], </b><span class="gmail-s2"><b>const</b></span><b> PetscInt uOff_x[], </b><span class="gmail-s2"><b>const</b></span><b> PetscScalar u[], </b><span class="gmail-s2"><b>const</b></span><b> PetscScalar u_t[], </b><span class="gmail-s2"><b>const</b></span><b> PetscScalar u_x[],</b></p>
<p class="gmail-p2"><b> </b><span class="gmail-s2"><b>const</b></span><b> PetscInt aOff[], </b><span class="gmail-s2"><b>const</b></span><b> PetscInt aOff_x[], </b><span class="gmail-s2"><b>const</b></span><b> PetscScalar a[], </b><span class="gmail-s2"><b>const</b></span><b> PetscScalar a_t[], </b><span class="gmail-s2"><b>const</b></span><b> PetscScalar a_x[],</b></p>
<p class="gmail-p2"><b><span class="gmail-Apple-converted-space"> </span>PetscReal t, </b><span class="gmail-s2"><b>const</b></span><b> PetscReal x[], </b><span class="gmail-s2"><b>const</b></span><b> PetscReal n[], PetscInt numConstants, </b><span class="gmail-s2"><b>const</b></span><b> PetscScalar constants[], PetscScalar f0[])</b></p>
<p class="gmail-p2"><b>{<span class="gmail-Apple-converted-space"> </span></b></p>
<p class="gmail-p2"><b><span class="gmail-Apple-converted-space"> </span>PetscInt d;</b></p>
<p class="gmail-p2"><b> </b><span class="gmail-s2"><b>double</b></span><b> radius = </b><span class="gmail-s3"><b>0.0</b></span><b>;</b></p>
<p class="gmail-p2"><b> </b><span class="gmail-s2"><b>const</b></span><b> </b><span class="gmail-s2"><b>double</b></span><b><span class="gmail-Apple-converted-space"> </span>zthresh = (</b><span class="gmail-s3"><b>3.</b></span><b> - </b><span class="gmail-s3"><b>4.5</b></span><b>/</b><span class="gmail-s3"><b>2.</b></span><b>)*</b><span class="gmail-s3"><b>.01</b></span><b>; </b><span class="gmail-s4"><b>// [m]</b></span></p>
<p class="gmail-p2"><b> </b><span class="gmail-s5"><b>for</b></span><b> (d = </b><span class="gmail-s3"><b>0</b></span><b>; d < </b><span class="gmail-s3"><b>2</b></span><b>; ++d) radius += x[d]*x[d];</b></p>
<p class="gmail-p2"><b><span class="gmail-Apple-converted-space"> </span>radius = sqrt(radius);<span class="gmail-Apple-converted-space"> </span></b></p>
<p class="gmail-p2"><b> </b><span class="gmail-s5"><b>if</b></span><b> ( radius > </b><span class="gmail-s3"><b>.001</b></span><b>/</b><span class="gmail-s3"><b>2.</b></span><b><span class="gmail-Apple-converted-space"> </span>)<span class="gmail-Apple-converted-space"> </span></b></p>
<p class="gmail-p2"><b><span class="gmail-Apple-converted-space"> </span>{f0[</b><span class="gmail-s3"><b>0</b></span><b>] =<span class="gmail-Apple-converted-space"> </span>constants[</b><span class="gmail-s3"><b>2</b></span><b>] * u[</b><span class="gmail-s3"><b>0</b></span><b>];}</b></p>
<p class="gmail-p2"><b> </b><span class="gmail-s5"><b>else</b></span><b> </b></p>
<p class="gmail-p2"><b><span class="gmail-Apple-converted-space"> </span>{</b></p>
<p class="gmail-p2"><b><span class="gmail-Apple-converted-space"> </span>f0[</b><span class="gmail-s3"><b>0</b></span><b>] = -constants[</b><span class="gmail-s3"><b>3</b></span><b>] <span class="gmail-Apple-converted-space"> </span>;<span class="gmail-Apple-converted-space"> </span></b></p>
<p class="gmail-p2"><b><span class="gmail-Apple-converted-space"> </span>}</b></p>
<p class="gmail-p2"><b>}<span class="gmail-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="h5"><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_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_3437437877740401020m_802134873794636337gmail-p1"><b></b></p>
<p class="m_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_3437437877740401020m_802134873794636337gmail-p1"><b>I want to pass the boundary condition/constraint ID (ids):<span class="m_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_3437437877740401020m_802134873794636337gmail-p2"><b>to the functions for the residual evaluation on the boundary.</b></p>
<p class="m_3437437877740401020m_802134873794636337gmail-p1"><b></b><br></p>
<p class="m_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_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="HOEnZb"><font color="#888888"><br clear="all"><div><br></div>-- <br><div class="m_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/~<wbr>knepley/</a><br></div></div></div></div></div>
</font></span></div></div>
</blockquote></div><br></div>