Rocstar  1.0
Rocstar multiphysics simulation application
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
remesh.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: remesh.C,v 1.4 2008/12/06 08:45:28 mtcampbe Exp $
24 
25 #include "roccom.h"
26 #include <iostream>
27 #include "../Rocsurf/test/IM_Reader.h"
28 #include "Remesher_Simmetrix.h"
29 
33 
34 using namespace std;
35 
36 int main(int argc, char *argv[]) {
37  COM_init( &argc, &argv);
38 
39  if ( argc < 3) {
40  std::cout << "Usage:\n\tTo run in serial: " << argv[0]
41  << " <surffile> <hdffile> " << endl;
42  std::cout << "\n\tTo run in parallel: <mpirun-command> " << argv[0]
43  << " -com-mpi <Rocin control file> <hdfoutput-prefix> " << endl;
44  exit(-1);
45  }
46 
47  std::cout << "Reading surface mesh file \"" << argv[1] << '"' << endl;
48 
49  std::string fname(argv[1]), wname;
50  string::size_type n0 = fname.find_last_of( "/");
51 
52  if ( n0 != std::string::npos)
53  fname = fname.substr( n0+1, fname.size());
54 
55  string::size_type ni;
56  ni = fname.find_first_of( ".:-*[]?\\\"\'0123456789");
57  COM_assertion_msg(ni, "File name must start with a letter");
58 
59  if ( ni == std::string::npos) {
60  wname = fname;
61  }
62  else {
63  while (fname[ni-1]=='_') --ni; // Remove the '_' at the end.
64  wname = fname.substr( 0, ni);
65  }
66 
67  std::cout << "Creating window \"" << wname << '"' << endl;
68 
69  // Read in IM/HDF format
70  int err = IM_Reader().read_winmesh( argv[1], wname);
71  COM_assertion( err>=0);
72 
73  std::cout << "finishing up window initialization" << endl;
74  COM_window_init_done( wname.c_str());
75 
76  std::cout << "loading Rocout" << endl;
78 
79  std::cout << "Performing remeshing" << endl;
80 
82  // First, create an empty window
83  COM_new_window("newmesh");
84  COM_window_init_done("newmesh");
85 
86  int PROP_init = COM_get_function_handle( "PROP.initialize");
87  int mesh_hdl = COM_get_attribute_handle((wname+".mesh").c_str());
88  COM_call_function( PROP_init, &mesh_hdl);
89 
90  PROP::Remesher_Simmetrix rem;
91  int PROP_set_remesher = COM_get_function_handle( "PROP.set_remesher");
92  COM_call_function( PROP_set_remesher, &rem);
93 
94  int PROP_remesh = COM_get_function_handle( "PROP.remesh_serial");
95  int newmesh_hdl = COM_get_attribute_handle("newmesh.mesh");
96 
97  double avel, fangle;
98  std::cout << "Enter average edge length (0 for current average)"
99  << std::flush;
100  std::cin >> avel;
101  std::cout << "Enter feature angle (in degrees. 0 to disable features)"
102  << std::flush;
103  std::cin >> fangle;
104 
105  COM_call_function( PROP_remesh, &newmesh_hdl, &avel, &fangle);
106 
107  std::cout << "Output window into file..." << endl;
108 
109  // Output pconn
110  int OUT_set = COM_get_function_handle( "OUT.set_option");
111  int OUT_write = COM_get_function_handle( "OUT.write_attribute");
112 
113  COM_call_function( OUT_set, "mode", "w");
114  int all_hdl = COM_get_attribute_handle( "newmesh.all");
115  COM_call_function( OUT_write, argv[2], &all_hdl,
116  (char*)wname.c_str(), "000");
117 
118  COM_finalize();
119 }
120 
121 
122 
123 
124 
125 
#define COM_assertion(EX)
Error checking utility similar to the assert macro of the C language.
#define COM_assertion_msg(EX, msg)
This file contains the prototypes for Roccom API.
int COM_get_attribute_handle(const char *waname)
Definition: roccom_c++.h:412
void COM_finalize()
Definition: roccom_c++.h:59
Definition: Rocin.h:64
Definition: Rocout.h:81
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
int main(int argc, char *argv[])
Definition: blastest.C:94
void COM_init(int *argc, char ***argv)
Definition: roccom_c++.h:57
void int int REAL REAL REAL *z blockDim dim * ni
Definition: read.cpp:77
int read_winmesh(const char *fname, const std::string &wname, bool del=true)
Definition: IM_Reader.h:58
#define COM_LOAD_MODULE_STATIC_DYNAMIC(moduleName, windowString)
Definition: roccom_basic.h:111
int COM_get_function_handle(const char *wfname)
Definition: roccom_c++.h:428
#define COM_EXTERN_MODULE(moduleName)
Definition: roccom_basic.h:116