Rocstar  1.0
Rocstar multiphysics simulation application
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
RFC_Window_overlay_IO.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: RFC_Window_overlay_IO.C,v 1.7 2008/12/06 08:43:29 mtcampbe Exp $
24 
25 /* \file RFC_Window_overlay_IO.C
26  * This file implements I/O for RFC_Window_overlay.
27  */
28 /* Author: Xiangmin Jiao
29  * Created: July., 2004
30  */
31 
32 #include "RFC_Window_overlay.h"
33 #include "Overlay_primitives.h"
34 #include "HDS_accessor.h"
35 #include "Timing.h"
36 #include <functional>
37 #include <cstdio>
38 #include <iostream>
39 #include <fstream>
40 #include <sstream>
41 #include <algorithm>
42 #include <cmath>
43 
45 
47 
48 using namespace std;
49 
54 void
56 
57  std::cout << "Writing feature info " << "..." << std::endl;
58 
59  // Construct a temporary window
60  std::string wname_fea = name()+"_fea_temp";
61 
62  COM_new_window( wname_fea.c_str());
63  COM_use_attribute( (wname_fea+".mesh").c_str(), (name()+".mesh").c_str());
64 
65  COM_new_attribute( (wname_fea+".frank").c_str(), 'n', COM_INTEGER, 1, "");
66  COM_new_attribute( (wname_fea+".face_angle").c_str(), 'n', COM_FLOAT, 1, "");
67 
68  if ( verb > 1) {
69  COM_new_attribute( (wname_fea+".turn_angle").c_str(), 'n', COM_FLOAT, 1, "");
70  COM_new_attribute( (wname_fea+".angle_defect").c_str(), 'n', COM_FLOAT, 1, "");
71  }
72 
73  Pane_set::iterator it=_pane_set.begin(), iend=_pane_set.end();
74  for ( it=_pane_set.begin(); it != iend; ++it) {
75  RFC_Pane_overlay &pane = (RFC_Pane_overlay &)*it->second;
76 
77  int *frank;
78  COM_allocate_array( (wname_fea+".frank").c_str(), pane.id(),
79  &(void*&)frank);
80 
81  float *face_angle=NULL, *turn_angle=NULL, *angle_defect=NULL;
82  COM_allocate_array( (wname_fea+".face_angle").c_str(), pane.id(),
83  &(void*&)face_angle);
84  if ( verb>1) {
85  COM_allocate_array( (wname_fea+".turn_angle").c_str(), pane.id(),
86  &(void*&)turn_angle);
87  COM_allocate_array( (wname_fea+".angle_defect").c_str(), pane.id(),
88  &(void*&)angle_defect);
89  }
90 
91  int s=pane.size_of_nodes();
92  RFC_Pane_overlay::HDS::Vertex_iterator vit=pane.hds().vertices_begin();
93  for ( int i=0; i<s; ++i, ++vit) if ( vit->halfedge()) {
94  Vertex *v = acc.get_primary(&*vit);
95  if ( is_feature_0( v)) {
96  if ( _f0_ranks.find(v)==_f0_ranks.end()) {
97  std::cout << "Found rank-0 vertex: " << v->point() << std::endl;
98  frank[i] = 2; // 1;
99  }
100  else
101  frank[i] = 2; // _f0_ranks[v]+1;
102  }
103  else
104  frank[i] = is_on_feature(v);
105 
106  // Compute face angle
107  face_angle[i] = 2.;
108  Halfedge *h0=acc.get_halfedge(v), *h1=h0;
109 
110  if ( acc.get_destination( h0)==v) do {
111  face_angle[i] = std::min( face_angle[i],
112  cos_face_angle( h1, acc.get_opposite(h1)));
113  } while ( (h1=acc.get_next_around_destination(h1)) != h0);
114  else { // v is an edge center for quadratic element
115  RFC_assertion( pane.is_quadratic());
116  face_angle[i] = cos_face_angle( h1, acc.get_opposite(h1));
117  }
118 
119  face_angle[i] = acos( face_angle[i])*r2d;
120 
121  if ( verb>1) {
122  if ( is_feature_0( v) && _f0_ranks[v]>2)
123  turn_angle[i] = 180;
124  else if ( acc.get_pane(v)->get_cos_edge_angle( v)==HUGE_VALF)
125  turn_angle[i] = 0;
126  else
127  turn_angle[i] = acos(acc.get_pane(v)->get_cos_edge_angle( v))*r2d;
128 
129  if ( acc.get_pane(v)->get_angle_defect(v)==HUGE_VALF)
130  angle_defect[i] = 0.;
131  else
132  angle_defect[i] = acc.get_pane(v)->get_angle_defect(v)*r2d;
133  }
134  }
135  }
136 
137  COM_window_init_done( wname_fea.c_str());
138 
139  // Load Rocout
141  int hdl_write = COM_get_function_handle( "RFC_OUT.write_attribute");
142 
143  // Call Rocut with the window to write out the pane.
144  int win_all = COM_get_attribute_handle_const( (wname_fea+".all").c_str());
145 
146  string fname_pre = out_pre + name() + "_fea_";
147 
148  int npanes, *paneIDs;
149  COM_get_panes( wname_fea.c_str(), &npanes, &paneIDs);
150 
151  for ( int i=0; i<npanes; ++i) {
152  std::ostringstream ostr;
153 
154  ostr << fname_pre;
155  ostr.fill('0'); ostr.width(5);
156  ostr << paneIDs[i] << ".hdf";
157 
158  COM_call_function( hdl_write, ostr.str().c_str(), &win_all,
159  wname_fea.c_str(), "000", NULL, NULL, &paneIDs[i]);
160  }
161  COM_free_buffer( &paneIDs);
162 
163  // Unload Rocout
165 
166  // Delete the temporary window
167  COM_delete_window( wname_fea.c_str());
168 }
169 
175 dump_strong_edges( const std::vector<pair<float,Halfedge*> > &tstrong_edges,
176  const std::vector<pair<float,Halfedge*> > &rstrong_edges){
177  int n=0;
178  string buf = out_pre + name() + "s1.plt";
179 
180  ofstream os( buf.c_str());
181  for (vector<pair<float,Halfedge*> >::const_iterator it=tstrong_edges.begin();
182  it!=tstrong_edges.end(); ++it, ++n) {
183  os << "GEOMETRY T=LINE3D C=GREEN"
184  << " LT=0.4" << endl << 1 << endl
185  << 2 << ' ' << it->second->origin()->point()
186  << ' ' << it->second->destination()->point()
187  << endl;
188  }
189 
190  if ( !tstrong_edges.empty())
191  std::cout << "\tStatistics: Theta-strong-edge angle: MAX ="
192  << acos(tstrong_edges.front().first)*r2d
193  << " and MIN=" << acos(tstrong_edges.back().first)*r2d
194  << std::endl;
195 
196  for (vector<pair<float,Halfedge*> >::const_iterator it=rstrong_edges.begin();
197  it!=rstrong_edges.end(); ++it, ++n) {
198  os << "GEOMETRY T=LINE3D C=GREEN"
199  << " LT=0.1" << endl << 1 << endl
200  << 2 << ' ' << it->second->origin()->point()
201  << ' ' << it->second->destination()->point()
202  << endl;
203  }
204  if ( !rstrong_edges.empty())
205  std::cout << " \tStatistics: r-strong-edge angle: MAX ="
206  << acos(rstrong_edges.front().first)*r2d
207  << " and MIN=" << acos(rstrong_edges.back().first)*r2d
208  << std::endl;
209 }
210 
214 
215 
216 
217 
218 
219 
const float & get_cos_edge_angle(const Vertex *v) const
Halfedge * get_opposite(Halfedge *h) const
Definition: HDS_accessor.h:99
void COM_delete_window(const char *wname)
Definition: roccom_c++.h:94
double s
Definition: blastest.C:80
RFC_Pane_overlay * get_pane(Vertex *v) const
Definition: HDS_accessor.h:128
RFC_BEGIN_NAME_SPACE HDS_accessor< Tag_true > acc
Halfedge * get_halfedge(Vertex *v) const
Definition: HDS_accessor.h:75
*********************************************************************Illinois Open Source License ****University of Illinois NCSA **Open Source License University of Illinois All rights reserved ****Developed free of to any person **obtaining a copy of this software and associated documentation to deal with the Software without including without limitation the rights to and or **sell copies of the and to permit persons to whom the **Software is furnished to do subject to the following this list of conditions and the following disclaimers ****Redistributions in binary form must reproduce the above **copyright this list of conditions and the following **disclaimers in the documentation and or other materials **provided with the distribution ****Neither the names of the Center for Simulation of Advanced the University of nor the names of its **contributors may be used to endorse or promote products derived **from this Software without specific prior written permission ****THE SOFTWARE IS PROVIDED AS WITHOUT WARRANTY OF ANY **EXPRESS OR INCLUDING BUT NOT LIMITED TO THE WARRANTIES **OF FITNESS FOR A PARTICULAR PURPOSE AND **NONINFRINGEMENT IN NO EVENT SHALL THE CONTRIBUTORS OR **COPYRIGHT HOLDERS BE LIABLE FOR ANY DAMAGES OR OTHER WHETHER IN AN ACTION OF TORT OR **ARISING OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE **USE OR OTHER DEALINGS WITH THE SOFTWARE v
Definition: roccomf90.h:20
#define RFC_END_NAME_SPACE
Definition: rfc_basic.h:29
#define COM_UNLOAD_MODULE_STATIC_DYNAMIC(moduleName, windowString)
Definition: roccom_basic.h:113
const Point & point() const
**********************************************************************Rocstar Simulation Suite Illinois Rocstar LLC All rights reserved ****Illinois Rocstar LLC IL **www illinoisrocstar com **sales illinoisrocstar com WITHOUT WARRANTY OF ANY **EXPRESS OR INCLUDING BUT NOT LIMITED TO THE WARRANTIES **OF FITNESS FOR A PARTICULAR PURPOSE AND **NONINFRINGEMENT IN NO EVENT SHALL THE CONTRIBUTORS OR **COPYRIGHT HOLDERS BE LIABLE FOR ANY DAMAGES OR OTHER WHETHER IN AN ACTION OF TORT OR **Arising OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE **USE OR OTHER DEALINGS WITH THE SOFTWARE **********************************************************************INTERFACE SUBROUTINE knode iend
void COM_use_attribute(const char *wname, const char *attr, int wg=1, const char *ptnname=0, int val=0)
Use the subset of panes of another window of which the given pane attribute has value val...
Definition: roccom_c++.h:224
int size_of_nodes() const
The total number of nodes in the pane.
Definition: Rocout.h:81
blockLoc i
Definition: read.cpp:79
void print_features()
Dump out the 0- and 1-features in Tecplot format into files &lt;name&gt;f0.plt, &lt;name&gt;f1.plt, respectively.
#define RFC_BEGIN_NAME_SPACE
Definition: rfc_basic.h:28
void COM_window_init_done(const char *w_str, int pane_changed=true)
Definition: roccom_c++.h:102
const NT & n
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_allocate_array(const char *wa_str, int pane_id=0, void **addr=NULL, int strd=0, int cap=0)
Allocate space for an attribute on a specific pane and return the address by setting addr...
Definition: roccom_c++.h:196
int COM_get_attribute_handle_const(const char *waname)
Definition: roccom_c++.h:420
Vector_n min(const Array_n_const &v1, const Array_n_const &v2)
Definition: Vector_n.h:346
Vertex * get_primary(Vertex *v) const
Definition: HDS_accessor.h:122
#define HUGE_VALF
Definition: Rocout_hdf4.C:719
bool is_quadratic() const
Does this pane contain quadratic elements?
Halfedge * get_next_around_destination(Halfedge *h) const
Definition: HDS_accessor.h:146
CImg< _cimg_Tfloat > acos(const CImg< T > &instance)
Definition: CImg.h:6051
Vertex * get_destination(Halfedge *h) const
Definition: HDS_accessor.h:93
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
void COM_get_panes(const char *wname, std::vector< int > &pane_ids, int rank=-2)
Definition: roccom_c++.h:350
void COM_free_buffer(int **buf)
Definition: roccom_c++.h:397
int id() const
#define RFC_assertion
Definition: rfc_basic.h:65
void dump_strong_edges(const std::vector< std::pair< float, Halfedge * > > &, const std::vector< std::pair< float, Halfedge * > > &)
Dump out the strong edges in Tecplot format into file &lt;name&gt;s1.plt.
#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
const float & get_angle_defect(const Vertex *v) const
#define COM_EXTERN_MODULE(moduleName)
Definition: roccom_basic.h:116