Simplify MetaD
MetaD.cpp is the longest source file we have, furthermore partially duplicated (for good reasons) in PBMetaD.cpp, I think we should find a way of building a basic class on top of bias to implement all the metadynamics variants in a more modular way @plumed/team-plumed2
I am not 100% the best option is to have a common base class more specialized than current Bias class. Let's also consider the possibility to add tools that perform common tasks and are used in multiple classes. Or perhaps the best is something in the middle, with some common infrastructure in a common class and also some parts of the code moved out of MetaD in some tool that can be used also in PBMetaD.
The good thing of using inheritance in the way Actions are structured now is that it forces options in the input file to be identical. Anything more than that I think could (sometime) be a overuse of inheritance.
So if we want to unify something in MetaD and PBMetaD I would suggest looking at which options are identical (and expected to remain identical in the future because of the way the two methods work). For instance, things like FILE might not fit well in a common class since in PBMetaD you would need an array of those whereas in METAD you don't. Are there options that are identical?
In the other direction, would it be possible to make a completely separate class that does all the MetaD calculation (say in tools/MetaD.cpp) and then in bias/MetaD.cpp declare a single one and in PBMetaD.cpp declare an array? The MetaD tool should not directly interact with the Action hierarchy (e.g. not use getNumberOfArguments()) but be sort of self-contained. This would me pretty much what we did for tools/RMSD.cpp vs colvar/RMSD.cpp. All the parsing should go in bias/(PB)MetaD.cpp of course, so the two methods could have different options.
I am just wondering, not sure it is feasible nor useful.
Just to add more on this, my point is more on the complexity of METAD itself than on the overlap with PBMETAD, anytime we have a new variant of METAD there is more complexity in the code. I would like to have somewhere a very basic METAD implementation on top of which one could build more complex variants. I agree multiple inheritance is not the maybe the best option, tools could be better. I need to look better at how the codes look like now