From 988b5e7e1cd0f015a2179e80709696ec4cf87d57 Mon Sep 17 00:00:00 2001 From: Alexander Jaust <alexander.jaust@ipvs.uni-stuttgart.de> Date: Fri, 20 Dec 2019 10:51:53 +0100 Subject: [PATCH] stuff --- .../iterative-reversed/CMakeLists.txt | 9 ++++ appl/coupling-ff-pm/monolithic/main.cc | 53 ++++++++++++++++--- 2 files changed, 56 insertions(+), 6 deletions(-) diff --git a/appl/coupling-ff-pm/iterative-reversed/CMakeLists.txt b/appl/coupling-ff-pm/iterative-reversed/CMakeLists.txt index 8b8a730..c5f76c9 100644 --- a/appl/coupling-ff-pm/iterative-reversed/CMakeLists.txt +++ b/appl/coupling-ff-pm/iterative-reversed/CMakeLists.txt @@ -26,3 +26,12 @@ target_link_libraries(test_pm_reversed PRIVATE ${Boost_LIBRARIES} ${PRECICE_LIB} target_include_directories(test_pm_reversed PRIVATE ${Boost_INCLUDE_DIRS}) # add a symlink for each input file add_input_file_links() + +macro(add_precice_file_links) + FILE(GLOB precice_files *.xml) + foreach(VAR ${input_files}) + get_filename_component(file_name ${VAR} NAME) + dune_symlink_to_source_files(FILES ${file_name}) + endforeach() +endmacro() +add_precice_file_links() diff --git a/appl/coupling-ff-pm/monolithic/main.cc b/appl/coupling-ff-pm/monolithic/main.cc index 01af755..c598067 100644 --- a/appl/coupling-ff-pm/monolithic/main.cc +++ b/appl/coupling-ff-pm/monolithic/main.cc @@ -92,7 +92,7 @@ auto velocityAtInterface(const Problem& problem, } template<class FluxVariables, class CouplingManager, class Problem, class GridVariables, class SolutionVector> -void writeVelocitiesOnInterfaceToFile( const std::string& filename, + std::tuple<double,double,double> writeVelocitiesOnInterfaceToFile( const std::string& filename, const CouplingManager& couplingManager, const Problem& problem, const GridVariables& gridVars, @@ -108,6 +108,9 @@ void writeVelocitiesOnInterfaceToFile( const std::string& filename, std::ofstream ofs( filename+".csv", std::ofstream::out | std::ofstream::trunc); ofs << "x,y,"; ofs << "velocityY" << "\n"; + double min = std::numeric_limits<double>::max(); + double max = std::numeric_limits<double>::min(); + double sum = 0.; for (const auto& element : elements(fvGridGeometry.gridView())) { fvGeometry.bind(element); @@ -124,17 +127,25 @@ void writeVelocitiesOnInterfaceToFile( const std::string& filename, { ofs << pos[i] << ","; } - const double v = couplingManager.couplingData().massCouplingCondition(element, fvGeometry, elemVolVars, scvf); + const double v = couplingManager.couplingData().massCouplingCondition(element, fvGeometry, elemVolVars, scvf) + / 1e3; + max = std::max( v, max ); + min = std::min( v, min ); + sum += v; + const int prec = ofs.precision(); + ofs << std::setprecision(std::numeric_limits<double>::digits10 + 1) << v << "\n"; + ofs.precision( prec ); ofs << v / 1e3 << "\n"; } } } ofs.close(); + return std::make_tuple(min, max, sum); } template<class CouplingManager, class Problem, class SolutionVector> -void writeStokesVelocitiesOnInterfaceToFile( const std::string& filename, + std::tuple<double,double,double> writeStokesVelocitiesOnInterfaceToFile( const std::string& filename, const CouplingManager& couplingManager, const Problem& problem, const SolutionVector& sol) @@ -146,6 +157,10 @@ void writeStokesVelocitiesOnInterfaceToFile( const std::string& filename, std::ofstream ofs( filename+".csv", std::ofstream::out | std::ofstream::trunc); ofs << "x,y,"; ofs << "velocityY" << "\n"; + + double min = std::numeric_limits<double>::max(); + double max = std::numeric_limits<double>::min(); + double sum = 0.; for (const auto& element : elements(fvGridGeometry.gridView())) { fvGeometry.bind(element); @@ -161,12 +176,18 @@ void writeStokesVelocitiesOnInterfaceToFile( const std::string& filename, ofs << pos[i] << ","; } const double v = sol[scvf.dofIndex()]; - ofs << v << "\n"; + max = std::max( v, max ); + min = std::min( v, min ); + sum += v; + const int prec = ofs.precision(); + ofs << std::setprecision(std::numeric_limits<double>::digits10 + 1) << v << "\n"; + ofs.precision( prec ); } } } ofs.close(); + return std::make_tuple(min, max, sum); } int main(int argc, char** argv) try @@ -342,22 +363,42 @@ int main(int argc, char** argv) try darcyVtkWriter.write(1.0); { + double min = std::numeric_limits<double>::max(); + double max = std::numeric_limits<double>::min(); + double sum = 0.; using FluxVariables = GetPropType<DarcyTypeTag, Properties::FluxVariables>; const std::string filename = getParam<std::string>("Problem.Name") + "-" + darcyProblem->name() + "-interface-velocity"; - writeVelocitiesOnInterfaceToFile<FluxVariables>( filename, + std::tie(min, max, sum) = writeVelocitiesOnInterfaceToFile<FluxVariables>( filename, *couplingManager, *darcyProblem, *darcyGridVariables, sol[darcyIdx] ); + const int prec = std::cout.precision(); + std::cout << "Velocity statistics:" << std::endl + << std::setprecision(std::numeric_limits<double>::digits10 + 1) + << " min: " << min << std::endl + << " max: " << max << std::endl + << " sum: " << sum << std::endl; + std::cout.precision( prec ); } //TODO make freeflow { + double min = std::numeric_limits<double>::max(); + double max = std::numeric_limits<double>::min(); + double sum = 0.; const std::string filename = getParam<std::string>("Problem.Name") + "-" + stokesProblem->name() + "-interface-velocity"; - writeStokesVelocitiesOnInterfaceToFile( filename, + std::tie(min, max, sum) = writeStokesVelocitiesOnInterfaceToFile( filename, *couplingManager, *stokesProblem, sol[stokesFaceIdx] ); + const int prec = std::cout.precision(); + std::cout << "Velocity statistics:" << std::endl + << std::setprecision(std::numeric_limits<double>::digits10 + 1) + << " min: " << min << std::endl + << " max: " << max << std::endl + << " sum: " << sum << std::endl; + std::cout.precision( prec ); } -- GitLab