Rocstar  1.0
Rocstar multiphysics simulation application
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
simpleblock.cpp
Go to the documentation of this file.
1 /* *******************************************************************
2  * Illinois Open Source License *
3  * *
4  * University of Illinois/NCSA *
5  * Open Source License *
6  * *
7  * Copyright@2008, University of Illinois. All rights reserved. *
8  * *
9  * Developed by: *
10  * *
11  * Center for Simulation of Advanced Rockets *
12  * *
13  * University of Illinois *
14  * *
15  * www.csar.uiuc.edu *
16  * *
17  * Permission is hereby granted, free of charge, to any person *
18  * obtaining a copy of this software and associated documentation *
19  * files (the "Software"), to deal with the Software without *
20  * restriction, including without limitation the rights to use, *
21  * copy, modify, merge, publish, distribute, sublicense, and/or *
22  * sell copies of the Software, and to permit persons to whom the *
23  * Software is furnished to do so, subject to the following *
24  * conditions: *
25  * *
26  * *
27  * @ Redistributions of source code must retain the above copyright *
28  * notice, this list of conditions and the following disclaimers. *
29  * *
30  * @ Redistributions in binary form must reproduce the above *
31  * copyright notice, this list of conditions and the following *
32  * disclaimers in the documentation and/or other materials *
33  * provided with the distribution. *
34  * *
35  * @ Neither the names of the Center for Simulation of Advanced *
36  * Rockets, the University of Illinois, nor the names of its *
37  * contributors may be used to endorse or promote products derived *
38  * from this Software without specific prior written permission. *
39  * *
40  * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, *
41  * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES *
42  * OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND *
43  * NONINFRINGEMENT. IN NO EVENT SHALL THE CONTRIBUTORS OR *
44  * COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER *
45  * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, *
46  * ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE *
47  * USE OR OTHER DEALINGS WITH THE SOFTWARE. *
48  *********************************************************************
49  * Please acknowledge The University of Illinois Center for *
50  * Simulation of Advanced Rockets in works and publications *
51  * resulting from this software or its derivatives. *
52  *********************************************************************/
53 /*
54 Create a single, extremely simple block-- a regular,
55 axis-aligned box.
56 
57 Orion Sky Lawlor, olawlor@acm.org, 7/18/2001
58 */
59 #include <stdio.h>
60 #include "adj.h"
61 #include "util.h"
62 #include "makeflo.h"
63 
64 void printUsage(const char *why)
65 {
66  printf("Usage: simpleblock <output .msh or .hdf file>\n"
67  " <X start> <X end> <X steps> \n"
68  " <Y start> <Y end> <Y steps> \n"
69  " <Z start> <Z end> <Z steps> \n"
70  " Write out a single axis-aligned block with the given dimensions\n"
71  "and coordinate extents. \n"
72  );
73  if (why!=NULL)
74  printf("Exiting> %s\n",why);
75  exit(1);
76 }
77 
79 
80 int main(int argc,char *argv[])
81 {
82 //Parse the command line arguments
83  if (argc!=11) printUsage("Not enough command-line arguments");
84  int curArg=1;
85  const char *outMesh=argv[curArg++];
86  blockDim dim;
87  vector3d start,end;
88  int axis;
89  static const char *axisNames[]={"X","Y","Z"};
90  for (axis=0;axis<3;axis++) {
91  double s,e;
92  if (1!=sscanf(argv[curArg++],"%lg",&s))
93  printUsage("Couldn't parse axis start");
94  if (1!=sscanf(argv[curArg++],"%lg",&e))
95  printUsage("Couldn't parse axis end");
96  start[axis]=s; end[axis]=e;
97  if (1!=sscanf(argv[curArg++],"%d",&dim[axis]))
98  printUsage("Couldn't parse axis size");
99  printf("Along %s axis: (%f - %f) in %d steps\n",axisNames[axis],
100  start[axis],end[axis],dim[axis]);
101  }
102 
103 //Build a regular 3D block of points
104  vector3d *locs=new vector3d[dim.getSize()];
105  blockLoc i;
106  for (i[2]=0; i[2]<dim[2]; i[2]++)
107  for (i[1]=0; i[1]<dim[1]; i[1]++)
108  for (i[0]=0; i[0]<dim[0]; i[0]++) {
109  vector3d p;
110  for (axis=0;axis<3;axis++)
111  p[axis]=start[axis]+((end[axis]-start[axis])*i[axis])/(dim[axis]-1);
112  locs[dim[i]]=p;
113  }
114  printf("Locations built\n");
115 
116  vector<block *> blocks;
117  blocks.push_back(new block(dim,0,0,locs));
118  printf("Block built\n");
119 
120 //Write out the new block
121  writeBlocks(blocks,outMesh);
122  printf("Program finished successfully\n");
123  return 0;
124 }
125 
126 
127 
128 
129 
130 
131 
double s
Definition: blastest.C:80
const char * writeBlocks(vector< block * > &blocks, const char *outMesh)
Definition: write.cpp:147
void printUsage(const char *why)
Definition: makeflo.cpp:68
Definition: adj.h:203
blockLoc i
Definition: read.cpp:79
bool blocks
Input data is block-structured grid.
Definition: hdf2pltV2.C:51
int main(int argc, char *argv[])
Definition: blastest.C:94
makefloParam parameters
Definition: makeflo.cpp:101
int getSize(void) const
Definition: gridutil.h:126