diff --git a/.classpath b/.classpath index e353bd8..5a214e2 100644 --- a/.classpath +++ b/.classpath @@ -7,7 +7,6 @@ - - + diff --git a/src/lambdacloud/core/Session.java b/src/lambdacloud/core/Session.java index a9a4347..eb08efc 100644 --- a/src/lambdacloud/core/Session.java +++ b/src/lambdacloud/core/Session.java @@ -245,4 +245,31 @@ public double runLocal(Node root, Map dict) { } return root.func.apply(args); } + + public CloudSD[] runSelect(Expr expr, Map dict) { + GraphBuilder gb = new GraphBuilder(config); + Node n = gb.build(expr); + return runSelelct(n, dict); + } + + public CloudSD[] runSelect(Node root, Map dict) { + double[] args = new double[root.args.size()]; + + for(int i=0; i diri = new HashMap(); -// diri.put(1, 0.0); -// //solve(pde2, mesh2, diri, "patch_triangle.dat"); -// solve(wf, mesh2, diri, "triangle.dat"); -// solve2(mesh2, diri, "triangle_hardcode.dat"); - peper_example(); + Func u = new Func("u", x, y); + Func v = new Func("v", x, y); + +// //Our PDE equation +// Eq pde = new Eq(0.5*dot(grad(u), grad(v)) + 0.1*u*v, (x*x+y*y)*v); +// //Read the mesh +// Mesh2D mesh = new Mesh2D("mesh1", x, y); +// mesh.readTriangleMesh("double_hex3.1.node", "double_hex3.1.ele"); +// solve(pde, mesh, null, "double_hex3.1.dat"); + + //Another PDE equation with Dirichlet condition + ////WeakForm wf = new WeakForm(dot(grad(u), grad(v)), (-2*(x*x+y*y)+36)*v, u, v); + //Eq pde2 = new Eq(u*v, (-2*(x*x+y*y)+36)*v); + Mesh2D mesh2 = new Mesh2D("mesh2"); + //mesh2.readGridGenMesh("patch_triangle.grd"); + mesh2.readGridGenMesh("triangle.grd"); + //Mark boundary nodes + double eps = 0.01; + for(Node n : mesh2.nodes) { + //if(1-Math.abs(n.coords[0]) diri = new HashMap(); + diri.put(1, 0.0); + //solve(pde2, mesh2, diri, "patch_triangle.dat"); + ////solve(wf, mesh2, diri, "triangle.dat"); + solve2(mesh2, diri, "triangle_hardcode.dat"); + + //peper_example(); } public static void peper_example() { @@ -262,6 +263,9 @@ public static void solve2(Mesh2D mesh, Map dirichlet, String ou List eles = mesh.getSubDomains(); double[][] matA = new double[mesh.nodes.size()][mesh.nodes.size()]; double[] vecb = new double[mesh.nodes.size()]; + + int NN = 10000*512/eles.size(); + for(int ii=0; ii dirichlet, String ou List addList = normalizeTerms(pde.lhs()); //Change of variables + System.out.println("Start change of variable..."); + long begin = System.currentTimeMillis(); for(Expr term : addList) { Integrate intTerm = (Integrate)term; // Integration term //Integrate on the domain @@ -206,9 +208,12 @@ public static void solve(WeakForm pde, Map dirichlet, String ou } } } + System.out.println("Change of variable done! Time: "+(System.currentTimeMillis()-begin)+"ms"); //Generate bytecode for the integration //You can save the class to some place for later use + System.out.println("Start generating bytecode..."); + begin = System.currentTimeMillis(); NumInt lhsNInt[][] = new NumInt[shapeFuns.length][shapeFuns.length]; NumInt lhsNIntB[][] = new NumInt[shapeFunsB.length][shapeFunsB.length]; NumInt rhsNInt[] = new NumInt[shapeFuns.length]; @@ -223,10 +228,11 @@ public static void solve(WeakForm pde, Map dirichlet, String ou // lhsNIntB[i][j] = new NumInt(lhsIntB[i][j]); // } // } + System.out.println("Bytecode gen done! Time: "+(System.currentTimeMillis()-begin)+"ms"); //Assemble the system System.out.println("Start assemble the system..."); - long begin = System.currentTimeMillis(); + begin = System.currentTimeMillis(); double[][] matA = new double[mesh.nodes.size()][mesh.nodes.size()]; double[] vecb = new double[mesh.nodes.size()]; for(Domain d : mesh.getSubDomains()) { diff --git a/src/symjava/symbolic/Table.java b/src/symjava/symbolic/Table.java index a0ba3b9..7441b7a 100644 --- a/src/symjava/symbolic/Table.java +++ b/src/symjava/symbolic/Table.java @@ -3,15 +3,15 @@ import symjava.symbolic.arity.NaryOp; /** - * An expressions table is similar to the table of a relational database (RDBMS). - * The expressions table itself is nothing but an array of expressions. + * An expression table is similar to the table of a relational database (RDBMS). + * The expression table itself is nothing but an array of expressions. * - * It will return an array of CloudSD when evaluating the expressions table. + * It will return an array of CloudSD when evaluating the expression table. * Each element of the returned CloudSD corresponds to a column of a RDBMS table. * * The main purpose of an expression table is to 'bind' the values of expressions - * together into a table. The length of values must be the same for each expression - * in the expressions table. + * together into a table. The length of the values must be the same for each expression + * in the expression table. * */ public class Table extends NaryOp {