|
9 | 9 | #include "Common/CFLog.hh"
|
10 | 10 | #include "Common/NullPointerException.hh"
|
11 | 11 | #include "Common/EventHandler.hh"
|
| 12 | +#include "Common/MemFunArg.hh" |
12 | 13 |
|
13 | 14 | #include "Environment/FileHandlerOutput.hh"
|
14 | 15 | #include "Environment/DirPaths.hh"
|
|
38 | 39 | #include "Framework/Framework.hh"
|
39 | 40 | #include "Framework/SimulationStatus.hh"
|
40 | 41 |
|
| 42 | +// #include <boost/mpl/list.hpp> |
| 43 | +// #include <boost/mpl/for_each.hpp> |
| 44 | + |
41 | 45 | //////////////////////////////////////////////////////////////////////////////
|
42 | 46 |
|
43 | 47 | using namespace std;
|
@@ -309,67 +313,44 @@ void StandardSubSystem::buildMeshData()
|
309 | 313 | // allocate all the mesh data
|
310 | 314 | vector <Common::SafePtr<MeshData> > meshDataVector =
|
311 | 315 | MeshDataStack::getInstance().getAllEntries();
|
312 |
| - for(CFuint iMesh = 0; iMesh < meshDataVector.size(); iMesh++) { |
313 |
| - meshDataVector[iMesh]->reallocate(); |
314 |
| - } |
| 316 | + |
| 317 | + for_each (meshDataVector.begin(), meshDataVector.end(), |
| 318 | + safeptr_mem_fun(&MeshData::reallocate)); |
315 | 319 |
|
316 | 320 | CFLog(NOTICE,"-------------------------------------------------------------\n");
|
317 | 321 | CFLog(NOTICE,"Setting up all MeshCreator's\n");
|
318 | 322 | CFLog(NOTICE,"-------------------------------------------------------------\n");
|
319 |
| - |
| 323 | + |
320 | 324 | // finally setup the mesh creators
|
321 |
| - for(CFuint iMC=0; iMC < m_meshCreator.size(); iMC++) |
322 |
| - { |
323 |
| - if(!m_meshCreator[iMC]->isNonRootMethod()) |
324 |
| - { |
325 |
| - m_meshCreator[iMC]->setMethod(); |
326 |
| - } |
327 |
| - } |
328 |
| - |
329 |
| - /// @TODO Why not FREE the mesh creator here also?????? |
330 |
| - |
| 325 | + Common::for_each_if (m_meshCreator.begin(), m_meshCreator.end(), |
| 326 | + mem_fun(&MeshCreator::setMethod), |
| 327 | + mem_fun(&MeshCreator::isNonRootMethod), false); |
| 328 | + |
331 | 329 | CFLog(NOTICE,"-------------------------------------------------------------\n");
|
332 | 330 | CFLog(NOTICE,"Building MeshData's\n");
|
333 | 331 | CFLog(NOTICE,"-------------------------------------------------------------\n");
|
334 |
| - |
335 |
| - // Create the CFMeshData for each Namespace |
336 |
| - for(CFuint iMC=0; iMC < m_meshCreator.size(); iMC++) |
337 |
| - { |
338 |
| - if( !m_meshCreator[iMC]->isNonRootMethod() ) |
339 |
| - { |
340 |
| - m_meshCreator[iMC]->generateMeshData(); |
341 |
| - } |
342 |
| - } |
343 |
| - |
| 332 | + |
| 333 | + Common::for_each_if (m_meshCreator.begin(), m_meshCreator.end(), |
| 334 | + mem_fun(&MeshCreator::generateMeshData), |
| 335 | + mem_fun(&MeshCreator::isNonRootMethod), false); |
| 336 | + |
344 | 337 | // Process the CFMeshData to do:
|
345 | 338 | // - renumbering
|
346 | 339 | // - conversion FVM <-> FEM
|
347 |
| - for(CFuint iMC=0; iMC < m_meshCreator.size(); iMC++) |
348 |
| - { |
349 |
| - if(!m_meshCreator[iMC]->isNonRootMethod()) |
350 |
| - { |
351 |
| - m_meshCreator[iMC]->processMeshData(); |
352 |
| - } |
353 |
| - } |
354 |
| - |
| 340 | + Common::for_each_if (m_meshCreator.begin(), m_meshCreator.end(), |
| 341 | + mem_fun(&MeshCreator::processMeshData), |
| 342 | + mem_fun(&MeshCreator::isNonRootMethod), false); |
| 343 | + |
355 | 344 | // Use the CFMeshData to build the mesh
|
356 |
| - for(CFuint iMC=0; iMC < m_meshCreator.size(); iMC++) |
357 |
| - { |
358 |
| - if(!m_meshCreator[iMC]->isNonRootMethod()) |
359 |
| - { |
360 |
| - m_meshCreator[iMC]->buildMeshData(); |
361 |
| - } |
362 |
| - } |
363 |
| - |
| 345 | + Common::for_each_if (m_meshCreator.begin(), m_meshCreator.end(), |
| 346 | + mem_fun(&MeshCreator::buildMeshData), |
| 347 | + mem_fun(&MeshCreator::isNonRootMethod), false); |
| 348 | + |
364 | 349 | /// @todo Creating a MeshDataAdapter for the MeshWriter should be temporary
|
365 | 350 | /// get ride of the Adapter, make it work directly with MeshData
|
366 |
| - for (CFuint i = 0; i < m_outputFormat.size(); ++i) |
367 |
| - { |
368 |
| - if(!m_outputFormat[i]->isNonRootMethod()) |
369 |
| - { |
370 |
| - m_outputFormat[i]->bindData(); |
371 |
| - } |
372 |
| - } |
| 351 | + Common::for_each_if (m_outputFormat.begin(), m_outputFormat.end(), |
| 352 | + mem_fun(&OutputFormatter::bindData), |
| 353 | + mem_fun(&OutputFormatter::isNonRootMethod), false); |
373 | 354 |
|
374 | 355 | for(CFuint iMeshData = 0; iMeshData < meshDataVector.size(); iMeshData++) {
|
375 | 356 | bool isNonRoot = false;
|
@@ -668,13 +649,12 @@ void StandardSubSystem::run()
|
668 | 649 | CFLog(VERBOSE, "StandardSubSystem::run() => m_errorEstimatorMethod.apply()\n");
|
669 | 650 | // estimate the error one final time
|
670 | 651 | m_errorEstimatorMethod.apply(mem_fun<void,ErrorEstimatorMethod>(&ErrorEstimatorMethod::estimate));
|
671 |
| - |
672 |
| - for(CFuint i = 0; i < subSysStatusVec.size() ; i++) |
673 |
| - { |
674 |
| - subSysStatusVec[i]->stopWatch(); |
675 |
| - } |
676 |
| - stopTimer.stop (); |
677 |
| - |
| 652 | + |
| 653 | + std::for_each (subSysStatusVec.begin(), subSysStatusVec.end(), |
| 654 | + safeptr_mem_fun(&SubSystemStatus::stopWatch)); |
| 655 | + |
| 656 | + stopTimer.stop(); |
| 657 | + |
678 | 658 | CFLog(NOTICE, "SubSystem WallTime: " << stopTimer << "s\n");
|
679 | 659 | m_duration = subSysStatusVec[0]->readWatchHMS();
|
680 | 660 |
|
@@ -711,7 +691,10 @@ void StandardSubSystem::unsetup()
|
711 | 691 |
|
712 | 692 | bool force = true;
|
713 | 693 | writeSolution(force);
|
714 |
| - |
| 694 | + |
| 695 | + // typedef boost::mpl::list<ErrorEstimatorMethod, SpaceMethod> acts; |
| 696 | + // boost::mpl::for_each<acts>(do_this_wrapper()); |
| 697 | + |
715 | 698 | CFLog(VERBOSE, "StandardSubSystem::unsetup() => OutputFormatter\n");
|
716 | 699 | // unset all the methods
|
717 | 700 | m_outputFormat.apply
|
@@ -759,50 +742,21 @@ void StandardSubSystem::unsetup()
|
759 | 742 |
|
760 | 743 | //////////////////////////////////////////////////////////////////////////////
|
761 | 744 |
|
762 |
| -vector<Method*> StandardSubSystem::getMethodList() const |
| 745 | +vector<Method*> StandardSubSystem::getMethodList() |
763 | 746 | {
|
764 | 747 | vector<Method*> mList;
|
765 |
| - |
766 |
| - for (CFuint i = 0; i < m_meshCreator.size(); ++i) { |
767 |
| - mList.push_back(m_meshCreator[i]); |
768 |
| - } |
769 |
| - |
770 |
| - for (CFuint i = 0; i < m_couplerMethod.size(); ++i) { |
771 |
| - mList.push_back(m_couplerMethod[i]); |
772 |
| - } |
773 |
| - |
774 |
| - for (CFuint i = 0; i < m_meshAdapterMethod.size(); ++i) { |
775 |
| - mList.push_back(m_meshAdapterMethod[i]); |
776 |
| - } |
777 |
| - |
778 |
| - for (CFuint i = 0; i < m_errorEstimatorMethod.size(); ++i) { |
779 |
| - mList.push_back(m_errorEstimatorMethod[i]); |
780 |
| - } |
781 |
| - |
782 |
| - for (CFuint i = 0; i < m_linearSystemSolver.size(); ++i) { |
783 |
| - mList.push_back(m_linearSystemSolver[i]); |
784 |
| - } |
785 |
| - |
786 |
| - for (CFuint i = 0; i < m_convergenceMethod.size(); ++i) { |
787 |
| - mList.push_back(m_convergenceMethod[i]); |
788 |
| - } |
789 |
| - |
790 |
| - for (CFuint i = 0; i < m_spaceMethod.size(); ++i) { |
791 |
| - mList.push_back(m_spaceMethod[i]); |
792 |
| - } |
793 |
| - |
794 |
| - for (CFuint i = 0; i < m_dataPreProcessing.size(); ++i) { |
795 |
| - mList.push_back(m_dataPreProcessing[i]); |
796 |
| - } |
797 |
| - |
798 |
| - for (CFuint i = 0; i < m_dataPostProcessing.size(); ++i) { |
799 |
| - mList.push_back(m_dataPostProcessing[i]); |
800 |
| - } |
801 |
| - |
802 |
| - for (CFuint i = 0; i < m_outputFormat.size(); ++i) { |
803 |
| - mList.push_back(m_outputFormat[i]); |
804 |
| - } |
805 |
| - |
| 748 | + |
| 749 | + copy(m_meshCreator.begin(), m_meshCreator.end(), back_inserter(mList)); |
| 750 | + copy(m_couplerMethod.begin(), m_couplerMethod.end(), back_inserter(mList)); |
| 751 | + copy(m_meshAdapterMethod.begin(), m_meshAdapterMethod.end(), back_inserter(mList)); |
| 752 | + copy(m_errorEstimatorMethod.begin(), m_errorEstimatorMethod.end(), back_inserter(mList)); |
| 753 | + copy(m_linearSystemSolver.begin(), m_linearSystemSolver.end(), back_inserter(mList)); |
| 754 | + copy(m_convergenceMethod.begin(), m_convergenceMethod.end(), back_inserter(mList)); |
| 755 | + copy(m_spaceMethod.begin(), m_spaceMethod.end(), back_inserter(mList)); |
| 756 | + copy(m_dataPreProcessing.begin(), m_dataPreProcessing.end(), back_inserter(mList)); |
| 757 | + copy(m_dataPostProcessing.begin(), m_dataPostProcessing.end(), back_inserter(mList)); |
| 758 | + copy(m_outputFormat.begin(), m_outputFormat.end(), back_inserter(mList)); |
| 759 | + |
806 | 760 | return mList;
|
807 | 761 | }
|
808 | 762 |
|
@@ -850,27 +804,23 @@ Common::Signal::return_t StandardSubSystem::modifyRestartAction(Common::Signal::
|
850 | 804 | std::string subsystemName = getName();
|
851 | 805 | std::string nspName = m_meshCreator[iMC]->getNamespace();
|
852 | 806 | std::string filename = SimulationStatus::getInstance().getLastOutputFile(subsystemName, nspName).string();
|
| 807 | + |
853 | 808 | CFLog(NOTICE,"Restarting from file : " << filename << "\n");
|
854 |
| - |
855 |
| -// CF_DEBUG_OBJ(Environment::DirPaths::getInstance().getWorkingDir().string()); |
856 |
| -// CF_DEBUG_OBJ(Environment::DirPaths::getInstance().getResultsDir().string()); |
857 |
| - |
858 |
| - DirPaths::getInstance().setWorkingDir( |
859 |
| - DirPaths::getInstance().getResultsDir().string() |
860 |
| - ); |
| 809 | + |
| 810 | + DirPaths::getInstance().setWorkingDir(DirPaths::getInstance().getResultsDir().string()); |
861 | 811 | m_meshCreator[iMC]->modifyFileNameForRestart(filename);
|
862 | 812 | }
|
863 | 813 | }
|
864 |
| - |
| 814 | + |
865 | 815 | m_initialTime = SimulationStatus::getInstance().getSimulationTime(getName());
|
866 | 816 | vector< SafePtr<SubSystemStatus> > subSystemStatusVec =
|
867 | 817 | SubSystemStatusStack::getInstance().getAllEntries();
|
868 |
| - |
| 818 | + |
869 | 819 | for(CFuint i=0; i<subSystemStatusVec.size(); ++i)
|
870 | 820 | {
|
871 | 821 | subSystemStatusVec[i]->setCurrentTimeDim(m_initialTime);
|
872 | 822 | }
|
873 |
| - |
| 823 | + |
874 | 824 | return Common::Signal::return_t ();
|
875 | 825 | }
|
876 | 826 |
|
|
0 commit comments