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;
172 cout <<
" <ELEMENT>" << endl;
174 for(j = 0; j < ny-1; ++j)
176 for(i = 0; i < nx-1; ++i)
178 cout <<
" <Q ID=\"" << cnt++ <<
"\">\t";
179 cout << j*((nx-1)+nx)+i <<
" " << j*((nx-1)+nx) + (nx-1)+i+1 <<
" " ;
180 cout << (j+1)*((nx-1)+nx)+i <<
" " << j*((nx-1)+nx) + (nx-1)+i ;
181 cout <<
" </Q>" << endl;
184 cout <<
" </ELEMENT>\n" << endl;
187 cout <<
"<COMPOSITE>" << endl;
188 cout <<
"<C ID=\"0\"> Q[0-" << (nx-1)*(ny-1)-1 <<
"] </C>" << endl;
190 cout <<
"<C ID=\"1\"> E[";
191 for(i = 0; i < nx-1; ++i)
199 cout <<
"] </C> // south border" << endl;
201 cout <<
"<C ID=\"2\"> E[";
202 for(i = 0; i < ny-1; ++i)
204 cout << (nx-1)*(i+1) + nx*i;
210 cout <<
"] </C> // west border" << endl;
212 cout <<
"<C ID=\"3\"> E[";
213 for(i = 0; i < nx-1; ++i)
215 cout << (nx-1)*(ny-1)+ nx*(ny-1)+ i;
221 cout <<
"] </C> // north border" << endl;
223 cout <<
"<C ID=\"4\"> E[";
224 for(i = 0; i < ny-1; ++i)
226 cout << (nx-1)*(i+1) + nx*i + nx-1;
232 cout <<
"] </C> // East border" << endl;
235 cout <<
"</COMPOSITE>\n" << endl;
238 cout <<
"<DOMAIN> C[0] </DOMAIN>\n" << endl;
239 cout <<
"</GEOMETRY>\n" << endl;
241 cout <<
"</NEKTAR>" << endl;
257 cout <<
"<CONDITIONS>" << endl;
259 cout <<
"<SOLVERINFO>" << endl;
260 cout <<
"<I PROPERTY=\"SolverType\" VALUE=\" \"/>" << endl;
261 cout <<
"</SOLVERINFO>\n" << endl;
263 cout <<
"<PARAMETERS>" << endl;
264 cout <<
"<P> TimeStep = 0.002 </P>" << endl;
265 cout <<
"</PARAMETERS>\n" << endl;
267 cout <<
"<VARIABLES>" << endl;
268 cout <<
" <V ID=\"0\"> u </V>" << endl;
269 cout <<
"</VARIABLES>\n" << endl;
271 cout <<
"<BOUNDARYREGIONS>" << endl;
272 cout <<
"<B ID=\"0\"> C[1] </B>" << endl;
273 cout <<
"<B ID=\"1\"> C[2] </B>" << endl;
274 cout <<
"<B ID=\"2\"> C[3] </B>" << endl;
275 cout <<
"<B ID=\"3\"> C[4] </B>" << endl;
276 cout <<
"</BOUNDARYREGIONS>\n" << endl;
278 cout <<
"<BOUNDARYCONDITIONS>" << endl;
279 cout <<
" <REGION REF=\"0\"> // South border " << endl;
280 cout <<
" <D VAR=\"u\" VALUE=\"0\" />" << endl;
281 cout <<
" </REGION>" << endl;
283 cout <<
" <REGION REF=\"1\"> // West border " << endl;
284 cout <<
" <D VAR=\"u\" VALUE=\"0\" />" << endl;
285 cout <<
" </REGION>" << endl;
287 cout <<
" <REGION REF=\"2\"> // North border " << endl;
288 cout <<
" <D VAR=\"u\" VALUE=\"0\" />" << endl;
289 cout <<
" </REGION>" << endl;
291 cout <<
" <REGION REF=\"3\"> // East border " << endl;
292 cout <<
" <D VAR=\"u\" VALUE=\"0\" />" << endl;
293 cout <<
" </REGION>" << endl;
294 cout <<
"</BOUNDARYCONDITIONS>" << endl;
296 cout <<
"</CONDITIONS>" << endl;
#define ASSERTL0(condition, msg)
void PrintConditions(void)
int main(int argc, char *argv[])
void Header(FILE *, int nel)