calcBKBtriang_quad

| main | Tutorials | Functions | website |

Computes the product B' x K x B for 2D quadratic trianlge elements in vectorized manner This is used internally from calcBKB.

Version : 1.0

Author : George Kourakos

email: giorgk@gmail.com

web : http://groundwater.ucdavis.edu/msim

Date 28-Mar-2014

Department of Land Air and Water

University of California Davis

Contents

Usage

BKB = calcBKBtriang_quad(B, K, ii)

Input

B: [Nel x N_sh^2] contains the contributions of each element to the final conductance matrix

K : [Nel x Nanis] Hydraulic conductiviy element values. The number of columns is defined by the anisotropy. Maximum number is 3.

ii : In case of nested assembly this indicates the iteration. In vectorized assembly this is not used

Output

BKB: the product B'*K*B

How to compute

In mSim we avoid by hand computations at all costs, therefore we used the symbolic toolbox to perform the vectorized computations. The following code show how we computed the products.

syms b1 b2 b3 b4 b5 b6
syms b7 b8 b9 b10 b11 b12
syms kx ky
B=[b1 b2 b3 b4 b5 b6; b7 b8 b9 b10 b11 b12];
BT = [b1 b7; b2 b8; b3 b9; b4 b10; b5 b11; b6 b12];
BKB = BT*[kx 0; 0 ky]*B
 
BKB =
 
[    kx*b1^2 + ky*b7^2,  b1*b2*kx + b7*b8*ky,  b1*b3*kx + b7*b9*ky,  b1*b4*kx + b7*b10*ky,  b1*b5*kx + b7*b11*ky,  b1*b6*kx + b7*b12*ky]
[  b1*b2*kx + b7*b8*ky,    kx*b2^2 + ky*b8^2,  b2*b3*kx + b8*b9*ky,  b2*b4*kx + b8*b10*ky,  b2*b5*kx + b8*b11*ky,  b2*b6*kx + b8*b12*ky]
[  b1*b3*kx + b7*b9*ky,  b2*b3*kx + b8*b9*ky,    kx*b3^2 + ky*b9^2,  b3*b4*kx + b9*b10*ky,  b3*b5*kx + b9*b11*ky,  b3*b6*kx + b9*b12*ky]
[ b1*b4*kx + b7*b10*ky, b2*b4*kx + b8*b10*ky, b3*b4*kx + b9*b10*ky,    kx*b4^2 + ky*b10^2, b4*b5*kx + b10*b11*ky, b4*b6*kx + b10*b12*ky]
[ b1*b5*kx + b7*b11*ky, b2*b5*kx + b8*b11*ky, b3*b5*kx + b9*b11*ky, b4*b5*kx + b10*b11*ky,    kx*b5^2 + ky*b11^2, b5*b6*kx + b11*b12*ky]
[ b1*b6*kx + b7*b12*ky, b2*b6*kx + b8*b12*ky, b3*b6*kx + b9*b12*ky, b4*b6*kx + b10*b12*ky, b5*b6*kx + b11*b12*ky,    kx*b6^2 + ky*b12^2]
 

Next to convert the above complex expressions to vectorized expresions we used the following loop and copy the output to an editor and with minimum editing we wrote the final expressions without actually write by hand indices and symbols

cnt=0;
for i=1:size(B,2)
    for j=1:size(B,2)
        cnt=cnt+1;
        fprintf(['BKB(:,%d) = ' char(BKB(i,j)) ';\n'],cnt);
    end
end
BKB(:,1) = b1^2*kx + b7^2*ky;
BKB(:,2) = b1*b2*kx + b7*b8*ky;
BKB(:,3) = b1*b3*kx + b7*b9*ky;
BKB(:,4) = b1*b4*kx + b7*b10*ky;
BKB(:,5) = b1*b5*kx + b7*b11*ky;
BKB(:,6) = b1*b6*kx + b7*b12*ky;
BKB(:,7) = b1*b2*kx + b7*b8*ky;
BKB(:,8) = b2^2*kx + b8^2*ky;
BKB(:,9) = b2*b3*kx + b8*b9*ky;
BKB(:,10) = b2*b4*kx + b8*b10*ky;
BKB(:,11) = b2*b5*kx + b8*b11*ky;
BKB(:,12) = b2*b6*kx + b8*b12*ky;
BKB(:,13) = b1*b3*kx + b7*b9*ky;
BKB(:,14) = b2*b3*kx + b8*b9*ky;
BKB(:,15) = b3^2*kx + b9^2*ky;
BKB(:,16) = b3*b4*kx + b9*b10*ky;
BKB(:,17) = b3*b5*kx + b9*b11*ky;
BKB(:,18) = b3*b6*kx + b9*b12*ky;
BKB(:,19) = b1*b4*kx + b7*b10*ky;
BKB(:,20) = b2*b4*kx + b8*b10*ky;
BKB(:,21) = b3*b4*kx + b9*b10*ky;
BKB(:,22) = b4^2*kx + b10^2*ky;
BKB(:,23) = b4*b5*kx + b10*b11*ky;
BKB(:,24) = b4*b6*kx + b10*b12*ky;
BKB(:,25) = b1*b5*kx + b7*b11*ky;
BKB(:,26) = b2*b5*kx + b8*b11*ky;
BKB(:,27) = b3*b5*kx + b9*b11*ky;
BKB(:,28) = b4*b5*kx + b10*b11*ky;
BKB(:,29) = b5^2*kx + b11^2*ky;
BKB(:,30) = b5*b6*kx + b11*b12*ky;
BKB(:,31) = b1*b6*kx + b7*b12*ky;
BKB(:,32) = b2*b6*kx + b8*b12*ky;
BKB(:,33) = b3*b6*kx + b9*b12*ky;
BKB(:,34) = b4*b6*kx + b10*b12*ky;
BKB(:,35) = b5*b6*kx + b11*b12*ky;
BKB(:,36) = b6^2*kx + b12^2*ky;

| main | Tutorials | Functions | website |