Rocstar  1.0
Rocstar multiphysics simulation application
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
readsdv.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 // $Id: readsdv.C,v 1.5 2008/12/06 08:43:29 mtcampbe Exp $
24 
25 // This file demonstrates how to read in a sdv file.
26 #include "roccom.h"
27 #include <vector>
28 #include <iostream>
29 
30 extern "C" void Rocin_load_module(const char *);
31 extern "C" void Rocin_unload_module(const char *);
32 
33 struct Subdiv {
34  std::vector<int> subfaces; // Connectivity of subfaces
35 
36  std::vector<int> subnode_parents; // Parent face ID
37  std::vector<float> subnode_ncs; // Natural coordinates in parent face
38  std::vector<int> subnode_subIDs; // Sub-node ID of input nodes
39  std::vector<int> subnode_counterparts; // Sub-node ID in other window
40 
41  std::vector<int> subface_parents; // Parent face ID
42  std::vector<float> subface_nat_coors; // Natural coors. of subnodes of susface
43  std::vector<int> subface_offsets; // Smallest sub-face ID in input face
44  std::vector<int> subface_counterparts; // Sub-face ID in other window
45 };
46 
47 // A sample program for reading an output file of Rocface for a single pane.
48 // Arguments: fname: the file name of the HDF file
49 // prefix: is the window name (also the base material name) in HDF files
50 // pid: the pane ID of the window.
51 // sd: the output structure contained in an Subdiv object.
52 void read_pane_sp( std::string &fname,
53  const std::string &prefix,
54  int pid,
55  Subdiv &sd) {
56 
57  // Load Rocin into Roccom
58  Rocin_load_module( "SDV_IN");
59 
60  // Obtain function handles to Rocin functions
61  int hdl_read = COM_get_function_handle( "SDV_IN.read_windows");
62  int hdl_obtain = COM_get_function_handle( "SDV_IN.obtain_attribute");
63 
64  // Define the base-window and sdv-window names
65  std::string bufprefix = "__BUF";
66  std::string sdv_material = prefix+"_sdv";
67  std::string sdv_wname = bufprefix+sdv_material;
68 
69  // Read the pane from the given file. Note that the file contains both
70  // the parent and the subdivided windows. Read only the subdivided one.
71  MPI_Comm comm_self = MPI_COMM_SELF;
72  COM_call_function( hdl_read, fname.c_str(), bufprefix.c_str(),
73  sdv_material.c_str(), &comm_self);
74  int hdl_all = COM_get_attribute_handle( (sdv_wname+".all").c_str());
75  COM_call_function( hdl_obtain, &hdl_all, &hdl_all, &pid);
76 
77  // Obtain number of sub-nodes, sub-faces, nodes, and faces
78  int nsubn, nsubf, nn, nf;
79  COM_get_size( (sdv_wname+".sn_parent_fcID").c_str(), pid, &nsubn);
80  COM_get_size( (sdv_wname+".:t3").c_str(), pid, &nsubf);
81 
82  COM_get_size( (sdv_wname+".sn_subID").c_str(), pid, &nn);
83  COM_get_size( (sdv_wname+".sf_offset").c_str(), pid, &nf);
84 
85  // Obtain the connectivity
86  sd.subfaces.resize( 3*nsubf);
87  COM_copy_array( (sdv_wname+".:t3").c_str(), pid, &sd.subfaces[0], 3);
88  // NOTE: The last argument (3) indicates that three sub-node IDs are stored
89  // consecutively for each sub-face. Use the number one (1) if the first
90  // sub-nodes of all sub-faces are stored together followed by the second
91  // sub-nodes and then third.
92 
93 
94  // Obtain subnode_parents, subnode_ncs, and subnode_counterparts
95  sd.subnode_parents.resize( nsubn);
96  COM_copy_array( (sdv_wname+".sn_parent_fcID").c_str(),
97  pid, &sd.subnode_parents[0]);
98 
99  sd.subnode_ncs.resize( 2*nsubn);
100  COM_copy_array( (sdv_wname+".sn_parent_ncs").c_str(), pid, &sd.subnode_ncs[0], 2);
101  // NOTE: The last argument (2) indicates that the two local coordinates are
102  // stored consecutively. Use the number one (1) if the first local parameter
103  // (xi) of all sub-nodes are stored together followed by the second one (eta).
104 
105  sd.subnode_subIDs.resize( nn);
106  COM_copy_array( (sdv_wname+".sn_subID").c_str(), pid, &sd.subnode_subIDs[0]);
107 
108  sd.subnode_counterparts.resize( nsubn);
109  COM_copy_array( (sdv_wname+".sn_cntpt_ndID").c_str(),
110  pid, &sd.subnode_counterparts[0]);
111 
112  sd.subface_parents.resize( nsubf);
113  COM_copy_array( (sdv_wname+".sf_parent").c_str(), pid, &sd.subface_parents[0]);
114 
115  sd.subface_nat_coors.resize( nsubf*6);
116  COM_copy_array( (sdv_wname+".sf_ncs").c_str(), pid,
117  &sd.subface_nat_coors[0], 6);
118  // NOTE: The last argument (6) indicates that the local coordinates are
119  // stored consecutively (xi1, eta1, xi2, eta2, xi3, eta3). Use the number
120  // one (1) if the xi1 for all nodes are stored together and then xi2, etc..
121 
122  // Obtain subface_offsets
123  sd.subface_offsets.resize( nf);
124  COM_copy_array( (sdv_wname+".sf_offset").c_str(), pid, &sd.subface_offsets[0]);
125 
126  sd.subface_counterparts.resize( nsubf);
127  COM_copy_array( (sdv_wname+".sf_cntpt_fcID").c_str(), pid,
128  &sd.subface_counterparts[0]);
129 
130  // Delete the window created by Rocin.
131  COM_delete_window( sdv_wname.c_str());
132 
133  // Unload Rocin from Roccom.
134  Rocin_unload_module( "SDV_IN");
135 }
136 
137 int main(int argc, char *argv[]) {
138  COM_init( &argc, &argv);
139 
140  if ( argc<3) {
141  std::cerr << "Usage: " << argv[0] << " <file-name> <prefix> <pane_id>\n"
142  << "Example: " << argv[0] << "A_101_sdv.hdf A 101" << std::endl;
143  exit(-1);
144  }
145 
146  std::string fname = argv[1], prefix = argv[2];
147  int pid = std::atoi(argv[3]);
148 
149  // Reading the given pane from the file into the structure.
150  Subdiv sd;
151  read_pane_sp( fname, prefix, pid, sd);
152 
153  COM_finalize();
154 }
155 
156 
157 
158 
159 
160 
void Rocin_load_module(const char *name)
Load the module Rocin into Roccom using the given module name.
Definition: Rocin.C:3063
void read_pane_sp(std::string &fname, const std::string &prefix, int pid, Subdiv &sd)
Definition: readsdv.C:52
here we put it at the!beginning of the common block The point to point and collective!routines know about but MPI_TYPE_STRUCT as yet does not!MPI_STATUS_IGNORE and MPI_STATUSES_IGNORE are similar objects!Until the underlying MPI library implements the C version of these are declared as arrays of MPI_STATUS_SIZE!The types and are OPTIONAL!Their values are zero if they are not available Note that!using these reduces the portability of MPI_IO INTEGER MPI_BOTTOM INTEGER MPI_DOUBLE_PRECISION INTEGER MPI_LOGICAL INTEGER MPI_2REAL INTEGER MPI_2DOUBLE_COMPLEX INTEGER MPI_LB INTEGER MPI_WTIME_IS_GLOBAL INTEGER MPI_COMM_SELF
void COM_delete_window(const char *wname)
Definition: roccom_c++.h:94
This file contains the prototypes for Roccom API.
std::vector< int > subfaces
Definition: readsdv.C:34
std::vector< int > subface_offsets
Definition: readsdv.C:43
std::vector< float > subnode_ncs
Definition: readsdv.C:37
int COM_get_attribute_handle(const char *waname)
Definition: roccom_c++.h:412
void COM_copy_array(const char *wa_str, int pane_id, void *val, int v_strd=0, int v_size=0, int offset=0)
Copy an array from an attribute on a specific pane into a given buffer.
Definition: roccom_c++.h:311
Definition: readsdv.C:33
std::vector< int > subnode_parents
Definition: readsdv.C:36
void COM_finalize()
Definition: roccom_c++.h:59
std::vector< int > subface_counterparts
Definition: readsdv.C:44
void COM_get_size(const char *wa_str, int pane_id, int *size, int *ng=0)
Get the sizes of an attribute.
Definition: roccom_c++.h:274
std::vector< int > subface_parents
Definition: readsdv.C:41
void COM_call_function(const int wf, int argc,...)
Definition: roccom_c.C:48
int main(int argc, char *argv[])
Definition: blastest.C:94
void COM_init(int *argc, char ***argv)
Definition: roccom_c++.h:57
std::vector< float > subface_nat_coors
Definition: readsdv.C:42
std::vector< int > subnode_counterparts
Definition: readsdv.C:39
std::vector< int > subnode_subIDs
Definition: readsdv.C:38
int COM_get_function_handle(const char *wfname)
Definition: roccom_c++.h:428
void Rocin_unload_module(const char *name)
Unload the module Rocin from Roccom.
Definition: Rocin.C:3066