17 void Header(FILE *,
int nel);
25 int main(
int argc,
char *argv[])
33 fprintf(stderr,
"Usage RectanuglarMesh file\n");
39 TiXmlDocument doc(argv[argc-1]);
40 bool loadOkay = doc.LoadFile();
42 std::stringstream errstr;
43 errstr <<
"Unable to load file: " << argv[argc-1] <<
" (";
44 errstr << doc.ErrorDesc() <<
", line " << doc.ErrorRow()
45 <<
", column " << doc.ErrorCol() <<
")";
48 TiXmlHandle docHandle(&doc);
49 TiXmlElement* master = NULL;
50 TiXmlElement* block = NULL;
52 master = doc.FirstChildElement(
"NEKBLOCK");
53 ASSERTL0(master,
"Unable to find NEKBLOCK tag in file.");
56 block = master->FirstChildElement(
"XBLOCK");
58 ASSERTL0(block,
"Unable to find XBLOCK tag in file.");
59 TiXmlElement *val = block->FirstChildElement(
"X");
62 TiXmlNode *xval = val->FirstChild();
64 std::istringstream valDataStrm(xval->ToText()->Value());
68 while(!valDataStrm.fail())
73 if (!valDataStrm.fail())
81 ASSERTL0(
false,
"Unable to read Xval data.");
84 val= val->NextSiblingElement(
"X");
87 block = master->FirstChildElement(
"YBLOCK");
89 val = block->FirstChildElement(
"Y");
92 TiXmlNode *yval = val->FirstChild();
94 std::istringstream valDataStrm(yval->ToText()->Value());
98 while(!valDataStrm.fail())
101 valDataStrm >> y_val;
103 if (!valDataStrm.fail())
111 ASSERTL0(
false,
"Unable to read Yval data.");
114 val= val->NextSiblingElement(
"Y");
117 cout <<
"<?xml version=\"1.0\" encoding=\"utf-8\" ?>" << endl;
118 cout <<
"<NEKTAR>" << endl;
121 cout <<
"<EXPANSIONS>" << endl;
122 cout <<
"<E COMPOSITE=\"C[0]\" NUMMODES=\"7\" FIELDS=\"u\" TYPE=\"MODIFIED\" />" <<endl;
123 cout <<
"</EXPANSIONS>\n" << endl;
128 cout <<
"<GEOMETRY DIM=\"2\" SPACE=\"2\">" << endl;
129 cout <<
" <VERTEX>" << endl;
133 for(j = 0; j < ny; ++j)
135 for(k = 0; k < nx; ++k)
137 cout <<
" <V ID=\"" << j*nx+k <<
"\">\t";
138 cout << std::setprecision(8)<< xc[k] <<
" " << yc[j] <<
" 0.0";
139 cout <<
" </V>" << endl;
143 cout <<
" </VERTEX>\n" << endl;
145 cout <<
" <EDGE>" << endl;
147 for(j = 0; j < ny-1; ++j)
149 for(i = 0; i < nx-1; ++i)
151 cout <<
" <E ID=\"" << cnt++ <<
"\">\t";
152 cout << j*nx+i <<
" " << j*nx + i+1 ;
153 cout <<
" </E>" << endl;
156 for(i = 0; i < nx; ++i)
158 cout <<
" <E ID=\"" << cnt++ <<
"\">\t";
159 cout << j*nx+i <<
" " << (j+1)*nx+i;
160 cout <<
" </E>" << endl;
164 for(i = 0; i < nx-1; ++i)
166 cout <<
" <E ID=\"" << cnt++ <<
"\">\t";
167 cout << j*nx+i <<
" " << j*nx + i+1 ;
168 cout <<
" </E>" << endl;
170 cout <<
" </EDGE>\n" << endl;
174 cout <<
" <ELEMENT>" << endl;
176 for(j = 0; j < ny-1; ++j)
178 for(i = 0; i < nx-1; ++i)
180 cout <<
" <Q ID=\"" << cnt++ <<
"\">\t";
181 cout << j*((nx-1)+nx)+i <<
" " << j*((nx-1)+nx) + (nx-1)+i+1 <<
" " ;
182 cout << (j+1)*((nx-1)+nx)+i <<
" " << j*((nx-1)+nx) + (nx-1)+i ;
183 cout <<
" </Q>" << endl;
186 cout <<
" </ELEMENT>\n" << endl;
189 cout <<
"<COMPOSITE>" << endl;
190 cout <<
"<C ID=\"0\"> Q[0-" << (nx-1)*(ny-1)-1 <<
"] </C>" << endl;
192 cout <<
"<C ID=\"1\"> E[";
193 for(i = 0; i < nx-1; ++i)
201 cout <<
"] </C> // south border" << endl;
203 cout <<
"<C ID=\"2\"> E[";
204 for(i = 0; i < ny-1; ++i)
206 cout << (nx-1)*(i+1) + nx*i;
212 cout <<
"] </C> // west border" << endl;
214 cout <<
"<C ID=\"3\"> E[";
215 for(i = 0; i < nx-1; ++i)
217 cout << (nx-1)*(ny-1)+ nx*(ny-1)+ i;
223 cout <<
"] </C> // north border" << endl;
225 cout <<
"<C ID=\"4\"> E[";
226 for(i = 0; i < ny-1; ++i)
228 cout << (nx-1)*(i+1) + nx*i + nx-1;
234 cout <<
"] </C> // East border" << endl;
237 cout <<
"</COMPOSITE>\n" << endl;
240 cout <<
"<DOMAIN> C[0] </DOMAIN>\n" << endl;
241 cout <<
"</GEOMETRY>\n" << endl;
243 cout <<
"</NEKTAR>" << endl;
259 cout <<
"<CONDITIONS>" << endl;
261 cout <<
"<SOLVERINFO>" << endl;
262 cout <<
"<I PROPERTY=\"SolverType\" VALUE=\" \"/>" << endl;
263 cout <<
"</SOLVERINFO>\n" << endl;
265 cout <<
"<PARAMETERS>" << endl;
266 cout <<
"<P> TimeStep = 0.002 </P>" << endl;
267 cout <<
"</PARAMETERS>\n" << endl;
269 cout <<
"<VARIABLES>" << endl;
270 cout <<
" <V ID=\"0\"> u </V>" << endl;
271 cout <<
"</VARIABLES>\n" << endl;
273 cout <<
"<BOUNDARYREGIONS>" << endl;
274 cout <<
"<B ID=\"0\"> C[1] </B>" << endl;
275 cout <<
"<B ID=\"1\"> C[2] </B>" << endl;
276 cout <<
"<B ID=\"2\"> C[3] </B>" << endl;
277 cout <<
"<B ID=\"3\"> C[4] </B>" << endl;
278 cout <<
"</BOUNDARYREGIONS>\n" << endl;
280 cout <<
"<BOUNDARYCONDITIONS>" << endl;
281 cout <<
" <REGION REF=\"0\"> // South border " << endl;
282 cout <<
" <D VAR=\"u\" VALUE=\"0\" />" << endl;
283 cout <<
" </REGION>" << endl;
285 cout <<
" <REGION REF=\"1\"> // West border " << endl;
286 cout <<
" <D VAR=\"u\" VALUE=\"0\" />" << endl;
287 cout <<
" </REGION>" << endl;
289 cout <<
" <REGION REF=\"2\"> // North border " << endl;
290 cout <<
" <D VAR=\"u\" VALUE=\"0\" />" << endl;
291 cout <<
" </REGION>" << endl;
293 cout <<
" <REGION REF=\"3\"> // East border " << endl;
294 cout <<
" <D VAR=\"u\" VALUE=\"0\" />" << endl;
295 cout <<
" </REGION>" << endl;
296 cout <<
"</BOUNDARYCONDITIONS>" << endl;
298 cout <<
"</CONDITIONS>" << endl;