Rocstar  1.0
Rocstar multiphysics simulation application
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
basic_actions.C
Go to the documentation of this file.
1 /* *******************************************************************
2  * Rocstar Simulation Suite *
3  * *
4  * License: See LICENSE file in top level of distribution package or *
5  * http://opensource.org/licenses/NCSA *
6  *********************************************************************/
7 /* *******************************************************************
8  * Rocstar Simulation Suite *
9  * Copyright@2015, Illinois Rocstar LLC. All rights reserved. *
10  * *
11  * Illinois Rocstar LLC *
12  * Champaign, IL *
13  * www.illinoisrocstar.com *
14  * sales@illinoisrocstar.com *
15  *********************************************************************/
16 /* *******************************************************************
17  * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, *
18  * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES *
19  * OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND *
20  * NONINFRINGEMENT. IN NO EVENT SHALL THE CONTRIBUTORS OR *
21  * COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER *
22  * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, *
23  * ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE *
24  * USE OR OTHER DEALINGS WITH THE SOFTWARE. *
25  *********************************************************************/
26 // $Id: basic_actions.C,v 1.82 2009/09/14 14:18:27 mtcampbe Exp $
27 
28 #include "basic_actions.h"
29 #include "FluidAgent.h"
30 #include "SolidAgent.h"
31 #include "BurnAgent.h"
32 
33 COM_EXTERN_MODULE(Rocsurf);
35 COM_EXTERN_MODULE(Rocmap);
37 
38 SetValueDouble::SetValueDouble( const std::string at, const double val) :
39  Action( 1, &at, NULL, NULL, (char *)"SetValueDouble"), v(val)
40 {
41  // Define I/O of the arguments.
42  int io[] = {OUT};
43  set_io( 1, io);
44 }
45 
46 // Obtain the attribute handles
47 void SetValueDouble::init( double t) {
49 }
50 
51 void SetValueDouble::run( double t, double dt, double alpha) {
52  MAN_DEBUG(3, ("Rocstar: SetValueDouble::run() %s with %e.\n", attr[0], v));
54 }
55 
56 SetZero::SetZero(const std::string at) : SetValueDouble( at, 0)
57 { action_name = (char *)"SetZero"; }
58 
59 CopyValue::CopyValue( const std::string from, const std::string to, int *cond) :
60  Action( 0, (const char**)NULL, NULL, NULL, (char *)"CopyValue"), condition(cond)
61 {
62  // Define I/O of the arguments.
63  int io[] = {IN, OUT};
64  set_io( 2, io);
65 
66  std::string atts[2];
67  atts[0] = from;
68  atts[1] = to;
69  set_attr(2, atts);
70 }
71 
72 // Obtain the attribute handles
73 void CopyValue::init( double t) {
76 }
77 
78 void CopyValue::run( double t, double dt, double alpha) {
79  MAN_DEBUG(3, ("Rocstar: CopyValue::run() %s => %s.\n", attr[0], attr[1]));
80  if (!condition || *condition)
82 }
83 
84 DummyPrint::DummyPrint( BurnAgent *bag, SolidAgent *sag, FluidAgent *fag, const std::string l):
85  Action( 0, (const char**)NULL, NULL, NULL, (char *)"DummyPrint"),
86  bagent(bag), sagent(sag), fagent(fag), label(l)
87 {
88  set_io( 0, NULL);
89 
90  set_attr(0, (const char**)NULL);
91 }
92 
93 // Obtain the attribute handles
94 void DummyPrint::init( double t) {
95  MAN_DEBUG(3, ("Rocstar: DummyPrint::init() with %s.\n", label.c_str()));
96 }
97 
98 void DummyPrint::run( double t, double dt, double alpha) {
99  MAN_DEBUG(3, ("Rocstar: DummyPrint::run() with %s.\n", label.c_str()));
100 
101  //debug_print(sagent->solidBuf+".x", 202, 1, "DummyPrint");
102  //debug_print(bagent->iburn_ng+".Tflm_alp", 102, 0);
103  //debug_print(bagent->iburn_ng+".rb", 102, 0);
104  //debug_print(bagent->iburn_ng+".rb_alp", 102, 0);
105  //debug_print(bagent->iburn_ng+".pf_alp", 102, 0);
106  //debug_print(fagent->fluidBufB+".mdot", 2, 0);
107  //debug_print(fagent->fluidBufB+".mdot_old", 2, 0);
108  //debug_print(fagent->fluidBufB+".mdot_alp", 2, 0);
109  //debug_print(fagent->fluidBufNG+".mdot_alp", 2, 0);
110 }
111 
113  Action( 0, (const char**)NULL, NULL, NULL, (char *)"BCInvoker"),
114  agent(ag), level(l)
115 {
116  set_io( 0, NULL);
117  set_attr(0, (const char**)NULL);
118 }
119 
120 void BCInvoker::init( double t) {
121  // init bcactions
122  agent->init_bcactions(t);
123 }
124 
125 void BCInvoker::run( double t, double dt, double alpha) {
126  MAN_DEBUG(3, ("Rocstar: BCInvoker::run() agent: %s level: %d.\n", agent->get_agent_name().c_str(), level));
127 
128 //RAF pass alpha, not time!!
129 // agent->obtain_bc(&t, &level);
130  agent->obtain_bc(&alpha, &level);
131 
132  MAN_DEBUG(3, ("Rocstar: BCInvoker::run() agent: %s level: %d DONE.\n", agent->get_agent_name().c_str(), level));
133 }
134 
136  Action( 0, (const char**)NULL, NULL, NULL, (char *)"GMInvoker"),
137  agent(ag)
138 {
139  set_io( 0, NULL);
140  set_attr(0, (const char**)NULL);
141 }
142 
143 void GMInvoker::init( double t) {
144  // init bcactions
145  agent->init_gmactions(t);
146 }
147 
148 void GMInvoker::run( double t, double dt, double alpha) {
149  MAN_DEBUG(3, ("Rocstar: GMInvoker::run() agent: %s with alpha=%e.\n", agent->get_agent_name().c_str(), alpha));
150 
151  agent->obtain_gm(&alpha);
152 
153  MAN_DEBUG(3, ("Rocstar: GMInvoker::run() agent: %s with alpha=%e DONE.\n", agent->get_agent_name().c_str(), alpha));
154 }
155 
157  Action( 0, (const char**)NULL, NULL, NULL, (char *)"BCInitInvoker"),
158  agent(ag)
159 {
160  set_io( 0, NULL);
161  set_attr(0, (const char**)NULL);
162 }
163 
164 void BCInitInvoker::init( double t) {
165  MAN_DEBUG(3, ("Rocstar: BCInitInvoker::init() agent: %s .\n", agent->get_agent_name().c_str()));
166  // init bcactions
168  MAN_DEBUG(3, ("Rocstar: BCInitInvoker::init() agent: %s DONE.\n", agent->get_agent_name().c_str()));
169 }
170 
171 void BCInitInvoker::run( double t, double dt, double alpha) {
172  MAN_DEBUG(3, ("Rocstar: BCInitInvoker::run() agent: %s t:%e dt:%e alpha:%e.\n", agent->get_agent_name().c_str(), t, dt, alpha));
173 
174  agent->run_bcinitaction(t, dt);
175 
176  MAN_DEBUG(3, ("Rocstar: BCInitInvoker::run() agent: %s DONE.\n", agent->get_agent_name().c_str()));
177 }
178 
179 // POST_UPDATE_FLUID
180 // first part of LoadTransfer_FSc_ALE: output f_ts
182  const std::string f_pf, const std::string fb_mdot,
183  const std::string b_rb,
184  const std::string f_ts) :
185  Action(0, (const char**)NULL, NULL, NULL, (char *)"ComputeFluidLoad_ALE"),
186  fagent(fag), sagent(sag)
187 {
188  int io[] = {IN, IN, IN, OUT};
189  set_io( 4, io);
190 
191  std::string atts[4];
192  atts[0] = f_pf;
193  atts[1] = fb_mdot;
194  atts[2] = b_rb;
195  atts[3] = f_ts;
196  set_attr(4, atts);
197 
199 
200  // create_attribute
201  // for SolidAgent ??????????????????
202 // if (traction_mode == NO_SHEER && size_ts == 3) {
203  sagent->register_new_attribute( sagent->solidBufBase, ".pf", 'e', COM_DOUBLE, 1, "Pa");
204 // }
205 
206  // for FluidAgent
207  if (traction_mode == NO_SHEER) {
209  }
210  else
212 }
213 
214 // Create buffer data
216 {
217  if (traction_mode == NO_SHEER) {
220  }
221  else {
222  f_pf_hdl = -1;
223  fb_pf_hdl = -1;
224  }
228 
229  if (traction_mode != NO_SHEER) {
233  }
234  else {
235  f_tf_hdl = -1;
236  fb_tf_hdl = -1;
237  fb_nf_alp_hdl = -1;
238  }
242 
243  MAN_DEBUG(3, ("ComputeFluidLoad_ALE::init() called - traction_mode: %d .\n", traction_mode));
244 }
245 
246 void ComputeFluidLoad_ALE::run( double t, double dt, double alpha) {
247  MAN_DEBUG(3, ("Rocstar: ComputeFluidLoad_ALE::run() with t:%e dt:%e.\n", t, dt));
248  // ts = tf + ( mdot*Vs
249 
250  // part 1 (POST_UPDATE_FLUID in fluid_agent.f90)
251  if (traction_mode != NO_SHEER) {
253 
254  // Compute tfmts = t_s-t_f (see developers guide).
255  // Here fb_mdot_tmp is used as buffer space.
257 
258  if ( sagent->withALE) {
260  }
261 
264 
265  // Compute ts = tf - (tf-ts)
267  }
268  else { // ts is a scalar
269 
271 
272  // Compute tsmpf = p_f-t_s (see developers guide).
273  // Here fb_mdot_tmp is used as buffer space.
275 
276  if ( sagent->withALE) {
278  }
279 
281 
282  // Compute ts = pf - (pf-ts)
284 
285  // Subtract from P_ambient if not zeros
286  double P_ambient = fagent->get_coupling()->get_rocmancontrol_param()->P_ambient;
287  if ( P_ambient != 0.0) {
289  }
290  }
291 
292  // debug_print(fagent->fluidBufNG+".ts", 102, 0, "LOAD");
293 }
294 
295 // UPDATE_INBUFF_GM_FLUID in fluid_agent.f90
297  const std::string a_vm, const std::string f_du_alp, double z):
298  Action(0, (const char**)NULL, NULL, NULL, (char *)"ComputeMeshMotion"),
299  fagent(ag), zoom(z)
300 {
301  int io[] = {IN, OUT};
302  set_io( 2, io);
303 
304  std::string atts[2];
305  atts[0] = a_vm;
306  atts[1] = f_du_alp;
307  set_attr(2, atts);
308 
309  fagent->register_new_attribute( fagent->propBufAll, ".vm", 'n', COM_DOUBLE, 3, "m/s");
310 }
311 
312 void ComputeMeshMotion::init( double t) {
315 
316  // can not be set earlier because surface window was unkown
317  //f_du_alp_hdl = COM_get_attribute_handle(fagent->get_surface_window()+".du_alp");
318  f_zoom_hdl = COM_get_attribute_handle(fagent->fluidBufNG+".zoomFact"); // used internally
319 }
320 
321 // gm callback
322 void ComputeMeshMotion::run( double t_dummy, double dt, double alpha) {
323  MAN_DEBUG(3, ("Rocstar: ComputeMeshMotion::run() with dt:%e alpha:%e.\n", dt, alpha));
324 
325  COM_assertion_msg(alpha>=0.0, "ERROR: ComputeMeshMotion called with invalid alpha!");
326 
327 // debug_print(fagent->get_surface_window()+".du_alp", 102, 0);
328 
329  double time = alpha * dt;
331 
332 // debug_print(fagent->propBufAll+".vm", 202, 1);
333 // debug_print(fagent->get_surface_window()+".du_alp", 102, 0);
334 
335  if (f_zoom_hdl>0) {
337  }
338 }
339 
340 static inline void load_rocsurf()
341 {
342  if (COM_get_window_handle("SURF") <= 0)
343  COM_LOAD_MODULE_STATIC_DYNAMIC( Rocsurf, "SURF");
344 }
345 
346 static inline void load_rocon(const RocmanControl_parameters *param, MPI_Comm comm)
347 {
348 
349  if(param->PROPCON_enabled && (COM_get_window_handle("PROPCON") <= 0)){
350  // std::cout << "Rocstar: LOADING ROCON" << std::endl;
352  int PROPCON_init_hndl = COM_get_function_handle("PROPCON.init_from_file");
353  std::string rocon_config_file("Rocon/RoconControl.txt");
354  COM_call_function(PROPCON_init_hndl,rocon_config_file.c_str(),&(param->PROPCON_ndiv));
355  // std::cout << "Rocstar: LOADED ROCON" << std::endl;
356  }
357 }
358 
359 static inline void load_rocprop(const RocmanControl_parameters *param, MPI_Comm comm)
360 {
361  if (COM_get_window_handle("PROP") <= 0) {
362  MAN_DEBUG(3, ("Rocstar: Loading module RocProp...\n"));
364 
365  int PROP_set_option = COM_get_function_handle( "PROP.set_option");
366  if (param->PROP_fom)
367  COM_call_function( PROP_set_option, "method", "fo");
368  else
369  COM_call_function( PROP_set_option, "method", "mp");
370  char val[256];
371  sprintf(val, "%d", param->PROP_rediter);
372  COM_call_function( PROP_set_option, "rediter", val);
373  sprintf(val, "%f", param->PROP_fangle);
374  COM_call_function( PROP_set_option, "fangle", val);
375 
376  int PROP_initialize = COM_get_function_handle("PROP.initialize");
377  int PROP_propagate = COM_get_function_handle("PROP.propagate");
378  COM_set_profiling_barrier( PROP_initialize, comm);
379  COM_set_profiling_barrier( PROP_propagate, comm);
380  }
381 }
382 
383 static inline void load_rocmap()
384 {
385  if (COM_get_window_handle("MAP") <= 0) {
386  MAN_DEBUG(3, ("Rocstar: Loading module RocMap...\n"));
387  COM_LOAD_MODULE_STATIC_DYNAMIC( Rocmap, "MAP");
388  }
389 }
390 
391 ComputeFaceCenters::ComputeFaceCenters(BurnAgent *ag, const std::string b_nc, const std::string b_cnts,
392  const std::string b_nrml):
393  Action(0, (const char**)NULL, NULL, NULL, (char *)"ComputeFaceCenters"), agent(ag)
394 {
395  int io[] = {IN, OUT};
396  set_io( 2, io);
397 
398  std::string atts[3];
399  atts[0] = b_nc;
400  atts[1] = b_cnts;
401  atts[2] = b_nrml;
402  set_attr(3, atts);
403 }
404 
405 void ComputeFaceCenters::init( double t) {
406 /*
407  b_nc_hdl = get_attribute_handle(0);
408  if (COM_get_attribute_handle(agent->get_surface_window()+".centers") > 0)
409  b_cnts_hdl = get_attribute_handle(1);
410  else
411  b_cnts_hdl = -1;
412 
413  load_rocsurf();
414  SURF_n2f = COM_get_function_handle( "SURF.interpolate_to_centers");
415 */
416 }
417 
418 void ComputeFaceCenters::run( double t, double dt, double alpha_dummy) {
419 
420  // ???????????
421 /*
422  double a = 0.0;
423  int level = 1;
424  agent->obtain_bc(&a, &level);
425 */
426 
428  b_cnts_hdl = -1;
429  if (COM_get_attribute_handle(agent->get_surface_window()+".centers") > 0){
431  }
432  b_nrml_hdl = -1;
433  if(COM_get_attribute_handle(agent->get_surface_window()+".normals") > 0){
435  }
436 
437  // ?????????????
438 // double zero = 0.0;
439 // agent->obtain_bc(&zero);
440 
441  if (b_cnts_hdl >= 0 || b_nrml_hdl >= 0) {
442  load_rocsurf();
443  MAN_DEBUG(3, ("Rocstar: ComputeFaceCenters::run() with t:%e dt:%e b_cnts_hdl:%d b_nrml_hdl:%d.\n", t, dt, b_cnts_hdl, b_nrml_hdl));
444  if(b_cnts_hdl >= 0){
445  SURF_n2f = COM_get_function_handle( "SURF.interpolate_to_centers");
447  }
448  if(b_nrml_hdl >= 0){
449  SURF_fn = COM_get_function_handle( "SURF.compute_element_normals");
451  }
452  }
453 }
454 
455 // zoom > 0 effective
457  const std::string b_rb,
458  const std::string a_vm,
459  double z):
460  Action(0, (const char**)NULL, NULL, NULL, (char *)"FluidPropagateSurface"), fagent(fag), bagent(bag), zoom(z)
461 {
462  int io[] = {IN, OUT};
463  set_io( 2, io);
464 
465  std::string atts[2];
466  atts[0] = b_rb;
467  atts[1] = a_vm;
468  set_attr(2, atts);
469 
470  fagent->register_new_attribute( fagent->propBufAll, ".vm", 'n', COM_DOUBLE, 3, "m/s");
471 }
472 
476 
477  std::string propBuf = fagent->propBufAll;
478  int PROP_fom = fagent->get_coupling()->get_rocmancontrol_param()->PROP_fom;
479  if (!PROP_fom) propBuf = fagent->propBuf;
480  p_rb_hdl = COM_get_attribute_handle( propBuf+".rb");
481  p_pmesh_hdl = COM_get_attribute_handle( propBuf+".pmesh");
482  p_vm_hdl = COM_get_attribute_handle( propBuf+".vm");
483  p_bflag_hdl = COM_get_attribute_handle( propBuf+".bflag");
484  p_cnstr_type = COM_get_attribute_handle( propBuf+".cnstr_type");
485  p_cflag_hdl = COM_get_attribute_handle( propBuf+".cflag");
486  p_pos_hdl = COM_get_attribute_handle( propBuf+".positions");
488 
491  PROP_set_cnstr = COM_get_function_handle("PROP.set_constraints");
492  PROP_propagate = COM_get_function_handle("PROP.propagate");
493  if(COM_get_window_handle("PROPCON") >= 0) {
494  PROPCON_find_intersections = COM_get_function_handle("PROPCON.find_intersections");
495  PROPCON_constrain_displacements = COM_get_function_handle("PROPCON.constrain_displacements");
496  PROPCON_burnout = COM_get_function_handle("PROPCON.burnout");
497  PROPCON_burnout_filter = COM_get_function_handle("PROPCON.burnout_filter");
498  }
499  else {
502  PROPCON_burnout = -1;
503  }
504  load_rocmap();
505  MAP_reduce_maxabs = COM_get_function_handle("MAP.reduce_maxabs_on_shared_nodes");
506  MAP_reduce_minabs = COM_get_function_handle("MAP.reduce_minabs_on_shared_nodes");
507 }
508 
509 void FluidPropagateSurface::run( double t, double dt, double alpha_dummy)
510 {
511  if (zoom <= 0.0 || fagent->get_coupling()->initial_start() ) return;
512 
513  int rank = 0;
514  MPI_Comm mycomm = fagent->get_communicator();
515  MPI_Comm_rank(mycomm,&rank);
516  if(rank == 0)
517  MAN_DEBUG(2, ("Rocstar: FluidPropagateSurface::run() with t:%e dt:%e zoom:%f p_cnstr_type:%d.\n", t, dt, zoom, p_cnstr_type));
518 
519  double zero = 0.0;
521 
523 
524  // Burnout strategy:
525  //
526  // integer array (bflag) lives on interacting boundary
527  // faces. bflag indicates whether the boundary face
528  // is burning/reacting/injecting, etc. In the current
529  // implementation, bflag can be 1 or 0 for burning or
530  // not-burning.
531  //
532  // integer array (cflag) lives on boundary nodes.
533  // cflag indicates the status of one or more geometrical
534  // or other imposed constraints on the deformation or
535  // solution space of the domain.
536  // In the current implementation cflag = 1 for nodes
537  // which have been constrained from further motion by
538  // the physical boundary. This happens when the domain
539  // boundary and the physical boundary come in contact.
540  //
541  // Based on the value of bflag, certain models may
542  // need to be used to determine physical quantities
543  // on the boundary. In the current implementation,
544  // the burnrate solver (Rocburn) can determine whether
545  // the propellant material should ignite, and if so
546  // it sets bflag to 1 and sets a burning rate
547  // for each burning face based on (aP^n), where
548  // [P = fluid pressure], and the temperature of the
549  // reacting surface.
550  //
551  //
552  // This function sets bflag to 0 for every burned out
553  // face. Burned out faces are determined by faces
554  // in which every node has cflag=1
555  // BurnOut(cflag,bflag);
556  if(PROPCON_burnout >= 0){
557  // std::cout << "Rocstar> Burning out surface elements with Rocon."
558  // << std::endl;
559  double data2 = 20000*dt;
561  MPI_Barrier(mycomm);
567  // COM_call_function( MAP_reduce_maxabs,
568  }
569 
570  //
571  // This function sets the burning rate (rb) to 0.
572  // The propagation code (Rocprop) sees rb as the
573  // (speed function). If the speed function is 0
574  // then Rocprop will not propagate the face. This will
575  // help Rocprop and Rocon to work together in keeping
576  // the propagation constrained to the constraint surface.
577  // p_rb_hdl = burning_rate
578  if(PROPCON_burnout_filter >= 0)
580  //
581 
582  // Now original code to propagate the mesh:
583  if ( p_cnstr_type > 0)
585 
586  double data = dt * zoom;
587 
588  MPI_Barrier(mycomm);
589  if(!rank && man_verbose > 2)
590  std::cout << "Rocstar: Calling Rocprop" << std::endl;
591  // p_rb_hdl is the "speed function"
593  MPI_Barrier(mycomm);
594  if(!rank && man_verbose > 2)
595  std::cout << "Rocstar: Rocprop done." << std::endl;
596  // Rocon determines if the domain boundary and the physical boundary have
597  // contacted and sets cflag (p_cflag_hdl) if so, and also constrains the
598  // nodes to not breach the physical boundary.
600  MPI_Barrier(mycomm);
601  if(!rank && man_verbose > 2)
602  std::cout << "Rocstar: Finding constraint intersections." << std::endl;
603  // std::cout << "Constraining displacements with Rocon" << std::endl;
604  // COM_call_function(PROPCON_find_intersections,&p_pmesh_hdl,&p_vm_hdl,&p_pos_hdl,&p_cflag_hdl);
605  MPI_Barrier(mycomm);
606  if(!rank && man_verbose > 2)
607  std::cout << "Rocstar: Reducing intersections." << std::endl;
608  // COM_call_function( MAP_reduce_maxabs, &p_cflag_hdl);
609  // COM_call_function( MAP_reduce_minabs, &p_cflag_hdl);
610  MPI_Barrier(mycomm);
611  if(!rank && man_verbose > 2)
612  std::cout << "Rocstar: Constraining displacements." << std::endl;
613  // COM_call_function(PROPCON_constrain_displacements,&p_pmesh_hdl,&p_vm_hdl,&p_pos_hdl,&p_cflag_hdl);
614  MPI_Barrier(mycomm);
615  if(!rank && man_verbose > 2)
616  std::cout << "Rocstar: Displacements constrained." << std::endl;
617  }
618 
620 
622 
623  // Let's try this to help fix Rocflo symmetry plane motion
625  // COM_call_function(MAP_reduce_minabs,&a_vm_hdl);
626 
627  if ( ! param->PROP_fom) {
628  // Move shared nodes between burning and nonburning panes.
630  }
631 
632  //
633  // Other functions that go elsewhere that are associated
634  // with burnout that I can think of are:
635  //
636  // Sets mass flux to 0.0 on burned out faces
637  // BurnOutFilter(bflag,0.0,mass_flux);
638  // or BurnOutFilter(bflag,mass_flux_insulation,mass_flux);
639  //
640  // Sets Tflame to Tgas for a perfect insulator, or
641  // something else if maybe the insulation chars or
642  // something.
643  // BurnOutFilter(bflag,gas_temp,tflame);
644  // or maybe BurOutFilter(bflag,ins_flame_temp,tflame);
645  //
646  //
647 
648 //debug_print(fagent->propBufAll+".vm", 102, 0);
649 }
650 
651 
652 // If solid has no ALE, mass conservation is not possible
653 // and the above approach will generate zero mdot, so we have to compute
654 // mdot as rhos*rb in this case.
656  const std::string b_rhos, const std::string b_rb,
657  const std::string f_mdot):
658  Action(0, (const char**)NULL, NULL, NULL, (char *)"MassTransfer"),
659  fagent(fag), bagent(bag)
660 {
661  int io[] = {IN, IN, OUT};
662  set_io( 3, io);
663 
664  std::string atts[3];
665  atts[0] = b_rhos;
666  atts[1] = b_rb;
667  atts[2] = f_mdot;
668  set_attr(3, atts);
669 
671 }
672 
673 void MassTransfer::init( double t) {
677 
679 }
680 
681 void MassTransfer::run( double t, double dt, double alpha_dummy) {
682  MAN_DEBUG(3, ("Rocstar: MassTransfer::run() with t:%e dt:%e.\n", t, dt));
683 
684  double zero = 0.0;
686 
688 
689  // Sets mass flux to 0.0 on burned out faces
690  // BurnOutFilter(bflag,0.0,mass_flux);
691  // or BurnOutFilter(bflag,mass_flux_insulation,mass_flux);
692 
693 // debug_print(fagent->fluidBufB+".mdot", 102, 0);
694 // debug_print(bagent->iburn_ng+".rb", 102, 0);
695 }
696 
698  const std::string fb_mdot_alp,
699  double z):
700  Action(0, (const char**)NULL, NULL, NULL, (char *)"ZoomInterface"),
701  fagent(fag), bagent(bag), zoom(z)
702 {
703  int io[] = {INOUT};
704  set_io( 1, io);
705 
706  std::string atts[1];
707  atts[0] = fb_mdot_alp;
708  set_attr(1, atts);
709 }
710 
711 void ZoomInterface::init( double t) {
714  // b_rb_alp_hdl = COM_get_attribute_handle( bagent->iburn_ng+".rb_alp");
717 }
718 
719 void ZoomInterface::run( double t, double dt, double alpha_dummy) {
720 
721  if (zoom <= 1.0) return;
722 
723  MAN_DEBUG(3, ("Rocstar: ZoomInterface::run() with t:%e dt:%e zoom:%e.\n", t, dt, zoom));
724 
725  // double z = zoom - 1;
726 
727  // COM_call_function( RocBlas::mul_scalar, &b_rb_alp_hdl, &z, &b_rb_alp_hdl);
728 
729  // Rocman should just pass in the normal mdot
730  // COM_call_function( RocBlas::axpy, &b_rb_alp_hdl, &fb_rhof_alp_hdl, &fb_mdot_alp_hdl, &fb_mdot_alp_hdl); (zoom)
732  // Sets mass flux to 0.0 on burned out faces
733  // BurnOutFilter(bflag,0.0,mass_flux);
734  // or BurnOutFilter(bflag,mass_flux_insulation,mass_flux);
735 
736  // z = zoom / z;
737 
738  // COM_call_function( RocBlas::mul_scalar, &b_rb_alp_hdl, &z, &b_rb_alp_hdl);
739 }
740 
741 // UPDATE_INBUFF_BC_FLUID
742 // compute rhofvf
743 ComputeRhofvf::ComputeRhofvf(FluidAgent *fag, std::string f_vs_alp, std::string f_rhof_alp, std::string f_rhofvf_alp):
744  Action(0, (const char**)NULL, NULL, NULL, (char *)"ComputeRhofvf"),
745  fagent(fag)
746 {
747  int io[] = {IN, IN, OUT};
748  set_io( 3, io);
749 
750  std::string atts[3];
751  atts[0] = f_vs_alp;
752  atts[1] = f_rhof_alp;
753  atts[2] = f_rhofvf_alp;
754  set_attr(3, atts);
755 }
756 
757 void ComputeRhofvf::init( double t) {
761 }
762 
763 void ComputeRhofvf::run( double t, double dt, double alpha_dummy) {
764 
765  MAN_DEBUG(3, ("Rocstar: ComputeRhofvf::run() with t:%e dt:%e.\n", t, dt));
766 
768 }
769 
770 // UPDATE_INBUFF_BC_FLUID fluid_agent.f90
771 // used in zomm>=1 and standalone
773  SolidAgent *sag,
774  const std::string fb_mdot_alp, const std::string rhofvf_alp,
775  double z):
776  Action(0, (const char**)NULL, NULL, NULL, (char *)"ComputeBurnPane"),
777  fagent(fag), bagent(bag), sagent(sag), zoom(z)
778 {
779  int io[] = {IN, OUT};
780  set_io( 2, io);
781 
782  std::string atts[2];
783  atts[0] = fb_mdot_alp;
784  atts[1] = rhofvf_alp;
785  set_attr(2, atts);
786 }
787 
788 void ComputeBurnPane::init( double t) {
791 
796 }
797 
798 void ComputeBurnPane::run( double t, double dt, double alpha_dummy) {
799  MAN_DEBUG(3, ("Rocstar: ComputeBurnPane::run() with t:%e dt:%e zoom:%f.\n", t, dt, zoom));
800 
801  // The rest of computation are on burning panes only
802  // Note that b_rb_alp is used here as a temporary variable.
803  // b_rb_alp is not used elsewhere.
804  if (zoom>=1.0 && sagent==NULL || sagent && sagent->withALE) {
806  // debug_print(fagent->fluidBufB+".mdot_alp", 102, 0);
807  // debug_print(fagent->fluidBufNG+".mdot_alp", 102, 0);
809  }
810  else {
812  }
813 
814  // debug_print(bagent->iburn_ng+".rb_alp", 102, 0);
815  // debug_print(fagent->fluidBufB+".rhofvf_alp", 102, 0);
816 
818 
819  //debug_print(fagent->fluidBufB+".rhofvf_alp", 102, 0);
820  //debug_print(fagent->fluidBufB+".mdot_alp", 102, 0);
821  //debug_print(fagent->fluidBufB+".rhof_alp", 102, 0);
822  //debug_print(fagent->fluidBufB+".nf_alp", 102, 0);
823  //debug_print(bagent->iburn_ng+".rb_alp", 102, 0);
824 }
825 
826 // INIT_INBUFF_BURN in burn_agent.f90
828  Action(0, (const char**)NULL, NULL, NULL, (char *)"CopyBurnFromParentMesh"),
829  bagent(bag), fagent(fag)
830 {
831  set_io( 0, (int *)NULL);
832 
833  set_attr(0, (const char**)NULL);
834 }
835 
837  burn_mesh = bagent->get_surface_window()+".mesh";
838  parent_mesh = bagent->parentWin+".mesh";
839  MAN_DEBUG(3, ("Rocstar: CopyBurnFromParentMesh::init() with t:%e %s %s.\n", t, burn_mesh.c_str(), parent_mesh.c_str()));
840 }
841 
842 void CopyBurnFromParentMesh::run( double t, double dt, double alpha_dummy) {
843  MAN_DEBUG(3, ("Rocstar: CopyBurnFromParentMesh::run() with t:%e dt:%e %s %s.\n", t, dt, burn_mesh.c_str(), parent_mesh.c_str()));
844  COM_copy_attribute( burn_mesh.c_str(), parent_mesh.c_str());
845 
846 /*
847  // ????????
848  double v = 0.0;
849  int f_du_alp_hdl = COM_get_attribute_handle(fagent->get_surface_window()+".du_alp");
850  COM_call_function( RocBlas::copy_scalar, &v, &f_du_alp_hdl);
851 */
852 }
853 
855  Action(0, (const char**)NULL, NULL, NULL, (char *)"CopyBflagFromBurn"),
856  bagent(bag)
857 {
858  set_io( 0, (int *)NULL);
859 
860  set_attr(0, (const char**)NULL);
861 }
862 
863 void CopyBflagFromBurn::init( double t) {
864  burn_bflag = bagent->get_surface_window()+".bflag";
865  parent_bflag = bagent->parentWin+".bflag";
866 }
867 
868 void CopyBflagFromBurn::run( double t, double dt, double alpha_dummy) {
869  MAN_DEBUG(3, ("Rocstar: CopyBflagFromBurn::run() with t:%e dt:%e.\n", t, dt));
870 
871 
872  if (!bagent->get_coupling()->initial_start() &&
874  COM_copy_attribute( parent_bflag.c_str(), burn_bflag.c_str());
875  }
876 
877 }
878 
879 // POST_INIT_FLUID
880 ComputePconn::ComputePconn(Agent *ag, std::string a_mesh, std::string a_pconn, std::string p_pmesh, int *cond):
881  Action(0, (const char**)NULL, NULL, NULL, (char *)"ComputePconn"),
882  agent(ag), a_mesh_str(a_mesh), a_pconn_str(a_pconn), p_pmesh_str(p_pmesh), cond_addr(cond)
883 {
884  int io[3] = {OUT, OUT, OUT};
885  set_io( 3, io);
886 
887  std::string atts[3];
888  atts[0] = a_mesh_str;
889  atts[1] = a_pconn_str;
890  atts[2] = p_pmesh_str;
891  set_attr(3, atts);
892 }
893 
894 void ComputePconn::init(double t)
895 {
896  if (cond_addr && *cond_addr == 0) return;
897 
901 
902  load_rocmap();
903  MAP_compute_pconn = COM_get_function_handle("MAP.compute_pconn");
904 
906  PROP_initialize = COM_get_function_handle("PROP.initialize");
907 }
908 
909 void ComputePconn::run( double t, double dt, double alpha_dummy) {
910 
911  if (cond_addr && *cond_addr == 0) return;
912 
913  MAN_DEBUG(3, ("Rocstar: (%s) ComputePconn::run() with t:%e dt:%e.\n", agent->get_agent_name().c_str(), t, dt));
914 
915  // Compute pconn for the whole surface, which will also be used
916  // by surface propagation.
918 
920 
921  // ??????????
922 /*
923  double v = 0.0;
924  int f_du_alp_hdl = COM_get_attribute_handle(fagent->get_surface_window()+".du_alp");
925  COM_call_function( RocBlas::copy_scalar, &v, &f_du_alp_hdl);
926 
927  double a = 0.0;
928  int level = 1;
929  fagent->obtain_bc(&a, &level);
930  level = 2;
931  fagent->obtain_bc(&a, &level);
932 */
933  // ??????????????
934 }
935 
936 // zoom > 0 effective
938  const std::string p_rb, const std::string a_vbar, double z):
939  Action(0, (const char**)NULL, NULL, NULL, (char *)"SolidPropagateSurface"),
940  sagent(fag), zoom(z)
941 {
942  int io[] = {IN, OUT};
943  set_io( 2, io);
944 
945  std::string atts[2];
946  atts[0] = p_rb;
947  atts[1] = a_vbar;
948  set_attr(2, atts);
949 
950 /*
951  fagent->register_new_attribute( fagent->propBufAll, ".vm", 'n', COM_DOUBLE, 3, "m/s");
952  fagent->register_new_attribute( fagent->propBufAll, ".rb", 'e', COM_DOUBLE, 1, "m/s");
953 */
954 }
955 
957 
958  if (sagent->withALE == 0) return;
959 
962 
963  std::string propBuf = sagent->propBufAll;
964  int PROP_fom = sagent->get_coupling()->get_rocmancontrol_param()->PROP_fom;
965  if (!PROP_fom) propBuf = sagent->propBuf;
966  p_vbar_hdl = COM_get_attribute_handle( propBuf+".vbar");
967  p_pmesh_hdl = COM_get_attribute_handle( propBuf+".pmesh");
968  p_vm_hdl = COM_get_attribute_handle( propBuf+".vm");
969  p_cnstr_hdl = COM_get_attribute_handle( propBuf+".cflag");
970  p_pos_hdl = COM_get_attribute_handle( propBuf+".positions");
971  //p_cnstr_type = COM_get_attribute_handle( propBuf+".cnstr_type");
972 
975  PROP_propagate = COM_get_function_handle("PROP.propagate");
976  if(COM_get_window_handle("PROPCON") >= 0){
977  PROPCON_find_intersections = COM_get_function_handle("PROPCON.find_intersections");
978  PROPCON_constrain_displacements = COM_get_function_handle("PROPCON.constrain_displacements");
979  }
980  else {
983  }
984  load_rocmap();
985  MAP_reduce_maxabs = COM_get_function_handle("MAP.reduce_maxabs_on_shared_nodes");
986 }
987 
988 void SolidPropagateSurface_ALE::run( double t, double dt, double alpha_dummy)
989 {
990  if (sagent->withALE == 0) return;
991 
992  int rank = 0;
993  MPI_Comm mycomm = sagent->get_communicator();
994  MPI_Comm_rank(mycomm,&rank);
995  if(!rank && man_verbose > 1)
996  std::cout << "Rocstar: SolidPropagateSurface_ALE::run() with t:"<< t
997  << "dt:" << dt << " zoom:" << zoom << std::endl;
998 
999  if ( !sagent->get_coupling()->initial_start() && zoom>0)
1000  {
1001  COM_call_function( RocBlas::neg, &p_rb_hdl, &p_rb_hdl); // Flip the sign of burn rate
1002  double dtz = dt*zoom;
1003 
1005 
1006  if(!rank && man_verbose > 2)
1007  std::cout << "Rocstar: Rocprop done" << std::endl;
1008 
1010 
1011  // Update shared nodes for the whole surface
1013  }
1014  else {
1015  double dtz = 0;
1017  }
1018 }
1019 
1021  Action( 0, (const char**)NULL, NULL, NULL, (char *)"Reset_du_alp"), fagent(fag)
1022 {
1023  // Define I/O of the arguments.
1024  set_io( 0, NULL);
1025  set_attr(0, (const char**)NULL);
1026 }
1027 
1028 // Obtain the attribute handles
1029 void Reset_du_alp::init( double t) {
1031 }
1032 
1033 void Reset_du_alp::run( double t, double dt, double alpha) {
1034  MAN_DEBUG(3, ("Rocstar: Reset_du_alp::run().\n"));
1035  double zero = 0.0;
1037 }
1038 
1039 
1040 
1041 
1042 
1043 
SolidAgent * sagent
DummyPrint(BurnAgent *bag, SolidAgent *sag, FluidAgent *fag, const std::string l)
Definition: basic_actions.C:84
void run(double t, double dt, double alpha)
void run(double t, double dt, double alpha)
void init(double t)
void init(double t)
SolidPropagateSurface_ALE(SolidAgent *ag, const std::string p_rb, const std::string a_vbar, double z)
Reset_du_alp(FluidAgent *fag)
ComputeFaceCenters(BurnAgent *ag, const std::string b_nc, const std::string b_cnts, const std::string b_nrml="")
std::string a_pconn_str
void run_bcinitaction(double t, double dt)
Definition: Agent.C:562
void init(double t)
BurnAgent * bagent
BCInvoker(Agent *ag, int l=1)
void init(double t)
Definition: basic_actions.C:47
void run(double t, double dt, double alpha)
Agent * agent
Definition: basic_actions.h:94
void init(double t)
BurnAgent * bagent
void run(double t, double dt, double alpha)
double init_time
Definition: Coupling.h:53
std::string fluidBufB
Definition: FluidAgent.h:80
void run(double t, double dt, double alpha)
#define COM_assertion_msg(EX, msg)
std::string get_agent_name() const
Definition: Agent.h:223
FluidAgent * fagent
static void load_rocprop(const RocmanControl_parameters *param, MPI_Comm comm)
void run(double t, double dt, double alpha)
Definition: basic_actions.C:78
void run(double t, double dt, double alpha)
Definition: basic_actions.C:51
int withALE
Definition: SolidAgent.h:84
int * condition
Definition: basic_actions.h:63
int get_attribute_handle(int i)
Definition: Action.C:93
static int axpy
Definition: RocBlas.h:41
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
void run(double t, double dt, double alpha)
void init(double t)
std::string propBufAll
Definition: FluidAgent.h:77
int get_attribute_handle_const(int i)
Definition: Action.C:110
std::string propBuf
Definition: SolidAgent.h:70
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
void init(double t)
Definition: Action.h:32
void run(double t, double dt, double alpha)
static void load_rocsurf()
std::string iburn_ng
Definition: BurnAgent.h:55
*********************************************************************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
void init(double t)
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 a_mesh_str
BurnAgent * bagent
char * action_name
Definition: Action.h:36
int man_verbose
std::string ifluid_i
Definition: FluidAgent.h:70
BCInitInvoker(Agent *ag)
void run(double t, double dt, double alpha)
std::string solidBufBase
Definition: SolidAgent.h:67
std::string propBuf
Definition: FluidAgent.h:79
static void load_rocmap()
FluidAgent * fagent
void obtain_bc(double *a, int *l=NULL)
Definition: Agent.C:524
Definition: Agent.h:110
ComputePconn(Agent *ag, std::string a_mesh, std::string a_pconn, std::string p_pmesh, int *cond=NULL)
ComputeBurnPane(FluidAgent *ag, BurnAgent *bag, SolidAgent *sag, const std::string fb_mdot_alp, const std::string rhofvf_alp, double z)
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
BurnAgent * bagent
static int mul_scalar
Definition: RocBlas.h:47
void init(double t)
Definition: basic_actions.C:73
ComputeRhofvf(FluidAgent *ag, std::string f_vs_alp, std::string f_rhof_alp, std::string f_rhofvf_alp)
void set_io(int n, const int *io)
Definition: Action.h:70
void run(double t, double dt, double alpha)
static int neg
Definition: RocBlas.h:40
GMInvoker(Agent *ag)
void COM_set_profiling_barrier(int hdl, MPI_Comm comm)
Definition: roccom_c++.h:554
void run(double t, double dt, double alpha)
Definition: basic_actions.C:98
static int sub_scalar
Definition: RocBlas.h:44
std::string p_pmesh_str
SetZero(const std::string at)
Definition: basic_actions.C:56
CopyValue(const std::string from, const std::string to, int *cond=NULL)
Definition: basic_actions.C:59
std::string propBufAll
Definition: SolidAgent.h:69
void init(double t)
void COM_call_function(const int wf, int argc,...)
Definition: roccom_c.C:48
ComputeMeshMotion(FluidAgent *ag, const std::string a_vm, const std::string f_du_alp, double z)
const int NO_SHEER
Definition: SolidAgent.h:31
void init(double t)
void init(double t)
std::string iburn_all
Definition: BurnAgent.h:54
void init(double t)
void run(double t, double dt, double alpha)
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
FluidAgent * fagent
void run(double t, double dt, double alpha)
FluidAgent * fagent
void init(double t)
ComputeFluidLoad_ALE(FluidAgent *fag, SolidAgent *sag, const std::string f_pf, const std::string fb_mdot, const std::string b_rb, const std::string f_ts)
std::string parent_bflag
void run(double t, double dt, double alpha)
void obtain_gm(double *da)
Definition: Agent.C:543
unsigned long time()
Get the value of a system timer with a millisecond precision.
Definition: CImg.h:4605
void run(double t, double dt, double alpha)
Agent * agent
Definition: basic_actions.h:84
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
bool ignmodel
Definition: BurnAgent.h:68
void set_attr(int n, const std::string at[], int *id=NULL)
Definition: Action.C:66
const RocmanControl_parameters * get_rocmancontrol_param()
Definition: Coupling.h:184
MassTransfer(FluidAgent *ag, BurnAgent *bag, const std::string b_rhos, const std::string b_rb, const std::string f_mdot)
FluidAgent * fagent
ZoomInterface(FluidAgent *ag, BurnAgent *bag, const std::string fb_mdot_alp, double z)
FluidPropagateSurface(FluidAgent *ag, BurnAgent *bag, const std::string b_rb, const std::string a_vm, double z)
void init(double t)
Definition: basic_actions.C:94
Definition: Rocon.H:61
void init(double t)
void run(double t, double dt, double alpha)
static int sub
Definition: RocBlas.h:36
static int rank
Definition: advectest.C:66
std::string parentWin
Definition: BurnAgent.h:51
MPI_Comm get_communicator() const
Definition: Agent.h:220
void init_bcinitaction(double t)
Definition: Agent.C:557
void run(double t, double dt, double alpha)
CopyBurnFromParentMesh(BurnAgent *bag, FluidAgent *fag)
CopyBflagFromBurn(BurnAgent *bag)
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
const Control_parameters * get_control_param()
Definition: Coupling.h:183
void run(double t, double dt, double alpha)
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
std::string burn_bflag
SetValueDouble(const std::string at, const double val)
Definition: basic_actions.C:38
int COM_get_function_handle(const char *wfname)
Definition: roccom_c++.h:428
void init_bcactions(double t)
Definition: Agent.C:445
static int div_scalar
Definition: RocBlas.h:46
std::string label
Definition: basic_actions.h:75
void init_gmactions(double t)
Definition: Agent.C:451
static void load_rocon(const RocmanControl_parameters *param, MPI_Comm comm)
void init(double t)
#define COM_EXTERN_MODULE(moduleName)
Definition: roccom_basic.h:116