コード例 #1
0
 public void imposeDirichletCondition(SparseBlockMatrix BM, SparseBlockVector BV, Function diri) {
   ElementList eList = mesh.getElementList();
   int nNode = mesh.getNodeList().size();
   for (int i = 1; i <= eList.size(); i++) {
     Element e = eList.at(i);
     DOFList DOFs = e.getAllDOFList(DOFOrder.NEFV);
     for (int j = 1; j <= DOFs.size(); j++) {
       DOF dof = DOFs.at(j);
       GeoEntity ge = dof.getOwner();
       if (ge instanceof Node) {
         Node n = (Node) ge;
         if (n.getNodeType() == NodeType.Dirichlet) {
           Variable v = Variable.createFrom(diri, n, 0);
           setDirichlet(BM, BV, dof.getGlobalIndex(), diri.value(v));
           setDirichlet(BM, BV, nNode + dof.getGlobalIndex(), diri.value(v));
           setDirichlet(BM, BV, nNode * 2 + dof.getGlobalIndex(), diri.value(v));
         }
       }
     }
   }
 }
コード例 #2
0
 public static void plotFunction(Mesh mesh, Function fun, String fileName) {
   NodeList list = mesh.getNodeList();
   int nNode = list.size();
   Variable var = new Variable();
   Vector v = new SparseVectorHashMap(nNode);
   for (int i = 1; i <= nNode; i++) {
     Node node = list.at(i);
     var.setIndex(node.globalIndex);
     var.set("x", node.coord(1));
     var.set("y", node.coord(2));
     v.set(i, fun.value(var));
   }
   plotVector(mesh, v, fileName);
 }