<p><b>xylar@lanl.gov</b> 2010-05-14 08:59:55 -0600 (Fri, 14 May 2010)</p><p>BRANCH COMMIT<br>
<br>
Added a few matlab files used for testing RBF interpolation of vectors<br>
</p><hr noshade><pre><font color="gray">Added: branches/ocean_projects/IBinterp/mpas/matlab/plane_vector_test.m
===================================================================
--- branches/ocean_projects/IBinterp/mpas/matlab/plane_vector_test.m                                (rev 0)
+++ branches/ocean_projects/IBinterp/mpas/matlab/plane_vector_test.m        2010-05-14 14:59:55 UTC (rev 273)
@@ -0,0 +1,77 @@
+  
+planarBasisVectors = zeros(2,3);
+planarBasisVectors(1,:) = [0.816496580927726, -0.408248290463863, -0.408248290463863];
+planarBasisVectors(2,:) = [0, 0.707106781186548, -0.707106781186548];
+
+planeNormal = [1,2];
+planeNormal = planeNormal/sqrt(sum(planeNormal.^2));
+
+planarIntercept = [0.5,0.5];
+interceptDotNormal = sum(planeNormal.*planarIntercept);
+
+edges = zeros(7^2*2,2);
+normals = zeros(size(edges));
+
+
+edgeIndex = 1;
+for(y = -3:3)
+    for(x = -3:3)
+        edges(edgeIndex,:) = [x+0.5,y];
+        normals(edgeIndex,:) = [1,0];
+        edges(edgeIndex+1,:) = [x,y+0.5];
+        normals(edgeIndex+1,:) = [0,1];
+        edgeIndex = edgeIndex + 2;
+    end
+end
+
+r = sqrt((edges(:,1)-0.0).^2 + (edges(:,2)-0.0).^2);
+
+indices = find(r &lt; 1.25);
+
+planeSourcePoints = edges(indices,:);
+offset = sum(planeSourcePoints.*(ones(length(indices),1)*planeNormal), 2) - interceptDotNormal;
+interfaceIndices = find(offset &gt; 0);
+planeSourcePoints(interfaceIndices,:) = planeSourcePoints(interfaceIndices,:) - offset(interfaceIndices)*planeNormal;
+
+normals = normals(indices,:);
+normals(interfaceIndices,:) = ones(length(interfaceIndices),1)*planeNormal;
+
+normals = [normals; [normals(interfaceIndices,2), -normals(interfaceIndices,1)]];
+planeSourcePoints = [planeSourcePoints; planeSourcePoints(interfaceIndices,:)];
+
+testFunction = [planeSourcePoints(:,1).^2.*planeSourcePoints(:,2), planeSourcePoints(:,2)];
+
+sourcePoints = planeSourcePoints*planarBasisVectors;
+
+unitVectors = normals*planarBasisVectors;
+
+testSamples = sum(testFunction.*normals, 2);
+
+pointCount = size(sourcePoints,1);
+matrixSize = pointCount+2;
+matrix = zeros(matrixSize, matrixSize);
+rhs = zeros(matrixSize,2);
+
+destPoint = planeSourcePoints(7,:);
+alpha = 1.35;
+for(j=1:pointCount)
+    for(i=1:pointCount)
+        rbf = 1/sqrt(1 + sum((planeSourcePoints(i,:)-planeSourcePoints(j,:)).^2)/alpha^2);
+        dotProduct = sum(normals(i,:).*normals(j,:));
+        matrix(i,j) = rbf*dotProduct;
+    end
+    rbf = 1/sqrt(1 + sum((destPoint-planeSourcePoints(j,:)).^2)/alpha^2);
+    rhs(j,:) = rbf*normals(j,:);
+    matrix(j,pointCount+(1:2)) = normals(j,:);
+    matrix(pointCount+(1:2),j) = normals(j,:);
+end
+
+for(i=1:2)
+    rhs(pointCount+i,i) = 1;
+end
+
+coeffs = matrix\rhs;
+
+functionValue(1) = sum(coeffs(1:pointCount,1).*noSlipSamples);
+functionValue(2) = sum(coeffs(1:pointCount,2).*noSlipSamples);
+functionValue(3) = sum(coeffs(1:pointCount,3).*noSlipSamples);
\ No newline at end of file

Added: branches/ocean_projects/IBinterp/mpas/matlab/vector_output.m
===================================================================
--- branches/ocean_projects/IBinterp/mpas/matlab/vector_output.m                                (rev 0)
+++ branches/ocean_projects/IBinterp/mpas/matlab/vector_output.m        2010-05-14 14:59:55 UTC (rev 273)
@@ -0,0 +1,298 @@
+ matrix2 = [
+ 1. ,
+ 0. ,
+ 0.8035571933447457 ,
+ 0. ,
+ 0. ,
+ 0.8035571933447452 ,
+ 0. ,
+ 0.6904941785382116 ,
+ 0. ,
+ 0.2580809098964746 ,
+ 0.5594728550010618 ,
+ 0.2693945426539801 ,
+ 0.5161618197929486 ,
+ 0.5387890853079595 ,
+ 1. ,
+ 0. ,
+ 0. ,
+ 1.0000000000000027 ,
+ 0. ,
+ 0.8035571933447478 ,
+ 0.559472855001064 ,
+ 0. ,
+ 0.8035571933447475 ,
+ 0. ,
+ 0.6904941785382136 ,
+ 0.4899987817260812 ,
+ 0. ,
+ 0.555639073776352 ,
+ -0.24499939086304057 ,
+ -0.27781953688817596 ,
+ 0. ,
+ 1.0000000000000013 ,
+ 0.8035571933447457 ,
+ 0. ,
+ 1. ,
+ 0. ,
+ 0. ,
+ 0.6904941785382116 ,
+ 0. ,
+ 0.8035571933447452 ,
+ 0. ,
+ 0.31504157072772077 ,
+ 0.5168469958789915 ,
+ 0.28708787159108184 ,
+ 0.6300831414554408 ,
+ 0.5741757431821631 ,
+ 1. ,
+ 0. ,
+ 0. ,
+ 0.8035571933447478 ,
+ 0. ,
+ 1.0000000000000027 ,
+ 0.8035571933447478 ,
+ 0. ,
+ 0.6904941785382136 ,
+ 0. ,
+ 0.8035571933447475 ,
+ 0.667481040666017 ,
+ 0. ,
+ 0.683325359428049 ,
+ -0.3337405203330085 ,
+ -0.3416626797140244 ,
+ 0. ,
+ 1.0000000000000013 ,
+ 0. ,
+ 0.559472855001064 ,
+ 0. ,
+ 0.8035571933447478 ,
+ 1.0000000000000027 ,
+ 0. ,
+ 0.5168469958789934 ,
+ 0. ,
+ 0.6904941785382136 ,
+ 0.7679105104586107 ,
+ 0. ,
+ 0.6433588228009317 ,
+ -0.3839552552293053 ,
+ -0.3216794114004658 ,
+ 0. ,
+ 1.0000000000000013 ,
+ 0.8035571933447452 ,
+ 0. ,
+ 0.6904941785382116 ,
+ 0. ,
+ 0. ,
+ 1. ,
+ 0. ,
+ 0.8035571933447455 ,
+ 0. ,
+ 0.3067983736783364 ,
+ 0.8035571933447452 ,
+ 0.3593617016255587 ,
+ 0.6135967473566721 ,
+ 0.7187234032511166 ,
+ 1. ,
+ 0. ,
+ 0. ,
+ 0.8035571933447475 ,
+ 0. ,
+ 0.6904941785382136 ,
+ 0.5168469958789934 ,
+ 0. ,
+ 1.0000000000000027 ,
+ 0. ,
+ 0.8035571933447478 ,
+ 0.5161618197929507 ,
+ 0. ,
+ 0.6433588228009319 ,
+ -0.2580809098964753 ,
+ -0.3216794114004659 ,
+ 0. ,
+ 1.0000000000000013 ,
+ 0.6904941785382116 ,
+ 0. ,
+ 0.8035571933447452 ,
+ 0. ,
+ 0. ,
+ 0.8035571933447455 ,
+ 0. ,
+ 1. ,
+ 0. ,
+ 0.4193739949588775 ,
+ 0.6904941785382116 ,
+ 0.4049746898727999 ,
+ 0.8387479899177541 ,
+ 0.8099493797455989 ,
+ 1. ,
+ 0. ,
+ 0. ,
+ 0.6904941785382136 ,
+ 0. ,
+ 0.8035571933447475 ,
+ 0.6904941785382136 ,
+ 0. ,
+ 0.8035571933447478 ,
+ 0. ,
+ 1.0000000000000027 ,
+ 0.7386180304789163 ,
+ 0. ,
+ 0.8708544747860466 ,
+ -0.3693090152394581 ,
+ -0.43542723739302325 ,
+ 0. ,
+ 1.0000000000000013 ,
+ 0.2580809098964746 ,
+ 0.4899987817260812 ,
+ 0.31504157072772077 ,
+ 0.667481040666017 ,
+ 0.7679105104586107 ,
+ 0.3067983736783364 ,
+ 0.5161618197929507 ,
+ 0.4193739949588775 ,
+ 0.7386180304789163 ,
+ 1.000000000000003 ,
+ 0.29208397519619794 ,
+ 0.8955334711889928 ,
+ -1.1916195027245058E-15 ,
+ -1.0671351496113749E-15 ,
+ 0.44721359549995826 ,
+ 0.8944271909999174 ,
+ 0.5594728550010618 ,
+ 0. ,
+ 0.5168469958789915 ,
+ 0. ,
+ 0. ,
+ 0.8035571933447452 ,
+ 0. ,
+ 0.6904941785382116 ,
+ 0. ,
+ 0.29208397519619794 ,
+ 1. ,
+ 0.3728129743218286 ,
+ 0.5841679503923952 ,
+ 0.7456259486436564 ,
+ 1. ,
+ 0. ,
+ 0.2693945426539801 ,
+ 0.555639073776352 ,
+ 0.28708787159108184 ,
+ 0.683325359428049 ,
+ 0.6433588228009317 ,
+ 0.3593617016255587 ,
+ 0.6433588228009319 ,
+ 0.4049746898727999 ,
+ 0.8708544747860466 ,
+ 0.8955334711889928 ,
+ 0.3728129743218286 ,
+ 1.000000000000003 ,
+ -1.0671351496113749E-15 ,
+ -1.1916195027245058E-15 ,
+ 0.44721359549995826 ,
+ 0.8944271909999174 ,
+ 0.5161618197929486 ,
+ -0.24499939086304057 ,
+ 0.6300831414554408 ,
+ -0.3337405203330085 ,
+ -0.3839552552293053 ,
+ 0.6135967473566721 ,
+ -0.2580809098964753 ,
+ 0.8387479899177541 ,
+ -0.3693090152394581 ,
+ -1.1916195027245058E-15 ,
+ 0.5841679503923952 ,
+ -1.0671351496113749E-15 ,
+ 1. ,
+ 0.8955334711889902 ,
+ 0.8944271909999155 ,
+ -0.44721359549995865 ,
+ 0.5387890853079595 ,
+ -0.27781953688817596 ,
+ 0.5741757431821631 ,
+ -0.3416626797140244 ,
+ -0.3216794114004658 ,
+ 0.7187234032511166 ,
+ -0.3216794114004659 ,
+ 0.8099493797455989 ,
+ -0.43542723739302325 ,
+ -1.0671351496113749E-15 ,
+ 0.7456259486436564 ,
+ -1.1916195027245058E-15 ,
+ 0.8955334711889902 ,
+ 1. ,
+ 0.8944271909999155 ,
+ -0.44721359549995865 ,
+ 1. ,
+ 0. ,
+ 1. ,
+ 0. ,
+ 0. ,
+ 1. ,
+ 0. ,
+ 1. ,
+ 0. ,
+ 0.44721359549995826 ,
+ 1. ,
+ 0.44721359549995826 ,
+ 0.8944271909999155 ,
+ 0.8944271909999155 ,
+ 0. ,
+ 0. ,
+ 0. ,
+ 1.0000000000000013 ,
+ 0. ,
+ 1.0000000000000013 ,
+ 1.0000000000000013 ,
+ 0. ,
+ 1.0000000000000013 ,
+ 0. ,
+ 1.0000000000000013 ,
+ 0.8944271909999174 ,
+ 0. ,
+ 0.8944271909999174 ,
+ -0.44721359549995865 ,
+ -0.44721359549995865 ,
+ 0. ,
+ 0.
+ ];
+ rhs2 = [
+ 0.6493311948292398 ,
+ 0. ,
+ 0.5368949876447039 ,
+ 0. ,
+ 0. ,
+ 0.885841265148462 ,
+ 0. ,
+ 0.6493311948292403 ,
+ 0. ,
+ 0.25808090989647475 ,
+ 0.8858412651484617 ,
+ 0.3216794114004652 ,
+ 0.516161819792949 ,
+ 0.6433588228009297 ,
+ 0.816496580927726 ,
+ 0. ,
+ 0. ,
+ 0.8035571933447464 ,
+ 0. ,
+ 0.6904941785382127 ,
+ 0.5168469958789927 ,
+ 0. ,
+ 1.0000000000000013 ,
+ 0. ,
+ 0.8035571933447468 ,
+ 0.5161618197929501 ,
+ 0. ,
+ 0.643358822800931 ,
+ -0.258080909896475 ,
+ -0.32167941140046546 ,
+ -0.408248290463863 ,
+ 0.707106781186548
+ ];
+
+
+
+matrix2 = reshape(matrix2, [16,16]);
+rhs2 = reshape(rhs2, [16,2]);
+

Added: branches/ocean_projects/IBinterp/mpas/matlab/vector_test2.m
===================================================================
--- branches/ocean_projects/IBinterp/mpas/matlab/vector_test2.m                                (rev 0)
+++ branches/ocean_projects/IBinterp/mpas/matlab/vector_test2.m        2010-05-14 14:59:55 UTC (rev 273)
@@ -0,0 +1,113 @@
+planeNormal = [1,2,3];
+planeNormal = planeNormal./sqrt(sum(planeNormal.^2));
+
+planeTangents = zeros(2,3);
+planeTangents(1,:) = [1,0,0];
+planeTangents(1,:) = planeTangents(1,:) - sum(planeTangents(1,:).*planeNormal)*planeNormal;
+planeTangents(1,:) = planeTangents(1,:)/sqrt(sum(planeTangents(1,:).^2));
+planeTangents(2,:) = cross(planeNormal, planeTangents(1,:));
+
+planeIntercept = [0.5,0.5,0];
+
+normalDotIntercept = sum(planeNormal.*planeIntercept);
+
+edges = zeros(7^3*3,3);
+normals = zeros(size(edges));
+
+
+edgeIndex = 1;
+for(z = -3:3)
+    for(y = -3:3)
+        for(x = -3:3)
+            edges(edgeIndex,:) = [x+0.5,y,z];
+            normals(edgeIndex,:) = [1,0,0];
+            edges(edgeIndex+1,:) = [x,y+0.5,z];
+            normals(edgeIndex+1,:) = [0,1,0];
+            edges(edgeIndex+2,:) = [x,y,z+0.5];
+            normals(edgeIndex+2,:) = [0,0,1];
+            edgeIndex = edgeIndex + 3;
+        end
+    end
+end
+
+r = sqrt((edges(:,1)-0.0).^2 + (edges(:,2)-0.0).^2 + (edges(:,3)-0.0).^2);
+
+% edgeCumSum = cumsum(histc(r,0:0.1:2));
+% 
+% plot(0:0.1:2,edgeCumSum);
+
+indices = [];
+for(edgeIndex = 1:size(edges,1))
+    if(r(edgeIndex) &gt; 1)
+        continue;
+    end
+    indices(end+1) = edgeIndex;
+end
+
+sourcePoints = edges(indices,:);
+normals = normals(indices,:);
+
+offset = planeNormal(1)*sourcePoints(:,1)...
+    + planeNormal(2)*sourcePoints(:,2)...
+    + planeNormal(3)*sourcePoints(:,3) - normalDotIntercept;
+
+interfaceMask = offset &gt; 0;
+
+
+indices = find(interfaceMask);
+normalIndices = zeros(length(interfaceMask)+2*length(indices),1);
+isTangent = false(size(normalIndices));
+for(i = 1:length(indices))
+    index = indices(i);
+    sourcePoints(index,:) = sourcePoints(index,:)...
+        - offset(index)*planeNormal;
+    normals(index,:) = planeNormal;
+    sourcePoints(end+1,:) = sourcePoints(index,:);
+    normals(end+1,:) = planeTangents(1,:);
+    isTangent(size(normals,1)) = true;
+    normalIndices(size(normals,1)) = index;
+    sourcePoints(end+1,:) = sourcePoints(index,:);
+    normals(end+1,:) = planeTangents(2,:);
+    isTangent(size(normals,1)) = true;
+    normalIndices(size(normals,1)) = index;
+end
+
+plot3(sourcePoints(:,1), sourcePoints(:,2), sourcePoints(:,3), '.'); axis equal;
+
+noSlipFunction = [sourcePoints(:,1),sourcePoints(:,2),sourcePoints(:,3)];
+freeSlipFunction = noSlipFunction;
+freeSlipFunction(interfaceMask,1) = planeNormal(1);
+freeSlipFunction(interfaceMask,2) = planeNormal(2);
+freeSlipFunction(interfaceMask,3) = planeNormal(3);
+
+noSlipSamples = sum(noSlipFunction.*normals,2);
+freeSlipSamples = sum(freeSlipFunction.*normals,2);
+
+pointCount = size(sourcePoints,1);
+matrixSize = pointCount+3;
+matrix = zeros(matrixSize, matrixSize);
+rhs = zeros(matrixSize,3);
+
+destPoint = sourcePoints(3,:);
+alpha = 1.35;
+for(j=1:pointCount)
+    for(i=1:pointCount)
+        rbf = 1/sqrt(1 + sum((sourcePoints(i,:)-sourcePoints(j,:)).^2)/alpha^2);
+        dotProduct = sum(normals(i,:).*normals(j,:));
+        matrix(i,j) = rbf*dotProduct;
+    end
+    rbf = 1/sqrt(1 + sum((destPoint-sourcePoints(j,:)).^2)/alpha^2);
+    rhs(j,:) = rbf*normals(j,:);
+    matrix(j,pointCount+(1:3)) = normals(j,:);
+    matrix(pointCount+(1:3),j) = normals(j,:);
+end
+
+for(i=1:3)
+    rhs(pointCount+i,i) = 1;
+end
+
+coeffs = matrix\rhs;
+
+functionValue(1) = sum(coeffs(1:6,1).*noSlipSamples);
+functionValue(2) = sum(coeffs(1:6,2).*noSlipSamples);
+functionValue(3) = sum(coeffs(1:6,3).*noSlipSamples);
\ No newline at end of file

</font>
</pre>