From: dr DanW on
Here is the solution I worked out for the surface integral question I
posed to the group about a week ago. I hope someone else can make use
of this solution in the future.

These are the expressions that, when equal to zero, define the
surfaces of my solid region, which is a circular cylinder with one
flat end and one slanted end.

In[1]:=
L = 15; R = 3.5; \[Theta] = 40.*Degree;

In[2]:=
cylinder = -R^2 + $y^2 + $z^2;
piston = $x;
termination = $z*Cos[\[Theta]] + ($x - L)*Sin[\[Theta]];

In[5]:=
xmax = L + R/Tan[\[Theta]];

So, the solid region is defined as

In[6]:=
tubeRegion = cylinder <= 0 && piston >= 0 && termination <= 0

Out[6]= -12.25 + $y^2 + $z^2 <= 0 && $x >= 0 && 0.642788 (-15 + $x) +
0.766044 $z <= 0

My problem is that I want to be able to integrate a function over the
entire surface of this region. That was not covered in my calculus
class, since I have boundaries that are not on constant coordinate
planes. The first thing to do is to break the problem down to
integrating over each of the three surfaces that bound the region.

To work one surface, my first thought was to change one of the
inequalities to an equality and do a 3D NIntegrate, but that gave me
zero since the resulting region has zero volume (duh.) So, it was
evident that I had to reduce the problem to 2D. So, pick a variable
and solve the surface equation for that variable:

In[7]:=
xform = Solve[cylinder == 0, $y]

Out[7]= {{$y -> -0.5 Sqrt[49. - 4. $z^2]}, {$y -> 0.5 Sqrt[49. - 4.
$z^2]}}

I will use this variable transformation to eliminate the $y variable
from the remaining expressions, essentially turning the 3D problem
into 2D problem in the parameters $x and $z. Looking up some formulas
for parametric surface integration in MathWorld, I calculate the
element of surface in the new coordinates

In[8]:=
ds = (Norm[Cross[D[#1, $x], D[#1, $z]]] & ) /@ ({$x, $y, $z} /. xform)

Out[8]= {Sqrt[1. + 4. Abs[$z/Sqrt[49. - 4. $z^2]]^2], Sqrt[
1. + 4. Abs[$z/Sqrt[49. - 4. $z^2]]^2]}

I also use the transformation of the remaining two bounding
inequalities. In this case, I cheat since one of the bounding
conditions is trivial and I can put them in directly as limits of
integration.

In[9]:=
select = Boole /@ (termination <= 0 /. xform)

Out[9]= {Boole[0.642788 (-15 + $x) + 0.766044 $z <= 0],
Boole[0.642788 (-15 + $x) + 0.766044 $z <= 0]}

To integrate a function f[x,y,z] over the one surface we have been
working with, the integral would be

(* NIntegrate[(f[x,y,z]/.xform).(ds select),{$x,0,xmax},
{$z,-3.35,3.35}] *)

For example, for the trivial case where we only want the surface area,
the function f[x,y,z] = 1, so the integral evaluates

In[11]:=
NIntegrate[(1 /. xform) . (ds*select), {$x, 0, xmax}, {$z, -3.35,
3.35}]

Out[11]= 268.164

Now repeat for the other two surfaces.

Other solutions were suggested, such as giving the surfaces a small
thickness, performing a volume integration, and dividing by the
thickness, or using Dirac functions to define the surfaces. I have
not tried either of these. Thanks to everybody for their help.

Enjoy,
Daniel