Rocstar  1.0
Rocstar multiphysics simulation application
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
bordertest_hex.C
Go to the documentation of this file.
1 /* *******************************************************************
2  * Rocstar Simulation Suite *
3  * Copyright@2015, Illinois Rocstar LLC. All rights reserved. *
4  * *
5  * Illinois Rocstar LLC *
6  * Champaign, IL *
7  * www.illinoisrocstar.com *
8  * sales@illinoisrocstar.com *
9  * *
10  * License: See LICENSE file in top level of distribution package or *
11  * http://opensource.org/licenses/NCSA *
12  *********************************************************************/
13 /* *******************************************************************
14  * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, *
15  * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES *
16  * OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND *
17  * NONINFRINGEMENT. IN NO EVENT SHALL THE CONTRIBUTORS OR *
18  * COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER *
19  * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, *
20  * ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE *
21  * USE OR OTHER DEALINGS WITH THE SOFTWARE. *
22  *********************************************************************/
23 #include "roccom.h"
24 #include <iostream>
25 #include <sstream>
26 
27 using namespace std;
28 
29 COM_EXTERN_MODULE( Rocmap);
31 
32 // ==== Routines for creating mesh information
33 void init_unstructure_mesh( double coors[18][3], int elmts[4][8]) {
34  coors[0][0] = 0.0;
35  coors[0][1] = 0.0;
36  coors[0][2] = 0.0;
37  coors[1][0] = 0.5;
38  coors[1][1] = 0.0;
39  coors[1][2] = 0.0;
40  coors[2][0] = 1.0;
41  coors[2][1] = 0.0;
42  coors[2][2] = 0.0;
43  coors[3][0] = 1.0;
44  coors[3][1] = 0.5;
45  coors[3][2] = 0.0;
46  coors[4][0] = 0.5;
47  coors[4][1] = 0.5;
48  coors[4][2] = 0.0;
49  coors[5][0] = 0.0;
50  coors[5][1] = 0.5;
51  coors[5][2] = 0.0;
52  coors[6][0] = 0.0;
53  coors[6][1] = 1.0;
54  coors[6][2] = 0.0;
55  coors[7][0] = 0.5;
56  coors[7][1] = 1.0;
57  coors[7][2] = 0.0;
58  coors[8][0] = 1.0;
59  coors[8][1] = 1.0;
60  coors[8][2] = 0.0;
61  coors[9][0] = 0.0;
62  coors[9][1] = 0.0;
63  coors[9][2] = 1.0;
64  coors[10][0] = 0.5;
65  coors[10][1] = 0.0;
66  coors[10][2] = 1.0;
67  coors[11][0] = 1.0;
68  coors[11][1] = 0.0;
69  coors[11][2] = 1.0;
70  coors[12][0] = 1.0;
71  coors[12][1] = 0.5;
72  coors[12][2] = 1.0;
73  coors[13][0] = 0.5;
74  coors[13][1] = 0.5;
75  coors[13][2] = 1.0;
76  coors[14][0] = 0.0;
77  coors[14][1] = 0.5;
78  coors[14][2] = 1.0;
79  coors[15][0] = 0.0;
80  coors[15][1] = 1.0;
81  coors[15][2] = 1.0;
82  coors[16][0] = 0.5;
83  coors[16][1] = 1.0;
84  coors[16][2] = 1.0;
85  coors[17][0] = 1.0;
86  coors[17][1] = 1.0;
87  coors[17][2] = 1.0;
88 
89  elmts[0][0] = 1;
90  elmts[0][1] = 2;
91  elmts[0][2] = 5;
92  elmts[0][3] = 6;
93  elmts[0][4] = 10;
94  elmts[0][5] = 11;
95  elmts[0][6] = 14;
96  elmts[0][7] = 15;
97 
98  elmts[1][0] = 2;
99  elmts[1][1] = 3;
100  elmts[1][2] = 4;
101  elmts[1][3] = 5;
102  elmts[1][4] = 11;
103  elmts[1][5] = 12;
104  elmts[1][6] = 13;
105  elmts[1][7] = 14;
106 
107  elmts[2][0] = 5;
108  elmts[2][1] = 4;
109  elmts[2][2] = 9;
110  elmts[2][3] = 8;
111  elmts[2][4] = 14;
112  elmts[2][5] = 13;
113  elmts[2][6] = 18;
114  elmts[2][7] = 17;
115 
116  elmts[3][0] = 6;
117  elmts[3][1] = 5;
118  elmts[3][2] = 8;
119  elmts[3][3] = 7;
120  elmts[3][4] = 15;
121  elmts[3][5] = 14;
122  elmts[3][6] = 17;
123  elmts[3][7] = 16;
124 
125 }
126 
127 int main(int argc, char *argv[]) {
128  const int num_nodes = 18, num_elmts = 4;
129 
130  double coors_s[num_nodes][3];
131  int elmts[num_elmts][8];
132 
133  COM_init( &argc, &argv);
134  COM_LOAD_MODULE_STATIC_DYNAMIC( Rocmap, "MAP");
136 
137  cout << "Creating window \"unstr\"" << endl;
138  COM_new_window("unstr");
139  COM_new_attribute("unstr.borders", 'n', COM_INTEGER, 1, "");
140 
141  init_unstructure_mesh( coors_s, elmts);
142  COM_set_size( "unstr.nc", 1, num_nodes);
143  COM_set_array( "unstr.nc", 1, &coors_s[0][0]);
144  COM_set_size( "unstr.:H8:", 1, num_elmts);
145  COM_set_array( "unstr.:H8:", 1, &elmts[0][0]);
146 
147  COM_resize_array( "unstr.borders");
148  COM_window_init_done("unstr");
149 
150  for(int i =0; i < num_nodes; ++i){
151  cout << "Coors_s[0][" << i <<"] = ["
152  << coors_s[i][0] << " , " << coors_s[i][1] << " , "
153  << coors_s[i][2] << "]" << endl;
154  }
155  for(int i =0; i < num_elmts; ++i){
156  cout << "Element " << i << ": "
157  << elmts[i][0] << " " << elmts[i][1] << " "
158  << elmts[i][2] << " " << elmts[i][3] << " "
159  << elmts[i][4] << " " << elmts[i][5] << " "
160  << elmts[i][6] << " " << elmts[i][7] << endl;
161  }
162 
163  int mesh_hdl = COM_get_attribute_handle("unstr.mesh");
164 
165 
166  std::cout << "Get border nodes... " << endl;
167 
168  int MAP_border_nodes = COM_get_function_handle( "MAP.pane_border_nodes");
169 
170  int borders_hdl = COM_get_attribute_handle( "unstr.borders");
171  COM_call_function( MAP_border_nodes, &mesh_hdl, &borders_hdl);
172 
173  // Output solution into file.
174  int OUT_write = COM_get_function_handle( "OUT.write_attribute");
175 
176  COM_call_function( OUT_write, "hexmesh", &borders_hdl,
177  "hexmesh", "000");
178 
179  COM_finalize();
180 }
181 
182 
183 
184 
185 
186 
void COM_set_size(const char *wa_str, int pane_id, int size, int ng=0)
Set sizes of for a specific attribute.
Definition: roccom_c++.h:136
This file contains the prototypes for Roccom API.
int COM_get_attribute_handle(const char *waname)
Definition: roccom_c++.h:412
const int num_nodes
Definition: ex1.C:96
void COM_finalize()
Definition: roccom_c++.h:59
Definition: Rocout.h:81
blockLoc i
Definition: read.cpp:79
int elmts[total_npanes][num_elmts][4]
Definition: ex1.C:109
void COM_window_init_done(const char *w_str, int pane_changed=true)
Definition: roccom_c++.h:102
void COM_new_window(const char *wname, MPI_Comm c=MPI_COMM_NULL)
Definition: roccom_c++.h:86
void COM_call_function(const int wf, int argc,...)
Definition: roccom_c.C:48
void COM_set_array(const char *wa_str, int pane_id, void *addr, int strd=0, int cap=0)
Associates an array with an attribute for a specific pane.
Definition: roccom_c++.h:156
int main(int argc, char *argv[])
Definition: blastest.C:94
const int num_elmts
Definition: ex1.C:97
void COM_init(int *argc, char ***argv)
Definition: roccom_c++.h:57
void COM_new_attribute(const char *wa_str, const char loc, const int type, int ncomp, const char *unit)
Registering an attribute type.
Definition: roccom_c++.h:118
double coors_s[total_npanes][num_nodes][3]
Definition: ex1.C:99
#define COM_LOAD_MODULE_STATIC_DYNAMIC(moduleName, windowString)
Definition: roccom_basic.h:111
void COM_resize_array(const char *wa_str, int pane_id=0, void **addr=NULL, int strd=-1, int cap=0)
Resize an attribute on a specific pane and return the address by setting addr.
Definition: roccom_c++.h:200
int COM_get_function_handle(const char *wfname)
Definition: roccom_c++.h:428
#define COM_EXTERN_MODULE(moduleName)
Definition: roccom_basic.h:116
void init_unstructure_mesh(double coors[18][3], int elmts[4][8])