Commit c3e9c35b authored by GILLES Sebastien's avatar GILLES Sebastien

#852 InputParameterList: add mpi in constructor.

parent 3fe26a2e
......@@ -107,7 +107,7 @@ namespace HappyHeart
}
// We can be here only if the file exists...
input_parameter_data_ = std::make_unique<InputParameterListT>(input_parameter_file);
input_parameter_data_ = std::make_unique<InputParameterListT>(input_parameter_file, mpi);
InitTimeKeepLog(mpi, GetInputParameterList());
}
......
......@@ -55,6 +55,7 @@ namespace HappyHeart
* purposes (namely mesh-related ones).
*/
explicit InputParameterList(const std::string& filename,
const Wrappers::Mpi& mpi,
Utilities::InputParameterListNS::DoTrackUnusedFields do_track_unused_fields =
Utilities::InputParameterListNS::DoTrackUnusedFields::yes);
......
......@@ -17,8 +17,10 @@ namespace HappyHeart
template<class TupleT>
InputParameterList<TupleT>::InputParameterList(const std::string& filename,
const Wrappers::Mpi& mpi,
Utilities::InputParameterListNS::DoTrackUnusedFields do_track_unused_fields)
: Utilities::InputParameterListNS::Base<InputParameterList, TupleT>(filename,
mpi,
do_track_unused_fields)
{
// \todo Deactivated for the moment, see #167
......
......@@ -34,7 +34,7 @@ int main(int argc, char ** argv)
BidomainNS::BidomainModel<HappyHeart::ReactionLawNS::ReactionLawName::CourtemancheRamirezNattel> model(mpi, input_parameter_data);
model.Run(input_parameter_data);
input_parameter_data.PrintUnused(mpi, std::cout);
input_parameter_data.PrintUnused(std::cout);
}
catch(const std::exception& e)
{
......
......@@ -34,7 +34,7 @@ int main(int argc, char ** argv)
BidomainNS::BidomainModel<HappyHeart::ReactionLawNS::ReactionLawName::MitchellSchaeffer> model(mpi, input_parameter_data);
model.Run(input_parameter_data);
input_parameter_data.PrintUnused(mpi, std::cout);
input_parameter_data.PrintUnused(std::cout);
}
catch(const std::exception& e)
{
......
......@@ -34,7 +34,7 @@ int main(int argc, char ** argv)
BidomainVentriclesNS::BidomainVentriclesModel<HappyHeart::ReactionLawNS::ReactionLawName::MitchellSchaeffer> model(mpi, input_parameter_data);
model.Run(input_parameter_data);
input_parameter_data.PrintUnused(mpi, std::cout);
input_parameter_data.PrintUnused(std::cout);
}
catch(const std::exception& e)
{
......
......@@ -34,7 +34,7 @@ int main(int argc, char ** argv)
ElasticityNS::ElasticityModel model(mpi, input_parameter_data);
model.Run(input_parameter_data);
input_parameter_data.PrintUnused(mpi, std::cout);
input_parameter_data.PrintUnused(std::cout);
}
catch(const std::exception& e)
{
......
......@@ -71,7 +71,7 @@ int main(int argc, char ** argv)
model.Run(input_parameter_data);
input_parameter_data.PrintUnused(mpi, std::cout);
input_parameter_data.PrintUnused(std::cout);
}
catch(const std::exception& e)
{
......
......@@ -34,7 +34,7 @@ int main(int argc, char ** argv)
HeatNS::HeatModel model(mpi, input_parameter_data);
model.Run(input_parameter_data);
input_parameter_data.PrintUnused(mpi, std::cout);
input_parameter_data.PrintUnused(std::cout);
}
catch(const std::exception& e)
{
......
......@@ -31,7 +31,7 @@ int main(int argc, char ** argv)
model.Run(input_parameter_data);
input_parameter_data.PrintUnused(mpi, std::cout);
input_parameter_data.PrintUnused(std::cout);
}
catch(const std::exception& e)
{
......
......@@ -30,7 +30,7 @@ int main(int argc, char ** argv)
HyperelasticityNS::TimeScheme::midpoint> model(mpi, input_parameter_data);
model.Run(input_parameter_data);
input_parameter_data.PrintUnused(mpi, std::cout);
input_parameter_data.PrintUnused(std::cout);
}
catch(const std::exception& e)
{
......
......@@ -30,7 +30,7 @@ int main(int argc, char ** argv)
HyperelasticityNS::TimeScheme::half_sum> model(mpi, input_parameter_data);
model.Run(input_parameter_data);
input_parameter_data.PrintUnused(mpi, std::cout);
input_parameter_data.PrintUnused(std::cout);
}
catch(const std::exception& e)
{
......
......@@ -30,7 +30,7 @@ int main(int argc, char ** argv)
model(mpi, input_parameter_data);
model.Run(input_parameter_data);
input_parameter_data.PrintUnused(mpi, std::cout);
input_parameter_data.PrintUnused(std::cout);
}
catch(const std::exception& e)
{
......
......@@ -71,7 +71,7 @@ int main(int argc, char ** argv)
model.Run(input_parameter_data);
input_parameter_data.PrintUnused(mpi, std::cout);
input_parameter_data.PrintUnused(std::cout);
}
catch(const std::exception& e)
{
......
......@@ -71,7 +71,7 @@ int main(int argc, char ** argv)
model.Run(input_parameter_data);
input_parameter_data.PrintUnused(mpi, std::cout);
input_parameter_data.PrintUnused(std::cout);
}
catch(const std::exception& e)
{
......
......@@ -35,7 +35,7 @@ int main(int argc, char ** argv)
ReactionDiffusionNS::ReactionDiffusionModel<HappyHeart::ReactionLawNS::ReactionLawName::CourtemancheRamirezNattel> model(mpi, input_parameter_data);
model.Run(input_parameter_data);
input_parameter_data.PrintUnused(mpi, std::cout);
input_parameter_data.PrintUnused(std::cout);
}
catch(const std::exception& e)
{
......
......@@ -34,7 +34,7 @@ int main(int argc, char ** argv)
ReactionDiffusionNS::ReactionDiffusionModel<HappyHeart::ReactionLawNS::ReactionLawName::FitzHughNagumo> model(mpi, input_parameter_data);
model.Run(input_parameter_data);
input_parameter_data.PrintUnused(mpi, std::cout);
input_parameter_data.PrintUnused(std::cout);
}
catch(const std::exception& e)
{
......
......@@ -36,7 +36,7 @@ int main(int argc, char ** argv)
ReactionDiffusionNS::ReactionDiffusionModel<HappyHeart::ReactionLawNS::ReactionLawName::MitchellSchaeffer> model(mpi, input_parameter_data);
model.Run(input_parameter_data);
input_parameter_data.PrintUnused(mpi, std::cout);
input_parameter_data.PrintUnused(std::cout);
}
catch(const std::exception& e)
{
......
......@@ -34,7 +34,7 @@ int main(int argc, char ** argv)
RivlinCubeNS::Model model(mpi, input_parameter_data);
model.Run(input_parameter_data);
input_parameter_data.PrintUnused(mpi, std::cout);
input_parameter_data.PrintUnused(std::cout);
}
catch(const std::exception& e)
{
......
......@@ -34,7 +34,7 @@ int main(int argc, char ** argv)
StokesNS::Model model(mpi, input_parameter_data);
model.Run(input_parameter_data);
input_parameter_data.PrintUnused(mpi, std::cout);
input_parameter_data.PrintUnused(std::cout);
}
catch(const std::exception& e)
{
......
......@@ -34,7 +34,7 @@ int main(int argc, char ** argv)
SurfacicBidomainNS::SurfacicBidomainModel<HappyHeart::ReactionLawNS::ReactionLawName::CourtemancheRamirezNattel> model(mpi, input_parameter_data);
model.Run(input_parameter_data);
input_parameter_data.PrintUnused(mpi, std::cout);
input_parameter_data.PrintUnused(std::cout);
}
catch(const std::exception& e)
{
......
......@@ -34,7 +34,7 @@ int main(int argc, char ** argv)
SurfacicBidomainNS::SurfacicBidomainModel<HappyHeart::ReactionLawNS::ReactionLawName::MitchellSchaeffer> model(mpi, input_parameter_data);
model.Run(input_parameter_data);
input_parameter_data.PrintUnused(mpi, std::cout);
input_parameter_data.PrintUnused(std::cout);
}
catch(const std::exception& e)
{
......
......@@ -34,7 +34,7 @@ int main(int argc, char ** argv)
ConformProjectorNS::Model model(mpi, input_parameter_data);
model.Run(input_parameter_data);
input_parameter_data.PrintUnused(mpi, std::cout);
input_parameter_data.PrintUnused(std::cout);
}
catch(const std::exception& e)
{
......
......@@ -34,7 +34,7 @@ int main(int argc, char ** argv)
P1_to_P2_NS::Model model(mpi, input_parameter_data);
model.Run(input_parameter_data);
input_parameter_data.PrintUnused(mpi, std::cout);
input_parameter_data.PrintUnused(std::cout);
}
catch(const std::exception& e)
{
......
......@@ -34,7 +34,7 @@ int main(int argc, char ** argv)
TestAtDofNS::Model model(mpi, input_parameter_data);
model.Run(input_parameter_data);
input_parameter_data.PrintUnused(mpi, std::cout);
input_parameter_data.PrintUnused(std::cout);
}
catch(const std::exception& e)
{
......
......@@ -31,6 +31,7 @@
# include "Utilities/InputParameterList/Private/TupleIteration.hpp"
# include "Utilities/InputParameterList/Private/ManualParsing.hpp"
# include "Utilities/InputParameterList/Private/Subtuple.hpp"
# include "Utilities/Mpi/Mpi.hpp"
namespace HappyHeart
......@@ -92,7 +93,7 @@ namespace HappyHeart
* of those anyway; to see an example of such a class see in Core/InputParameter or in HappyHeart documentation.
*/
template<class DerivedT, class TupleT>
class Base
class Base : public ::HappyHeart::Crtp::HappyHeartMpi<Base<DerivedT, TupleT>>
{
public:
......@@ -116,6 +117,9 @@ namespace HappyHeart
public:
//! Mpi parent.
using mpi_parent = ::HappyHeart::Crtp::HappyHeartMpi<Base<DerivedT, TupleT>>;
//! The underlying tuple type.
using Tuple = TupleT;
......@@ -137,6 +141,7 @@ namespace HappyHeart
* purposes (namely mesh-related ones).
*/
explicit Base(std::string filename,
const Wrappers::Mpi& mpi,
DoTrackUnusedFields do_track_unused_fields = DoTrackUnusedFields::yes);
//! Disable copy constructor.
......@@ -167,7 +172,6 @@ namespace HappyHeart
* So this method should be called at the very end of your program if you want the information
* it gives.
*
* \param[in] mpi Mpi object used in the calculation.
* \param[in,out] out Stream to which the output will be printed. If nothing added then all input
* parameters were used.
*
......@@ -175,7 +179,7 @@ namespace HappyHeart
* be exhaustive.
*
*/
void PrintUnused(const Wrappers::Mpi& mpi, std::ostream& out) const;
void PrintUnused(std::ostream& out) const;
//! Get the path to the input parameter file.
const std::string& GetInputFile() const;
......
......@@ -25,8 +25,10 @@ namespace HappyHeart
template<class DerivedT, class TupleT>
Base<DerivedT, TupleT>::Base(std::string filename,
const Wrappers::Mpi& mpi,
DoTrackUnusedFields do_track_unused_fields)
: ops_(nullptr),
: mpi_parent(mpi),
ops_(nullptr),
input_parameter_file_(filename)
{
int is_initialized;
......@@ -261,7 +263,7 @@ namespace HappyHeart
template<class DerivedT, class TupleT>
void Base<DerivedT, TupleT>::PrintUnused(const Wrappers::Mpi& mpi, std::ostream& out) const
void Base<DerivedT, TupleT>::PrintUnused(std::ostream& out) const
{
// First gather the data from all processors: it is possible (though unlikely) than a given
// input parameter is read only in some of the processors.
......@@ -273,6 +275,8 @@ namespace HappyHeart
assert(identifiers.size() == stats.size());
// Then reduce it on the root processor.
const auto& mpi = mpi_parent::MpiHappyHeart();
auto&& reduced_stats = mpi.ReduceOnRootProcessor(stats, Wrappers::MpiNS::Op::LogicalOr);
assert(reduced_stats.size() == stats.size());
......
......@@ -34,7 +34,7 @@ int main(int argc, char ** argv)
___VARIABLE_problemName:identifier___NS::Model model(mpi, input_parameter_data);
model.Run(input_parameter_data);
input_parameter_data.PrintUnused(mpi, std::cout);
input_parameter_data.PrintUnused(std::cout);
}
catch(const std::exception& e)
{
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment