Rocstar  1.0
Rocstar multiphysics simulation application
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
bordertestg_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[24][3], int elmts[6][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  coors[18][0] = 1.5;
89  coors[18][1] = 0.0;
90  coors[18][2] = 0.0;
91  coors[19][0] = 1.5;
92  coors[19][1] = 0.5;
93  coors[19][2] = 0.0;
94  coors[20][0] = 1.5;
95  coors[20][1] = 1.0;
96  coors[20][2] = 0.0;
97  coors[21][0] = 1.5;
98  coors[21][1] = 0.0;
99  coors[21][2] = 1.0;
100  coors[22][0] = 1.5;
101  coors[22][1] = 0.5;
102  coors[22][2] = 1.0;
103  coors[23][0] = 1.5;
104  coors[23][1] = 1.0;
105  coors[23][2] = 1.0;
106 
107  elmts[0][0] = 1;
108  elmts[0][1] = 2;
109  elmts[0][2] = 5;
110  elmts[0][3] = 6;
111  elmts[0][4] = 10;
112  elmts[0][5] = 11;
113  elmts[0][6] = 14;
114  elmts[0][7] = 15;
115 
116  elmts[1][0] = 2;
117  elmts[1][1] = 3;
118  elmts[1][2] = 4;
119  elmts[1][3] = 5;
120  elmts[1][4] = 11;
121  elmts[1][5] = 12;
122  elmts[1][6] = 13;
123  elmts[1][7] = 14;
124 
125  elmts[2][0] = 5;
126  elmts[2][1] = 4;
127  elmts[2][2] = 9;
128  elmts[2][3] = 8;
129  elmts[2][4] = 14;
130  elmts[2][5] = 13;
131  elmts[2][6] = 18;
132  elmts[2][7] = 17;
133 
134  elmts[3][0] = 6;
135  elmts[3][1] = 5;
136  elmts[3][2] = 8;
137  elmts[3][3] = 7;
138  elmts[3][4] = 15;
139  elmts[3][5] = 14;
140  elmts[3][6] = 17;
141  elmts[3][7] = 16;
142 
143  elmts[4][0] = 3;
144  elmts[4][1] = 19;
145  elmts[4][2] = 20;
146  elmts[4][3] = 4;
147  elmts[4][4] = 12;
148  elmts[4][5] = 22;
149  elmts[4][6] = 23;
150  elmts[4][7] = 13;
151 
152  elmts[5][0] = 4;
153  elmts[5][1] = 20;
154  elmts[5][2] = 21;
155  elmts[5][3] = 9;
156  elmts[5][4] = 13;
157  elmts[5][5] = 23;
158  elmts[5][6] = 24;
159  elmts[5][7] = 18;
160 
161 }
162 
163 int main(int argc, char *argv[]) {
164  const int num_nodes = 24, num_elmts = 6;
165  const int ghost_nodes = 6, ghost_elements = 2;
166 
167  double coors_s[num_nodes][3];
168  int elmts[num_elmts][8];
169 
170  COM_init( &argc, &argv);
171 
172  cout << "Creating window \"unstr\"" << endl;
173  COM_new_window("unstr");
174  COM_new_attribute("unstr.normals", 'e', COM_DOUBLE, 3, "m");
175  COM_new_attribute("unstr.centers", 'e', COM_DOUBLE, 3, "m");
176 
177  init_unstructure_mesh( coors_s, elmts);
178  COM_set_size( "unstr.nc", 1, num_nodes, ghost_nodes);
179  COM_set_array( "unstr.nc", 1, &coors_s[0][0]);
180  COM_set_size( "unstr.:H8:", 1, num_elmts, ghost_elements);
181  COM_set_array( "unstr.:H8:", 1, &elmts[0][0]);
182 
183  COM_resize_array( "unstr.atts");
184 
185  for(int i =0; i < num_nodes; ++i){
186  cout << "Coors_s[0][" << i <<"] = ["
187  << coors_s[i][0] << " , " << coors_s[i][1] << " , "
188  << coors_s[i][2] << "]" << endl;
189  }
190  for(int i =0; i < num_elmts; ++i){
191  cout << "Element " << i << ": "
192  << elmts[i][0] << " " << elmts[i][1] << " "
193  << elmts[i][2] << " " << elmts[i][3] << " "
194  << elmts[i][4] << " " << elmts[i][5] << " "
195  << elmts[i][6] << " " << elmts[i][7] << endl;
196  }
197 
198  // Allocate memory for displacements
199  const string disps("unstr.disps");
200  char loc;
201  int size, type;
202  string unit;
203  COM_get_attribute("unstr.nc", &loc, &type, &size, &unit);
204  COM_new_attribute(disps.c_str(), 'n', COM_DOUBLE, 3, unit.c_str());
205  COM_resize_array(disps.c_str());
206  COM_window_init_done("unstr");
207  int mesh_hdl = COM_get_attribute_handle("unstr.mesh");
208 
209  COM_LOAD_MODULE_STATIC_DYNAMIC( Rocmap, "MAP");
211 
212  int MAP_compute_pconn = COM_get_function_handle( "MAP.compute_pconn");
213  const string pconn = "unstr.pconn";
214  int pconn_hdl = COM_get_attribute_handle( pconn.c_str());
215  COM_call_function( MAP_compute_pconn, &mesh_hdl, &pconn_hdl);
216 
217  COM_finalize();
218 }
219 
220 
221 
222 
223 
224 
void COM_get_attribute(const std::string wa_str, char *loc, int *type, int *ncomp, std::string *unit)
Definition: roccom_c++.h:269
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])