Rocstar  1.0
Rocstar multiphysics simulation application
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
transfer_actions.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: transfer_actions.C,v 1.59 2008/12/06 08:45:22 mtcampbe Exp $
24 
25 #include "basic_actions.h"
26 #include "transfer_actions.h"
27 #include "FluidAgent.h"
28 #include "SolidAgent.h"
29 #include "BurnAgent.h"
30 
31 COM_EXTERN_MODULE(Rocsurf);
32 COM_EXTERN_MODULE(Rocface);
33 
34 static inline void load_rocsurf()
35 {
36  if (COM_get_window_handle("SURF") <= 0) {
37  COM_LOAD_MODULE_STATIC_DYNAMIC( Rocsurf, "SURF");
38  }
39 }
40 
41 extern void compute_overlay( FluidAgent *fagent, SolidAgent *sagent, double t);
42 
43 void _load_rocface(FluidAgent *fagent, SolidAgent *sagent, const RocmanControl_parameters *param)
44 {
45  int rank = fagent->get_comm_rank();
46 
47  // INIT_ROCFACE of rocman.f90
48  if (COM_get_window_handle( "RFC") <=0 ) {
49  if(rank == 0)
50  MAN_DEBUG(3, ("Rocstar: load module RocFace.\n"));
51  COM_LOAD_MODULE_STATIC_DYNAMIC( Rocface, "RFC");
52 
53  int RFC_setv = COM_get_function_handle( "RFC.set_verbose");
54  COM_call_function( RFC_setv, &param->rfc_verb);
55 
56 #if 0
57  // if remeshed
58  MAN_DEBUG(3, ("Rocstar: remeshed: %d.\n", param->remeshed));
59  if (param->remeshed) {
60  double t = fagent->get_coupling()->get_control_param()->current_time;
61  compute_overlay( fagent, sagent, t);
62  }
63 #endif
64 
65  // load overlay
66  MPI_Comm comm = fagent->get_communicator();
67 
68  int RFC_read = COM_get_function_handle( "RFC.read_overlay");
69  int fluid_mesh = COM_get_attribute_handle_const( fagent->fluidBufNG+".mesh");
70  int solid_mesh = COM_get_attribute_handle_const( sagent->solidBuf+".mesh");
71  std::string rfc_dir = "Rocman/"+fagent->get_modinstance_name()+sagent->get_modinstance_name()+"/";
72  //std::string rfc_dir = "Rocman/RocfloRocsolid/";
73  std::string fluid_dir = rfc_dir+"ifluid";
74  std::string solid_dir = rfc_dir+"isolid";
75 
76  if(rank == 0)
77  MAN_DEBUG(2, ("Rocstar: read RocFace overlay mesh from %s.\n", rfc_dir.c_str()));
78 
79  //COM_call_function( RFC_read, &fluid_mesh, &solid_mesh, &comm, fluid_dir.c_str(), solid_dir.c_str(), "HDF");
80  COM_call_function( RFC_read, &fluid_mesh, &solid_mesh, &comm, fluid_dir.c_str(), solid_dir.c_str(), "CGNS");
81 
82  int RFC_transfer = COM_get_function_handle("RFC.least_squares_transfer");
83  int RFC_interpolate = COM_get_function_handle("RFC.interpolate");
84  COM_set_profiling_barrier( RFC_transfer, comm);
85  COM_set_profiling_barrier( RFC_interpolate, comm);
86  }
87 }
88 
90 {
91  // INIT_ROCFACE of rocman.f90
92  _load_rocface(fagent, sagent, param);
93 }
94 
96  Action(0, (const char **)NULL, NULL, NULL, name),
97  fagent(fag), sagent(sag)
98 {
99 }
100 
101 
102 // Transfer load from fluid to solid
103 // Arguments: tf_FF (IN), mdot (IN), rb (IN),
104 // tf_SF (OUT)
106  const std::string f_ts,
107  const std::string s_ts,
108  const std::string s_pf) :
109  InterMeshTransfer(fag, sag, (char *)"LoadTransfer_FS"),
110  f_ts_str(f_ts), s_ts_str(s_ts), s_pf_str(s_pf)
111 {
112  int io[] = {IN, IN, OUT};
113  set_io( 3, io);
114 
115  std::string atts[3];
116  atts[0] = f_ts;
117  atts[1] = s_ts;
118  atts[2] = s_pf;
119  set_attr(3, atts);
120 
122 
123  // create_attribute
124  // for SolidAgent ??????????????????
125 // if (traction_mode == NO_SHEER && size_ts == 3) {
126  sagent->register_new_attribute( sagent->solidBufBase, ".pf", 'e', COM_DOUBLE, 1, "Pa");
127 // }
128 
129  // for FluidAgent
130  std::string::size_type pos = f_ts_str.find( ".");
131  COM_assertion_msg(pos!=std::string::npos, "LoadTransfer_FS failed!");
132  std::string f = f_ts_str.substr( 0, pos);
133  std::string ts = f_ts_str.substr( pos, f_ts_str.size());
134  if (traction_mode == NO_SHEER) {
136  }
137  else
139 }
140 
141 // Create buffer data
142 void LoadTransfer_FS::init( double t) {
143  // find out size_ts ???
144  int dummy;
145  std::string unit;
146  char loc;
147  COM_get_attribute( sagent->solidBufBase+".ts", &loc, &dummy, &size_ts, &unit);
148  if (size_ts == 1 && traction_mode != NO_SHEER) {
149  COM_assertion_msg(0, "If traction mode is with sheer, then solid tractions must be vectors!");
150  MPI_Abort(MPI_COMM_WORLD, -1);
151  }
152 
154 
155  // for SolidAgent
158  if (traction_mode == NO_SHEER && size_ts == 3)
160  else
161  s_pf_hdl = -1;
162 
165 
166  RFC_transfer = COM_get_function_handle("RFC.least_squares_transfer");
167 
168  load_rocsurf();
169  SURF_compute_face_normals = COM_get_function_handle( "SURF.compute_element_normals");
170 
171  MAN_DEBUG(3, ("LoadTransfer_FS::init() called - traction_mode: %d size_ts: %d.\n", traction_mode, size_ts));
172 }
173 
174 void LoadTransfer_FS::run( double t, double dt, double alpha) {
175  MAN_DEBUG(3, ("Rocstar: LoadTransfer_FS::run() with t:%e dt:%e.\n", t, dt));
176  // ts = tf + ( mdot*Vs
177 
178  // part 1 (POST_UPDATE_FLUID in fluid_agent.f90)
179  if (traction_mode != NO_SHEER) {
181  }
182  else { // ts is a scalar
184  }
185 
186  // part 2 (solid_agent.f90 INIT_INBUFF_SOLID())
187  if (traction_mode == NO_SHEER && size_ts == 3) {
192  }
193  else if ( traction_mode == NO_SHEER && size_ts == 1) {
195  }
196  else if (size_ts == 1) {
197  COM_assertion_msg(0, "ERROR: NOT IMPLEMENTED!");
198  }
199  else {
200  COM_assertion_msg(0, "ERROR: NOT IMPLEMENTED!");
201  }
202 }
203 
204 // Transfer load from fluid to solid with Burn
205 // Arguments: tf_FF (IN), mdot (IN), rb (IN),
206 // tf_SF (OUT)
208  BurnAgent *bag,
209  const std::string f_pf,
210  const std::string fb_mdot,
211  const std::string b_rb,
212  const std::string s_ts,
213  const std::string s_pf) :
214  InterMeshTransfer(fag, sag, (char *)"LoadTransfer_FSc_ALE"),
215  bagent(bag)
216 {
217  int io[] = {IN, IN, IN, IN, OUT};
218  set_io( 5, io);
219 
220  std::string atts[5];
221  atts[0] = f_pf;
222  atts[1] = fb_mdot;
223  atts[2] = b_rb;
224  atts[3] = s_ts;
225  atts[4] = s_pf;
226  set_attr(5, atts);
227 
229 
230  // create_attribute
231  // for SolidAgent ??????????????????
232 // if (traction_mode == NO_SHEER && size_ts == 3) {
233  sagent->register_new_attribute( sagent->solidBufBase, ".pf", 'e', COM_DOUBLE, 1, "Pa");
234 // }
235 
236  // for FluidAgent
237  if (traction_mode == NO_SHEER) {
239  }
240  else
242 
243 // fagent->register_new_attribute( fagent->fluidBufB, ".mdot_tmp", 'e', COM_DOUBLE, 1, "kg/(m^2 s)");
244 }
245 
246 // Create buffer data
247 void LoadTransfer_FSc_ALE::init( double t) {
248  // find out size_ts
249  int dummy;
250  std::string unit;
251  char loc;
252  COM_get_attribute( sagent->solidBufBase+".ts", &loc, &dummy, &size_ts, &unit);
253  if (size_ts == 1 && traction_mode != NO_SHEER) {
254  COM_assertion_msg(0, "If traction mode is with sheer, then solid tractions must be vectors!");
255  MPI_Abort(MPI_COMM_WORLD, -1);
256  }
257 
258  //f_pf_hdl = COM_get_attribute_handle_const( fagent->fluidBufNG+".pf");
263  if (traction_mode == NO_SHEER && size_ts == 3)
265  else
266  s_pf_hdl = -1;
267 
272 
275 
278 
280  RFC_transfer = COM_get_function_handle("RFC.least_squares_transfer");
281 
282  load_rocsurf();
283  SURF_compute_face_normals = COM_get_function_handle( "SURF.compute_element_normals");
284 
285  MAN_DEBUG(3, ("LoadTransfer_FSc_ALE::init() called - traction_mode: %d size_ts: %d.\n", traction_mode, size_ts));
286 }
287 
288 void LoadTransfer_FSc_ALE::run( double t, double dt, double alpha) {
289  MAN_DEBUG(3, ("Rocstar: LoadTransfer_FSc_ALE::run() with t:%e dt:%e.\n", t, dt));
290  // ts = tf + ( mdot*Vs
291 
292 #if 1
293  // part 1 (POST_UPDATE_FLUID in fluid_agent.f90)
294  if (traction_mode != NO_SHEER) {
296 
297  // Compute tfmts = t_s-t_f (see developers guide).
298  // Here fb_mdot_tmp is used as buffer space.
300 
301  if ( sagent->withALE) {
303  }
304 
307 
308  // Compute ts = tf - (tf-ts)
310  }
311  else { // ts is a scalar
312 
314 
315  // Compute tsmpf = p_f-t_s (see developers guide).
316  // Here fb_mdot_tmp is used as buffer space.
318 
319  if ( sagent->withALE) {
321  }
322 
324 
325  // Compute ts = pf - (pf-ts)
327 
328  //debug_print(fagent->fluidBufB+".mdot", 102, 0, "LOADTRANSFER");
329  //debug_print(fagent->fluidBufB+".ts", 102, 0, "LOADTRANSFER");
330 
331  // Subtract from P_ambient if not zeros
332  double P_ambient = fagent->get_coupling()->get_rocmancontrol_param()->P_ambient;
333  if ( P_ambient != 0.0) {
335  }
336  }
337 
338 #endif
339 
340  // part 2 (solid_agent.f90 INIT_INBUFF_SOLID())
341  if (traction_mode == NO_SHEER && size_ts == 3) {
346  }
347  else if ( traction_mode == NO_SHEER && size_ts == 1) {
349  //debug_print(sagent->solidBuf+".ts", 102, 0, fagent->get_communicator(), "LOADTRANSFER");
350  }
351  else if (size_ts == 1) {
352  COM_assertion_msg(0, "If traction mode is with sheer, then solid tractions must be vectors!");
353  }
354  else {
356  }
357 }
358 
359 // Transfer load from fluid to solid with Burn (part 2 only)
360 // Arguments: f_ts (IN)
361 // s_ts (OUT) tf_SF (OUT)
363  FluidAgent *fag, SolidAgent *sag,
364  BurnAgent *bag,
365  const std::string f_ts,
366  const std::string s_ts,
367  const std::string s_pf) :
368  InterMeshTransfer(fag, sag, (char *)"LoadTransferOnly_FSc_ALE"),
369  bagent(bag)
370 {
371  int io[] = {IN, OUT, OUT};
372  set_io( 3, io);
373 
374  std::string atts[3];
375  atts[0] = f_ts;
376  atts[1] = s_ts;
377  atts[2] = s_pf;
378  set_attr(3, atts);
379 
381 
382  // create_attribute
383  // for SolidAgent ??????????????????
384 // if (traction_mode == NO_SHEER && size_ts == 3) {
385  sagent->register_new_attribute( sagent->solidBufBase, ".pf", 'e', COM_DOUBLE, 1, "Pa");
386 // }
387 
388  // for FluidAgent
389  if (traction_mode == NO_SHEER) {
391  }
392  else
394 
395 // fagent->register_new_attribute( fagent->fluidBufB, ".mdot_tmp", 'e', COM_DOUBLE, 1, "kg/(m^2 s)");
396 }
397 
398 // Create buffer data
400  // find out size_ts
401  int dummy;
402  std::string unit;
403  char loc;
404  COM_get_attribute( sagent->solidBufBase+".ts", &loc, &dummy, &size_ts, &unit);
405  if (size_ts == 1 && traction_mode != NO_SHEER) {
406  COM_assertion_msg(0, "If traction mode is with sheer, then solid tractions must be vectors!");
407  MPI_Abort(MPI_COMM_WORLD, -1);
408  }
409 
410  //f_pf_hdl = COM_get_attribute_handle_const( fagent->fluidBufNG+".pf");
413  if (traction_mode == NO_SHEER && size_ts == 3)
415  else
416  s_pf_hdl = -1;
417 
419  RFC_transfer = COM_get_function_handle("RFC.least_squares_transfer");
420 
421  load_rocsurf();
422  SURF_compute_face_normals = COM_get_function_handle( "SURF.compute_element_normals");
423 
424  MAN_DEBUG(3, ("LoadTransferOnly_FSc_ALE::init() called - traction_mode: %d size_ts: %d.\n", traction_mode, size_ts));
425 }
426 
427 void LoadTransferOnly_FSc_ALE::run( double t, double dt, double alpha) {
428  MAN_DEBUG(3, ("Rocstar: LoadTransferOnly_FSc_ALE::run() with t:%e dt:%e.\n", t, dt));
429 
430  // part 2 (solid_agent.f90 INIT_INBUFF_SOLID())
431  if (traction_mode == NO_SHEER && size_ts == 3) {
436  }
437  else if ( traction_mode == NO_SHEER && size_ts == 1) {
439  }
440  else if (size_ts == 1) {
441  COM_assertion_msg(0, "If traction mode is with sheer, then solid tractions must be vectors!");
442  }
443  else {
445  }
446 }
447 
448 /*
449 // Arguments: tf_FF (IN), mdot (IN), rb (IN),
450 // tf_SF (OUT)
451 LoadTransfer_FSc_ALE::LoadTransfer_FSc_ALE( FluidAgent *fag, SolidAgent *sag, const char *at[], int *is, void *p) :
452  InterMeshTransfer(fag, sag, "LoadTransfer_FS") {
453  int io[] = {IN, OUT};
454  set_io( 2, io);
455 }
456 
457 // Create buffer data
458 void LoadTransfer_FSc_ALE::init( double t) {
459 }
460 
461 void LoadTransfer_FSc_ALE::run( double t, double dt, double alpha) {
462  // ts = tf + ( mdot*Vs
463 }
464 */
465 
466 
467 // solid_agent.f90 POST_UPDATE_SOLID
468 GetDeformedMesh::GetDeformedMesh(FluidAgent *fag, SolidAgent *sag, const std::string s_x, const std::string s_uhat, const std::string s_y):
469  InterMeshTransfer(fag, sag, (char *)"GetDeformedMesh"),
470  s_x_str(s_x), s_uhat_str(s_uhat), s_y_str(s_y)
471 {
472  int io[] = {IN, IN, OUT};
473  set_io( 3, io);
474 
475  std::string atts[4];
476  atts[0] = s_x;
477  atts[1] = s_uhat;
478  atts[2] = s_y;
479  set_attr(3, atts);
480 
481  // register attributes
482 /*
483  std::string::size_type pos = s_x_str.find( ".");
484  COM_assertion_msg(pos!=std::string::npos, "GetDeformedMesh::create_attribute failed!");
485  std::string s = s_x_str.substr( 0, pos);
486  std::string x = s_x_str.substr( pos, s_x_str.size());
487  sagent->register_use_attribute( s, x, sagent->solidBufBase, ".nc");
488 
489  pos = s_y_str.find( ".");
490  COM_assertion_msg(pos!=std::string::npos, "GetDeformedMesh::create_attribute failed!");
491  s = s_y_str.substr( 0, pos);
492  std::string y = s_y_str.substr( pos, s_y_str.size());
493  sagent->register_clone_attribute( 0, s, y, sagent->get_surface_window(), ".nc");
494 */
495 }
496 
497 void GetDeformedMesh::init( double t) {
501 
502 #if 0
503  // POST_INIT_SOLID
505  // initial_start ?????
506  if (t == 0.0) {
507 // double alpha = 0.0;
508 // ????????????????? strange bug called in bcinitscheduler::init()
509 // sagent->obtain_bc(&alpha);
510  }
511 #endif
512 }
513 
514 // POST_UPDATE_SOLID
515 void GetDeformedMesh::run( double t, double dt, double alpha) {
516  MAN_DEBUG(3, ("Rocstar: calling GetDeformedMesh::run() with t:%e dt:%e alpha:%e.\n", t, dt, alpha));
518 }
519 
520 // solid_agent.f90 POST_UPDATE_SOLID
521 GetDeformedMesh_ALE::GetDeformedMesh_ALE(FluidAgent *fag, SolidAgent *sag, const std::string s_x, const std::string s_uhat, const std::string s_y, double z):
522  InterMeshTransfer(fag, sag, (char *)"GetDeformedMesh_ALE"),
523  s_x_str(s_x), s_uhat_str(s_uhat), s_y_str(s_y), zoom(z)
524 {
525  int io[] = {IN, IN, OUT};
526  set_io( 3, io);
527 
528  std::string atts[4];
529  atts[0] = s_x;
530  atts[1] = s_uhat;
531  atts[2] = s_y;
532  set_attr(3, atts);
533 
534 /*
535  // register attributes
536  std::string::size_type pos = s_x_str.find( ".");
537  COM_assertion_msg(pos!=std::string::npos, "GetDeformedMesh_ALE::create_attribute failed!");
538  std::string s = s_x_str.substr( 0, pos);
539  std::string x = s_x_str.substr( pos, s_x_str.size());
540  sagent->register_use_attribute( s, x, sagent->solidBufBase, ".nc");
541 
542  // s_y = solidBuf+".nc"
543  pos = s_y_str.find( ".");
544  COM_assertion_msg(pos!=std::string::npos, "GetDeformedMesh_ALE::create_attribute failed!");
545  s = s_y_str.substr( 0, pos);
546  std::string y = s_y_str.substr( pos, s_y_str.size());
547  sagent->register_clone_attribute( 0, s, y, sagent->get_surface_window(), y);
548 */
549 }
550 
551 void GetDeformedMesh_ALE::init( double t) {
555 
557 
562 
563  load_rocsurf();
564  SURF_compute_bounded_volumes = COM_get_function_handle( "SURF.compute_bounded_volumes");
565  SURF_compute_face_areas = COM_get_function_handle( "SURF.compute_element_areas");
566 
567 #if 0
568  // POST_INIT_SOLID
570  // initial_start ?????
571  if (t == 0.0) {
572 // double alpha = 0.0;
573 // ????????????????? strange bug called in bcinitscheduler::init()
574 // sagent->obtain_bc(&alpha);
575  }
576 #endif
577 }
578 
579 // POST_UPDATE_SOLID
580 void GetDeformedMesh_ALE::run( double t, double dt, double alpha) {
581  MAN_DEBUG(3, ("Rocstar: calling GetDeformedMesh_ALE::run() with t:%e dt:%e alpha:%e withALE=%d zoom=%e.\n", t, dt, alpha, withALE, zoom));
582 
583  double mdot_min;
584 
586  // compute volumes only for faces with nonzero burning rate
588 
589  //debug_print(sagent->solidBuf+".nc", 202, 1);
590  //debug_print(sagent->solidBuf+".x", 202, 1);
591 
592  // Compute mass injection using s_x and s_y as buffers.
593  // So far s_y stores the undeformed configuration s_x.
594  int one = 1;
596 
597  //debug_print(sagent->solidBuf+".nc", 202, 1);
598  //debug_print(attr[2], 202, 1);
599 
600 #if 0
601  // Check whether the burning rates are nonnegative.
602  int comm = MPI_COMM_SELF;
604 
605  if ( mdot_min < 0) {
606  printf("Rocstar ERROR: Negative mdot found %e. Aborting...\n", mdot_min);
607  MPI_Abort( MPI_COMM_WORLD, -1);
608  }
609 #else
610  double zero = 0.0;
612 #endif
613 
614  // Compute deformed configuration
617 
618  // Compute mdot=dV*rhos/area/dt
622  }
623  else {
624  // Compute deformed configuration
626  // Compute mdot as rb*rhos
627  if ( withALE)
629  }
630 }
631 
632 
633 // fluid_agent.f90 INIT_INBUFF_FLUID
635  const std::string s_u, const std::string f_total_disp,
636  const std::string f_vm):
637  InterMeshTransfer(fag, sag, (char *)"MeshMotionTransfer_SF")
638 {
639  // isolid_i+".nc" (in), isolid_i+".u" (in), fagent->ifluid_i+".vm" (out)
640  int io[] = {IN, IN, INOUT, OUT};
641  set_io( 4, io);
642 
643  std::string atts[4];
644  atts[0] = sagent->solidBufBase+".nc";
645  atts[1] = s_u;
646  atts[2] = f_total_disp;
647  atts[3] = f_vm;
648  set_attr(4, atts);
649 
650  // Change to transfer total_displacement from solid to fluids, and obtain
651  // incremental displacement as (nc_t0+total_disp)-nc_tn. This is prone
652  // to cancellation errors but avoids accumulation of any errors.
653  fagent->register_clone_attribute( 0, fagent->ifluid_i, ".total_disp", fagent->get_surface_window(), ".du_alp");
655  // nc_tmp is used to compare against solid nodal coordinates.
656  //fagent->register_clone_attribute( 0, fagent->ifluid_i, ".nc_tmp", fagent->get_surface_window(), ".nc");
657  //fagent->register_new_attribute( fagent->ifluid_i, ".sq_dist", 'n', COM_DOUBLE, 1, "m");
658 }
659 
661  // skip 0
665 
668 
669  // POST_INIT_FLUID in fluid_agent.f90
670  // initial_start ?????
671 // if (t == 0.0) {
672  // TODO ???
673 // COM_call_function( RocBlas::copy, &f_nc_hdl, &f_nc_t0_hdl);
674  // UPDATE_INBUFF_GM_FLUID ???????????????
675 // double zero = 0.0;
676 // fagent->obtain_gm(&zero);
677 // }
678 
680  RFC_interpolate = COM_get_function_handle("RFC.interpolate");
681 }
682 
683 // INIT_INBUFF_FLUID
684 void MeshMotionTransfer_SF::run( double t, double dt, double alpha) {
685  MAN_DEBUG(3, ("Rocstar: calling MeshMotionTransfer_SF::run() with t:%e dt:%e alpha:%e.\n", t, dt, alpha));
686 
687  // b. Interpolates total displacement from solid nodes to fluid nodes
688  //debug_print(sagent->solidBuf+".u", 109, 0, sagent->get_communicator(), "U");
690 
691  // Compute incremental mesh volocity
692  if (!fagent->get_coupling()->initial_start()) {
693  // Compute incremental mesh volocity
697  }
698 }
699 
700 
701 // transfer vs from solid nodes to fluid faces using Rocface
703  SolidAgent *sag, const std::string s_vs, const std::string f_vs):
704  InterMeshTransfer(fag, sag, (char *)"DeformationVelTransfer_SF"),
705  s_vs_str(s_vs), f_vs_str(f_vs)
706 {
707  // added a builtin in (ifluid_i+".vm")
708  // ifluid_i+".vm" (in), isolid_i+".vs", ifluid_i+".vs"
709  int io[] = {IN, IN, OUT};
710  set_io( 3, io);
711 
712  std::string atts[3];
713  atts[0] = fagent->ifluid_i+".vm";
714  atts[1] = s_vs;
715  atts[2] = f_vs;
716  set_attr(3, atts);
717 }
718 
722 
724 
725  RFC_transfer = COM_get_function_handle("RFC.least_squares_transfer");
726 }
727 
728 void DeformationVelTransfer_SF::run( double t, double dt, double alpha) {
729  MAN_DEBUG(3, ("Rocstar: DeformationVelTransfer_SF::run() with t:%e dt:%e alpha:%e.\n", t, dt, alpha));
730 
731  // c. Transfer vs from solid nodes to fluid faces using Rocface
733 }
734 
735 
736 MeshMotionTransferISS::MeshMotionTransferISS(FluidAgent *fag, SolidAgent *sag, const std::string s_u, const std::string s_vs, const std::string f_vm):
737  InterMeshTransfer(fag, sag, (char *)"MeshMotionTransferISS"),
738  s_u_str(s_u), s_vs_str(s_vs), f_vm_str(f_vm)
739 {
740  // isolid_i+".u" (in), isolid_i+".vs" (in), ifluid_i+".vm" (out)
741  int io[] = {IN, IN, OUT};
742  set_io( 3, io);
743 
744  std::string atts[3];
745  atts[0] = s_u;
746  atts[1] = s_vs;
747  atts[2] = f_vm;
748  set_attr(3, atts);
749 
750  std::string::size_type pos = f_vm_str.find( ".");
751  COM_assertion_msg(pos!=std::string::npos, "MeshMotionTransferISS failed!");
752  std::string f = f_vm_str.substr( 0, pos);
753  std::string vm = f_vm_str.substr( pos, f_vm_str.size());
754  fagent->register_new_attribute( f, vm, 'n', COM_DOUBLE, 3, "m/s");
755  // used internally
758  // avoid vs because vs is 'e'
763 }
764 
769 
776 
777  // set zero
778  double zero = 0.0;
781 
783  RFC_interpolate = COM_get_function_handle("RFC.interpolate");
784 }
785 
786 // INIT_INBUFF_FLUID
787 void MeshMotionTransferISS::run( double t, double dt, double alpha_dummy) {
788  MAN_DEBUG(3, ("Rocstar: calling MeshMotionTransferISS::run() with t:%e dt:%e.\n", t, dt));
789  // fomular: Vm = (un-un-1)/deltaT + (vsn - vsn-1) /2
790 
793 
795 
797 
799 
800  double half = 0.5;
802 
804 
805  // save copies
808 }
809 
810 // burn_agent.f90 INIT_INBUFF_BURN
811 // Transfer rhos from solid faces to fluid faces
813  const std::string s_rhos, const std::string f_rhos):
814  InterMeshTransfer(fag, sag, (char *)"TransferSolidDensity"),
815  s_rhos_str(s_rhos), f_rhos_str(f_rhos)
816 {
817  int io[] = {IN, OUT};
818  set_io( 2, io);
819 
820  std::string atts[2];
821  atts[0] = s_rhos;
822  atts[1] = f_rhos;
823  set_attr(2, atts);
824 
825  fagent->register_new_attribute(fagent->fluidBufNG, ".rhos", 'e', COM_DOUBLE, 1, "kg/(m^3)");
826 
827 /*
828  sagent->register_use_attribute( sagent->solidBuf, ".x", sagent->solidBufBase, ".nc");
829  sagent->register_clone_attribute( 0, sagent->solidBuf, ".nc", sagent->get_surface_window(), ".nc");
830 */
831 }
832 
833 void TransferSolidDensity::init( double t) {
834  MAN_DEBUG(3, ("Rocstar: TransferSolidDensity::init() with t:%e.\n", t));
837 
839 
840  RFC_transfer = COM_get_function_handle("RFC.least_squares_transfer");
841 }
842 
843 void TransferSolidDensity::run( double t, double dt, double alpha) {
844  int rhos_mode = sagent->rhos_mode;
845 
846  MAN_DEBUG(3, ("Rocstar: TransferSolidDensity::run() with rhs_mode=%d t:%e dt:%e alpha:%e.\n", rhos_mode, t, dt, alpha));
847 
848  if (rhos_mode == 1) // Constant density
850  else if (fagent->get_coupling()->initial_start())
852  else if (rhos_mode == 3) // Varying density
854 }
855 
856 
857 // solid_agent.f90 INIT_INBUFF_SOLID
858 // Transfer rb (burn rate) from fluid faces to solid faces
860  SolidAgent *sag,
861  const std::string b_rb, const std::string s_rb):
862  InterMeshTransfer(fag, sag, (char *)"TransferBurnRate_FS_ALE"),
863  b_rb_str(b_rb), s_rb_str(s_rb)
864 {
865  int io[] = {IN, OUT};
866  set_io( 2, io);
867 
868  std::string atts[2];
869  atts[0] = b_rb;
870  atts[1] = s_rb;
871  set_attr(2, atts);
872 }
873 
875  if (sagent->withALE == 0) return;
876 
879  int PROP_fom = fagent->get_coupling()->get_rocmancontrol_param()->PROP_fom;
880  if ( PROP_fom) {
882  }
883  else {
885  }
888 
890  RFC_transfer = COM_get_function_handle("RFC.least_squares_transfer");
891 }
892 
893 void TransferBurnRate_FS_ALE::run( double t, double dt, double alpha) {
894  if (sagent->withALE == 0) return;
895 
896  MAN_DEBUG(3, ("Rocstar: TransferBurnRate_FS_ALE::run() with t:%e dt:%e alpha:%e.\n", t, dt, alpha));
897 
898  // Transfer rb from fluid faces to solid faces
899  double zero = 0.0;
901 
902  // Here we use f_mdot_tmp as buffer space for holding f_rb
904 
906 
908 }
909 
910 // INIT_INBUFF_FLUID
911 // Depending on whether solid has ALE or not, we need to compute mdot
912 // differently. If solid has ALE, to ensure mass conservation, we compute
913 // mdot using a geometric construction on the solid side and transfer
914 // mdot to fluids. If solid has no ALE, mass conservation is not possible
915 // and the above approach will generate zero mdot, so we have to compute
916 // mdot as rhos*rb in this case.
918  BurnAgent *bag, const std::string f_mdot):
919  InterMeshTransfer(fag, sag, (char *)"MassTransfer_SF_ALE"),
920  bagent(bag)
921 {
922  int io[] = {OUT};
923  set_io( 1, io);
924 
925  std::string atts[1];
926  atts[0] = f_mdot;
927  set_attr(1, atts);
928 
929  fagent->register_new_attribute(fagent->ifluid_i, ".rhos", 'e', COM_DOUBLE, 1, "kg/(m^3)");
930  fagent->register_new_attribute(fagent->ifluid_i, ".mdot", 'e', COM_DOUBLE, 1, "kg/(m^2 s)");
932 }
933 
934 void MassTransfer_SF_ALE::init( double t) {
935  //f_mdot_hdl = COM_get_attribute_handle( fagent->fluidBufNG+".mdot");
937 
941 
942  // ALE
947 
949  RFC_transfer = COM_get_function_handle("RFC.least_squares_transfer");
950 }
951 
952 void MassTransfer_SF_ALE::run( double t, double dt, double alpha_dummy) {
953  MAN_DEBUG(3, ("[%d] Rocstar: MassTransfer_SF_ALE::run() with t:%e dt:%e.\n", fagent->get_comm_rank(), t, dt));
954 
955  if (sagent->withALE) {
958  }
959  else {
960  double zero = 0.0;
963  }
964 }
965 
966 
967 // trasnfer temperature from solid to fluid
968 // s_Ts in solid is 'n' f_Tf in fluid is 'e'
970  const std::string s_Ts,
971  const std::string fb_Tflm, const std::string fn_Tb):
972  InterMeshTransfer(fag, sag, (char *)"TemperatureTransfer_SF")
973 {
974  int io[] = {IN, OUT, OUT};
975  set_io( 3, io);
976 
977  std::string atts[3];
978  atts[0] = s_Ts;
979  atts[1] = fb_Tflm;
980  atts[2] = fn_Tb;
981  set_attr(3, atts);
982 
984 
985  // Tb is rocman internal buffer
986  std::string::size_type pos = fn_Tb.find( ".");
987  COM_assertion_msg(pos!=std::string::npos, "LoadTransfer_FS failed!");
988  std::string fn = fn_Tb.substr( 0, pos);
989  std::string Tb = fn_Tb.substr( pos, fn_Tb.size());
990  fagent->register_clone_attribute( 0, fn, Tb, fagent->get_surface_window(), ".Tb_alp", 0);
991  fagent->register_clone_attribute( 0, fn, Tb+"_old", fagent->get_surface_window(), ".Tb_alp", 0);
992 }
993 
998 
1000 
1002 
1004  RFC_transfer = COM_get_function_handle("RFC.least_squares_transfer");
1005  RFC_interpolate = COM_get_function_handle("RFC.interpolate");
1006 }
1007 
1008 void TemperatureTransfer_SF::run( double t, double dt, double alpha_dummy) {
1009  MAN_DEBUG(3, ("[%d] Rocstar: TemperatureTransfer_SF::run() with t:%e dt:%e.\n", fagent->get_comm_rank(), t, dt));
1010 
1011  //debug_print(sagent->solidBuf+".Ts", 102, 0);
1013 
1014  // extract burn and non-burn values
1017  //debug_print(fagent->fluidBufNG+".Tf", 2, 0);
1018 }
1019 
1020 
1021 // Transfer normal heat flux from fluid to solid
1022 // Arguments: qr_FF (IN), qc_FF (IN), qs_SF (OUT)
1023 // qev: is face centered ('e')
1025  BurnAgent *bag,
1026  const std::string f_qc, const std::string f_qr,
1027  const std::string b_qev, const std::string s_qs):
1028  InterMeshTransfer(fag, sag, (char *)"HeatTransfer_FS"), bagent(bag)
1029 {
1030  int io[] = {IN, IN, IN, OUT};
1031  set_io( 4, io);
1032 
1033  std::string atts[4];
1034  atts[0] = f_qc;
1035  atts[1] = f_qr;
1036  atts[2] = b_qev;
1037  atts[3] = s_qs;
1038  set_attr(4, atts);
1039 
1040  // temporary buffer for solid
1045 }
1046 
1047 void HeatTransfer_FS::init( double t) {
1049  int with_qr = COM_get_attribute_handle( attr[1]) > 0;
1050  if (with_qr)
1052  else
1053  f_qr_hdl = -1;
1056 
1059  f_qev_hdl = get_attribute_handle( fagent->fluidBufNG+".qev"); // burn
1060  s_qev_hdl = get_attribute_handle( sagent->solidBuf+".qev"); // burn
1061 
1062  // TODO: set qev_flag to signal rocburn
1063  /*
1064  COM_new_attribute( attr.c_str(),'w',COM_INT,1,"");
1065  */
1066  int one = 1;
1067  int qev_flag_hdl = get_attribute_handle( bagent->get_surface_window()+".qev_flag"); // burn
1068  //COM_call_function( RocBlas::copy_scalar, &one, &qev_flag_hdl);
1069  int *vm =NULL;
1070  int strid, cap;
1071  COM_get_array((bagent->get_surface_window()+".qev_flag").c_str(), 0, &vm, &strid, &cap);
1072  COM_assertion_msg(vm!=NULL, "Error: qev_flag!");
1073  *vm = 1;
1074 
1076  RFC_transfer = COM_get_function_handle("RFC.least_squares_transfer");
1077  RFC_interpolate = COM_get_function_handle("RFC.interpolate");
1078 
1079  MAN_DEBUG(3, ("[%d] Rocstar: HeatTransfer_FS::init() with t:%e with_qr=%d.\n", fagent->get_comm_rank(), t, with_qr));
1080 }
1081 
1082 // qc is 'e', qs is 'e'
1083 void HeatTransfer_FS::run( double t, double dt, double alpha_dummy) {
1084  MAN_DEBUG(3, ("[%d] Rocstar: HeatTransfer_FS::run() with t:%e dt:%e.\n", fagent->get_comm_rank(), t, dt));
1085 
1086  int size_ts = sagent->size_ts;
1087  int traction_mode = sagent->traction_mode;
1088 
1089  if (traction_mode == NO_SHEER && size_ts == 3) {
1090  COM_assertion_msg(0, "Not implemented!");
1091  }
1092  else if ( traction_mode == NO_SHEER && size_ts == 1) {
1093  //debug_print(fagent->get_surface_window()+".qc", 2, 0);
1094  //debug_print(fagent->get_surface_window()+".qr", 2, 0);
1095  if (f_qr_hdl != -1) {
1099  }
1100  else
1102  //debug_print(sagent->solidBuf+".qs", 101, 0, bagent->get_communicator(), "s_qs");
1103  // add qsource
1104  if (b_qev_hdl == -1) {
1105  std::cerr << "Rocstar WARNING: No qev is obtained! " << std::endl;
1106  // only on burn surface
1108  }
1109  else {
1110  //debug_print(bagent->iburn_ng+".qev", 102, 0, bagent->get_communicator(), "b_qev");
1111  // copy qev from burn to fluid, transfer to solid
1114  // only on burn surface
1116  }
1117  }
1118  else if (size_ts == 1) {
1119  COM_assertion_msg(0, "If traction mode is with sheer, then solid tractions must be vectors!");
1120  }
1121  else {
1125  }
1126 }
1127 
1128 // for remesh, reinitialize nc_t0
1129 // called only when -remeshed in init_scheduler
1131  const std::string s_u, const std::string f_total_disp,
1132  const std::string f_nc, const std::string f_nc_t0):
1133  InterMeshTransfer(fag, sag, (char *)"RemeshInit")
1134 {
1135  int io[] = {IN, IN, INOUT, OUT};
1136  set_io( 4, io);
1137 
1138  std::string atts[4];
1139  atts[0] = s_u;
1140  atts[1] = f_total_disp;
1141  atts[2] = f_nc;
1142  atts[3] = f_nc_t0;
1143  set_attr(4, atts);
1144 
1145  fagent->register_clone_attribute( 0, fagent->ifluid_i, ".total_disp", fagent->get_surface_window(), ".du_alp");
1147 }
1148 
1149 void RemeshInit::init( double t) {
1154 
1156  RFC_interpolate = COM_get_function_handle("RFC.interpolate");
1157 }
1158 
1159 void RemeshInit::run( double t, double dt, double alpha) {
1160  MAN_DEBUG(3, ("Rocstar: calling RemeshInit::run() with t:%e dt:%e alpha:%e.\n", t, dt, alpha));
1161 
1163 
1165 }
1166 
1167 
1168 
1169 
1170 
1171 
1172 
void run(double t, double dt, double alpha)
void run(double t, double dt, double alpha)
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 init(double t)
TransferSolidDensity(FluidAgent *fag, SolidAgent *sag, const std::string s_rhos, const std::string f_rhos)
TemperatureTransfer_SF(SolidAgent *sag, FluidAgent *ag, const std::string s_Tf, const std::string fb_Tflm_alp, const std::string fn_Tb)
std::string get_modinstance_name() const
Definition: Agent.h:222
SolidAgent * sagent
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_SELF
void COM_get_attribute(const std::string wa_str, char *loc, int *type, int *ncomp, std::string *unit)
Definition: roccom_c++.h:269
void load_rocface(const RocmanControl_parameters *param)
std::string fluidBufB
Definition: FluidAgent.h:80
#define COM_assertion_msg(EX, msg)
void run(double t, double dt, double alpha)
std::string f_ts_str
LoadTransfer_FSc_ALE(FluidAgent *fag, SolidAgent *sag, BurnAgent *bag, const std::string f_pf, const std::string fb_mdot, const std::string b_rb, const std::string s_ts, const std::string s_pf)
void run(double t, double dt, double alpha)
int withALE
Definition: SolidAgent.h:84
static int min_scalar_MPI
Definition: RocBlas.h:49
void COM_get_array(const char *wa_str, int pane_id, void **addr, int *strd, int *cap)
Get the address for an attribute on a specific pane.
FluidAgent * fagent
MeshMotionTransfer_SF(FluidAgent *fag, SolidAgent *sag, const std::string s_u, const std::string f_total_disp, const std::string f_vm)
int get_attribute_handle(int i)
Definition: Action.C:93
static int copy
Definition: RocBlas.h:34
static int div
Definition: RocBlas.h:39
int COM_get_attribute_handle(const char *waname)
Definition: roccom_c++.h:412
int get_attribute_handle_const(int i)
Definition: Action.C:110
std::string propBuf
Definition: SolidAgent.h:70
void run(double t, double dt, double alpha)
void register_clone_attribute(int cond, std::string target_window_, std::string attr_, std::string parent_window_, std::string parent_attr_, int wg_=1, const char *ptnname_=0, int val_=0)
Definition: Agent.C:328
static int copy_scalar
Definition: RocBlas.h:43
Definition: Action.h:32
GetDeformedMesh_ALE(FluidAgent *fag, SolidAgent *sag, const std::string s_x, const std::string uhat, const std::string s_y, double z)
std::string iburn_ng
Definition: BurnAgent.h:55
HeatTransfer_FS(FluidAgent *ag, SolidAgent *sag, BurnAgent *bag, const std::string f_qc, const std::string f_qr, const std::string fb_qev, const std::string s_qs)
void run(double t, double dt, double alpha)
void register_new_attribute(std::string target_window_, std::string attr_, char loc_, int type_, int ncomp_, const char *unit_)
Definition: Agent.C:322
std::string get_surface_window() const
Definition: Agent.h:217
std::string ifluid_i
Definition: FluidAgent.h:70
std::string solidBufBase
Definition: SolidAgent.h:67
MassTransfer_SF_ALE(FluidAgent *ag, SolidAgent *sag, BurnAgent *bag, const std::string f_mdot)
DeformationVelTransfer_SF(FluidAgent *fag, SolidAgent *sag, const std::string s_vs, const std::string f_vs)
static int add
Definition: RocBlas.h:35
void init(double t)
char ** attr
Definition: Action.h:37
void int int int REAL REAL REAL * z
Definition: write.cpp:76
Coupling * get_coupling()
Definition: Agent.h:213
std::string fluidBufNG
Definition: FluidAgent.h:78
static int mul_scalar
Definition: RocBlas.h:47
std::string solidBuf
Definition: SolidAgent.h:68
RemeshInit(FluidAgent *fag, SolidAgent *sag, const std::string s_u, const std::string f_total_disp, const std::string f_nc, const std::string f_nc_t0)
TransferBurnRate_FS_ALE(FluidAgent *fag, SolidAgent *sag, const std::string b_rb, const std::string s_rb)
LoadTransfer_FS(FluidAgent *fag, SolidAgent *sag, const std::string f_ts, const std::string s_ts, const std::string s_pf)
int size_ts
Definition: SolidAgent.h:86
void set_io(int n, const int *io)
Definition: Action.h:70
static int neg
Definition: RocBlas.h:40
void COM_set_profiling_barrier(int hdl, MPI_Comm comm)
Definition: roccom_c++.h:554
void run(double t, double dt, double alpha)
void _load_rocface(FluidAgent *fagent, SolidAgent *sagent, const RocmanControl_parameters *param)
static int sub_scalar
Definition: RocBlas.h:44
void run(double t, double dt, double alpha)
void run(double t, double dt, double alpha)
static int maxof_scalar
Definition: RocBlas.h:52
std::string propBufAll
Definition: SolidAgent.h:69
void COM_call_function(const int wf, int argc,...)
Definition: roccom_c.C:48
const int NO_SHEER
Definition: SolidAgent.h:31
void init(double t)
std::string iburn_all
Definition: BurnAgent.h:54
int COM_get_attribute_handle_const(const char *waname)
Definition: roccom_c++.h:420
int COM_get_window_handle(const char *wname)
Definition: roccom_c++.h:404
InterMeshTransfer(FluidAgent *fag, SolidAgent *sag, char *name=NULL)
void run(double t, double dt, double alpha)
void COM_copy_attribute(const char *wname, const char *attr, int wg=1, const char *ptnname=0, int val=0)
Copy an attribute onto another.
Definition: roccom_c++.h:244
#define MAN_DEBUG(l, x)
Definition: rocman.h:98
int get_comm_rank() const
Definition: Agent.h:224
double current_time
Definition: Coupling.h:54
void set_attr(int n, const std::string at[], int *id=NULL)
Definition: Action.C:66
static void load_rocsurf()
const RocmanControl_parameters * get_rocmancontrol_param()
Definition: Coupling.h:184
void run(double t, double dt, double alpha)
MeshMotionTransferISS(FluidAgent *fag, SolidAgent *sag, const std::string s_u, const std::string s_vs, const std::string f_vm)
void init(double t)
static int sub
Definition: RocBlas.h:36
void compute_overlay(FluidAgent *fagent, SolidAgent *sagent, double t)
Definition: Surfdiver.C:192
static int rank
Definition: advectest.C:66
std::string parentWin
Definition: BurnAgent.h:51
MPI_Comm get_communicator() const
Definition: Agent.h:220
void run(double t, double dt, double alpha)
void register_use_attribute(std::string target_window_, std::string attr_, std::string parent_window_, std::string parent_attr_, int wg_=1, const char *ptnname_=0, int val_=0)
Definition: Agent.C:334
BurnAgent * bagent
const Control_parameters * get_control_param()
Definition: Coupling.h:183
GetDeformedMesh(FluidAgent *fag, SolidAgent *sag, const std::string s_x, const std::string uhat, const std::string s_y)
static int mul
Definition: RocBlas.h:38
int initial_start() const
Definition: Coupling.h:163
#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
static int div_scalar
Definition: RocBlas.h:46
void run(double t, double dt, double alpha)
int traction_mode
Definition: SolidAgent.h:87
LoadTransferOnly_FSc_ALE(FluidAgent *fag, SolidAgent *sag, BurnAgent *bag, const std::string f_ts, const std::string s_ts, const std::string s_pf)
int rhos_mode
Definition: SolidAgent.h:85
void run(double t, double dt, double alpha)
#define COM_EXTERN_MODULE(moduleName)
Definition: roccom_basic.h:116