add post_constructor() method to computes for symmetry with fixes
This commit is contained in:
@ -115,6 +115,7 @@ class Compute : protected Pointers {
|
||||
void modify_params(int, char **);
|
||||
virtual int modify_param(int, char **) { return 0; }
|
||||
virtual void reset_extra_dof();
|
||||
virtual void post_constructor() {}
|
||||
|
||||
void init_flags();
|
||||
virtual void init() = 0;
|
||||
|
||||
@ -1293,7 +1293,18 @@ Compute *Modify::add_compute(int narg, char **arg, int trysuffix)
|
||||
error->all(FLERR, utils::check_packages_for_style("compute", arg[2], lmp));
|
||||
|
||||
compute_list = std::vector<Compute *>(compute, compute + ncompute + 1);
|
||||
return compute[ncompute++];
|
||||
|
||||
// post_constructor() can call virtual methods in parent or child
|
||||
// which would otherwise not yet be visible in child class
|
||||
// post_constructor() allows new compute to create other computes
|
||||
// ncompute increment must come first so recursive call to add_compute within
|
||||
// post_constructor() will see updated ncompute
|
||||
|
||||
auto *newcompute = compute[ncompute];
|
||||
++ncompute;
|
||||
newcompute->post_constructor();
|
||||
|
||||
return newcompute;
|
||||
}
|
||||
|
||||
/* ----------------------------------------------------------------------
|
||||
|
||||
Reference in New Issue
Block a user