104 loc(loc_), type(type_), ncomp(ncomp_), unit(unit_)
118 std::cerr <<
"Rocstar Error: NewAttribute::create(): Could not create " << bufname+
attr <<
" in two different ways " << std::endl;
124 MAN_DEBUG(3, (
"NewAttribute::create: %s%s.\n", bufname.c_str(),
attr.c_str()));
130 std::string target_window_, std::string attr_,
131 std::string parent_window_, std::string parent_attr_,
132 int wg_,
const char *ptnname_,
int val_):
134 parent_window(parent_window_), parent_attr(parent_attr_),
135 wg(wg_), val(val_), condition(cond)
137 ptnname = ptnname_?strdup(ptnname_):NULL;
149 std::string unit1, unit2;
152 if (loc1 != loc2 || type1 != type2 || ncomp1 != ncomp2 || unit1 != unit2) {
153 std::cerr <<
"Rocstar Error: CloneAttribute::create(): Could not create " <<
target_window+
attr <<
" in two different ways " << std::endl;
171 UseAttribute::UseAttribute(
Agent *ag, std::string target_window_, std::string attr_, std::string parent_window_, std::string parent_attr_,
int wg_,
const char *ptnname_,
int val_):
173 parent_window(parent_window_), parent_attr(parent_attr_),
174 wg(wg_), ptnname(ptnname_), val(val_)
187 std::string unit1, unit2;
190 if (loc1 != loc2 || type1 != type2 || ncomp1 != ncomp2 || unit1 != unit2) {
191 std::cerr <<
"Rocstar Error: NewAttribute::create(): Could not create " <<
target_window+
attr <<
" in two different ways " << std::endl;
202 const char *agentname, MPI_Comm com,
bool wgm,
bool skipio)
203 : agent_name(agentname), communicator(com), coupling(cp), action(this),
204 withgm(wgm), rocmod_name( mod), mod_instance(obj), skipInputIO(skipio)
212 inDir = obj; inDir.append(
"/Rocin/");
217 std::string physicsname = agentname;
218 physicsname = physicsname+
"-PhysicsAction";
238 sprintf(fname,
"%s%s",
mod_instance.c_str(),
".initialize");
242 sprintf(fname,
"%s%s",
mod_instance.c_str(),
".update_solution");
246 sprintf(fname,
"%s%s",
mod_instance.c_str(),
".finalize");
251 sprintf(fname,
"%s%s",
mod_instance.c_str(),
".pre_hdf_output");
255 sprintf(fname,
"%s%s",
mod_instance.c_str(),
".post_hdf_output");
261 if (pre_hdf_handle != -1)
263 if (post_hdf_handle != -1)
266 sprintf(fname,
"%s%s",
mod_instance.c_str(),
".compute_integrals");
286 sprintf(global,
"%s%s", window_name,
".global");
294 char window_func[128];
296 sprintf(window_func,
"%s.init_callback", window_name);
301 global,
"biiI", types);
306 sprintf(window_func,
"%s.obtain_bc", window_name);
310 sprintf(window_func,
"%s.obtain_gm", window_name);
328 void Agent::register_clone_attribute(
int cond, std::string target_window_, std::string attr_, std::string parent_window_, std::string parent_attr_,
int wg_,
const char *ptnname_,
int val_)
334 void Agent::register_use_attribute(std::string target_window_, std::string attr_, std::string parent_window_, std::string parent_attr_,
int wg_,
const char *ptnname_,
int val_)
336 UseAttribute *newAttr =
new UseAttribute(
this, target_window_, attr_, parent_window_, parent_attr_, wg_, ptnname_, val_);
343 for (
unsigned int i=0;
i<
n;
i++) {
353 for (
unsigned int i=0;
i<
n;
i++) {
376 for (
unsigned int i=0;
i<
n;
i++) {
401 sprintf(str,
"%s%d",
"bcSched", l);
485 MAN_DEBUG(3, (
"Rocstar: %s::init_callback called: surfwin: %s volwin: %s.\n",
get_agent_name().c_str(), surf_win, vol_win));
497 std::cerr <<
"Rocstar: Warning: No actions defined for "
498 <<
"Initialization callback for module "
509 MAN_DEBUG(3, (
"Rocstar: Agent::init_callback called: surfwin: %s volwin: %s DONE.\n", surf_win, vol_win));
527 std::cerr <<
"Rocstar: Warning: No actions defined for "
528 <<
"level-" << *l <<
" boundary condition "
533 int level = (l==NULL)?1:*l;
546 std::cerr <<
"Rocstar: Warning: No actions defined for "
551 MAN_DEBUG(3, (
"[%d] Rocstar: Agent::obtain_gm called with alpha: %e.\n",
comm_rank, *da))
581 std::sprintf( chrstring,
"%.5e", t*1.e10);
583 s =
""; s.append( &chrstring[9]); s.append(
".");
584 s.append( &chrstring[0], 1); s.append( &chrstring[2], 5);
593 std::string fname =
inDir; fname.append( base); fname.append(
"_in_");
596 fname.append( timeLevel); fname.append(
".txt");
601 FILE *fp =
fopen( fname.c_str(),
"r");
602 ctrl_exist = (fp!=NULL);
603 if ( !ctrl_exist && t!=0.0 ) {
604 fname =
outDir + base +
"_in_" + timeLevel +
".txt";
605 fp =
fopen( fname.c_str(),
"r");
606 ctrl_exist = (fp!=NULL);
612 std::cout <<
"Rocstar: Found control file " << fname << std::endl;
620 std::cout <<
"Rocstar: Did not find control file " << fname << std::endl;
635 std::string fname =
outDir;
644 fname.append( base); fname.append(
"_");
647 fname.append( timeLevel); fname.append(
"_");
672 fname.append( timeLevel); fname.append(
"_");
674 std::string ctrl_fname =
outDir; ctrl_fname.append( base);
676 std::string::size_type pos = ctrl_fname.find(
'*');
677 if ( pos != std::string::npos) ctrl_fname.erase( pos);
678 ctrl_fname.append(
"_in_"); ctrl_fname.append( timeLevel);
679 ctrl_fname.append(
".txt");
681 MAN_DEBUG(3, (
"[%d] Rocstar: Agent %s::write_control_file %s with file prefix %s at t:%e.\n",
comm_rank,
get_agent_name().c_str(), ctrl_fname.c_str(), fname.c_str(), t));
691 const std::string surf_i,
692 const std::string surf_nb,
693 const std::string surf_b,
694 const std::string surf_ni) {
695 std::string bcflag = surfAll+
".bcflag";
696 std::string atts = surfAll+
".all";
745 double nrm_val=0.0, nrm_diff=0.0, ratio;
752 ratio = nrm_diff/nrm_val;
755 int result = (ratio <= tol);
758 std::cout <<
" Convergence ratio of " << str <<
" is " << ratio << std::endl;
767 fprintf(f,
"graph: { title: \"%s\" label: \"%s\" \n\
769 display_edge_labels: yes \n\
770 layoutalgorithm: tree \n\
771 scaling: maxspect \n\
772 color : lightyellow \n\
773 node.color : lightblue \n\
774 node.textcolor : lightblue \n\
775 node.bordercolor: black \n\
776 node.borderwidth: 1 \n\
777 edge.color : lightblue \n\
778 edge.arrowsize : 7 \n\
779 edge.thickness : 2 \n\
780 edge.fontname:\"helvO08\" \n\
787 fprintf(f,
"graph: { title: \"%s\" label: \"%s\" \n\
789 display_edge_labels: yes \n\
790 layoutalgorithm: tree \n\
791 scaling: maxspect \n\
793 node.color : lightblue \n\
794 node.textcolor : black \n\
795 node.bordercolor: black \n\
796 node.borderwidth: 1 \n\
797 edge.color : lightblue \n\
798 edge.arrowsize : 7 \n\
799 edge.thickness : 2 \n\
800 edge.fontname:\"helvO08\" \n\
801 node.label: \"no type\" \n", main_action.c_str(), main_action.c_str());
809 fprintf(f,
"node: { title:\"%s\" label:\"%s\"}\n", main_physics.c_str(), main_physics.c_str());
814 fprintf(f,
"edge: { sourcename: \"%s\" targetname: \"%s\" label: \"\"}\n", bcinit, main_action.c_str());
int COMMPI_Comm_rank(MPI_Comm c)
int COM_Type
Indices for derived data types.
std::string target_window
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 run_bcinitaction(double t, double dt)
virtual void init_module(double t, double dt)
void write_data_files(double t, const std::string base, const std::string attr, const char *ref=NULL)
std::string parent_window
void create(std::string bufname)
const char * option(const char *const name, const int argc, const char *const *const argv, const char *defaut, const char *const usage=0)
void set_name(const char *name)
Scheduler * get_bcScheduler(unsigned int level)
T mod(const T &x, const T &m)
Return the modulo of a number.
void COM_get_attribute(const std::string wa_str, char *loc, int *type, int *ncomp, std::string *unit)
double max_timestep(double t, double dt)
#define COM_assertion_msg(EX, msg)
std::string get_agent_name() const
void create(std::string bufname)
InterpolateList interpolateList
virtual void assign(std::string bufname)
virtual void add_action(Action *)
void COM_set_object(const char *wa_str, int pane_id, Type *addr)
int COM_get_attribute_handle(const char *waname)
static int nrm2_scalar_MPI
void set_alpha(double alpha)
virtual void print(FILE *f)
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)
void add_bcaction(Action *act, int l=1)
void add_bcinitaction(Action *act)
void register_new_attribute(std::string target_window_, std::string attr_, char loc_, int type_, int ncomp_, const char *unit_)
std::string get_surface_window() const
void callMethod(Scheduler_voidfn1_t fn, double t)
int compute_integrals_handle
void get_time_string(double t, std::string &s)
void print(const char *fname)
const std::string agent_name
void obtain_bc(double *a, int *l=NULL)
void add_gmaction(Action *act)
CloneAttribute(Agent *ag, 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)
void create_window(const char *window_name)
void COM_use_attribute(const char *wname, const char *attr, int wg=1, const char *ptnname=0, int val=0)
Use the subset of panes of another window of which the given pane attribute has value val...
Coupling * get_coupling()
int read_by_control_file(double t, const std::string base, const std::string window)
void init_subscheduler(double t)
void split_surface_window(const std::string surfAll, const std::string surf_i, const std::string surf_nb, const std::string surf_b, const std::string surf_ni)
virtual void create_buffer_all()
static int write_ctrl_handle
UserScheduler gmScheduler
UseAttribute(Agent *ag, 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)
int check_convergence_help(int vcur, int vpre, double tol, std::string str)
void COM_set_profiling_barrier(int hdl, MPI_Comm comm)
void COM_window_init_done(const char *w_str, int pane_changed=true)
static int write_attr_handle
virtual void create(std::string bufname)
void COM_clone_attribute(const char *wname, const char *attr, int wg=1, const char *ptnname=0, int val=0)
Clone the subset of panes of another window of which the given pane attribute has value val...
void COM_new_window(const char *wname, MPI_Comm c=MPI_COMM_NULL)
void COM_call_function(const int wf, int argc,...)
void write_control_file(double t, const std::string base, const std::string window)
static int read_by_control_handle
void init_callback(const char *surf_win, const char *vol_win, void *option=NULL)
void(Scheduler::* Scheduler_voidfn1_t)(double)
int COM_get_window_handle(const char *wname)
void init_function_handles()
void set_name(const char *name)
void register_interpolate(InterpolateBase *ip)
void obtain_gm(double *da)
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.
void create(std::string bufname)
NewAttribute(Agent *ag, std::string target_window_, std::string attr_, char loc_, int type_, int ncomp_, const char *unit_)
virtual void store_solutions(int converged)
const RocmanControl_parameters * get_rocmancontrol_param()
UserScheduler bcInitScheduler
void create_registered_attributes(std::string tmpBuf)
std::string parent_window
void create_registered_window_attributes(std::string target_window)
static int read_files_handle
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)
virtual void init_convergence(int iPredCorr)
void run(double t, double dt, double alpha)
static int obtain_attr_handle
Agent(Coupling *cp, std::string mod, std::string obj, const char *agent_name, MPI_Comm com, bool wgm=false, bool skipio=false)
void init_bcinitaction(double t)
void init_actions(double t)
UserScheduler icScheduler
void add_icaction(Action *act)
void run_actions(double t, double dt)
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)
const Control_parameters * get_control_param()
std::FILE * fopen(const char *const path, const char *const mode)
Open a file, and check for possible errors.
void COM_resize_array(const char *wa_str, int pane_id=0, void **addr=NULL, int strd=-1, int cap=0)
Resize an attribute on a specific pane and return the address by setting addr.
void init_bcactions(double t)
int COM_get_function_handle(const char *wfname)
void init_gmactions(double t)
AttributeList attributeList