Advertisement
Guest User

Untitled

a guest
Oct 23rd, 2018
88
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.43 KB | None | 0 0
  1. public class Grid {
  2.  
  3. int nH, nL, nh, nE;
  4. double H, L;
  5. Node node[];
  6. Element element[];
  7.  
  8.  
  9. void genGrid(){
  10.  
  11. int avoidElement = 1; //nie tworzymy elementów co nH
  12.  
  13. for(int i=0;i<element.length;i++){
  14. if(i==avoidElement*nH-avoidElement)avoidElement++;
  15. element[i]= new Element(i+avoidElement,nH);
  16. }
  17.  
  18. for(int i=0;i<node.length;i++){
  19. node[i]=new Node();
  20. }
  21. double delX = H/(nH-1);
  22. double delY = L/(nL-1);
  23. double x = 0, y = 0;
  24. int counter = 0;
  25. for(int i=1;i<=nL;i++){
  26. for(int j=0;j<nH;j++){
  27. node[counter].x=x;
  28. node[counter].y=y;
  29. y+=delY;
  30. counter++;
  31. }
  32. y=0;
  33. x+=delX;
  34. }
  35. }
  36.  
  37. void printGrid(){
  38. for(int i=0;i<element.length;i++){
  39. System.out.printf("Dla elementu " + i + " "); element[i].printElement();
  40. }
  41. for(int i=0;i<node.length;++i){
  42. System.out.printf("Wspolrzedne wezla " + i + ": "); node[i].printNode();
  43. }
  44. }
  45.  
  46. public Grid(int nH, int nL, double H, double L) {
  47. this.nH = nH;
  48. this.nL = nL;
  49. this.nh = nH * nL;
  50. this.nE = (nL - 1) * (nH - 1);
  51. this.H = H;
  52. this.L = L;
  53. this.node = new Node[nh];
  54. this.element = new Element[nE];
  55. }
  56. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement