@@ -41,7 +41,7 @@ public class ReadCSVStructured2D {
41
41
public String fileName = null ;
42
42
43
43
@ In
44
- public String splitter = " " ;
44
+ public String splitter = ", " ;
45
45
46
46
@ In
47
47
public boolean printFile = false ;
@@ -69,114 +69,116 @@ public class ReadCSVStructured2D {
69
69
private int nElements = -999 ;
70
70
private int nBorderEdges = -999 ;
71
71
72
- // private int step = 0;
72
+ private int step = 0 ;
73
73
74
74
/**
75
75
* @param args
76
76
* @throws IOException
77
77
*/
78
- @ Initialize
78
+ @ Execute
79
79
public void process () throws IOException {
80
80
81
+ if (step ==0 ) {
82
+
83
+ verticesCoordinates .add (0 , new Double [] {-9999.0 ,-9999.0 });
84
+ elementsVertices .add (0 , new Integer [] {-9999 ,-9999 ,-9999 });
85
+ elementsLabel .add (0 , -9999 );
86
+ borderEdgesVertices .add (0 , new Integer [] {-9999 ,-9999 });
87
+ borderEdgesLabel .add (0 , -9999 );
88
+
89
+ File file = new File (fileName );
90
+ FileInputStream fis = new FileInputStream (file );
91
+ InputStreamReader isr = new InputStreamReader (fis );
92
+ BufferedReader br = new BufferedReader (isr );
93
+
94
+ String line ;
95
+ System .out .println ("Opened the file: " + fileName + "\n \n " );
96
+
97
+ if (printFile == true ) {
98
+ while ((line = br .readLine ()) != null ){
99
+ System .out .println (line );
100
+ }
101
+ }
81
102
82
- verticesCoordinates .add (0 , new Double [] {-9999.0 ,-9999.0 });
83
- elementsVertices .add (0 , new Integer [] {-9999 ,-9999 ,-9999 });
84
- elementsLabel .add (0 , -9999 );
85
- borderEdgesVertices .add (0 , new Integer [] {-9999 ,-9999 });
86
- borderEdgesLabel .add (0 , -9999 );
103
+ int iLine = 0 ;
104
+ while ((line = br .readLine ()) != null ){
87
105
88
- File file = new File (fileName );
89
- FileInputStream fis = new FileInputStream (file );
90
- InputStreamReader isr = new InputStreamReader (fis );
91
- BufferedReader br = new BufferedReader (isr );
106
+ String [] lineContent = line .split (splitter );
92
107
93
- String line ;
94
- System .out .println ("Opened the file: " + fileName + "\n \n " );
95
-
96
- if (printFile == true ) {
97
- while ((line = br .readLine ()) != null ){
98
- System .out .println (line );
99
- }
100
- }
101
-
102
- int iLine = 0 ;
103
- while ((line = br .readLine ()) != null ){
104
-
105
- String [] lineContent = line .split (splitter );
106
-
107
- if (iLine ==0 ) {
108
-
109
- nVertices = Integer .valueOf (lineContent [0 ]);
110
- nElements = Integer .valueOf (lineContent [1 ]);
111
- nBorderEdges = Integer .valueOf (lineContent [2 ]);
112
-
113
- } else if (iLine >0 && iLine <=nVertices ) {
114
-
115
- verticesCoordinates .add (iLine , new Double [] { Double .valueOf (lineContent [0 ]),Double .valueOf (lineContent [1 ]) } );
116
-
117
- } else if (iLine >nVertices && iLine <=nVertices +nElements ) {
118
-
119
- elementsVertices .add (iLine -nVertices , new Integer [] { Integer .valueOf (lineContent [0 ]),Integer .valueOf (lineContent [1 ]),
120
- Integer .valueOf (lineContent [2 ]),Integer .valueOf (lineContent [3 ]) } );
121
- elementsLabel .add (iLine -nVertices , Integer .valueOf (lineContent [4 ]));
122
-
123
- } else {
124
-
125
- borderEdgesVertices .add (iLine -(nVertices +nElements ), new Integer [] {-9999 , -9999 } );
126
- borderEdgesLabel .add (iLine -(nVertices +nElements ), -9999 );
127
-
128
- if (Integer .valueOf (lineContent [2 ]) == -1 ) {
129
- // this is an internal boundary
130
- } else {
131
-
132
- borderEdgesVertices .set (iLine -(nVertices +nElements ), new Integer [] { Integer .valueOf (lineContent [0 ]),Integer .valueOf (lineContent [1 ]) } );
133
- borderEdgesLabel .set (iLine -(nVertices +nElements ), Integer .valueOf (lineContent [2 ]));
134
-
108
+ if (iLine ==0 ) {
109
+
110
+ nVertices = Integer .valueOf (lineContent [0 ]);
111
+ nElements = Integer .valueOf (lineContent [1 ]);
112
+ nBorderEdges = Integer .valueOf (lineContent [2 ]);
113
+
114
+ } else if (iLine >0 && iLine <=nVertices ) {
115
+
116
+ verticesCoordinates .add (iLine , new Double [] { Double .valueOf (lineContent [0 ]),Double .valueOf (lineContent [1 ]) } );
117
+
118
+ } else if (iLine >nVertices && iLine <=nVertices +nElements ) {
119
+
120
+ elementsVertices .add (iLine -nVertices , new Integer [] { Integer .valueOf (lineContent [0 ]),Integer .valueOf (lineContent [1 ]),
121
+ Integer .valueOf (lineContent [2 ]),Integer .valueOf (lineContent [3 ]) } );
122
+ elementsLabel .add (iLine -nVertices , Integer .valueOf (lineContent [4 ]));
123
+
124
+ } else {
125
+
126
+ borderEdgesVertices .add (iLine -(nVertices +nElements ), new Integer [] {-9999 , -9999 } );
127
+ borderEdgesLabel .add (iLine -(nVertices +nElements ), -9999 );
128
+
129
+ if (Integer .valueOf (lineContent [2 ]) == -1 ) {
130
+ // this is an internal boundary
131
+ } else {
132
+
133
+ borderEdgesVertices .set (iLine -(nVertices +nElements ), new Integer [] { Integer .valueOf (lineContent [0 ]),Integer .valueOf (lineContent [1 ]) } );
134
+ borderEdgesLabel .set (iLine -(nVertices +nElements ), Integer .valueOf (lineContent [2 ]));
135
+
136
+ }
135
137
}
138
+
139
+ iLine ++;
140
+
136
141
}
137
142
138
- iLine ++;
143
+ br .close ();
144
+ System .out .println ("Reading mesh file completed." );
139
145
140
- }
141
146
142
- br .close ();
143
- System .out .println ("Reading mesh file completed." );
144
147
148
+ /*
149
+ * Check informations are correctly stored
150
+ */
151
+ if (checkData == true ) {
145
152
153
+ System .out .println ("\n \t nVertices : " +nVertices );
154
+ System .out .println ("\t nElements : " +nElements );
155
+ System .out .println ("\t nBorderEdges : " +nBorderEdges );
146
156
147
- /*
148
- * Check informations are correctly stored
149
- */
150
- if (checkData == true ) {
151
-
152
- System .out .println ("\n \t nVertices : " +nVertices );
153
- System .out .println ("\t nElements : " +nElements );
154
- System .out .println ("\t nBorderEdges : " +nBorderEdges );
157
+ System .out .println ("\n Vertices set :" );
158
+ for (int vertex =1 ; vertex <verticesCoordinates .size (); vertex ++) {
159
+ System .out .println (" " + vertex + " : " + verticesCoordinates .get (vertex )[0 ] + "," +verticesCoordinates .get (vertex )[1 ]);
160
+ }
155
161
156
- System .out .println ("\n Vertices set :" );
157
- for (int vertex =1 ; vertex <verticesCoordinates .size (); vertex ++) {
158
- System .out .println (" " + vertex + " : " + verticesCoordinates .get (vertex )[0 ] + "," +verticesCoordinates .get (vertex )[1 ]);
159
- }
162
+ System .out .println ("\n Elements' vertices :" );
163
+ for (int element =1 ; element <elementsVertices .size (); element ++) {
164
+ System .out .println (" " + element + " : " + elementsVertices .get (element )[0 ] + "," +elementsVertices .get (element )[1 ]
165
+ + "," +elementsVertices .get (element )[2 ] + "," +elementsVertices .get (element )[3 ] + " ; " + elementsLabel .get (element ));
166
+ }
160
167
161
- System .out .println ("\n Elements' vertices :" );
162
- for (int element =1 ; element < elementsVertices .size (); element ++) {
163
- System .out .println (" " + element + " : " + elementsVertices .get (element )[0 ] + "," +elementsVertices .get (element )[1 ]
164
- + "," + elementsVertices . get ( element )[ 2 ] + "," + elementsVertices . get ( element )[ 3 ] + " ; " + elementsLabel .get (element ));
165
- }
168
+ System .out .println ("\n Border edges :" );
169
+ for (int edge =1 ; edge < borderEdgesVertices .size (); edge ++) {
170
+ System .out .println (" " + edge + " : " + borderEdgesVertices .get (edge )[0 ] + "," +borderEdgesVertices .get (edge )[1 ]
171
+ + " ; " + borderEdgesLabel .get (edge ));
172
+ }
166
173
167
- System .out .println ("\n Border edges :" );
168
- for (int edge =1 ; edge <borderEdgesVertices .size (); edge ++) {
169
- System .out .println (" " + edge + " : " + borderEdgesVertices .get (edge )[0 ] + "," +borderEdgesVertices .get (edge )[1 ]
170
- + " ; " + borderEdgesLabel .get (edge ));
171
174
}
172
175
173
- }
174
-
175
- System .out .println ("\n Exit ReadCSVStructured\n \n \n " );
176
+ System .out .println ("\n Exit ReadCSVStructured\n \n \n " );
176
177
177
- // }
178
+ }
178
179
179
- // step++;
180
+ step ++;
181
+
180
182
}// close @Execute
181
183
182
184
public static void main (String [] args ) throws IOException {
0 commit comments