private void generateMesh() { int[] ind = new int[4]; m.nDim = 2; // Connectivity array int nh = nt; int nv = nc; m.nEl = nh * nv; m.elems = new Element[m.nEl]; int n = 0; for (int iv = 0; iv < nv; iv++) { for (int ih = 0; ih < nh; ih++) { m.elems[n] = Element.newElement("quad4"); int in0 = iv * (nh + 1) + ih + 1; ind[0] = in0; ind[1] = in0 + 1; int in1 = (iv + 1) * (nh + 1) + ih + 1; ind[2] = in1 + 1; ind[3] = in1; m.elems[n].setElemConnectivities(ind); m.elems[n].setElemMaterial(mat); n++; } } // Node coordinate array m.nNod = (nt + 1) * (nc + 1); m.newCoordArray(); n = 0; for (int iv = 0; iv < nv + 1; iv++) { for (int ih = 0; ih < nh + 1; ih++) { //int pc = (ic + 1) / 2; //if (ic % 2 == 0 && it % 2 == 0) // corner noder - 0, 2, 4, 6 //{ m.setNodeCoord(n, 0, (ri + dt * ih) * Math.Cos((theta1 + dtheta * iv) * Math.PI / 180.0)); m.setNodeCoord(n, 1, (ri + dt * ih) * Math.Sin((theta1 + dtheta * iv) * Math.PI / 180.0)); n++; //} //else if (ic % 2 == 1 && it % 2 == 0) // midside node on horizontal element side - 3, 7 //{ //m.setNodeCoord(n, 0, (ri + dt * it) * Math.Cos((theta1 + dtheta * ic) * Math.PI / 180.0)); //m.setNodeCoord(n, 1, (ri + dt * it) * Math.Sin((theta1 + dtheta * ic) * Math.PI / 180.0)); //n++; //} //else if (ic % 2 == 0 && it % 2 == 1) // midside node on vertical element side - 1, 5 //{ //m.setNodeCoord(n, 0, (ri + dt * it) * Math.Cos((theta1 + dtheta * ic) * Math.PI / 180.0)); //m.setNodeCoord(n, 1, (ri + dt * it) * Math.Sin((theta1 + dtheta * ic) * Math.PI / 180.0)); //n++; //} } } }
private void doTranslate() { if (m.nDim == 2 && axis == 'z') { return; } int iax = getIntAxis(axis); for (int i = 0; i < m.nNod; i++) { m.setNodeCoord(i, iax, m.getNodeCoord(i, iax) + value); } }
// Add scaled displacements to nodal coordinates and // center finite element mesh void modifyNodeCoordinates() { // Deformed shape: add scaled displacements // to nodal coordinates if (VisData.showDeformShape) { setBoundingBox(); double displMax = 0; for (int i = 0; i < fem.nNod; i++) { double d = 0; for (int j = 0; j < fem.nDim; j++) { double s = VisData.displ[i * fem.nDim + j]; d += s * s; } displMax = Math.Max(d, displMax); } displMax = Math.Sqrt(displMax); // Scale for visualization of deformed shape double scaleD = sizeMax * VisData.deformScale / displMax; for (int i = 0; i < fem.nNod; i++) { for (int j = 0; j < fem.nDim; j++) { fem.setNodeCoord(i, j, fem.getNodeCoord(i, j) + scaleD * VisData.displ[i * fem.nDim + j]); } } } setBoundingBox(); // Translate JFEM model to have the bounding // box center at (0,0,0). double[] xyzC = new double[3]; for (int j = 0; j < 3; j++) { xyzC[j] = 0.5 * (xyzmin[j] + xyzmax[j]); } for (int i = 0; i < fem.nNod; i++) { for (int j = 0; j < fem.nDim; j++) { fem.setNodeCoord(i, j, fem.getNodeCoord(i, j) - xyzC[j]); } } }
private void generateMesh() { int[] ind = new int[2]; m.nDim = this.ndim; // Connectivity array m.nEl = this.n; m.elems = new Element[m.nEl]; int el = 0; for (int i = 0; i < this.n; i++) { m.elems[el] = Element.newElement(this.elType); m.elems[el].A = this.a; ind[0] = i + 1; ind[1] = i + 2; m.elems[el].setElemConnectivities(ind); m.elems[el].setElemMaterial(mat); el++; } // Node coordinate array m.nNod = this.n + 1; m.newCoordArray(); int nid = 0; double L, l; double lij = 0, mij = 0, nij = 0; L = Math.Sqrt(Math.Pow(ys[1] - ys[0], 2) + Math.Pow(xs[1] - xs[0], 2) + (m.nDim == 3 ? Math.Pow(zs[1] - zs[0], 2) : 0.0)); l = L / (double)this.n; lij = (xs[1] - xs[0]) / L; mij = (ys[1] - ys[0]) / L; nij = (m.nDim == 3 ? (zs[1] - zs[0]) / L : 0.0); for (int i = 0; i < this.n + 1; i++) { m.setNodeCoord(nid, 0, xs[0] + i * l * lij); m.setNodeCoord(nid, 1, ys[0] + i * l * mij); if (m.nDim == 3) { m.setNodeCoord(nid, 2, zs[0] + i * l * nij); } nid++; } }
private void generateMesh() { int[] ind = new int[4]; m.nDim = 2; // Connectivity array m.nEl = nx * ny; m.elems = new Element[m.nEl]; int el = 0; for (int iy = 0; iy < ny; iy++) { for (int ix = 0; ix < nx; ix++) { m.elems[el] = Element.newElement("quad4"); m.elems[el].t = this.t; int in0 = iy * (nx + 1) + ix + 1; ind[0] = in0; ind[1] = in0 + 1; int in1 = (iy + 1) * (nx + 1) + ix + 1; ind[2] = in1 + 1; ind[3] = in1; m.elems[el].setElemConnectivities(ind); m.elems[el].setElemMaterial(mat); el++; } } // Node coordinate array m.nNod = (nx + 1) * (ny + 1);// (3 * nx + 2) * ny + 2 * nx + 1; m.newCoordArray(); int n = 0; for (int iy = 0; iy < ny + 1; iy++) { for (int ix = 0; ix < nx + 1; ix++) { m.setNodeCoord(n, 0, xs[ix]); m.setNodeCoord(n, 1, ys[iy]); n++; } } }
private void generateMesh() { int[] ind = new int[8]; m.nDim = 2; // Connectivity array m.nEl = nx * ny; m.elems = new Element[m.nEl]; int el = 0; for (int iy = 0; iy < ny; iy++) { for (int ix = 0; ix < nx; ix++) { m.elems[el] = Element.newElement("quad8r"); int in0 = iy * (3 * nx + 2) + 2 * ix; ind[0] = in0 + 1; ind[1] = in0 + 2; ind[2] = in0 + 3; int in1 = iy * (3 * nx + 2) + 2 * nx + 1 + ix + 1; ind[3] = in1 + 1; ind[7] = in1; int in2 = (iy + 1) * (3 * nx + 2) + 2 * ix; ind[4] = in2 + 3; ind[5] = in2 + 2; ind[6] = in2 + 1; m.elems[el].setElemConnectivities(ind); m.elems[el].setElemMaterial(mat); el++; } } // Node coordinate array m.nNod = (3 * nx + 2) * ny + 2 * nx + 1; m.newCoordArray(); int n = 0; for (int iy = 0; iy < 2 * ny + 1; iy++) { int py = (iy + 1) / 2; for (int ix = 0; ix < 2 * nx + 1; ix++) { int px = (ix + 1) / 2; if (ix % 2 == 0 && iy % 2 == 0) { m.setNodeCoord(n, 0, xs[px]); m.setNodeCoord(n, 1, ys[py]); n++; } else if (ix % 2 == 1 && iy % 2 == 0) { m.setNodeCoord(n, 0, 0.5 * (xs[px - 1] + xs[px])); m.setNodeCoord(n, 1, ys[py]); n++; } else if (ix % 2 == 0 && iy % 2 == 1) { m.setNodeCoord(n, 0, xs[px]); m.setNodeCoord(n, 1, 0.5 * (ys[py - 1] + ys[py])); n++; } } } }
private void generateMesh() { int[] ind = new int[8]; m.nDim = 2; // Element connectivities m.nEl = nh * nv; m.elems = new Element[m.nEl]; int n = 0; for (int iv = 0; iv < nv; iv++) { for (int ih = 0; ih < nh; ih++) { m.elems[n] = Element.newElement("quad8r"); int in0 = iv * (3 * nh + 2) + 2 * ih; ind[0] = in0 + 1; ind[1] = in0 + 2; ind[2] = in0 + 3; int in1 = iv * (3 * nh + 2) + 2 * nh + ih + 2; ind[3] = in1 + 1; ind[7] = in1; int in2 = (iv + 1) * (3 * nh + 2) + 2 * ih; ind[4] = in2 + 3; ind[5] = in2 + 2; ind[6] = in2 + 1; m.elems[n].setElemConnectivities(ind); m.elems[n].setElemMaterial(mat); n++; } } // Shift of midside nodes for element in xi, eta midsideNodeShift(); // Node coordinate array m.nNod = (3 * nh + 2) * nv + 2 * nh + 1; m.newCoordArray(); n = 0; double dxi = 1.0 / nh; double det = 1.0 / nv; for (int iv = 0; iv < 2 * nv + 1; iv++) { for (int ih = 0; ih < 2 * nh + 1; ih++) { if (iv % 2 == 1 && ih % 2 == 1) { continue; } double xi = -1.0 + dxi * ih; double et = -1.0 + det * iv; // First quadratic transform: xi,et -> s,t double s, t; if (ih % 2 == 0) { s = quadraticTransform(xip, xi, et); } else { s = 0.5 * (quadraticTransform(xip, xi - dxi, et) + quadraticTransform(xip, xi + dxi, et)); } if (iv % 2 == 0) { t = quadraticTransform(etp, xi, et); } else { t = 0.5 * (quadraticTransform(etp, xi, et - det) + quadraticTransform(etp, xi, et + det)); } // Second quadratic transform: s,t -> x,y m.setNodeCoord(n, 0, quadraticTransform(xp, s, t)); m.setNodeCoord(n, 1, quadraticTransform(yp, s, t)); n++; } } }
private void generateMesh() { int[] ind = new int[8]; m.nDim = 2; // Connectivity array m.nEl = nc * nt; m.elems = new Element[m.nEl]; int el = 0; for (int ic = 0; ic < nc; ic++) { for (int it = 0; it < nt; it++) { m.elems[el] = Element.newElement("quad8r"); int in0 = ic * (3 * nt + 2) + 2 * it; ind[0] = in0 + 1; ind[1] = in0 + 2; ind[2] = in0 + 3; int in1 = ic * (3 * nt + 2) + 2 * nt + it + 2; ind[3] = in1 + 1; ind[7] = in1; int in2 = (ic + 1) * (3 * nt + 2) + 2 * it; ind[4] = in2 + 3; ind[5] = in2 + 2; ind[6] = in2 + 1; m.elems[el].setElemConnectivities(ind); m.elems[el].setElemMaterial(mat); el++; } } // Node coordinate array m.nNod = (3 * nt + 2) * nc + 2 * nt + 1; m.newCoordArray(); int n = 0; for (int ic = 0; ic < 2 * nc + 1; ic++) { //int pt = (ic + 1) / 2; for (int it = 0; it < 2 * nt + 1; it++) { //int pc = (it + 1) / 2; if (ic % 2 == 0 && it % 2 == 0) // corner noder - 0, 2, 4, 6 { m.setNodeCoord(n, 0, (ri + dt * it) * Math.Cos((theta1 + dtheta * ic) * Math.PI / 180.0)); m.setNodeCoord(n, 1, (ri + dt * it) * Math.Sin((theta1 + dtheta * ic) * Math.PI / 180.0)); n++; } else if (ic % 2 == 1 && it % 2 == 0) // midside node on horizontal element side - 3, 7 { m.setNodeCoord(n, 0, (ri + dt * it) * Math.Cos((theta1 + dtheta * ic) * Math.PI / 180.0)); m.setNodeCoord(n, 1, (ri + dt * it) * Math.Sin((theta1 + dtheta * ic) * Math.PI / 180.0)); n++; } else if (ic % 2 == 0 && it % 2 == 1) // midside node on vertical element side - 1, 5 { m.setNodeCoord(n, 0, (ri + dt * it) * Math.Cos((theta1 + dtheta * ic) * Math.PI / 180.0)); m.setNodeCoord(n, 1, (ri + dt * it) * Math.Sin((theta1 + dtheta * ic) * Math.PI / 180.0)); n++; } } } }