CHAPTER
T
In fbert spH0, H1objectstype obworksp
3.1 H0 Type ObjectsWe
abstrac
3.1.1Num
to a givcalculu
1. For eMass. first look at various integration methods and then inferred from these integration methods the datation of an integrable object.
Quadratureerical integration is also known as quadrature, which means the process of finding a square equal in area
en area. The trapezoidal rule and the Simpsons rule are the most fundalmental ones that are introduced ins1. For a one dimensional function f(x), the trapezoidal rule and Simpsons rule evaluate the areas of the
xample, p. 602-609, in T.M. Apostol, 1969, Calculus, 2nd eds., vol. 2, Blaisdell Publishing Company, Waltham, hree Variational MethodsUsing H0, H1, and H2 Type Objects
unctional analysis, H0 (= L2 = W0,2), H1 (=W1,2), and H2 (= W2,2) are Sobolev spaces. They are also Hil-aces that has the inner product defined. For the users of VectorSpace C++ Library, it is sufficient to know, and H2 type objects are integrable objects (among them H1 and H2 type objects are also differentiable). The applications such as those in variational methods can be easily implemented with H0, H1, and H2jects. C++ programs using VectorSpace C++ Library in this chapter are projects contained in projectace file Hn.dsw under directory vs\ex\Hn.Workbook of Applications in VectorSpace C++ Library 165
Variational Methods Using H0, H1, and H2 Type Objects
166 W
Chapter 3
approxquadra
where trated iformul
We notbe avoithe ex
Extend
Extend
Fq
Trapezoidal rule Simpsons rule
f(x)
f(x)
linear interpolationquadratic interpolation
x
x
x
xorkbook of Applications in VectorSpace C++ Library
imated linear and quadratic interpolation functions, respectively. Formula of the approximated linear andtic interpolation functions are
Trapezoidal rule:
Simpsons rule: Eq. 31
O( ) indicates order of errors as a function of size h and derivatives of f(x). The two methods are illus-n Figure 31 . Formula without the necessity of evaluating the function at the end-points (open-typea) exists; e.g.,
Eq. 32
ice that f(x0) and f(x5) are not in Eq. 32. So, if a singularity of f(x) presents at any such end-points it canded. Repeatedly using the trapezoidal rule or Simpsons rule of Eq. 31 in many smaller segments yieldstended-type formula
ed trapezoidal rule:
ed Simpsons rule:
Eq. 33
f x( )dxx0
x1 h 12---f x0( ) 12---f x1( )+ O h3f( )+=f x( )dx
x0
x2 h 13---f x0( ) 43---f x1( ) 13---f x2( )+ + O h5f 4( )( )+=
igure 31 Approximation by two linear interpolation functions (left-hand-side), and by one uadratic interpolation function (right-hand-side), where h = xi+1 - xi is the size of one segment.
x0 x1 x0 x1 x2h = x1 - x0
f x( )dxx0
x5 h 5524------f x1( ) 524------f x2( ) 524------f x3( ) 5524------f x4( )+ + + O h5f 4( )( )+=
f x( )dx0
N h 12---f x0( ) f x1( ) f x2( ) f xN 1( )12---f xN( )+ + + + + O
xN x0( )3fN 1+( )2------------------------------ +=
f x( )dx0
N h 13---f x0( )43---f x1( )
23---f x2( )
43---f x3( )
23---f xN 2( )
43---+ f xN 1( )
13---f xN( )+ + + + + + O
1N 1+( )4--------------------- +=
H0 Type ObjectsThe above formula are all expressible as
Eq. 34
where c- xi), an
using extend
The claof inteanotherusing clater. Fsegmendomainfor the discuss
Higunfortuwe can
sian quintegraapproxnal. Le
hcif xi( )i 0=
N
Workbook of Applications in VectorSpace C++ Library 167
i is an array of coefficients in Eq. 31, Eq. 32, and Eq. 33. They all use equally spaced intervals (h = xi+1d f(xi) are evaluated at positions xi = x0 + i h. For example, an integration problem
Eq. 35
extended Simpsons rule can be written in C++ with VectorSpace C++ Library as (see project:ed_simpson)
// QUADRATURE: EXTENDED SIMPSONS RULEconst int N = 11; // number of integration segmentsdouble c[N] = {1.0/3.0, 4.0/3.0, 2.0/3.0, 4.0/3.0, // ci
2.0/3.0, 4.0/3.0, 2.0/3.0, 4.0/3.0, 2.0/3.0, 4.0/3.0, 1.0/3.0},
X[2] = {1.0, 2.0}, // starting and end pointsh = (X[1]-X[0])/N; // size of one segment
Quadrature qp(c, X[0], X[1], N); // domain [a, b], 11 integration points// THE INTEGRATIONH0 x(qp);C0 area = (x.pow(2) - 2 * x + 1) | J(h); // = 1/3cout
Variational Methods Using H0, H1, and H2 Type Objects
168 W
Chapter 3
f() = 0 + 1 + 22 + 33 Eq. 36where i are the coefficients for the cubic function f(). First we normalize the integration domain to [-1, 1], andassume that the integration points are spaced symmetrically and weighted equally. Therefore, W0 = W1 and 0 =-1. Integration of Eq. 36 at the interval of [-1, 1] gives
The tw
From th
For arbintegrabe founized intfunctio
where
We notas theyThen, w
1. A.H.orkbook of Applications in VectorSpace C++ Library
= 2 0 + 2 Eq. 37
o-point Gaussian quadrature wieghting coefficients Wi at integration points i gives (with i = 0, 1)
W0f(0) + W1f(1) =W0(f(1) + f(1)) = 2W0 ( 0 + 2 12) Eq. 38
e right-hand-sides of both Eq. 37 and Eq. 36, we have
2 0 + 2 = 2W0 ( 0 + 2 12) Eq. 39
itary values of 0 and 2 Eq. 39 must always hold. Therefore, we obtain weightings W0 = W1 = 1, andtion point coordinates 0 = - 1 = -1 / . Tabulated values of Wi and i with more integration points cand in Stroud and Secrest1. Gaussian integration can be applied to integral domains other than the normal-erval [-1, 1]. For example, for an actual integration domain of [1, 2], we can define a linear interpolationn f(x) = f(), with the natural coordinate (Gaussian integration domain in [-1, 1]), as
f() = (1-) f(x0) + (1+) f(x1) Eq. 310
we can check f(1) = f(x0) and f(1) = f(x1). We can also define a similar linear coordinate transformation
x() = (1-) x0 + (1+) x1 Eq. 311
e that the forms of the interpolation function and the coordinate transformation do not have to be the same are in this example. Again, we can check at the starting point x(1) = x0, and at the end point x(1) = x1.ithout loss of generality for a multi-dimensional case, we write
Eq. 312
Stroud and D. Secrest, 1966, Gaussian quadrature formulas, Prentice-Hall, Englewood Cliffs, N.J.
f ( ) d1
1 23---
f ( ) d1
1
23---
3
12---
12---
12---
12---
f x( ) xd f x( )det x------ d
f x( )J Wif xi( )Jii 0=
N
d
=
H0 Type Objectswhere is the integration domain, and is the normalized integration domain. Define J = x/ as the Jaco-bian matrix, and J = det J =det ( x/ ) is the Jacobian. In an one-dimensional case, if the coordinate transforma-tion rule x() is chosen to be linear such as Eq. 310, Ji = dx/d = (x1-x0)/2 equal the same constant.Comparing Eq. 312 with Eq. 34, we find that (1) the constant Ji is in place of segment size h, (2) thewieghting coefficients Wi is in place of the coefficients ci and (3) the integration point coordinates in Eq. 312 isnow taThe int
using linear
The Gaorder ature aretion polinear tintegration is stant va
Weing of aH0 typobjectsIntegraIntegracounter
3.1.2An
and a p
Workbook of Applications in VectorSpace C++ Library 169
king from tabulated numbers instead of simply computed from a equally spaced formula of xi = x0 + i h.egration problem in Eq. 35,
Gauss quadrature, can be re-written in C++ with VectorSpace C++ Library as (project:_coordinate_transformation)
double X[2] = {1.0, 2.0}; // integration domain [1, 2]Quadrature qp(1, 2); // one dimension, 2 integration pointsH0 z(qp), // natural coordinate
x = (1-z) /2*X[0] + (1+z)/2 * X[1]; // x() = (1/2)(1-) x0 + (1/2)(1+) x1 J omega((X[1]-X[0])/2); // J = dx/d = (x1-x0)/2 C0 area = (x-1).pow(2) | omega; // Eq. 35; analytical value = 1/3cout
Variational Methods Using H0, H1, and H2 Type Objects
170 W
Chapter 3
mathematics and to encapsulate the details of low-level memory management. The pointer array of C0, u, isreferring to double *v.
ConstTw
page 16ial examform of
where
where gature (osatisfie= , g(source
ditions
Therefo
1. p. 42
Integrable_Scalar Object Quadrature Point Values Physical Memoryorkbook of Applications in VectorSpace C++ Library
ructorso examples of using variable dedicated constructor for H0 type Integrable_Scalar have been shown on7 and page 169 for Simpsons rule and Gaussian quadrature, respectively. We show a few more non-triv-ples, in the followings. Consider a diffusion problem, e.g., heat conduction or chemical diffusion, in the
a differential equation1
, with Eq. 313
f(x) is the source term. The solution to Eq. 313 can be expressed in integral form as
Eq. 314
(x, ) is Greens function. The physical interpretation of the Greens function is that g(x, ) is the temper-r concentration) sampling at x when a unit concentrated point source is located at . Therefore, g(x, )
s Eq. 313; i.e., with g(x, ) in place of u(x) in the differential equation. We also require, at the location xx, ) to be continuous. And the net flux of the infinitesimal control line segment at x = equals to theintensity; i.e., g(+, ) - g(-, ) = -1, which is also known as the jump condition. From the above con-, the Greens function can be solved as
Eq. 315
re, Eq. 314 can be re-written as
Eq. 316
in I. Stakgold, 1979, Greens function and boundary value problems, John Wiley & Sons, New York.
x C0* of Scalaru double*vTABLE 3.1 Dual abstraction of an Integrable_Scalar.
d2ux2d
-------- f x( )= 0 x 1 u 0( ),< < u 1( ), = =
u x( ) g x ,( )f ( )d 1 x( ) x+ +0
1=
g x ,( ) x 1 ( ) 0 x <
H0 Type Objectswhere at interval [0, x] of the integration domain < x, so the second line of Eq. 315 is applicable, and at theinterval [x, 1] of the integration domain, x < , the first line of Eq. 315 is applicable .
For a specific case with source distribution as f(x) = sin (pix), and homogeneous boundary conditions = =0, we can compute ten point values of the solution u(x) at interval of h = 0.1. Program Listing 31 implementedthe sol 2sin(pix)sixth d
#include int main()
doubdoubdoub
w
for(inQH
Cififdco
if}retur
}
ListingWorkbook of Applications in VectorSpace C++ Library 171
ution using Eq. 316. The analytical solution corresponding to this source distribution is u = - (1/ pi ), which is used to compare with the computed result of the integral equation. They only differs after theigit after the decimal point ( see TABLE 3.2.)
x - (1/ pi2) sin(pix) Program Listing 310.0 0.000000 0.0000000.1 0.031310 0.0313110.2 0.059555 0.0595550.3 0.081971 0.0819700.4 0.096362 0.0963610.5 0.101321 0.1013200.6 0.096362 0.0963610.7 0.081971 0.0819700.8 0.059555 0.059555
TABLE 3.2. Comparison of analytical solution and the result computed from integral expression Eq. 316.
include/vs.h {le const PI = 3.141592654;le const alpha = 0.0; double const beta = 0.0;le x = 0.0,[11] = {1.0/3.0, 4.0/3.0, 2.0/3.0, 4.0/3.0, 2.0/3.0, 4.0/3.0, 2.0/3.0, 4.0/3.0, 2.0/3.0,
4.0/3.0, 1.0/3.0}; t i = 0; i < 11; i++) {uadrature q1(w, 0.0, x, 11), q2(w, x, 1.0, 11);0 z1(q1), z2(q2),
f_1 = sin(PI*z1), f_2 = sin(PI*z2); 0 integ_1, integ_2;(i !=0) integ_1 &= (1-x)*( (z1*f_1) | J(x/10.0); else integ_1 &= C0(0.0);(i !=10) integ_2 &= x*( ((1-z2)*f_2) | J((1-x)/10.0); else integ_2 &= C0(0.0);ouble u = (double)(integ_1+integ_2) + (1-x)*alpha+x*beta;ut
Variational Methods Using H0, H1, and H2 Type Objects
172 W
Chapter 3
Forfusion
The sol
The Gk()[g
Substit
The
Programmodificsolutio320 artions arwhile texampl
0.9 0.031310 0.0313111.0 0.000000 0.000000
x - (1/ pi2) sin(pix) Program Listing 31
TABLE 3.2. Comparison of analytical solution and the orkbook of Applications in VectorSpace C++ Library
heat conduction or chemical diffusion problem as shown in Eq. 313, the thermal diffusivity (or the dif-coefficient) can be a function of positions (x). We may have a slightly different problem as
Eq. 317
ution can be expressed in integral form as
Eq. 318
reens function should satisfy Eq. 317 and should be continuous at x = . The jump condition is(+,)-g(-, )] = -1. These conditions lead to the Greens function for this problem as
Eq. 319
uting Eq. 319 into Eq. 318, with the case of k(x) = (1+x), and f(x) = x, gives
Eq. 320
exact solution for this case is
uexact = -x2/4 +x/2 Eq. 321
Listing 32 implements Eq. 320, which are codes from the Program Listing 31 with only very slightations. The results of Program Listing 32 are listed in TABLE 3.2. for comparison with the analytical
n. Only last three points in the interval of [0.8, 1.0] has 1.e-6 in error. We emphasize that Eq. 316 and Eq.e much more complicated than that of the corresponding analytical solutions. However, analytical solu-e only possible when the given f(x) and k(x) happen to give an analytical solvable differential equations,he Greens function method is quite general for less restricted forms of f(x) and k(x). This concludes thee for the Integrable_Scalar object of H0 type.
result computed from integral expression Eq. 316.
ddx------ k x( )
dudx------ f x( ) 0 x 1 u 0( );<
H0 Type Objects
#include include/vs.h int main() {
double x = 0.0,w[11] = {1.0/3.0, 4.0/3.0, 2.0/3.0, 4.0/3.0, 2.0/3.0, 4.0/3.0, 2.0/3.0, 4.0/3.0, 2.0/3.0,
4.0/3.0, 1.0/3.0}; for(int i = 0; i < 11; i++) {
QHCififdco
if}retur
}
extended Simpsons rule
ListinggreenWorkbook of Applications in VectorSpace C++ Library 173
x -x2/4 +x/2 Program Listing 320.0 0.000000 0.0000000.1 0.047500 0.0475000.2 0.090000 0.0900000.3 0.127500 0.1275000.4 0.160000 0.1600000.5 0.187500 0.1875000.6 0.210000 0.2100000.7 0.227500 0.2275000.8 0.240000 0.2400010.9 0.247500 0.2475011.0 0.250000 0.250001
TABLE 3.3. Comparison of analytical solution and the result computed from integral expression Eq. 320.
uadrature q1(w, 0.0, x, 11), q2(w, x, 1.0, 11);0 z1(q1), z2(q2); 0 integ_1, integ_2;(i !=0) integ_1 &= ( (z1*log(1+z1)) | J(x/10.0); else integ_1 &= C0(0.0);(i !=10) integ_2 &= log(1+x)*( z2 | J((1-x)/10.0); else integ_2 &= C0(0.0);ouble u = (double)(integ_1+integ_2) ;ut
Variational Methods Using H0, H1, and H2 Type Objects
174 W
Chapter 3
The constant strings used for the virtual constructors (for example, using macro definition H0 x =INTEGRABLE_SCALAR(const char*, ...)) and the autonomous virtual constructor (for example, using H0 x= H0(const char*, ...)) are shown in the following box.
OperaThe
operatoargumedinate returnsnate trastant Jaxstarting
Theoperatocommo
The sefriend fbox for
by
by
Strings orkbook of Applications in VectorSpace C++ Library
tors and Functions most important operator for the Integrable_Scalar object is the integration operator. The integrationr is H0::operator | (const J&) that takes a Jacobian class J(const H0&) or J(const double&) as itsnt. We notice that unless we have H1 type object capability we can not do the differentiation of the coor-transformation x() to construct the Jacobian class, such as J(d(x)), where x is an H1 object, and d(x) an H0 object that contains the derivative information of the x. For the time being, as long as the coordi-nsformation x() is chosen to be linear we can use J(const double& J) to define the corresponding con-cobian easily, where the single argument is a reference to a const double, and its value is J = (xend point -point)/2, as shown in the above example.
rest of the operators and functions are listed in the following box. They are mostly comformable to thers and functions of the Scalar object. Promotion of C0 type to H0 type object by binary operators is an practice just as in standard C++ language. For example,
H0 x;C0 y;H0 z1 = x+y; // invoke H0::operator +(const C0&);H0 z2 = y+z; // invoke H0s friend operator +(const C0&, const H0&)
cond operator invoked, operator +(const C0&, const H0&) is a binary operator which is declared aunction (operator) to H0 class. These operators, needed for the promotion operation, are not listed in the simplicity.
virtual constructor string VectorSpace C++ library definition priority
referenceH0& H0 type Integrable_Scalar object 1H0* a pointer to H0 type Integrable_Scalar object 2double*, const Quadrature&, int, int 3
double pointer, Quadrature, m_row_size, m_col_size
valueconst Quadrature& Quadrature 4const H0& H0 type Integrable_Scalar object 5const H0* pointer to H0 type Integrable_Scalar object 6
in H0 virtual constructor for Integrable_Scalar object.
H0 Type Objects
Partial
operator or function VectorSpace C++ library definition remark
symbolic operatorsH0& operator &= ( ) assignment by reference
a
lo
fuWorkbook of Applications in VectorSpace C++ Library 175
listing of H0 type Integrable_Scalar class arithmetic operators, logic operators and functions.
H0& operator = ( ) assignment by valueH0 operator & ( ) const column concatenationH0 operator && () const one-by-one column concatenationH0 operator | ( ) const row concatenationH0 operator || () const one-by-one row concatenation
rithmatic operatorsH0 operator + ( ) const positive unaryH0 operator - ( ) const negative unaryH0 operator + (const H0&) const additionH0 operator - (const H0&) const subtractionH0 operator * (const H0&) const multiplicationH0 operator / (const H0&) const multiplicationH0& operator += (const H0&) replacement additionH0& operator -= (const H0&) replacement subtractionH0& operator *= (const H0&) replacement multiplicationH0& operator /= (const H0&) replacement division
gic operatorsint operator == (const H0&) const equal TRUE == 1int operator != (const H0&) const not equal FALSE == 0int operator >= (const H0&) const greater or equalint operator (const H0&) const greaterint operator < (const H0&) const less
nctionsH0 pow(int) const powerH0 sqrt(const C0&) const square rootH0 exp(const C0&) const exponentH0 log(const C0&) const logH0 sin(const C0&) const sinH0 cos(const C0&) const cos
Variational Methods Using H0, H1, and H2 Type Objects
176 W
Chapter 3
3.1.3 Integrable_Vector
ConstructorsA dedicated constructor of an Integrable_Vector, H0::H0(int, double*, const Quadrature&), contains a ref-
erence
of C0,
FollowIntegraH0::op
In this
We metype obintegra
i.e., x1 orkbook of Applications in VectorSpace C++ Library
to a Quadrature instance, and a pointer array of C0 *u. The dual abstraction is used. The pointer arrayu, is referring to a double *v.
ing is an example of an array of quadratic interpolation functions N constructed as an H0 typeble_Vector object. The access of each element of the Integrable_Vector is done by the selector,erator [](int) (see project: quadratic_coordinate_transformation).
double f(double x) { return (x-1)*(x-1); } // Quadrature qp(1, 2); // 1-dimension, 2-points Gaussian H0 z(qp), // natural coordinates
N(3, (double*)0, qp); // Integrable_Vector object of H0 typeN[0] = (z-1)*z/2.0; // N0 = (-1)/2N[1] = (1-z.pow(2)); // N1= 1-2 N[2] = (z+1)*z/2.0; // N2 = (+1)/2H0 y = N[0]*f(1.0)+N[1]*f(1.5)+N[2]*f(2.0); // y = Nifi C0 area = y | J(0.5); // H0::operator | (const J&)cout
H0 Type Objects
which used in
Weentiatiostant Ja
f
Assum1), and
1
f(x2) = 3
f(x3) = 2Workbook of Applications in VectorSpace C++ Library 177
is exactly the linear coordinate transformation rule of Eq. 311. Therefore, we have J = (2-1)/2 = 0.5 as the above example.
show an example of a 2-D problem using Gaussian quadrature. Again, without H1 type objects for differ-n operation, we restrict the integration domain to be a square or a rhombic region in order to have con-cobian everywhere. In this example, a set of bilinear interpolation functions are used
(, ) = (1)(1) f(x0) + (1+)(1) f(x1) + (1+)(1+) f(x2) + (1)(1+) f(x3) Eq. 323
ing a plane as shown in , f(x0) = 1, f(x1) = 2, f(x2) = 2, and f(x3) = 3, where x0 = (0, 0), x1 = (1, 0),x2 = (1, x3 = (0, 1). The constant Jacobian of the problem is J = 1/4, where the area of the referential domain
and , is 4. (in project: integration_2d).
double f[4] = {1.0, 2.0, 2.0, 3.0}; // f(xi) Quadrature qp(2, 4); // 2-D, and 2x2 (= 4) integration pointsH0 z(2, (double*)0, qp), zai, eta; // natural coordinateszai &= z[0], eta &= z[1]; // alias of elements in the Integrable_VectorC0 volume = ((1-zai)*(1-eta)/4 *f[0] // + (1+zai)*(1-eta)/4*f[1] +(1+zai)*(1+eta)/4*f[2] +(1-zai)*(1+eta)/4*f[3]) | J(0.25);cout
Variational Methods Using H0, H1, and H2 Type Objects
178 W
Chapter 3
The constant strings used for the virtual constructors (for example, using macro definition in H0 x =INTEGRABLE_VECTOR(const char*, ...)) and the autonomous virtual constructor (for example, using H0 x= H0(const char*, ...)) are shown in the following box.
OperaIn t
compoIntegraC0 typThey a
virtual constructor string VectorSpace C++ library definition priority
by
by
Strings orkbook of Applications in VectorSpace C++ Library
tors and Functionshe above example the integration operator is applied on Integrable_Scalar objects of H0 type, which arenents of an Integrable_Vector object of H0 type. The integration operator can be applied to an H0 typeble_Vector object directly. However, the return value of the integration operator in this case is a Vector ofe instead of a Scalar of C0 type. The rest of the operators and functions are listed in the following box.re mostly conformable to the operators and functions of the Vector objects of C0 type.
referenceH0& H0 type Integrable_Vector H0* a pointer to H0 type Integrable_Vector int, double*, const Quadrature&, length, double* != 0, Quadrature 7 int, int m_row_size, m_col_size
valueint, const Quadrature& length, Quadrature 8const H0* H0* int, H0&, int, const Quadrature length, H0, starting index, Quadrature 9
(the only one for reference Integrable_Vector)in H0 virtual constructor for H0 type Integrable_Vector class.
H0 Type Objects
Partial l
operator or function VectorSpace C++ remark
symbolic operatorsH0& operator &= ( ) assignment by reference
ar
lo
fuWorkbook of Applications in VectorSpace C++ Library 179
isting of Integrable_Vector object arithmatic operators, logic operators and functions.
H0& operator = ( ) assignment by valueH0& operator [] (int) selector return scalarH0 operator & ( ) const column concatenationH0 operator && () const one-by-one column concatenationH0 operator | ( ) const row concatenation return matrixH0 operator || ( ) const one-by-one row concatenation return matrix
ithmetic operatorsH0 operator ~ ( ) const transposed (into a row vector) return matrixH0 operator + ( ) const positive (primary casting) unaryH0 operator - ( ) const negative unaryH0 operator + (const H0&) const additionH0 operator - (const H0&) const subtractionH0 operator * (const H0&) const multiplication by a scalar; scalar productof two vectorsH0 operator %(const H0&) const tensor product of two vectorsH0 operator / (const H0&) const division (by a scalar or a matrix only)H0& operator += (const H0&) replacement additionH0& operator -= (const H0&) replacement subtractionH0& operator *= (const H0&) replacement multiplication (by a scalar only)H0& operator /= (const H0&) replacement division (by a scalar only)
gic operatorsint operator == (const H0&) const equal TRUE == 1int operator != (const H0&) const not equal FALSE == 0int operator >= (const H0&) const greater or equalint operator (const H0&) const greaterint operator < (const H0&) const less
nctionsint length() const length of the Integrable_Vectordouble norm(int = 2) const 1-norm or 2-normdouble norm(const char*) const infinite-norm takes strings infinity, or maximumH0 pow(int) const power (applied to each element of the Integrable_Vector)H0 sqrt(const H0&) const square root(applied to each element of the Integrable_Vector)H0 exp(const H0&) const exponent (applied to each element of the Integrable_Vector)H0 log(const H0&) const log (applied to each element of the Integrable_Vector)H0 sin(const H0&) const sin (applied to each element of the Integrable_Vector)H0 cos(const H0&) const cos (applied to each element of the Integrable_Vector)
Variational Methods Using H0, H1, and H2 Type Objects
180 W
Chapter 3
3.1.4 Integrable_Matrix
ConstructorsA dedicated constructor of an Integrable_Matrix, H0::H0(int, int, double*, const Quadrature&), contains a
referenabstrac
A spage 25Integraduced l
TheINTEG= H0(c
by
by
Strings orkbook of Applications in VectorSpace C++ Library
ce to a Quadrature instance, and a pointer array of C0 *u (pointer to C0 type Matrix object). The dualtion is also used. The pointer array of C0, u, is referring to a double *v.
imple example of an Integrable_Matrix is the consistent mass matrix; e.g., M in Eq. 3217 on8, generated from the tensor product operation (using % in VectorSpace C++ Library ) of two
ble_Vector objects of H0 type. Integrable_Matrix is often encountered in variational calculus to be intro-ater in this Chapter.
constant strings used for the virtual constructors (for example, using macro definition in H0 x =RABLE_MATRIX(const char*, ...)) and the autonomous virtual constructor (for example, using H0 x
onst char*, ...)) are shown in the following box.
Integrable_Matrix Object Quadrature Point Values Physical Memoryx C0* of Matrixu double*v
TABLE 3.5. Dual abstraction of an Integrable_Matrix.
virtual constructor string VectorSpace C++ library definition priority
referenceH0& H0 type Matrix H0* a pointer to H0 type Matrix int, int, double*, row-length, column-length, double* != 0,
const Quadrature&, int, int memory-row-length, memory-column-length 10
valueint, int, double*, row-length, column-length, double* = 0,
const Quadrature&, int, int memory-row-length, memory-column-length 11int, int, const Quadrature& row-length, column-length 12int, int, const double*, row-length, column-length, double*, 13
const Quadrature&, int, int memory-row-length, memory-column-lengthint, int, H0&, int, int, row-length, column-length, H0&, 14
const Quadrature& starting row-index, starting column-index(the only one for reference Integrable_Matrix)
in H0 virtual constructor for H0 type Integrable_Matrix class.
H0 Type Objects
OperaThe
functio
3.1.5The
from thobject of C0 ttion oobjectstions ca
Partial l
operator or function VectorSpace C++ library definition remark
functionsH0 pow(int) const power (applied to each element of the Matrix)H0 sqrt(const H0&) const square root (applied to each element of the Matrix)
mWorkbook of Applications in VectorSpace C++ Library 181
tors and Functions operators and functions are listed in the above box. They are mostly conformable to the operators andns of the Matrix object of C0 type.
Utility Integrable ObjectsIntegrable_Subvector and Integrable_Submatrix Integrable_Subvector and the Integrable_Submatrix objects of H0 type are straight-forward extensionse Subvector and Submatrix objects of C0 type. However, it is not necessary to have Integrable_Basis
of H0 type. We can simply use primary integrable objects in Sections 3.1.2 to 3.1.4 with the Basis objectype to make Integrable_Subvector or Integrable_Submatrix objects. In Fourth-order Differential Equa-n page 205, many examples of alternative but equivalent approaches of using different utility integrable are shown. With these flexible utility integrable objects, the C++ code of the mathematical implementa-n be made to look much closer to the mathematical expressions we find in the mathematics literature.
isting of H0 type Integrable_Matrix class arithmetic operators, logic operators and functions.
H0 exp(const H0&) const exponent (applied to each element of the Matrix)H0 log(const H0&) const log (applied to each element of the Matrix))H0 sin(const H0&) const sin (applied to each element of the Matrix)H0 cos(const H0&) const cos (applied to each element of the Matrix
atrix algebra fucntionsint rank() const rank of a MatrixH0 identity() const identity MatrixH0 cond() const condition number of a MatrixH0 inverse() const inverse of a MatrixH0 det() const determinant of a Matrix
Variational Methods Using H0, H1, and H2 Type Objects
182 W
Chapter 3
Partial
operator or function VectorSpace C++ library definition remark
symbolic operatorsH0& operator &= ( ) assignment by referenceH0& operator = ( ) assignment by value
ar
m
lo
fuorkbook of Applications in VectorSpace C++ Library
listing of H0 type Integrable_Matrix class arithmetic operators, logic operators and functions.
H0& operator [ ] (int) row selectorH0& operator( )(int) column selectorH0& operator ( )(int, int) element selectorH0 operator & ( ) const column concatenationH0 operator && () const one-by-one column concatenationH0 operator | ( ) const row concatenationH0 operator || ( ) const one-by-one row concatenation
ithmetic operatorsH0 operator + ( ) const positive (primary casting) unaryH0 operator - ( ) const negative unaryH0 operator + (const C0&) const additionH0 operator - (const C0&) const subtractionH0 operator * (const C0&) const multiplicationH0 operator / (const C0&) const division (by Integrable_Scalar or Integrable_Matrix only)H0& operator += (const C0&) replacement additionH0& operator -= (const C0&) replacement subtractionH0& operator *= (const C0&) replacement multiplication (by an Integrable_Scalar only)H0& operator /= (const C0&) replacement division (by an Integrable_Scalar only)
atrix algebra operatorsH0 operator ~ ( ) const transposeH0 operator !( ) const matrix decomposition
gic operatorsint operator == (const H0&) const equal TRUE == 1int operator != (const H0&) const not equal FALSE == 0int operator >= (const H0&) const greater or equalint operator (const H0&) const greaterint operator < (const H0&) const less
nctionsint row_length() const row-length of the Integrable_Matrixint col_length() const column-length of the Integrable_MatrixH0 norm(in) const 1 (maximum column-sum)-norm or 2 (spectral)- normH0 norm(const char*) const infinity(max row-sum),Forbenisu(Forbenius-norm)
H1 Type and H2 Type Objects3.2 H1 Type and H2 Type Objects
We can consider H1 and H2 types as natural extensions of C1 and C2 types. That is the high-level dataabstraction in the dual abstraction of H1 and H2 type object is a pointer array to C1 and C2 type objects (i.e.,C1*, or C2*), and the length of the pointer array equals the number of quadrature points. The low-level dataabstracof tangefficienentitiesgents),
3.2.1Inte
integra
ConstThe
u[0]
u[1]
u[2]
C1 Workbook of Applications in VectorSpace C++ Library 183
tion is pointers to double (double*) to represent the memory space of the base point, tangent, and tangentent, in which the values of all quadrature points are connected together in a continuous memory space fort memory management. A cross-relation of the dual abstraction is shown in Figure 33. The high-level, in this case, three conceptually separate C1 type objects have their sub-entities (base points and tan- share the continuous memory spaces.
Integrable_Tangent_Bundle / Integrable_Vector_of_Tangent_Bundlegrable_Tangent_Bundle and Integrable_Vector_of_Tangent_Bundle are two H1 type objects that are theble extension of Tangent_Bundle and Vector_of_Tangent_Bundle objects of C1 type.
ructors dedicated constructors for an Integrable_Tangent_Bundle are
Figure 33 Cross relation by dual representation of an H1 type object.
basepoint tangent
double * v
quadraturepoint # 1
quadraturepoint # 2
quadraturepoint # 3
double* dv
(assume spatial dimension = 3)
*u;
quadraturepoint # 1quadraturepoint # 2quadraturepoint # 3
quadraturepoint # 1
quadraturepoint # 2
quadraturepoint # 3
C1( tangent bundle)*u double *v, *dvmathematical abstraction physical memory space
Variational Methods Using H0, H1, and H2 Type Objects
184 W
Chapter 3
H1::H1(const Quadrature&)H1::H1(double* v, const Quadrature&)H1::H1(double* v, int spatial_dimension, const Quadrature&)
The dedicated constructor for an Integrable_Vector_of_Tangent_Bundle is
For the
Thefollowiand the
respect
by
by
Strings orkbook of Applications in VectorSpace C++ Library
H1::H1(int vector_size, double* v, const Quadrature&)
dedicated constructor, the size of the vector equals the number of the spatial dimension.
constant strings used for the virtual constructors and autonomous virtual constructor are listed in theng two boxes. The macro defintions used for the virtual constructors of the Integrable_Tangent_Bundle Integrable_Vector_of_Tangent_Bundle are
H1 x = INTEGRABLE_TANGENT_BUNDLE(const char*, ...); H1 x = INTEGRABLE_VECTOR_OF_TANGENT_BUNDLE(const char*, ...);
ively. And, H1 x = H1(const char*, ...) is used for autonomous virtual constructors.
virtual constructor string VectorSpace C++ library definition priority
referenceH1& H1 type Matrix 1H1* a pointer to H1 type Matrix 2double*, double*, Quadrature v, dv, 7double*, double*, int, Quadraturev, dv, spatial dimension, 8
valueQuadrature, 3int, Quadrature memory-row-length, memory-column-length 4const double&, const double&, v, dv, (for spatial dimension = 1 only) 5 const Quadrature&const double*, const double*, v, dv, 6
int, Quadrature& spatial dimensionconst H0&, const H0& base point, tangent 9const H0*, const H0* base point, tangent 10const H1& Integrable_Tangent_Bundle 11const H1* Integrable_Tangent_Bundle* 12
in H1 virtual constructor for H1 type Integrable_Tangent_Bundle class.
H1 Type and H2 Type Objects
1-D Int
The sam
is used
On pagbian thIntegra
This nu
virtual constructor string VectorSpace C++ library definition priority
by referenceH1& H1 type Matrix
by
StringsWorkbook of Applications in VectorSpace C++ Library 185
egration: We seek the integration of the example shown on page 176. That is
Eq. 324
e quadratic coordinate tranformation rule
x() = (-1) x0 + (1-2) x1 + (+1) x2, and recall from Eq. 312 the 1-D version is
e 176 we restrict ourselves to have equal-spaced points of x0, x1, and x2, in order to have a constant Jaco-roughout the integration domain. Now Jacobian of the coordinate tranformation rule in this case is anble_Scalar of H0 type
Eq. 325
merical integration problem can be coded with VectorSpace C++ Library as (project: integration_1d)
double x[3] = {1.0, 1.5, 3.0}; // x=[1, 3], analytical value form Eq. 324 is 8/3Quadrature qp(1,3);
H1* a pointer to H1 type Matrix int, int, double*, double*, vector size, spatial dimension, v, dv, 14
Quadrature, int, int quadrature, memory row size, and column size value
int, int, Quadrature, vector size, spatial dimension 13const H0&, const H0& base point , tangent const H0*, const H0* base point, tangent int, const H1* vector size, Integrable_Tangent_Bundle* 15const H1& Integrable_Vector_of_Tangent_Bundle const H1* Integrable_Vector_of_Tangent_Bundle*
in H1 virtual constructor for H1 type Integrable_Vector_of_Tangent_Bundle class.
x 1( )2 xdx0
x2
x x2 x33-----+ x0
x2
=
12---
12---
f x( ) xd f x( )x------ d
f x( )J Wif xi( )Jii 0=
N
d
=
J dx ( )d--------------=
Variational Methods Using H0, H1, and H2 Type Objects
186 W
Chapter 3
H1 zai(qp), // Integrable_Tangent_BundleX = -(1-zai)*zai/2.0 * x[0]
+(1-zai)*(1+zai) * x[1]+zai*(1+zai)/2.0 * x[2];
C0 v = (((H0)X)-1).pow(2) | J(d(X)); //
Now thin the a
Line Inthe arcFigure
The va
The arc
by appmethod
x 1( )2 xd1
3 223---=
y = orkbook of Applications in VectorSpace C++ Library
cout
H1 Type and H2 Type ObjectsAn alternative approach is found in finite element method, which is also adopted by boundary element
method. A point in a curved element is represented by a position vector r ={x, y}T as shown in Figure 35. Weuse quadratic interpolation functions for coordinate transformation of the position vector, r, with three nodalcoordinates (x0, y0), (x1, y1), and (x2, y2).
where curve d
again, b
That is
This in
ProformatimethodWorkbook of Applications in VectorSpace C++ Library 187
x() = (-1) x0 + (1-2) x1 + (+1) x2
y() = (-1) y0 + (1-2) y1 + (+1) y2 Eq. 329
is the parameter for the coordinate transformation of x and y coordinates. An infinitesimal length of ther can be obtained as (see Figure 35)
Eq. 330
y applying pythagorean law. The integrand in Eq. 330 is
Eq. 331
the Euclidean norm of Jacobian of the coordinate transformation rule. Therefore, we have
Eq. 332
tegration formula is simply written consistent with the coordinate transformation method.gram Listing 33 implements the arc length method with Eq. 326 and Eq. 328, and the coordinate trans-on method with Eq. 329 and Eq. 330. The program computes the line integration using arc length, if the macro definition __ARC_LENGTH is defined at the compile time. Otherwise, the default
12---
12---
12---
12---
xr
xdr
Figure 35 Derivatives of the position vector r = {x, y}T .
dry
r yd
rd ddx
2
ddy
2+ d=
ddx
2
ddy
2+ d
dr2
J 2=
dr J 2d=
Variational Methods Using H0, H1, and H2 Type Objects
188 W
Chapter 3
method is the coordinate transformation method.
The function sqrt() is only defined for C0 and H0 types but can be extended easily for H1 type by an adhoc implementation of a free function sqrt(), which takes an Integrable_of_Tangent_Bundle of H1 type argu-ment. The virtual constructor of the Integrable_Tangent_Bundle uses macro definition as in
.
#include "#define N#if defineH1 sqrt(co
retur
}#endifint main()
constdoubfor(in
X#ifndef __
X#endif
}QuadH1 za
N
x,
N[0] C0 lefor(in
x
#if definey le
#elsey le
#endif}cout Eq. 394
Listing 315 implements the Green function defined in Eq. 394, the transverse loading f(x) is taken asant 1.0. The results of eleven-points values are shown in Figure 321 for compared with the exact solu-
g 1 ,( ) 1= g ,+( ) g ,( ) 1=
g g
include/vs.h") {le x = 0.0,t[17] = {14.0/45.0, 64.0/45.0, 24.0/45.0, 64.0/45.0, 28.0/45.0 64.0/45.0, 24.0/45.0,
64.0/45.0, 28.0/45.0, 64.0/45.0, 24.0/45.0, 64.0/45.0, 28.0/45.0, 64.0/45.0,24.0/45.0, 64.0/45.0, 14.0/45.0};
t i = 0; i < 11; i++) {uadrature q1(wt, 0.0, x, 17), q2(wt, x, 1.0, 17);ouble c = 1.0/2.0, B = -1.0/6.0;0 z1(q1), z2(q2);0 A = (1.0 + z2) / 2.0,
a = 1.0/2.0+1.0/2.0*z1.pow(2)-1.0/6.0*z1.pow(3),b = -1.0 - 1.0/2.0*z1.pow(2),
ntegrand1 = a + b*(1.0-x)+ c*pow((1.0-x), 2),ntegrand2 = A*pow(x, 2) + B*pow(x, 3);0 integal_1, integal_2;
f(i != 0) integal_1 &= integrand1 | J(x / 16.0); else integal_1 &= C0(0.0);f(i != 10) integal_2 &= integrand2 | J((1.0-x) / 16.0); else integal_2 &= C0(0.0);ouble w = (double) (integal_1 + integal_2);out
Variational Methods
0.5
0.6Workbook of Applications in VectorSpace C++ Library 221
0.2 0.4 0.6 0.8 1
0.1
0.2
0.3
0.4
Figure 321 Point-values are integral equation solution using the Green function compared with the curve of the exact solution.
w
Variational Methods Using H0, H1, and H2 Type Objects
222 W
Chapter 3
Poisson EquationThe two sub-sections on second-order differential equation and the fourth-order differential equation dis-
cussed above are ordinary differential equations with only one dimension. We now deal with the Poisson equa-tion which is a partial differetial equation with dimensions greater than one.
Conary con
Denotegrate o
The firn is theWe inv
The ma
where
Dirichl
Programthe 2-Dthroughorkbook of Applications in VectorSpace C++ Library
sider the Poisson equation defined in an unit square region with homogenous essential or natural bound-ditions
Eq. 395
the square region as and its boundary as . Multiply the left-hand-side with the variation v and inte-ver the square region .
Eq. 396
st identity uses the integration by parts and the second identity uses divergence theorem of Gauss, where surface unit normal vector. For homogeneous boundary conditions the boundary integral term vanishes.estigate three sets of boundary conditions
1. Dirichlet boundary conditions: u = 0 on all sides,2. Neumann boundary conditions: on all sides,3. Mixed boundary conditions: u = 0 on x0 = 1 and x1 = 1; on x0 = 0 and x1 = 0.
trix form for the Eq. 396 in this particular 2-D settings can be re-written as
Eq. 397
bi is the right-hand-side vector.
et Boundary Conditions : the basis functions to satisfy these conditions are
i = mn = sin((m+1)pix0) sin((n+1)pix1) ; m, n = 0, 2, ..., N-1, and i = m N + n. Eq. 398
Listing 316 implements Eq. 397 with basis functions in Eq. 398, where N = 3 and f = 1. Notice that integration are obtained by forming a 2-D array of weightings. The Jacobian of this problem is constantout the whole integration domain. Figure 322 shows the results obtained from Program Listing 316.
2 u f=
v2udV vu( ) v u[ ]dV
v udV vu nds
v udV
= = =
u n 0=u n 0=
Mi jix0
--------
jx0
--------
ix1
--------
jx1
--------+ dx0dx1 bi,0
1
0
1
ifdx0dx10
1
0
1
= =
Variational Methods
Neuma
For thisconsideditions
#include "include\vs.h"#define PI 3.141597int main() {
double f_0 = 1.0, weight[5][5],bode[5] = {14.0/45.0, 64.0/45.0, 24.0/45.0, 64.0/45.0, 14.0/45.0};
for(int i = 0; i < 5; i++)f
QuadJ d_aH1 x
for(if
H0 Mfor(i
MC0 M
bc
for(icout retur
}
ListingWorkbook of Applications in VectorSpace C++ Library 223
nn Boundary Conditions : the basis functions are
i = mn = cos(mpix0) cos(npix1) ; m, n = 0, 1, 2, ..., N-1, and i = m N + n Eq. 399
Neumann boundary condition to be solvable, f can not be a non-zero constant. On physical ground if wer the Poisson equation to be for the heat conduction problem, the homogeneous Neumann boundary con-
mean that the square region is to be insulated from its surroundings. The temperature in the region will
or(int j = 0; j < 5; j++) weight[i][j] = bode[i] * bode[j];rature qp(weight[0], 0.0, 1.0, 5, 0.0, 1.0, 5);(pow( (1.0/4.0), 2.0));(2, (double*)0, qp), phi = INTEGRABLE_VECTOR_OF_TANGENT_BUNDLE(
"int, int, Quadrature",9, 2, qp);nt m = 0; m < 3; m++)or(int n = 0; n < 3; n++) phi[m*3+n] = sin((m+1.0)*PI*x[0])*sin((n+1.0)*PI*x[1]);_diag(9, (double*)0, qp);
nt i = 0; i < 9; i++)_diag[i] = d(phi[i]).pow(2);
= M_diag | d_a, = ( ((H0)phi) * f_0 ) | d_a,(9, (double*)0);
nt i = 0; i < 9; i++) c[i] = b[i] / M[i];
Variational Methods Using H0, H1, and H2 Type Objects
224 W
Chapter 3
increase with time, since the internal source f is added to the region. For a steady state solution to be possiblewith totally insulated condition, we conclude that the N(A*) of the Laplace operator consists of constant func-tions (with the homogeneous Neuman boundary conditions.) Therefore, the solvability condition, from Eq. 350,requires the orthogonal relation which has the internal source to equal the internal sink; i.e.,
In this definiti
Mixed form
We choare sho
Green
1. Prob2nd eds
-
0
gorkbook of Applications in VectorSpace C++ Library
Eq. 3100
case, we choose f = cos pix which satisfies Eq. 3100. For the computation we only need to replace theon for i (N = 2) and the source term f = cos pix.
Boundary Conditions : We choose approximation basis functions to be algebraic polynomials of the
i = (1-x02+i) (1-x12+i); i = 0, 1, 2, ..., N-1 Eq. 3101
ose N = 2 and f = 1. The results of the Neumann boundary conditions and the mixed boundary conditionswn in Figure 323.
Function Method : The Green function for Eq. 395 with the Dirichlet boundary condtions is1
Eq. 3102
lem 9.3.9 in p. 147 of G.F. Carrier, and C.E. Pearson, 1988, Partial Differential Equations: Theory and technique ., Academic Press Inc., San Diego, CA.
f Vd 0=
00.2
0.40.6
0.81 0
0.2
0.4
0.6
0.8
1
0
0.1
0.2
0.3
00.2
0.40.6
0.81 0
0.2
0.4
0.6
0.8
1
0
.1
2
3
00.2
0.40.6
0.81 0
0.2
0.4
0.6
0.8
1
-0.10.05
0.050.1
00.2
0.40.6
0.81 0
0.2
0.4
0.6
0.8
1
.105051
Figure 323 Solutions of the Poisson equation with the Neumann and mixed boundary conditions.
Neumann boundary conditions, with f = cos pix Mixed boundary conditions, with f = 1.0
x y ,;,( ) 1npi npi( )sinh-------------------------------- npi( ) npix( ) npi 1 y +( )( )( ) npi 1 y ( )( )coshcosh{ }sinsin
n 1=
=
Variational MethodsProgram Listing 317 (project: green_poisson) is the code for Poisson equations with the Dirichlet boundaryconditions using the Green function (Eq. 3102). The computation approximates the infinite series only up to n =8. The results of this approximation are shown in Figure 324.
#include "include\vs.h"#define PI 3.141597H0 cosh(int main(
cons
bode66
for(if
QuadJ d_adoubH0 zfor(i
f
}c
}retur
}
ListingWorkbook of Applications in VectorSpace C++ Library 225
const H0& a) { return (exp(a)+exp(-a))/2.0; }) {t double f_0 = -1.0,[17] = {14.0/45.0, 64.0/45.0, 24.0/45.0, 64.0/45.0, 28.0/45.0, 64.0/45.0, 24.0/45.0, 4.0/45.0, 28.0/45.0, 64.0/45.0, 24.0/45.0, 64.0/45.0, 28.0/45.0, 64.0/45.0, 24.0/45.0, 4.0/45.0, 14.0/45.0}, weight[17][17];
nt i = 0; i < 17; i++)or(int j = 0; j < 17; j++) weight[i][j] = bode[i] * bode[j];rature qp(weight[0], 0.0, 1.0, 17, 0.0, 1.0, 17);(pow( (1.0/16.0), 2.0));le x0, x1;(2, (double*)0, qp), integrand(qp), zai, eta; zai &= z[0]; eta &= z[1];nt i = 0; i < 11; i++) {or(int j = 0; j < 11; j++) {
x0 = 0.1 * j; x1 = 0.1 * i;integrand = 0.0;for(int n = 1; n
Variational Methods Using H0, H1, and H2 Type Objects
226 W
Chapter 3
3.3.2 Weighted-Residual MethodFor a linear differential equation Au = f, with a self-adjoint operator A, the approximated solution uN is
Eq. 3103
where residua
The resvalue t
where approxual me
Point-The
is
For a fu
Therefocollocaresidua
Con
1. p. 14tions in
u uN cii+=orkbook of Applications in VectorSpace C++ Library
is set to the essential boundary conditions of u, and is homogenous on the boundaries. Define thel RN of the approximated solution as
Eq. 3104
idual can be distributed in an over-all manner through-out the whole domain, and then set the integratedo be zero, such as
Eq. 3105
w is the weighting function. Different ways of defining the weighting function lead to different types ofimation methods. The general class of methods in the form of Eq. 3105 is known as the weighted-resid-thods.
Collocation Method weighting function of the point-collocation method can be expressed using the Dirac delta function that
w = (x-) Eq. 3106nction f(x), we have
Eq. 3107
re, substituting Eq. 3106 into Eq. 3105 gives RN() = 0. What we have to do is simply pick a number oftion points i , evaluate their corresponding residuals, and obtain a system of equations by setting thesel equations to zero.
sidering the example1
Eq. 3108
and on in C.A. Brebbia, J.C.F. Telles, and L.C. Wrobel, 1984, Boundary element techniques: Theory and applica-engineering, Springer-Verlag, Berlin, Germany.
N
i
RN AuN f=
w RN,( ) wRN d 0= =
x ( )f x( ) xd f ( )=
x2
2
dd u
u x+ + 0 0 x 1<
Variational Methodssubject to boundary conditions u(0) = u(1) = 0. The exact solution to this problem is
Eq. 3109
Two teEq. 36
That isare take
We canhand, onumbeproject
For a VoperatiNominmated the exafrom th
uexactx( )sin1( )sin--------------- x=Workbook of Applications in VectorSpace C++ Library 227
rm approixmation basis functions which satisfy this homogenous boundary condition can be taken from1 in page 204,
0 = x (1-x), and 1 = x2 (1-x)
u2 = c0 0 + c1 1. Two collocation points are necessary for solving the two unkown coefficients, and theyn at 0 = 1/4 and 1 = 3/4. These two points generate two residual equations in matrix form as
Eq. 3110
also write Eq. 3110 as M c = - b. This two-point collocation problem is simple enough to be solved byr you can code it with VectorSpace C++ Library, which has the advantage that it can be extended to higherr of basis functions and collocation points, and the matrix solution procedure becomes inevitable (see: point_collocation)
double x[2] = {0.25, 0.75}; // 0 = 1/4, 1 = 3/4C0 M(2, 2, (double*)0), b(2, x);for(int i = 0; i < 2; i++) {
C2 z(x[i]),phi = VECTOR_OF_TANGENT_OF_TANGENT_BUNDLE(int, int, 2, 1);
phi[0] = z*(1-z); phi[1] = z.pow(2)*(1-z); // 0 = x (1-x), 1 = x2 (1-x)M[i] = (+dd(phi))(0)+((C0)phi); // d2/dx2 +
}C0 c = -b / M;cout
Variational Methods Using H0, H1, and H2 Type Objects
228 W
Chapter 3
Wemethodfunctiosequtiv
where
Considnate traderivat
Notice point-crespect
This fin
Solution - Exact
0.
0.
0.
0.
0.
0.06
0.07
0.2 0.4 0.6 0.8 1orkbook of Applications in VectorSpace C++ Library
can investigate further on the relationships of the point-collocation method and the finite difference. Considering the domain (cell) has three equally spaced points xi-1, xi, and xi+1, the approximatingn u correspoinding to these three points are given as ui-1, ui, and ui+1. The value of u in between two con-e points can be interpolated with a set of quadratic interpolation functions as
u = ui-1 1 + ui 2 + ui+1 3 Eq. 3111
1 = (-1)/2, 2 = (1-) (1+), and 3 = (1+)/2, where -1 < < 1 Eq. 3112ering the cell length = 2h for the three equally spaced points, we have a constant Jacobian for the coordi-nsformation rule through-out the whole cell as d/dx = 1/h. With a point-collocation on = 0, the first
ive of u with respect to x is
du/ dx = (du/ d) (d/dx) = [(-1/2)ui-1 + 2ui + (+1/2)ui+1] = (ui+1-ui-1) Eq. 3113
that the point-collocation is taken at = 0. Eq. 3113 is the central difference formula. We can check thatollocation at = -1/2 and = 1/2 will yield the backward difference and the forward difference formula,ively. The second derivative of u can be derived accordingly as
d2u/ dx2 = (d2u/ d2) (d/dx)2 = (ui-1-2 ui + ui+1) Eq. 3114
ite difference formula for the second derivative is independent of ; i.e., the position of collocation point.
Figure 325 Two-points collocation solution and error comparing to the exact solution.
0.2 0.4 0.6 0.8 1
01
02
03
04
05
-0.0008
-0.0006
-0.0004
-0.0002
1h--- 0=
12h------
1h2-----
Variational MethodsSubdomain-Collocation Method
The weighting function for the subdomain-collocation method is taken as a step function defined, for exam-ple, as
where x
That ising fun
The suEq. 31
Conmains
The co
Workbook of Applications in VectorSpace C++ Library 229
Eq. 3115
, 1, and 2 can be all defined in the interval of (-1, 1). For a function f(x), we have
Eq. 3116
the domain of integration is now restricted to the subdomain bounded by [1, 2]. Substituting the weight-ction of Eq. 3115 in the weighted-residual statement of Eq. 3105 gives
Eq. 3117
bdomain-collocation method evaluates a number of subdomains bounded by different sets of [1, 2] in17, for solving the coefficient vector c.
sidering the same example in the point-collocation case with the same basis functions and two subdo-1 = (-1, 0), and 2 = (0, 1), we then have
Eq. 3118
de which implements Eq. 3118 with VectorSpace C++ Library is (project: subdomain_collocation)
double x[2][2] = {{-1.0, 0.0}, {0.0, 1.0}}, // 1 =(-1,0), 2 = (0, 1)w[5] = {14.0/45.0, 64.0/45.0, 24.0/45.0, 64.0/45.0, 14.0/45.0}; // Bodes integration rule
C0 M(2, 2, (double*)0), b(2, (double*)0);for(int i = 0; i < 2; i++) {
Quadrature qp(w, x[i][0], x[i][1], 5); // Quadrautre in subdomain iJ d_l((x[i][1]-x[i][0])/4.0);
w1 1 x 2<
Variational Methods Using H0, H1, and H2 Type Objects
230 W
Chapter 3
H2 z(qp),phi = INTEGRABLE_VECTOR_OF_TANGENT_OF_TANGENT_BUNDLE(
int, int, Quadrature, 2, 1, qp);phi[0] = z*(1-z); phi[1] = z.pow(2)*(1-z); // 0 = x (1-x), 1 = x2 (1-x)M[i] = (+dd(phi))(0)+((H0)phi) | d_l; // d2/dx2 +
The coin Figu
We
This giforward
MethoIn s
a distridata withe dist
Forpower
0
0
0
0
0
0
0
dd
12---
12---
orkbook of Applications in VectorSpace C++ Library
b[i] = - ((H0)z) | d_l;}C0 c = b / M;cout
Variational Methods
wi = xi, i = 0, 1, 2, .... Eq. 3120
That is the residuals (or errors) are distributed through-out the domain with various moments of x. We notice thatthe weighting function for the weighted residual method in general is not necessarily required to satisfy thehomogeneous boundary conditions.
Contion 0
The co
The resWorkbook of Applications in VectorSpace C++ Library 231
sider the example in the point-collocation and subdomain collocation with the approximation basis func-= x (1-x), and 1 = x2 (1-x). We use first two weighting moments w0 = 1 and w1 = x. This gives
Eq. 3121
de which implements Eq. 3121 with VectorSpace C++ Library is (project: method_of_moment)
double w[5] = {14.0/45.0, 64.0/45.0, 24.0/45.0, 64.0/45.0, 14.0/45.0}; // Bodes integration ruleC0 M(2, 2, (double*)0), b(2, (double*)0);Quadrature qp(w, 0.0, 1.0, 5);J d_l(1.0/4.0);for(int i = 0; i < 2; i++) {
H2 x(qp),phi = INTEGRABLE_VECTOR_OF_TANGENT_OF_TANGENT_BUNDLE(
int, int, Quadrature, 2, 1, qp);phi[0] = x*(1-x); phi[1] = x.pow(2)*(1-x); // 0 = x (1-x), 1 = x2 (1-x)M[i] = (((H0)x).pow(i)*(+dd(phi))(0)+((H0)phi)) | d_l; // d2/dx2 + b[i] = - ((H0)x).pow(i+1) | d_l;
}C0 c = b / M;cout
Variational Methods Using H0, H1, and H2 Type Objects
232 W
Chapter 3
Galerkin Method: Bubnov-Galerkin / Petrov-Galerkin Methods and Weak FormulationWe have chosen the weighting functions to be a Dirac delta function in point-collocation, a step function in
subdomain collocation, and a set of power of coordinate x for the method of moment. In Galerkin method theweighting functions are simply the same as the approximation basis functions.That is
Consid
For two
The co
The resing funsymmeorkbook of Applications in VectorSpace C++ Library
wi = i = x(i+1) (1-x), i = 0, 1, 2, ... Eq. 3122
er the same example we solved starting from the point-collocation method in the above. We have
Eq. 3123
term approximation (i = 0, 1), the matrix form can be written as
Eq. 3124
de implements Eq. 3124 with VectorSpace C++ Library as (project: galerkin_method)
double w[5] = {14.0/45.0, 64.0/45.0, 24.0/45.0, 64.0/45.0, 14.0/45.0}; // Bodes integration ruleC0 M(2, 2, (double*)0), b(2, (double*)0);Quadrature qp(w, 0.0, 1.0, 5);J d_l(1.0/4.0);for(int i = 0; i < 2; i++) {
H2 x(qp),phi = INTEGRABLE_VECTOR_OF_TANGENT_OF_TANGENT_BUNDLE(
int, int, Quadrature, 2, 1, qp);phi[0] = x*(1-x); phi[1] = x.pow(2)*(1-x); // 0 = x (1-x), 1 = x2 (1-x)M[i] = (((H0)phi)[i]*(+dd(phi))(0)+((H0)phi)) | d_l; // d2/dx2 + b[i] = - (((H0)phi)[i]*((H0)x)) | d_l;
}C0 c = b / M;cout
Variational Methods
Forwith ho
where aweak fotor, theas the P
A s
with hoin pola
The ap
For the
1. p. 29
Error
0
0
0
0.08
0.1
0.12
0.14
0.04
0.06
0.08Workbook of Applications in VectorSpace C++ Library 233
a positive definite operator A = (T*) T, where T* is the self-adjoint of T (i.e., T*=T), the Galerkin methodmogeneous boundary conditions gives
(Ai, j) = (Ti, Tj) = a(i, j) Eq. 3125= (
i, A j ) Eq. 3126
( . , . ) is a bilinear form which is symmetrical. Therefore, A is self-adjoint ( Eq. 3126), and the resultantrmulation with the Galerkin weighting is symmetrical (Eq. 3125). In the case of the self-adjoint opera-
Galerkin method with wi = i is also known as the Bubnov-Galerkin method. When wi i , it is knownetrov-Galerkin method
econd example is the eigenvalue problem of a circular membrance of radius a given by1
Eq. 3127
mogeneous essential boundary conditions. This axisymmetric problem can be reduced to a 1-D problemr coordinate r as
Eq. 3128
proximation basis functions which satisfy the homogeneous boundary conditions are
Eq. 3129
Galerkin method with wi = i, we have
2 in J.N. Reddy, 1986, Applied functional analysis and variational methods in engineering, McGraw-Hill, Inc.
Figure 328 Galerkin method solution and its error.
0.2 0.4 0.6 0.8 1
.02
.04
.06
0.2 0.4 0.6 0.8 1
0.02
u2 u=
1r---
rdd
rrd
du u=
i 2 i 1+( )pir2a------ i,cos 0 1 2 N 1, , , ,= =
Variational Methods Using H0, H1, and H2 Type Objects
234 W
Chapter 3
Eq. 3130
Therefore,
We hav
We solthe Laperrors fing As
HowevTherefohand-si
Programto solv
Thetion of
i1r---
rdd
rrd
dj
2pirdr( )cj0
a
ij 2pirdr( )cj0
a
=orkbook of Applications in VectorSpace C++ Library
Eq. 3131
e a generalized eigenvalue problem of the form
Ax = B x Eq. 3132
ve Eq. 3131 for N = 2 and a = 1. First, we notice that the off-diagonals of A is analytically identical sincelace operator is self-adjoint. However, numerically, the off-diagonals of A can be slightly different due torom numerical integration. We can either ignore such differences or symmetrize A numerically by defin-= (A+AT)/2. Now we can solve the generalized eigenvalue problem by using the inverse of B as
B -1Asx = x Eq. 3133
er, (B -1As) will not be symmetrical. We can not use a symmetrical eigenvalue solver for this problem.re, we first use Cholesky decomposition for the symmetrical matrix B = LLT. The symmetry of the left-de can now be preserved by pre-multipling L -1 and post-multipling (L-1)T on Eq. 3132 to give
(L -1) As ((L-1)T) x = x Eq. 3134
Listing 318 implements the Galerkin method with Laplace operator in Eq. 3131, and using Eq. 3134e the symmetric eigenvalue problem.
results are shown in Figure 329. The surface graphs represent the modes from eigenvectors as a func-vi j j, where vi is the i-th eigenvector. The frequencies i are computed from eigenvalues i as
i rddj
ri r22
dd j
dr0
a
cj ijrdr
0
a
cj=
i i=
Variational Methods
#include "include\vs.h"#define PI 3.141592654int main() {
double a_= 1.0,weight[25] = {14.0/45.0, 64.0/45.0, 24.0/45.0, 64.0/45.0, 28.0/45.0, 64.0/45.0, 24.0/45.0,
64.0/45.0, 28.0/45.0, 64.0/45.0, 24.0/45.0, 64.0/45.0, 28.0/45.0, 64.0/45.0,
QuadJ d_rH2 r(
p
phi[0H0 dfor(iC0 A
BC0 LCholfor(ifor(i
ife
C0 LClav
cout cout retur
}
radius a = 1extended Bodes integration rule
ListingcirculWorkbook of Applications in VectorSpace C++ Library 235
24.0/45.0, 64.0/45.0, 28.0/45.0, 64.0/45.0, 24.0/45.0, 64.0/45.0, 28.0/45.0,64.0/45.0, 24.0/45.0, 64.0/45.0, 14.0/45.0};
rature qp(weight, 0.0, a_, 25);(a_/24.0);(double*)0, qp),hi = INTEGRABLE_VECTOR_OF_TANGENT_OF_TANGENT_BUNDLE(
"int, int, Quadrature", 3, 1, qp);] = cos((PI/2.0/a_)*r); phi[1] = cos((3.0*PI/2.0/a_)*r); phi[2] = cos(5.0*PI/2.0/a_*r);2_phi = INTEGRABLE_VECTOR("int, Quadrature", 3, qp);nt i = 0; i < 3; i++) d2_phi[i] = dd(phi)(i)[0][0]; = -( ( d(phi)(0)%((H0)phi) + d2_phi%((H0)phi)*((H0)r) ) | d_r ), = ( ((H0)phi)%((H0)phi) * ((H0)r) ) | d_r; = MATRIX("int, int", 3, 3);esky Ch(B);nt i = 0; i < 3; i++)nt j = 0; j < 3; j++)(i >= j) L[i][j] = Ch.rep_ptr()[0][i*(1+i)/2+j];lse L[i][j] = 0.0;_inv = L.inverse(), = L_inv*((A+~A)/2.0*(~L_inv)),mbda = Eigen(C).Eigenvalues(), = Eigen(C).Eigenvectors();
Variational Methods Using H0, H1, and H2 Type Objects
236 W
Chapter 3
A third example is a non-linear differential equation1
Eq. 3135
The ex
This prthat
This is
Therefo
The wej , giv
where cof the n
An iter
1. p. 29
ux2
2
dd u
xddu
2+ 1 0 x 1 with u' 0( ),<
Variational Methods
Eq. 3142
where c k+1 k kThat is
where I
Programand its the inccompilbasis fu
Otherw
The reselabora
I cjk 1+( ) I cjk cjk+( ) I cjk( ) cI
cjk
cjk+ 0= =Workbook of Applications in VectorSpace C++ Library 237
j = cj + cj . The approximation in this equation is the Taylor expansion to the first-order derivatives. the increment of the solution cjk can be solved by
Eq. 3143
T the tangent of I(c) can be defined as
Eq. 3144
Listing 319 implements the three-parameters approximation of the weak formulation I(c) (Eq. 3141)tangent IT (Eq. 3144), then, uses the iterative alogrithm (Eq. 3143; i.e., Newtons method) to solve forrement of the Ritz coefficients c. The preprocessing macro __PETROV_GALERKIN, if defined ate time, the corresponding code segment implements the Petrov-Galerkin method with the approximationnctions for weighting as
Eq. 3145
ise, the Bubnov-Galerkin method is assumed and i = i. The approximated solution is
Eq. 3146
ults of the computation are shown in Figure 330. The data speak for themselve without the need for anytion.
cjk cI
ck
1I cjk( ) IT[ ] 1 I cjk( )= =
IT cI
cici xd
di j xddvN
xddj
vN 2+( )+ xd0
1
= =
i2i 1+
2--------------pi i,cos 0 1 2, ,= =
u wN 2+ c0 1 x( ) c1 1 x2
( ) c2 1 x3( ) 2+ + += =
Variational Methods Using H0, H1, and H2 Type Objects
238 W
Chapter 3
#include "include\vs.h"#define EPSILON 1.e-12int main() {
double weight[13] = {14.0/45.0, 64.0/45.0, 24.0/45.0, 64.0/45.0, 28.0/45.0, 64.0/45.0, 24.0/45.0, 64.0/45.0, 28.0/45.0, 64.0/45.0, 24.0/45.0, 64.0/45.0, 14.0/45.0};
QuadJ d_lH1 xphi =
phi[0#if define#define P
H1 p
psi[0]#else
H1 ppsi &
#endifC0 c(do {
} whicout retur
}
extended Bodes integration rule
Listing
uorkbook of Applications in VectorSpace C++ Library
rature qp(weight, 0.0, 1.0, 13);(1.0/12.0); (qp), INTEGRABLE_VECTOR_OF_TANGENT_BUNDLE(
"int, int, Quadrature", 3, 1, qp);] = 1.0-x; phi[1] = 1.0-x.pow(2); phi[2] = 1.0-x.pow(3);d(__PETROV_GALERKIN)I 3.141592654si = INTEGRABLE_VECTOR_OF_TANGENT_BUNDLE(
"int, int, Quadrature", 3, 1, qp); = cos(PI/2.0*x); psi[1] = cos(3.0*PI/2.0*x); psi[2] = cos(5.0*PI/2.0*x);
si;= phi;
3,(double*)0), delta_c(3,(double*)0);
H1 v = c * phi;C0 I = ( d(psi)(0) * ( ((H0)v)+sqrt(2.0) ) * d(v)[0] + ((H0)psi) ) | d_l, I_t = ( d(psi)(0) % (((H0)phi) * d(v)[0] + d(phi)(0) * ( ((H0)v)+sqrt(2.0) ) ) ) | d_l;delta_c = - I / I_t;c += delta_c;cout
Variational MethodsLeast Squares Method
The basic idea of the least squares method is introduced in Eq. 126 of Chapter 1 on page 35. The minimiza-tion of the squares of the residual norm is
The facstatemewith th
For a n
For the
and the
The sec
Programthe exax2), 1 parameshown main cment mWorkbook of Applications in VectorSpace C++ Library 239
Eq. 3147
tor 2 can be dropped since the equation equals zero. Comparing Eq. 3147 with the weighted-residualnt it shows that the least squares method is a special case of the weighted-residual method
e weighting function w as
Eq. 3148
on-linear problem, we define
Eq. 3149
non-linear problem in the last section,
Eq. 3150
first derivatives of RN is
Eq. 3151
ond derivatives is
Eq. 3152
Listing 320 implements Eq. 3149 to Eq. 3152, with three-parameter approximation. Considering thatct solution of the problem is an even function we assume the approximation basis functions are 0 = (1-= (1-x4), and 2 = (1-x6). This set of approximation basis functions are as accurate as if we had used six-ter approximation with continuous power of algebraic functions. The errors of this computation arein Figure 331. Before we proceed any further, we notice that the combination of the concept of subdo-ollocation method and weak formulation with Galerkin method provides the foundations of the finite ele-ethod which we will discuss in details in Chapter 4 and Chapter 5.
RN 22
c------------------ 2 RNRNc----------, 0= =
RN w,( ) 0=
wRNc----------=
I c( ) RNRNc----------, and IT c
I
ci=,
RNc----------
RNc----------, RN
2RNc 2
-------------, += =
RN vN 2+( ) x22
dd vN
xddvN
2
1+=
RNc---------- x2
2
dd vN
x2
2
dd
vN 2+( ) 2 xdd
xddvN
+ +=
2RNc 2
------------- x2
2
dd
x2
2
dd 2
xdd
xdd+ +=
Variational Methods Using H0, H1, and H2 Type Objects
240 W
Chapter 3
#include "include\vs.h"#define EPSILON 1.e-12int main() {
double weight[13] = {14.0/45.0, 64.0/45.0, 24.0/45.0, 64.0/45.0, 28.0/45.0, 64.0/45.0, 24.0/45.0, 64.0/45.0, 28.0/45.0, 64.0/45.0, 24.0/45.0, 64.0/45.0, 14.0/45.0};
QuadJ d_lH2 x
phi[0H0 dfor(inC0 c(do {
} whicout retur
}
extended Bodes integration rule0 = (1-x2), 1 = (1-x4), and 2 = (1-x6)
2d vN dvN
2
Listingnonlinorkbook of Applications in VectorSpace C++ Library
rature qp(weight, 0.0, 1.0, 13);(1.0/12.0);((double*)0, qp),
phi = INTEGRABLE_VECTOR_OF_TANGENT_OF_TANGENT_BUNDLE("int, int, Quadrature", 3, 1, qp);
] = 1.0-x.pow(2); phi[1] = 1.0-x.pow(4); phi[2] = 1.0-x.pow(6);2_phi = INTEGRABLE_VECTOR("int, Quadrature", 3, qp);t i = 0; i < 3; i++) d2_phi[i] = dd(phi)(i)[0][0];3, (double*)0), delta_c(3, (double*)0);
H2 w = c * phi;H0 R = d(w)[0].pow(2)+(((H0)w)+sqrt(2.0))*dd(w)[0][0]-1.0,
dR = 2.0*d(phi)(0)*d(w)[0]+((H0)phi)*dd(w)[0][0]+d2_phi*(((H0)w)+sqrt(2.0)),ddR = 2.0*(d(phi)(0)%d(phi)(0))+((H0)phi)%d2_phi+d2_phi%((H0)phi);
C0 I = ( dR*R ) | d_l, I_t = ( dR%dR+ddR*R ) | d_l;delta_c = -I /I_t;c += delta_c;cout
Variational Methods3.3.3 Boundary Solution Methods
Consider the residual of the Poisson equation as in Eq. 395; i.e., , in the context of theweighted-residual statement,
Eq. 3153
If we inas
when tis equivlation) 3154 iand intgral,ag
An altetify, dir
TrefftIn T
tions sa
(i.e., f =
Con
1. p. 45N.J.2. p. 38enginee
RN 2u f+=
RN w,( ) RNw d 2u f+( )w d 0= = =Workbook of Applications in VectorSpace C++ Library 241
tegrate by part once, and apply Greens theorem to transform the volume integral to the surface integral
Eq. 3154
he approximation basis functions for u and w are the same the first term in the left-hand-side of Eq. 3154alent to the corresponding term in the Bubnov-Galerkin method for a self-adjoint operator (weak formu-
discussed in Eq. 3125. When the right-hand-side of Eq. 3154 is included in the variational statment, Eq.s also equivalent to the corresponding term in the Rayleigh-Ritz method in Eq. 353. Taking Eq. 3154egrating by parts once more, and applying Greens theorem to transform volume integral to surface inte-ain, we have
Eq. 3155
rnative view to the weighted-residual derivation from Eq. 3153 is possible. By setting f = - , we iden-ectly, Eq. 3154 as Greens first identity, and Eq. 3155 as Greens second identity.1
z Methodrefftz method, both u and w in Eq. 3155 are taken as harmonic functions. By definition, harmonic founc-tisfy the Laplace operator
Eq. 3156
0). We obtain the boundary integral equation as
Eq. 3157
sidering the Poisson equation2
0 in L.E. Malvern, 1969, Introduction to the mechanics of a continuous medium, Prentice-Hall, Englewood Cliffs,
in C.A. Brebbia, J.C.F. Telles, and L.C. Wrobel, 1984, Boundary element Techniques: Theory and applications in ring, Springer-Verlag, Berlin, Germany.
u w f+ w d n u( )w d
=
2w( )u fw+( ) d n w( )u d
n u( )w d
=
2u
2u 2w 0= =
n w( )u d n u( )w d
=
Variational Methods Using H0, H1, and H2 Type Objects
242 W
Chapter 3
Eq. 3158
with u = 0 at x = , and y = . It can be transformed into a Laplace equation with
2 2
where
with v w in Eside of at x = 1
Substit
Eq. 31
Due tomonic tives in
2u f=
1 1
f---orkbook of Applications in VectorSpace C++ Library
u = (x +y ) + v Eq. 3159
v is approximated by a subset of algebraic harmonic basis functions
H0 = 1.0,H1 = (x2-y2).H2 = (x4 - 6x2y2 + y4),H3 = (x6-15x4y2+15x2y4-y6),H4 = (x8 - 28 x6y2 + 70 x4y4 -28 x2y6 + y8),... etc.,
= ci i and v v = (x2+y2) f /4, at the boundaries x = , and y = . Then, v is taken in place of u andq. 3157. For this problem ; i.e., total flux vanish on the boundaries, the right-hand-Eq. 3157 equals zero. Considering the symmetry of the problem, we only need to compute the boundary, and 0 < y < 1.
Eq. 3160
uting v = ci i into Eq. 3160, we have
Eq. 3161
61 can be re-written in matrix form as M c = b where
Eq. 3162
the symmetry of the problem with respect to x and y, only H0, H2 and H4 out of the list of algebraic har-functions will be taken. In view of the problem at hand, H0 = 1.0 can not be in i, because the x-deriva- the matrix M and vector b are both zero. We can remedy this by taking only
1 = H2 = (x4 - 6x2y2 + y4) and 2 = H4 = (x8 - 28 x6y2 + 70 x4y4 -28 x2y6 + y8) Eq. 3163
4
1 1q n u( ) 0=
vx-----v
x 1=yd
0
1
vx-----v x 1=
yd0
1
=
ix------- i
x 1=yd
0
1
c i x-------v x 1=
yd0
1
=
Mix------- i
x 1=y and b,d
0
1
i x-------v x 1=
yd0
1
= =
Variational Methodsv = c1 1 + c2 2 with u = -v + v + c0 where v = (x2+y2) f /4. Without the solution for a constant term, the bound-ary integral equation is indetermined up to the constant value c0. After we obtain c1 and c2, c0 can be computedby requiring
conside
Proputed fand y a
The masegmen
Thetion of almost
1 1Workbook of Applications in VectorSpace C++ Library 243
Eq. 3164
ring u = 0 at this boundary. That is
Eq. 3165
gram Listing 321 implements Eq. 3162 with basis functions Eq. 3163 and integrating constant c0 com-rom Eq. 3165. Alternatively we can use transcendental harmonic functions symmetrized with respect to xs
1 = cos(pix/2) cosh(piy/2) + cos(piy/2) cosh(pix/2), and 2 = cos(3pix/2) cosh(3piy/2) + cos(3piy/2) cosh(3pix/2)
cro definition __TRANSCENDENTAL, if defined at compile time, turns on the corresponding codets.
first quadrant solution of this problem is shown in Figure 332, which is directly comparable to the solu-the same problem shown in the right-hand side of Figure 323. Transcendental harmonic functions giveidentical results.
u yd0 0 v c11 c22 c0+ + +( )
x 1=yd
0= =
c0 v c11 c22+ +( )x 1=
yd0
1
=
00.2
0.40.6
0.81 0
0.2
0.4
0.6
0.8
1
0
0.1
0.2
0.3
00.2
0.40.6
0.81 0
0.2
0.4
0.6
0.8
1
0
.1
2
3
Figure 332 The first quadrant solution of the Poisson equation using the Trefftz method.
x
y
u
u = -v -0.0453175 H2+0.0013438 H4+0.29469
Variational Methods Using H0, H1, and H2 Type Objects
244 W
Chapter 3
#include "include\vs.h"int main() {const double f_ = 1.0; const double PI = 3.141592654;double weight[13] = {14.0/45.0, 64.0/45.0, 24.0/45.0, 64.0/45.0, 28.0/45.0, 64.0/45.0,
24.0/45.0, 64.0/45.0, 28.0/45.0, 64.0/45.0, 24.0/45.0, 64.0/45.0, 14.0/45.0};Quadrature qp(weight, 0.0, 1.0, 13);J d_lH1 X
ph
x,
((H0)H0 v
#if defineH1 cophi[0phi[1
#elsephi[0phi[1
#endifH0 dC0 M
b C0 c cout C0 c_cout retur
}
extended Bodes integration rule
Listingorkbook of Applications in VectorSpace C++ Library
(1.0/12.0); = INTEGRABLE_VECTOR_OF_TANGENT_BUNDLE(
"int, int, Quadrature", 2, 2, qp),i = INTEGRABLE_VECTOR_OF_TANGENT_BUNDLE(
"int, int, Quadrature", 2, 2, qp), y; x &= X[0]; y &= X[1];x) = 1.0; d(y) = 0.0;_bar = f_/4.0 *(((H0)x).pow(2)+((H0)y).pow(2));d(__TRANSCENDENTAL)sh(const H1& a) { return (exp(a)+exp(-a))/2.0; }
] = cos(PI/2.0*x)*cosh(PI/2.0*y) + cos(PI/2.0*y)*cosh(PI/2.0*x);] = cos(3.0*PI/2.0*x)*cosh(3.0*PI/2.0*y) + cos(3.0*PI/2.0*y)*cosh(3.0*PI/2.0*x);
] = x.pow(4) - 6.0*x.pow(2)*y.pow(2) + y.pow(4);] = x.pow(8) -28.0*x.pow(6)*y.pow(2)+70.0*x.pow(4)*y.pow(4)
-28.0*x.pow(2)*y.pow(6)+y.pow(8);
phi_dx = d(phi)(0); = dphi_dx % ((H0)phi) | d_l,= dphi_dx * v_bar | d_l;= b / M;
Variational MethodsBoundary Element Method
If we consider the Poisson equation and set f = - , Eq. 3155 becomes the Greens second identity
Eq. 3166
In the
bounda
where conduc
where have alconduc
For simrequirecession
This ca
where cgral eqas
2u
2w( )u 2u( ) w( ) d n w( )u d n u( )w d=
n uWorkbook of Applications in VectorSpace C++ Library 245
case of heat conduction, we use temperature T in place of u; therefore, we have the heat flow q =, the weighting function w is taken as the fundamental solution (Greens function) T* in the
ry element method, which satisfies
Eq. 3167
(x, ) is the Dirac delta function with x as the sampling point, as the point source location, and k is thetivity. In two-dimensional case, the solution is
Eq. 3168
k is the conductivity and r is the distance between x and ; i.e., . Weso taken the thickness of the medium as unity for simplicity. The heat flow q according to Fouriers law oftion is
Eq. 3169
plicity, we deal with problems without internal heat source; i.e., f = 0. When , domain integral isd. From programming point of view, the advantage of the boundary element method begins to make con- to the finite element method. Substituting Eq. 3168 and Eq. 3169 into Eq. 3166, we have
Eq. 3170
n be proved to be
Eq. 3171
= 1 if is inside , c = 0 if is outside , and c = 1/2 if is on a smooth boundary . The boundary inte-uation for the boundary element method is obtained by discretizing the boundary to boundary elements
u n=
2 T x ,( ) x ,( ) k--------------------=
T x ,( ) 12pik----------ln r( )=
r x ,( ) x0 0( )2 x1 1( )2+=
q k T 12pir2----------- x0 0( )e0 x1 1( )e1+[ ]= =
f 0
x ,( )k-------------------- T 0( )T d
d
n q k--------------- T n q( )T d
d
=
c T ( ) n q( )T d n q ( )T d
=
Variational Methods Using H0, H1, and H2 Type Objects
246 W
Chapter 3
Eq. 3172
where T and q can be either a variable or a specified boundary condition. For the matrix form representation ofEq. 31
Therefo
This caright onstant sh
where ables T3172, Eq. 31
where
and
1. p. 69enginee
c T ( ) n q( )e T x ,( ) de
e
Te n q x ,( )( ) de
e
=orkbook of Applications in VectorSpace C++ Library
72, we reserve T and q as the unknown and T and q as corresponding boundary conditions, and denote
Eq. 3173
re the matrix form of Eq. 3172 is
Eq. 3174
n be re-written as A x = b. Two singular integrations in Eq. 3174 occur, when the source location is the element under consideration; i.e., all diagonal terms on the left-hand-side. For an element with con-ape function, it can be proved that1
Eq. 3175
h is the size of the constant element with one variable node on the middle of the element. After the vari- and q are solved from Eq. 3174. The interior temperature at any location can be recovered using Eq.by setting c = 1. The interior heat flux can also be recovered by applying Fouriers law of conduction and72 (c = 1). We have a response gradient boundary integral equation as
Eq. 3176
Eq. 3177
in C.A. Brebbia, J.C.F. Telles, and L.C. Wrobel, 1984, Boundary element Techniques: Theory and applications in ring, Springer-Verlag, Berlin, Germany.
Gij T x i,( ) and H i j n q x i,( )( ) with Hi j,dj=,d
j H i j ij2------= =
Hi j Gi jTjqj
H i jTj Gi jqj+=
H i i n q ( ) de 0 and Gi i,= T d
e h2pik---------- ln 2h--- 1+== =
q ( ) k T ( ) -------------- k n q( )eT x ,( )
----------------------- de Te n q x ,( )( ) ------------------------------------- d
e
e
e
= =
T x ,( )i
-----------------------
12pik----------r
1 ri-------
xi i( )2pikr2
------------------- cesin ri-------,
xi i( )r
-----------------------= = =
Variational Methods
Eq. 3178
WeWe invare insu100. Blinear tuniformthe varand heListing
n q x ,( )( )i
-------------------------------------
12pikr2--------------- r 2 n ei( ) 2r 3
r----- x ( ) n( )
=
12pikr2--------------- ni
2 xi i( ) x ( ) n( )r2
------------------------------------------------------+
=
#include static constatic C0static C0static C0static C0double w
x
y
z
e
void LHSvoid LHSvoid RHSvoid T_revoid q_reint main(
LHSLHSRHSC0 Y
TT
cout cout T_recout q_reccout cout retur
}
ListinWorkbook of Applications in VectorSpace C++ Library 247
consider a trivial example which solution is self-evident for checking our implementation of this method.estigate conduction of heat on a squre region -1 < x < 1, and -1 < y < 1. The upper and lower boundarieslated from its sorrounding by setting qy = 0, the left boundary has T = 0, and the right boundary has T =
ecause of the steady state condition , the gradient on the x direction is constant. This leads to aemperature distribution and constant heat flux on x direction. On y direction, temperature distribution is and heat flux is zero. Program Listing 322 to Program Listing 326 implement Eq. 3174 to solve for
iables T and q on the boundaries, then, use Eq. 3172 and Eq. 3176 to recover the interior temperatureat flux. We discritize each side of the square region into eight equal length constant elements. Program 322 is the main() program of the boundary element method.
2T 0=
"include\vs.h"st double PI = 3.141592654;
A(32, 32, (double*)0); f(32, (double*)0); H(32, 16, A, 0, 0); mG(32, 16, A, 0, 16);[9] = {14.0/45.0, 64.0/45.0, 24.0/45.0, 64.0/45.0, 28.0/45.0, 64.0/45.0, 24.0/45.0, 64.0/45.0, 14.0/45.0},[8][2] = {{-1.0, -0.75}, {-0.75, -0.5}, {-0.5, -0.25}, {-0.25, -0.0}, {0.0, 0.25}, {0.25, 0.5},
{0.5, 0.75}, {0.75, 1.0}},[8][2] = {{-1.0, -0.75}, {-0.75, -0.5}, {-0.5, -0.25}, {-0.25, -0.0}, {0.0, 0.25}, {0.25, 0.5},
{0.5, 0.75}, {0.75, 1.0}},ai[8] = {-0.875, -0.625, -0.375, -0.125, 0.125, 0.375, 0.625, 0.875},ta[8] = {-0.875, -0.625, -0.375, -0.125, 0.125, 0.375, 0.625, 0.875};_0_15();_16_31();(); covery(const C0&, const C0&, const C0&); covery(const C0&, const C0&, const C0&, const C0&);) {_0_15();_16_31();(); = f / A, _gamma(16, Y, 0), q_gamma(16, Y, 16),(8, 8, (double*)0), q_x(8, 8, (double*)0), q_y(8, 8, (double*)0);
Variational Methods Using H0, H1, and H2 Type Objects
248 W
Chapter 3
Proupper bassigneintegrazero ac
lower bbounda
The -Gbounda
void LHS_0_15() {for(int i = 0; i < 16; i++) H[i][i] = -1.0/2.0;for(int i = 0; i < 8; i++) {
for(int j = 0; j < 8; j++) {Quadrature qp(w, x[j][0], x[j][1], 9);J d_l(0.25/8.0);
}}for(in
fo
}}
}
Hii (diagonal) is -1/2
1
Listingorkbook of Applications in VectorSpace C++ Library
gram Listing 323 implements the first 16 rows of matrix A corresponding to source position i on the 8oundary elements and 8 lower boundary elements. From Eq. 3173 the diagonal elements of Hij are firstd -1/2. For this particular case, if source position i is located at any element of the upper boundary, thetion of Hij for all upper boundary elements (with second index j) become signular and their values arecording to Eq. 3175. This is also true for sources position at lower boundary elements, which makes alloundary element integrals zero. For source position i at upper boundary and integral on the lower
ry elements (with index j), and vice versa, we have
Eq. 3179
ij terms in the first 16 rows of matrix A corresponding to the 8 upper boundary elements and 8 lowerry elements are simply
Eq. 3180
H ij n q x i,( )( ) dj x1 1( )2pir2--------------------- d
j 22pir2----------- d
j 1pir2-------- d
j= = = =
Gi j T x i,( ) dj ln r x i,( )( )2pik--------------------------- d
j= =
H0 X(qp),R_pow_2 = 4+(X-zai[i]).pow(2);H[i][j+8] = H[i+8][j] = 1.0/(PI*R_pow_2) | d_l;
t i = 0; i < 8; i++) {r(int j = 0; j < 8; j++) { Quadrature qp(w, y[j][0], y[j][1], 9);J d_l(0.25/8.0);H0 Y(qp),
R0 = sqrt(pow(1.0-zai[i], 2)+(Y-1).pow(2)),R1 = sqrt(pow(1.0+zai[i], 2)+(Y-1).pow(2)),R2 = sqrt(pow(1.0-zai[i], 2)+(Y+1).pow(2)),R3 = sqrt(pow(1.0+zai[i], 2)+(Y+1).pow(2));
mG[i][j] = 1.0/(2.0*PI)*log(R0) | d_l; mG[i][j+8] = 1.0/(2.0*PI)*log(R1) | d_l;mG[i+8][j] = 1.0/(2.0*PI)*log(R2) | d_l; mG[i+8][j+8] = 1.0/(2.0*PI)*log(R3) | d_l;
Hi jpir2-------- d
j=
Gi jln r( )2pik------------ d
j=
323 Function LHS_0_15() (project: boundary_element_method).
Variational Methods
Simon 8 rignals of
Otherw
void LHS_16_31() {double mG_diag = 0.125 / PI * (log(0.125)-1.0);for(int i = 0; i < 16; i++) mG[i+16][i] = mG_diag;for(int i = 0; i < 8; i++) {
for(int j = 0; j < 8; j++) {Quadrature qp(w, y[j][0], y[j][1], 9);J d_l(0.25/8.0);
}}for(ifor(i
QJHRm
}for(i
fo
}}
G i ih
2pik---------- ln2h--- 1+=
ListinWorkbook of Applications in VectorSpace C++ Library 249
ilarly, Program Listing 324 implements the last 16 rows of matrix A corresponding to source position iht boundary elements and 8 left boundary elements. Now the singular integration corresponds to diago--Gij terms in the last 16 rows of matrix A. According to Eq. 3175, that is
Eq. 3181
ise, -Gij use the definition in Eq. 3180. For the terms of Hij
Eq. 3182
H0 Y(qp);if(i != j) {
if(i
Variational Methods Using H0, H1, and H2 Type Objects
250 W
Chapter 3
where bof eithe
Proright bosider risource
For soui.e., bi =
Promentat
Theorates fgularitintegra
void RHS() {for(int i = 0; i < 8; i++) {
for(int j = 0; j < 8; j++) {Quadrature qp(w, y[j][0], y[j][1], 9);J d_l(0.25/8.0);H0 Y(qp),
}}for(infor(in
fo
}}
}
100 1 0( )
Listingorkbook of Applications in VectorSpace C++ Library
oth coordinate x1 and the inner product of surface normal and coordinate basis can have the valuer 1 or -1.
gram Listing 325 implements the right-hand-side vector of Eq. 3174. Since only Tj corresponding toundary elements are not zero (i.e., T16 ~ T23 = 100, all other T = 0 and all q = 0), we only need to con-
ght-hand-side values of -Hij Tj with index j running from 16 to 23, i.e., 16th to 23rd columns of H. Forposition on upper and lower boundary elements (i = 0~15), we have
Eq. 3183
rce position on left boundary elements, singular integrals occur. Therefore, bi = -c Tj, where c = -1/2; 100/2 = 50, for i = 16~23. For source position on right boundary elements (i = 24~31), we have
Eq. 3184
gram Listing 326 for interior temperature and interior heat flux recovery is a straight forward imple-ion of Eq. 3172 and Eq. 3176.
results of this simple problem are trivial. It is suffice to say that close to boundaries the accuracy deteri-ast, since we have a lot of ln(r), 1/r, 1/r2 ... etc. in the equations. This phenomenon is known as hypersin-y of the boundary integral equation. These complex functions are very chanlleging for numericaltion. Special integration rules for these functions are common practice in boundary element method.
n e1
bi H
ijTj 100 n q x i,( )( ) dj 100 n e0( ) x0 0( )2pir2----------------------------------------- d
j 1002pi--------- 1 0( )r2------------------- d
j= = ==
bi H
ijTj 100 n q x i,( )( ) dj 100 n e0( ) x0 0( )2pir2----------------------------------------- d
j 100pi--------- 1r2---- d
j= = ==
R0_2 = pow(1-zai[i], 2)+(Y-1).pow(2),R1_2 = pow(1-zai[i], 2)+(Y+1).pow(2);
f[i] += (-100.0*(1-zai[i]))/(2.0*PI*R0_2) | d_l;f[i+8] += (-100.0*(1-zai[i]))/(2.0*PI*R1_2) | d_l;
t i = 16; i < 24; i++) f[i] = 100.0 / 2.0;t i = 24; i < 32; i++) {r(int j = 0; j < 8; j++) {Quadrature qp(w, y[j][0], y[j][1], 9);J d_l(0.25/8.0);H0 Y(qp), R_pow_2 = 4+(Y-eta[i-24]).pow(2);f[i] += - 100.0 / (PI*R_pow_2) | d_l;
bi = 100/2
bi 2pi--------- r2------------------- d
j=
bi100pi
---------
1r2---- d
j=
325 Function RHS() (project: boundary_element_method).
Variational Methods
void T_recovery(const C0& T_gamma, const C0&
Top Related