41 Rocface::Rocface( std::string mname) : _mname(mname), _cookie(RFC_COOKIE) {}
45 while ( !_trs_windows.empty()) {
46 TRS_Windows::iterator it = _trs_windows.begin();
48 _trs_windows.erase( it);
53 set_verbose(
int *verb)
61 overlay(
const COM::Attribute *a1,
62 const COM::Attribute *a2,
67 std::string n1 = a1->window()->name();
68 std::string n2 = a2->window()->name();
70 Overlay ovl( a1->window(), a2->window(), path);
78 get_name( n1, n2, wn1); get_name( n2, n1, wn2);
80 TRS_Windows::iterator it1 = _trs_windows.find( wn1);
81 TRS_Windows::iterator it2 = _trs_windows.find( wn2);
82 if ( it1 != _trs_windows.end()) {
84 delete it1->second;
delete it2->second;
88 insert( TRS_Windows::value_type( wn1, NULL)).first;
91 insert( TRS_Windows::value_type( wn2, NULL)).first;
100 ovl.export_windows( it1->second, it2->second);
105 clear_overlay(
const char *m1,
113 std::string wn1, wn2;
114 get_name( n1, n2, wn1); get_name( n2, n1, wn2);
116 TRS_Windows::iterator it1 = _trs_windows.find( wn1);
117 if ( it1 != _trs_windows.end()) {
118 delete it1->second; _trs_windows.erase( it1);
120 TRS_Windows::iterator it2 = _trs_windows.find( wn2);
122 delete it2->second; _trs_windows.erase( it2);
125 std::cerr <<
"Rocface: ERROR: The overlay of window \"" << n1
126 <<
"\" and window \"" << n2 <<
"\" does not exist for deleting"
134 read_overlay(
const COM::Attribute *a1,
135 const COM::Attribute *a2,
136 const MPI_Comm *comm,
139 const char *format) {
142 std::string n1 = a1->window()->name();
143 std::string n2 = a2->window()->name();
146 std::string wn1, wn2;
147 get_name( n1, n2, wn1); get_name( n2, n1, wn2);
149 TRS_Windows::iterator it1 = _trs_windows.find( wn1);
150 TRS_Windows::iterator it2 = _trs_windows.find( wn2);
152 if ( it1 != _trs_windows.end()) {
154 delete it1->second;
delete it2->second;
158 insert( TRS_Windows::value_type( wn1, NULL)).first;
160 insert( TRS_Windows::value_type( wn2, NULL)).first;
164 MPI_Comm com = (comm==NULL)?a1->window()->get_communicator():*comm;
166 BLUE, com, prefix1, format);
169 GREEN, com, prefix2, format);
171 if ( prefix1 == NULL) prefix1 = n1.c_str();
172 if ( prefix2 == NULL) prefix2 = n2.c_str();
174 if ( it1->second->comm_rank()==0 && _ctrl.verb) {
175 std::cout <<
"RFACE: Reading in subdivision of window " << n1
176 <<
" from files with prefix \""
177 << prefix1 <<
"\"...." << std::flush;
179 it1->second->read_sdv( prefix1, format);
180 if ( it1->second->comm_rank()==0 && _ctrl.verb) {
181 std::cout <<
"Done" << std::endl;
184 if ( it2->second->comm_rank()==0 && _ctrl.verb) {
185 std::cout <<
"RFACE: Reading in subdivision of window " << n2
186 <<
" from files with prefix \""
187 << prefix2 <<
"\"...." << std::flush;
189 it2->second->read_sdv( prefix2, format);
190 if ( it2->second->comm_rank()==0 && _ctrl.verb) {
191 std::cout <<
"Done" << std::endl;
198 write_overlay(
const COM::Attribute *a1,
199 const COM::Attribute *a2,
202 const char *format) {
205 std::string n1 = a1->window()->name();
206 std::string n2 = a2->window()->name();
209 std::string wn1, wn2;
210 get_name( n1, n2, wn1); get_name( n2, n1, wn2);
212 TRS_Windows::iterator it1 = _trs_windows.find( wn1);
213 if ( it1 == _trs_windows.end()) {
214 std::cerr <<
"RFACE: ERROR: The overlay of window \"" << n1
215 <<
"\" and window \"" << n2 <<
"\" does not exist for output"
220 TRS_Windows::iterator it2 = _trs_windows.find( wn2);
223 if ( prefix1 == NULL) prefix1 = n1.c_str();
224 if ( prefix2 == NULL) prefix2 = n2.c_str();
226 if ( it1->second->comm_rank()==0 && _ctrl.verb) {
227 std::cout <<
"RFACE: Writing subdivision of window \""
228 << n1 <<
"\"...." << std::flush;
230 if ( format && std::strcmp( format,
"Tecplot")==0) {
231 it1->second->write_tec_ascii( (std::string(prefix1)+
"_orig").c_str());
232 it1->second->write_tec_sub( prefix1);
235 it1->second->write_sdv( prefix1, format);
237 if ( it1->second->comm_rank()==0 && _ctrl.verb) {
238 std::cout <<
"Done" << std::endl;
241 if ( it2->second->comm_rank()==0 && _ctrl.verb) {
242 std::cout <<
"Writing subdivision of window \""
243 << n2 <<
"\"...." << std::flush;
246 if ( format && std::strcmp( format,
"Tecplot")==0) {
247 it2->second->write_tec_ascii( (std::string(prefix2)+
"_orig").c_str());
248 it2->second->write_tec_sub( prefix2);
251 it2->second->write_sdv( prefix2, format);
253 if ( it2->second->comm_rank()==0 && _ctrl.verb) {
254 std::cout <<
"Done" << std::endl;
259 Rocface::get_transfer_window(
const COM::Attribute *attr) {
260 return _trs_windows.find( attr->window()->name())->second;
263 Rocface::get_transfer_window( COM::Attribute *attr) {
264 return _trs_windows.find( attr->window()->name())->second;
268 set_tags(
const COM::Attribute *src,
const COM::Attribute *trg,
269 const COM::Attribute *tags) {
275 std::string n1 = src->window()->name();
276 std::string n2 = trg->window()->name();
279 get_name( n2, n1, wn2);
281 TRS_Windows::iterator it2 = _trs_windows.find( wn2);
283 if ( it2 == _trs_windows.end()) {
284 std::cerr <<
"Rocface: ERROR: The overlay of window \"" << n1
285 <<
"\" and window \"" << n2 <<
"\" does not exist"
291 it2->second->set_tags( tags);
299 template <
class Source_type,
class Target_type,
bool conserv>
316 Source_type &sf, Target_type &tf,
317 const Real alpha,
const int order,
318 Real *tol,
int *iter,
319 const int verbose,
const bool load);
330 const Real alpha,
const int order,
331 Real *tol,
int *iter,
332 const int verbose,
const bool) {
345 const Real alpha,
const int order,
346 Real *tol,
int *iter,
347 const int verbose,
const bool) {
348 trans.
transfer( sf, tf, alpha, order, verbose);
360 const Real alpha,
const int order,
361 Real *tol,
int *iter,
362 const int verbose,
const bool) {
363 trans.
transfer( sf, tf, alpha, order, verbose);
376 const Real alpha,
const int order,
377 Real *tol,
int *iter,
378 const int verbose,
const bool load) {
380 trans.
transfer( sf, tf, alpha, tol, iter, order, verbose);
382 trans.
comp_loads( sf, tf, alpha, order, verbose);
394 const Real alpha,
const int order,
395 Real *tol,
int *iter,
396 const int verbose,
const bool load) {
398 trans.
transfer( sf, tf, alpha, tol, iter, order, verbose);
400 trans.
comp_loads( sf, tf, alpha, order, verbose);
405 template <
class Source_type,
class Target_type,
bool conserv>
406 void Rocface::transfer(
const COM::Attribute *src, COM::Attribute *trg,
407 const Real alpha,
const int order,
408 Real *tol,
int *iter,
bool load) {
411 std::string n1 = src->window()->name();
412 std::string n2 = trg->window()->name();
414 std::string wn1, wn2;
415 get_name( n1, n2, wn1); get_name( n2, n1, wn2);
417 TRS_Windows::iterator it1 = _trs_windows.find( wn1);
418 TRS_Windows::iterator it2 = _trs_windows.find( wn2);
420 if ( it1 == _trs_windows.end() || it2 == _trs_windows.end()) {
421 std::cerr <<
"RFACE: ERROR: The overlay of window \"" << n1
422 <<
"\" and window \"" << n2 <<
"\" does not exist"
427 if ( !it1->second->replicated()) {
428 it1->second->replicate_metadata( *it2->second);
431 Target_type tf( trg);
432 Source_type sf( src);
435 typename Traits::Transfer_type trans( w1, w2);
439 if ( w2->comm_rank()==0) {
441 std::cout <<
"RFACE: Conservatively transferring ";
443 std::cout <<
"RFACE: Interpolating ";
444 std::cout <<
" from " << w1->
name()+
"."+src->name()
445 <<
" to " << w2->name()+
"."+trg->name() << std::endl;
447 Vector_n min_v( sf.dimension()), max_v(sf.dimension());
448 trans.minmax( *w1, sf, min_v, max_v);
450 Vector_n integral(sf.dimension(),0);
451 trans.integrate( *w1, sf, integral, order);
454 std::cout <<
"RFACE: Before transfer\nRFACE:\tminimum: " << min_v
455 <<
"\nRFACE:\tmaximum: " << max_v;
457 std::cout <<
"\nRFACE:\tintegral: " << std::setprecision(10)
459 std::cout << std::endl;
464 Traits::transfer( trans, sf, tf, alpha, order, tol, iter, _ctrl.verb, load);
468 Vector_n min_v( sf.dimension()), max_v(sf.dimension());
469 trans.minmax( *w2, tf, min_v, max_v);
471 Vector_n integral(sf.dimension(),0);
472 trans.integrate( *w2, tf, integral, order);
474 if ( w2->comm_rank()==0 && _ctrl.verb) {
475 std::cout <<
"RFACE: After transfer\nRFACE:\tminimum: " << min_v
476 <<
"\nRFACE:\tmaximum: " << max_v;
478 std::cout <<
"\nRFACE:\tintegral: " << std::setprecision(10)
480 std::cout << std::endl;
491 least_squares_transfer(
const COM::Attribute *src,
500 Real alpha = (alp_in == NULL) ? 1. : *alp_in;
501 int order = (ord_in == NULL) ? 1+trg->is_nodal() : *ord_in;
505 if ( trg->is_nodal()) {
506 Real tol = (tol_io == NULL) ? 1.e-6 : *tol_io;
507 int iter = (iter_io == NULL) ? 100 : *iter_io;
509 if ( src->is_nodal()) {
510 transfer<Nodal_data_const, Nodal_data, true>
511 ( src, trg, alpha, order, &tol, &iter);
514 transfer<Facial_data_const, Nodal_data, true>
515 ( src, trg, alpha, order, &tol, &iter);
518 if (tol_io != NULL) *tol_io = tol;
519 if (iter_io != NULL) *iter_io = iter;
522 if ( src->is_nodal()) {
523 transfer<Nodal_data_const, Facial_data, true>
524 ( src, trg, alpha, order);
527 transfer< Facial_data_const, Facial_data, true>
528 ( src, trg, alpha, order);
535 interpolate(
const COM::Attribute *src,
536 COM::Attribute *trg) {
541 transfer< Nodal_data_const, Nodal_data, false>
547 load_transfer(
const COM::Attribute *src,
554 const Real alpha = (_a == NULL)?-1.:*_a;
555 const int order = (_o == NULL)?1:*_o;
557 if ( src->is_nodal()) {
558 transfer<Nodal_data_const, Nodal_data, true>
559 ( src, trg, alpha, order, NULL, NULL,
true);
562 transfer<Facial_data_const, Nodal_data, true>
563 ( src, trg, alpha, order, NULL, NULL,
true);
568 void Rocface::init(
const std::string &mname) {
570 Rocface *rfc =
new Rocface( mname);
573 std::string glb=mname+
".global";
585 (Member_func_ptr)(&Rocface::overlay),
586 glb.c_str(),
"biiII", types);
590 (Member_func_ptr)(&Rocface::read_overlay),
591 glb.c_str(),
"biiiIII", types);
595 (Member_func_ptr)(&Rocface::set_tags),
596 glb.c_str(),
"biii", types);
601 (Member_func_ptr)(&Rocface::least_squares_transfer),
602 glb.c_str(),
"bioIIBB", types);
605 (Member_func_ptr)(&Rocface::interpolate),
606 glb.c_str(),
"bio", types);
610 (Member_func_ptr)(&Rocface::load_transfer),
611 glb.c_str(),
"bioII", types);
616 (Member_func_ptr)(&Rocface::write_overlay),
617 glb.c_str(),
"biiIII", types);
621 (Member_func_ptr)(&Rocface::clear_overlay),
622 glb.c_str(),
"bii", types);
627 glb.c_str(),
"bi", types);
632 (Member_func_ptr)(&Rocface::set_verbose),
633 glb.c_str(),
"bi", types);
644 std::string ctrlname = _mname+
"__CTRL";
651 COM_set_array( (ctrlname+
".verbosity").c_str(), 0, &_ctrl.verb);
655 COM_set_array( (ctrlname+
".snap_tolerance").c_str(), 0, &_ctrl.snap);
670 void Rocface::finalize(
const std::string &mname) {
674 std::string glb=mname+
".global";
687 { Rocface::init( std::string(name)); }
689 { Rocface::finalize( std::string(name)); }
693 { Rocface::init( std::string(name, length)); }
695 { Rocface::finalize( std::string(name, length)); }
698 { Rocface::init( std::string(name, length)); }
700 { Rocface::finalize( std::string(name, length)); }
703 { Rocface::init( std::string(name, length)); }
705 { Rocface::finalize( std::string(name, length)); }
708 { Rocface::init( std::string(name, length)); }
710 { Rocface::finalize( std::string(name, length)); }
std::string name() const
The name of the window.
void transfer(const Nodal_data_const &sf, Nodal_data &tf, const Real alpha, Real *t, int *iter, int doa, bool ver)
The main entry to the data transfer algorithm.
Transfer_f2f Transfer_type
int COM_Type
Indices for derived data types.
void Rocin_load_module(const char *name)
Load the module Rocin into Roccom using the given module name.
Transfer_f2n Transfer_type
#define COM_assertion(EX)
Error checking utility similar to the assert macro of the C language.
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
void transfer(const Nodal_data_const &sv, Facial_data &tf, const Real alpha, int doa=0, bool verb=false)
The main entry to the data transfer algorithm.
void rocface_load_module(const char *name, long int length)
Specialization for transfering from faces to nodes.
void COM_delete_window(const char *wname)
Specialization for transfering from nodes to nodes.
void rocface_unload_module_(const char *name, long int length)
#define COM_assertion_msg(EX, msg)
void rocface_load_module_(const char *name, long int length)
Defines the interface. Implementations only present in specializations.
void COM_set_object(const char *wa_str, int pane_id, Type *addr)
static void transfer(Transfer_type &trans, Facial_data_const &sf, Nodal_data &tf, const Real alpha, const int order, Real *tol, int *iter, const int verbose, const bool load)
See above.
void ROCFACE_LOAD_MODULE_(const char *name, long int length)
static void transfer(Transfer_type &trans, Nodal_data_const &sf, Facial_data &tf, const Real alpha, const int order, Real *tol, int *iter, const int verbose, const bool)
double length(Vector3D *const v, int n)
void COM_get_object(const char *wa_str, int pane_id, Type **addr)
void ROCFACE_LOAD_MODULE(const char *name, long int length)
#define RFC_END_NAME_SPACE
static void transfer(Transfer_type &trans, Facial_data_const &sf, Facial_data &tf, const Real alpha, const int order, Real *tol, int *iter, const int verbose, const bool)
static void transfer(Transfer_type &trans, Nodal_data_const &sf, Nodal_data &tf, const Real alpha, const int order, Real *tol, int *iter, const int verbose, const bool)
Specialization for transfering nodal forces using Farhat's algorithm.
#define RFC_BEGIN_NAME_SPACE
Transfer_n2n Transfer_type
#define RFC_assertion_msg
void Rocface_unload_module(const char *)
void COM_window_init_done(const char *w_str, int pane_changed=true)
#define USE_RFC_NAME_SPACE
void COM_new_window(const char *wname, MPI_Comm c=MPI_COMM_NULL)
Interpolator Transfer_type
void COM_call_function(const int wf, int argc,...)
void COM_set_array(const char *wa_str, int pane_id, void *addr, int strd=0, int cap=0)
Associates an array with an attribute for a specific pane.
Transfer_n2f Transfer_type
static void transfer(Transfer_type &trans, Source_type &sf, Target_type &tf, const Real alpha, const int order, Real *tol, int *iter, const int verbose, const bool load)
void Rocface_load_module(const char *)
void rocface_unload_module(const char *name, long int length)
void COM_new_attribute(const char *wa_str, const char loc, const int type, int ncomp, const char *unit)
Registering an attribute type.
void COM_set_member_function(const char *wf_str, Member_func_ptr func, const char *wa_str, const char *intents, const COM_Type *types)
void set_tolerance(double tol)
static void transfer(Transfer_type &trans, Nodal_data_const &sf, Nodal_data &tf, const Real alpha, const int order, Real *tol, int *iter, const int verbose, const bool load)
Specialization for transfering from faces to faces.
void ROCFACE_UNLOAD_MODULE_(const char *name, long int length)
void transfer(const Facial_data_const &sf, Nodal_data &tf, const Real alpha, Real *tol, int *iter, int doa, bool verb)
The main entry to the data transfer algorithm.
Specialization for transfering from nodes to faces.
void comp_loads(const Facial_data_const &sf, Nodal_data &tf, const Real alpha, const int order, bool verb)
Compute the nodal load vector.
void transfer(const Nodal_data_const &sf, Nodal_data &tf, bool verb)
The main entry to the data transfer algorithm.
int COM_get_function_handle(const char *wfname)
void read_control_file(const char *fname, Control_parameter &cp)
void transfer(const Facial_data_const &sf, Facial_data &tf, const Real alpha, int doa=0, bool verb=false)
The main entry to the data transfer algorithm.
void comp_loads(const Nodal_data_const &sf, Nodal_data &tf, const Real alpha, const int doa, bool verb)
Compute the nodal load vector.
void ROCFACE_UNLOAD_MODULE(const char *name, long int length)
void Rocin_unload_module(const char *name)
Unload the module Rocin from Roccom.