Skip to content

Commit 7485d64

Browse files
committed
add runSelect
1 parent 2b9ad47 commit 7485d64

File tree

5 files changed

+73
-37
lines changed

5 files changed

+73
-37
lines changed

.classpath

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,6 @@
77
<classpathentry kind="lib" path="lib/libsvm.jar"/>
88
<classpathentry kind="lib" path="lib/jzlib.jar"/>
99
<classpathentry kind="lib" path="lib/netty-all-5.0.0.Alpha2.jar" sourcepath="/home/yueming/Downloads/netty-5.0.0.Alpha2/jar/all-in-one/netty-all-5.0.0.Alpha2-sources.jar"/>
10-
<classpathentry kind="con" path="org.eclipse.jdt.launching.JRE_CONTAINER/org.eclipse.jdt.internal.debug.ui.launcher.StandardVMType/java1.8.0_45"/>
11-
<classpathentry combineaccessrules="false" kind="src" path="/Futureye_v2"/>
10+
<classpathentry kind="con" path="org.eclipse.jdt.launching.JRE_CONTAINER/org.eclipse.jdt.internal.debug.ui.launcher.StandardVMType/Java8"/>
1211
<classpathentry kind="output" path="bin"/>
1312
</classpath>

src/lambdacloud/core/Session.java

Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -245,4 +245,31 @@ public double runLocal(Node root, Map<String, Double> dict) {
245245
}
246246
return root.func.apply(args);
247247
}
248+
249+
public CloudSD[] runSelect(Expr expr, Map<String, double[]> dict) {
250+
GraphBuilder gb = new GraphBuilder(config);
251+
Node n = gb.build(expr);
252+
return runSelelct(n, dict);
253+
}
254+
255+
public CloudSD[] runSelect(Node root, Map<String, double[]> dict) {
256+
double[] args = new double[root.args.size()];
257+
258+
for(int i=0; i<root.args.size(); i++) {
259+
Double d = dict.get(root.args.get(i).toString());
260+
if(d == null) {
261+
Node child = root.children.get(root.args.get(i).toString());
262+
args[i] = runSimple(child, dict);
263+
} else {
264+
args[i] = d;
265+
}
266+
}
267+
268+
CloudSD input = new CloudSD().init(args);
269+
CloudSD output = new CloudSD();
270+
root.cfunc.apply(output, input);
271+
//Will block
272+
output.fetch();
273+
return output.getData(0);
274+
}
248275
}

src/symjava/examples/Example6.java

Lines changed: 33 additions & 29 deletions
Original file line numberDiff line numberDiff line change
@@ -31,35 +31,36 @@
3131
*/
3232
public class Example6 {
3333
public static void main(String[] args) {
34-
// Func u = new Func("u", x, y);
35-
// Func v = new Func("v", x, y);
36-
//
37-
//// //Our PDE equation
38-
//// Eq pde = new Eq(0.5*dot(grad(u), grad(v)) + 0.1*u*v, (x*x+y*y)*v);
39-
//// //Read the mesh
40-
//// Mesh2D mesh = new Mesh2D("mesh1", x, y);
41-
//// mesh.readTriangleMesh("double_hex3.1.node", "double_hex3.1.ele");
42-
//// solve(pde, mesh, null, "double_hex3.1.dat");
43-
//
44-
// //Another PDE equation with Dirichlet condition
45-
// WeakForm wf = new WeakForm(dot(grad(u), grad(v)), (-2*(x*x+y*y)+36)*v, u, v);
46-
// //Eq pde2 = new Eq(u*v, (-2*(x*x+y*y)+36)*v);
47-
// Mesh2D mesh2 = new Mesh2D("mesh2");
48-
// //mesh2.readGridGenMesh("patch_triangle.grd");
49-
// mesh2.readGridGenMesh("triangle.grd");
50-
// //Mark boundary nodes
51-
// double eps = 0.01;
52-
// for(Node n : mesh2.nodes) {
53-
// //if(1-Math.abs(n.coords[0])<eps || 1-Math.abs(n.coords[1])<eps || Math.abs(n.coords[0])<eps || Math.abs(n.coords[1])<eps )
54-
// if(Math.abs(3-Math.abs(n.coords[0]))<eps || Math.abs(3-Math.abs(n.coords[1]))<eps)
55-
// n.setType(1);
56-
// }
57-
// Map<Integer, Double> diri = new HashMap<Integer, Double>();
58-
// diri.put(1, 0.0);
59-
// //solve(pde2, mesh2, diri, "patch_triangle.dat");
60-
// solve(wf, mesh2, diri, "triangle.dat");
61-
// solve2(mesh2, diri, "triangle_hardcode.dat");
62-
peper_example();
34+
Func u = new Func("u", x, y);
35+
Func v = new Func("v", x, y);
36+
37+
// //Our PDE equation
38+
// Eq pde = new Eq(0.5*dot(grad(u), grad(v)) + 0.1*u*v, (x*x+y*y)*v);
39+
// //Read the mesh
40+
// Mesh2D mesh = new Mesh2D("mesh1", x, y);
41+
// mesh.readTriangleMesh("double_hex3.1.node", "double_hex3.1.ele");
42+
// solve(pde, mesh, null, "double_hex3.1.dat");
43+
44+
//Another PDE equation with Dirichlet condition
45+
////WeakForm wf = new WeakForm(dot(grad(u), grad(v)), (-2*(x*x+y*y)+36)*v, u, v);
46+
//Eq pde2 = new Eq(u*v, (-2*(x*x+y*y)+36)*v);
47+
Mesh2D mesh2 = new Mesh2D("mesh2");
48+
//mesh2.readGridGenMesh("patch_triangle.grd");
49+
mesh2.readGridGenMesh("triangle.grd");
50+
//Mark boundary nodes
51+
double eps = 0.01;
52+
for(Node n : mesh2.nodes) {
53+
//if(1-Math.abs(n.coords[0])<eps || 1-Math.abs(n.coords[1])<eps || Math.abs(n.coords[0])<eps || Math.abs(n.coords[1])<eps )
54+
if(Math.abs(3-Math.abs(n.coords[0]))<eps || Math.abs(3-Math.abs(n.coords[1]))<eps)
55+
n.setType(1);
56+
}
57+
Map<Integer, Double> diri = new HashMap<Integer, Double>();
58+
diri.put(1, 0.0);
59+
//solve(pde2, mesh2, diri, "patch_triangle.dat");
60+
////solve(wf, mesh2, diri, "triangle.dat");
61+
solve2(mesh2, diri, "triangle_hardcode.dat");
62+
63+
//peper_example();
6364
}
6465

6566
public static void peper_example() {
@@ -262,6 +263,9 @@ public static void solve2(Mesh2D mesh, Map<Integer, Double> dirichlet, String ou
262263
List<Domain> eles = mesh.getSubDomains();
263264
double[][] matA = new double[mesh.nodes.size()][mesh.nodes.size()];
264265
double[] vecb = new double[mesh.nodes.size()];
266+
267+
int NN = 10000*512/eles.size();
268+
for(int ii=0; ii<NN; ii++)
265269
for(Domain d : eles) {
266270
Element e = (Element)d;
267271
double[] coords = e.getNodeCoords();

src/symjava/examples/Example7.java

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -144,6 +144,8 @@ public static void solve(WeakForm pde, Map<Integer, Double> dirichlet, String ou
144144

145145
List<Expr> addList = normalizeTerms(pde.lhs());
146146
//Change of variables
147+
System.out.println("Start change of variable...");
148+
long begin = System.currentTimeMillis();
147149
for(Expr term : addList) {
148150
Integrate intTerm = (Integrate)term; // Integration term
149151
//Integrate on the domain
@@ -206,9 +208,12 @@ public static void solve(WeakForm pde, Map<Integer, Double> dirichlet, String ou
206208
}
207209
}
208210
}
211+
System.out.println("Change of variable done! Time: "+(System.currentTimeMillis()-begin)+"ms");
209212

210213
//Generate bytecode for the integration
211214
//You can save the class to some place for later use
215+
System.out.println("Start generating bytecode...");
216+
begin = System.currentTimeMillis();
212217
NumInt lhsNInt[][] = new NumInt[shapeFuns.length][shapeFuns.length];
213218
NumInt lhsNIntB[][] = new NumInt[shapeFunsB.length][shapeFunsB.length];
214219
NumInt rhsNInt[] = new NumInt[shapeFuns.length];
@@ -223,10 +228,11 @@ public static void solve(WeakForm pde, Map<Integer, Double> dirichlet, String ou
223228
// lhsNIntB[i][j] = new NumInt(lhsIntB[i][j]);
224229
// }
225230
// }
231+
System.out.println("Bytecode gen done! Time: "+(System.currentTimeMillis()-begin)+"ms");
226232

227233
//Assemble the system
228234
System.out.println("Start assemble the system...");
229-
long begin = System.currentTimeMillis();
235+
begin = System.currentTimeMillis();
230236
double[][] matA = new double[mesh.nodes.size()][mesh.nodes.size()];
231237
double[] vecb = new double[mesh.nodes.size()];
232238
for(Domain d : mesh.getSubDomains()) {

src/symjava/symbolic/Table.java

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -3,15 +3,15 @@
33
import symjava.symbolic.arity.NaryOp;
44

55
/**
6-
* An expressions table is similar to the table of a relational database (RDBMS).
7-
* The expressions table itself is nothing but an array of expressions.
6+
* An expression table is similar to the table of a relational database (RDBMS).
7+
* The expression table itself is nothing but an array of expressions.
88
*
9-
* It will return an array of CloudSD when evaluating the expressions table.
9+
* It will return an array of CloudSD when evaluating the expression table.
1010
* Each element of the returned CloudSD corresponds to a column of a RDBMS table.
1111
*
1212
* The main purpose of an expression table is to 'bind' the values of expressions
13-
* together into a table. The length of values must be the same for each expression
14-
* in the expressions table.
13+
* together into a table. The length of the values must be the same for each expression
14+
* in the expression table.
1515
*
1616
*/
1717
public class Table extends NaryOp {

0 commit comments

Comments
 (0)