Rocstar  1.0
Rocstar multiphysics simulation application
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
Rocmap.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: Rocmap.C,v 1.19 2009/08/27 14:04:49 mtcampbe Exp $
24 
25 #include "Rocmap.h"
26 #include "roccom.h"
27 #include "Pane_connectivity.h"
28 #include "Pane_communicator.h"
29 #include "Pane_boundary.h"
30 
32 
33 // Compute pane connectivity map between shared nodes.
34 void Rocmap::compute_pconn( const COM::Attribute *mesh,
35  COM::Attribute *pconn) {
36  // Compute the pane connectivity from scratch
37  Pane_connectivity pc( mesh, mesh->window()->get_communicator());
38 
39  pc.compute_pconn( pconn);
40 }
41 
42 // Determine the nodes at pane boundaries of a given mesh
43 void Rocmap::pane_border_nodes( const COM::Attribute *mesh,
44  COM::Attribute *isborder,
45  int *ghost_level) {
46  Pane_boundary::determine_borders( mesh, isborder, ghost_level?*ghost_level:0);
47 }
48 
49 // Get the number of communicating panes.
50 void Rocmap::size_of_cpanes( const COM::Attribute *pconn, const int *pane_id,
51  int *npanes_total, int *npanes_ghost) {
52 
53  Pane_connectivity::size_of_cpanes(pconn, pane_id, npanes_total, npanes_ghost);
54 }
55 
56 // Perform an average-reduction on the shared nodes for the given attribute.
57 void Rocmap::reduce_average_on_shared_nodes(COM::Attribute *att,
58  COM::Attribute *pconn){
59  Pane_communicator pc(att->window(), att->window()->get_communicator());
60  pc.init(att,pconn);
61  pc.begin_update_shared_nodes();
62  pc.reduce_average_on_shared_nodes();
63  pc.end_update_shared_nodes();
64 }
65 
66 // Perform an average-reduction on the shared nodes for the given attribute.
67 void Rocmap::reduce_minabs_on_shared_nodes(COM::Attribute *att,
68  COM::Attribute *pconn){
69  Pane_communicator pc(att->window(), att->window()->get_communicator());
70  pc.init(att,pconn);
71  pc.begin_update_shared_nodes();
72  pc.reduce_minabs_on_shared_nodes();
73  pc.end_update_shared_nodes();
74 }
75 
76 // Perform a maxabs-reduction on the shared nodes for the given attribute.
77 void Rocmap::reduce_maxabs_on_shared_nodes(COM::Attribute *att,
78  COM::Attribute *pconn){
79  Pane_communicator pc(att->window(), att->window()->get_communicator());
80  pc.init(att,pconn);
81  pc.begin_update_shared_nodes();
82  pc.reduce_maxabs_on_shared_nodes();
83  pc.end_update_shared_nodes();
84 }
85 
86 // Update ghost nodal or elemental values for the given attribute.
87 void Rocmap::update_ghosts(COM::Attribute *att,
88  const COM::Attribute *pconn){
89  Pane_communicator pc(att->window(), att->window()->get_communicator());
90  pc.init(att, pconn);
91 
92  if (att->is_elemental()){
93  pc.begin_update_ghost_cells();
94  pc.end_update_ghost_cells();
95  }
96  else{
97  pc.begin_update_ghost_nodes();
98  pc.end_update_ghost_nodes();
99  }
100 }
101 
102 void Rocmap::load( const std::string &mname) {
103  COM_new_window( mname.c_str());
104 
105  COM_Type types[4];
106  types[0] = COM_METADATA;
107  types[1] = COM_METADATA;
108  COM_set_function( (mname+".reduce_average_on_shared_nodes").c_str(),
110 
111  COM_set_function( (mname+".reduce_maxabs_on_shared_nodes").c_str(),
113 
114  COM_set_function( (mname+".reduce_minabs_on_shared_nodes").c_str(),
116 
117  COM_set_function( (mname+".update_ghosts").c_str(),
118  (Func_ptr)update_ghosts, "iI", types);
119 
120  types[0] = types[1] = COM_METADATA;
121  COM_set_function( (mname+".compute_pconn").c_str(),
122  (Func_ptr)compute_pconn, "io", types);
123 
124  types[0] = types[1] = COM_METADATA; types[2] = COM_INT;
125  COM_set_function( (mname+".pane_border_nodes").c_str(),
126  (Func_ptr)pane_border_nodes, "ioI", types);
127 
128  types[0] = COM_METADATA;
129  types[1] = types[2] = types[3] = COM_INT;
130  COM_set_function( (mname+".size_of_cpanes").c_str(),
131  (Func_ptr)size_of_cpanes, "iioO", types);
132 
133  COM_window_init_done( mname.c_str());
134 }
135 
136 void Rocmap::unload( const std::string &mname) {
137  COM_delete_window( mname.c_str());
138 }
139 
140 extern "C" void Rocmap_load_module( const char *mname)
141 { Rocmap::load( mname); }
142 
143 extern "C" void Rocmap_unload_module( const char *mname)
144 { Rocmap::unload( mname); }
145 
146 
147 // Fortran bindings
148 extern "C" void rocmap_load_module( const char *mname, long int length)
149 { Rocmap::load( std::string(mname, length)); }
150 
151 extern "C" void rocmap_unload_module( const char *mname, long int length)
152 { Rocmap::unload( std::string(mname, length)); }
153 
154 extern "C" void ROCMAP_LOAD_MODULE( const char *mname, long int length)
155 { Rocmap::load( std::string(mname, length)); }
156 
157 extern "C" void ROCMAP_UNLOAD_MODULE( const char *mname, long int length)
158 { Rocmap::unload( std::string(mname, length)); }
159 
160 extern "C" void rocmap_load_module_( const char *mname, long int length)
161 { Rocmap::load( std::string(mname, length)); }
162 
163 extern "C" void rocmap_unload_module_( const char *mname, long int length)
164 { Rocmap::unload( std::string(mname, length)); }
165 
166 extern "C" void ROCMAP_LOAD_MODULE_( const char *mname, long int length)
167 { Rocmap::load( std::string(mname, length)); }
168 
169 extern "C" void ROCMAP_UNLOAD_MODULE_( const char *mname, long int length)
170 { Rocmap::unload( std::string(mname, length)); }
171 
173 
174 
175 
176 
177 
178 
#define MAP_END_NAMESPACE
Definition: mapbasic.h:29
int COM_Type
Indices for derived data types.
Definition: roccom_basic.h:122
Utility for constructing pane connectivities in parallel.
static void compute_pconn(const COM::Attribute *mesh, COM::Attribute *pconn)
Compute pane connectivity map between shared nodes.
Definition: Rocmap.C:34
void COM_delete_window(const char *wname)
Definition: roccom_c++.h:94
static void reduce_minabs_on_shared_nodes(COM::Attribute *att, COM::Attribute *pconn=NULL)
Perform a minabs-reduction on the shared nodes for the given attribute.
Definition: Rocmap.C:67
void compute_pconn(COM::Attribute *pconn_n, COM::Attribute *pconn_f=NULL)
Create b2v mapping for nodes and facets (edges or faces) correspondence.
void COM_set_function(const char *wf_str, Func_ptr func, const char *intents, const COM_Type *types)
Definition: roccom_c++.h:323
This file contains the prototypes for Roccom API.
void ROCMAP_LOAD_MODULE(const char *mname, long int length)
Definition: Rocmap.C:154
Handles communication of shared nodes, ghost nodes or ghost cells across panes.
double length(Vector3D *const v, int n)
static void size_of_cpanes(const COM::Attribute *pconn, const int *pane_id, int *npanes_total, int *npanes_ghost=NULL)
Get the number of communicating panes.
Definition: Rocmap.C:50
void rocmap_load_module(const char *mname, long int length)
Definition: Rocmap.C:148
static void unload(const std::string &mname)
Unloads Rocmap from Roccom.
Definition: Rocmap.C:136
void ROCMAP_UNLOAD_MODULE(const char *mname, long int length)
Definition: Rocmap.C:157
static void reduce_maxabs_on_shared_nodes(COM::Attribute *att, COM::Attribute *pconn=NULL)
Perform a maxabs-reduction on the shared nodes for the given attribute.
Definition: Rocmap.C:77
void rocmap_load_module_(const char *mname, long int length)
Definition: Rocmap.C:160
void(* Func_ptr)()
Pointer of functions.
Definition: roccom_basic.h:123
void COM_window_init_done(const char *w_str, int pane_changed=true)
Definition: roccom_c++.h:102
static void pane_border_nodes(const COM::Attribute *mesh, COM::Attribute *isborder, int *ghost_level=NULL)
Determine the nodes at pane boundaries of a given mesh.
Definition: Rocmap.C:43
void rocmap_unload_module_(const char *mname, long int length)
Definition: Rocmap.C:163
void COM_new_window(const char *wname, MPI_Comm c=MPI_COMM_NULL)
Definition: roccom_c++.h:86
void ROCMAP_UNLOAD_MODULE_(const char *mname, long int length)
Definition: Rocmap.C:169
Encapsulates information about distribution of panes on all processes and handles across pane communi...
void rocmap_unload_module(const char *mname, long int length)
Definition: Rocmap.C:151
static void determine_borders(const COM::Attribute *mesh, COM::Attribute *isborder, int ghost_level=0)
Determine the nodes at pane boundaries of a given mesh.
static void update_ghosts(COM::Attribute *att, const COM::Attribute *pconn=NULL)
Update ghost nodal or elemental values for the given attribute.
Definition: Rocmap.C:87
void init(void **ptrs, COM_Type type, int ncomp, const int *sizes=NULL, const int *strds=NULL)
Initialize the communication buffers.
static void reduce_average_on_shared_nodes(COM::Attribute *att, COM::Attribute *pconn=NULL)
Perform an average-reduction on the shared nodes for the given attribute.
Definition: Rocmap.C:57
#define MAP_BEGIN_NAMESPACE
Definition: mapbasic.h:28
static void load(const std::string &mname)
Loads Rocmap onto Roccom with a given module name.
Definition: Rocmap.C:102
static void size_of_cpanes(const COM::Attribute *pconn, const int *pane_id, int *npanes_total, int *npanes_ghost=NULL)
Get the number of communicating panes.
void Rocmap_unload_module(const char *mname)
Definition: Rocmap.C:143
void ROCMAP_LOAD_MODULE_(const char *mname, long int length)
Definition: Rocmap.C:166
Utility for detecting boundaries of a pane.
void Rocmap_load_module(const char *mname)
Definition: Rocmap.C:140