Rocstar  1.0
Rocstar multiphysics simulation application
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
smooth_volume.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: smooth_volume.C,v 1.8 2008/12/06 08:45:25 mtcampbe Exp $
24 
25 #include "roccom.h"
26 #include "mapbasic.h"
27 #include "Rocblas.h"
28 #include <iostream>
29 #include <sstream>
30 #include <cstdlib>
31 #include <fstream>
32 
33 using namespace std;
34 
35 // Necessary for handling modules in static or dynamic fashion
39 COM_EXTERN_MODULE( Rocmap);
40 COM_EXTERN_MODULE( Roblas);
41 
42 // Get the MPI rank of the process
43 int get_comm_rank( MPI_Comm comm) {
44  int rank;
45  int ierr = MPI_Comm_rank( comm, &rank); assert( ierr == 0);
46  return rank;
47 }
48 
49 // Get the size of the MPI communicator
50 int get_comm_size( MPI_Comm comm) {
51  int size;
52  int ierr = MPI_Comm_size( comm, &size); assert( ierr == 0);
53  return size;
54 }
55 
56 
57 int main(int argc, char *argv[]) {
58  MPI_Init( &argc, &argv);
59 
60  if ( argc < 5) {
61  std::cout << "Usage: " << argv[0]
62  << " <Rocin input file><Output file name><Niter><Invert Tets>" << endl;
63  exit(-1);
64  }
65  string inputfname(argv[1]);
66  string outputfname(argv[2]);
67  int niter = atoi(argv[3]);
68  int invert_tets = atoi(argv[4]);
69 
70  std::cout << "niter = " << niter << "\ninvert_tets = " << invert_tets << "\n\n";
71 
72  MPI_Comm comm = MPI_COMM_WORLD;
73  int size_of_p = get_comm_size(comm);
74  int myrank = get_comm_rank(comm);
75 
76  COM_init( &argc, &argv);
77 
78  // LOAD MODULES
82  COM_LOAD_MODULE_STATIC_DYNAMIC( Rocmap, "MAP");
84 
85  // GET FUNCTION HANDLES
86  int OUT_write = COM_get_function_handle( "OUT.write_attribute");
87  int OUT_add = COM_get_function_handle( "OUT.add_attribute");
88  int IN_read = COM_get_function_handle( "IN.read_by_control_file");
89  int MOP_init = COM_get_function_handle( "MOP.initialize");
90  int MOP_det = COM_get_function_handle( "MOP.determine_physical_border");
91  int MOP_set = COM_get_function_handle ( "MOP.set_value");
92  int MOP_smth = COM_get_function_handle( "MOP.smooth");
93  int MOP_asp = COM_get_function_handle( "MOP.add_aspect_ratios");
94  int BLAS_add = COM_get_function_handle("BLAS.add");
95 
96  // SET OUTPUT LEVELS
97  COM_set_verbose(11);
99 
100  // BUILD FILE and WINDOW NAMES
101  ostringstream rankstream;
102  rankstream << myrank+1;
103  //rankstream << myrank;
104  const string wname("smoothed_mesh");
105 
106  // READ IN FILES
107  COM_call_function( IN_read,
108  inputfname.c_str(),
109  wname.c_str(),
110  &comm);
111 
112  COM_new_attribute((wname+".disp").c_str(),'n',COM_DOUBLE,3,"m");
113  COM_resize_array((wname+".disp").c_str(),0,NULL,3);
114  COM_window_init_done(wname.c_str());
115 
116  // SMOOTH THE WINDOW
117  std::cout << "Smoothing the window\n";
118  ostringstream MyStream;
119  int method = 0;
120  COM_call_function(MOP_set, "method", &method);
121  int verb = 2;
122  COM_call_function(MOP_set, "verbose", &verb);
123  COM_call_function(MOP_set, "inverted", &invert_tets);
124 
125  int VOL_pmesh = COM_get_attribute_handle((wname+".pmesh").c_str());
126  int VOL_disp = COM_get_attribute_handle((wname+".disp").c_str());
127  int VOL_nc = COM_get_attribute_handle((wname+".nc").c_str());
128  int VOL_all = COM_get_attribute_handle((wname+".all").c_str());
129  string MyString = "00";
130 
131  niter++;
132  for (int i = 1; i < niter; i++){
133  COM_call_function( MOP_smth, &VOL_pmesh, &VOL_disp);
134  string::size_type len;
135  len = MyString.length();
136  MyString.erase(0,len+1);
137  MyStream.str("");
138  MyStream << "00" << i;
139  MyString = MyStream.str();
140 
141  // ADD DISPS ONTO NC
142  COM_call_function( BLAS_add,&VOL_disp,&VOL_nc,&VOL_nc);
143 
144  // CALCULATE ASPECT RATIOS
145  //COM_call_function(MOP_asp, &VOL_all);
146  }
147 
148  // PRINT SMOOTHED WINDOW
149  COM_call_function( OUT_write,
150  outputfname.c_str(), //filename_pre
151  &VOL_all, // attribute
152  wname.c_str(), // material
153  MyString.c_str() // time
154  );
155 
156  COM_print_profile("", "");
157 
158  COM_finalize();
159  MPI_Finalize();
160 }
161 
162 
163 
164 
165 
166 
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_WORLD
int get_comm_rank(MPI_Comm comm)
Definition: pcommpartest.C:32
This file contains the prototypes for Roccom API.
A Roccom mesh optimization module.
Definition: Rocmop.h:41
void COM_set_verbose(int i)
Definition: roccom_c++.h:543
int COM_get_attribute_handle(const char *waname)
Definition: roccom_c++.h:412
void COM_finalize()
Definition: roccom_c++.h:59
int get_comm_size(MPI_Comm comm)
Definition: pcommpartest.C:37
void COM_print_profile(const char *fname, const char *header)
Definition: roccom_c++.h:557
Definition: Rocin.h:64
Definition: Rocout.h:81
blockLoc i
Definition: read.cpp:79
void COM_window_init_done(const char *w_str, int pane_changed=true)
Definition: roccom_c++.h:102
void COM_set_profiling(int i)
Definition: roccom_c++.h:550
void COM_call_function(const int wf, int argc,...)
Definition: roccom_c.C:48
Definition for Rocblas API.
int main(int argc, char *argv[])
Definition: blastest.C:94
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
static int rank
Definition: advectest.C:66
#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