diff --git a/CMakeLists.txt b/CMakeLists.txt index 06a0e3d31..e5091da0c 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -851,6 +851,7 @@ if (BUILD_TESTING) file(GLOB_RECURSE TEST_SOURCES_MD "test/unit/coupling/interface/impl/SimpleMD/*Test.cpp") elseif("${MD_SIM}" STREQUAL "LS1_MARDYN") file(GLOB_RECURSE TEST_SOURCES_MD "test/unit/coupling/interface/impl/ls1/*Test.cpp") + list(FILTER TEST_SOURCES_TOP EXCLUDE REGEX "test/unit/coupling/InstanceHandlingTest.cpp") elseif("${MD_SIM}" STREQUAL "LAMMPS_MD" OR "${MD_SIM}" STREQUAL "LAMMPS_DPD") file(GLOB_RECURSE TEST_SOURCES_MD "test/unit/coupling/interface/impl/LAMMPS/*Test.cpp") else() diff --git a/coupling/interface/impl/ls1/LS1StaticCommData.h b/coupling/interface/impl/ls1/LS1StaticCommData.h index 91d269592..ed31fe3a2 100644 --- a/coupling/interface/impl/ls1/LS1StaticCommData.h +++ b/coupling/interface/impl/ls1/LS1StaticCommData.h @@ -19,28 +19,32 @@ class LS1StaticCommData { void operator=(LS1StaticCommData const&) = delete; // data sets and gets - void setConfigFilename(std::string name) { ls1ConfigFilename = name; } - const std::string getConfigFilename() { return ls1ConfigFilename; } + void setConfigFilename(std::string name) { _ls1ConfigFilename = name; } + const std::string getConfigFilename() { return _ls1ConfigFilename; } - void setBoxOffsetAtDim(int dim, double offset) { boxoffset[dim] = offset; } - const double getBoxOffsetAtDim(int dim) { return boxoffset[dim]; } + void setBoxOffsetAtDim(int dim, double offset) { _boxoffset[dim] = offset; } + const double getBoxOffsetAtDim(int dim) { return _boxoffset[dim]; } #if (COUPLING_MD_PARALLEL == COUPLING_MD_YES) - void setLocalCommunicator(MPI_Comm comm) { localComm = comm; } - MPI_Comm getLocalCommunicator() { return localComm; } + void setLocalCommunicator(MPI_Comm comm) { _localComm = comm; } + MPI_Comm getLocalCommunicator() { return _localComm; } - void setDomainGridDecompAtDim(int dim, int breakdown) { domainGridDecomp[dim] = breakdown; } - const int getDomainGridDecompAtDim(int dim) { return domainGridDecomp[dim]; } - std::array getDomainGridDecomp() { return domainGridDecomp; } + void setDomainGridDecompAtDim(int dim, int breakdown) { _domainGridDecomp[dim] = breakdown; } + const int getDomainGridDecompAtDim(int dim) { return _domainGridDecomp[dim]; } + std::array getDomainGridDecomp() { return _domainGridDecomp; } + + void setSubdomainWeights(std::array, 3> subdomainWeights) { _subdomainWeights = subdomainWeights; } + const std::array ,3> getSubdomainWeights() { return _subdomainWeights; } #endif private: LS1StaticCommData() {} - std::string ls1ConfigFilename; - std::array boxoffset; // temporary till ls1 offset is natively supported + std::string _ls1ConfigFilename; + std::array _boxoffset; // temporary till ls1 offset is natively supported #if (COUPLING_MD_PARALLEL == COUPLING_MD_YES) - MPI_Comm localComm; - std::array domainGridDecomp; + MPI_Comm _localComm; + std::array _domainGridDecomp; + std::array ,3 >_subdomainWeights; #endif }; } // namespace interface diff --git a/ls1 b/ls1 index 6032ae49a..70a849599 160000 --- a/ls1 +++ b/ls1 @@ -1 +1 @@ -Subproject commit 6032ae49ad742f9bd595b7b83da38b6bb65b35a4 +Subproject commit 70a84959903d27ac3713a042873578ed89c5dec3 diff --git a/test/unit/coupling/interface/impl/ls1/LS1MDSolverInterfaceTest.cpp b/test/unit/coupling/interface/impl/ls1/LS1MDSolverInterfaceTest.cpp index adc80c6de..d53d17b22 100644 --- a/test/unit/coupling/interface/impl/ls1/LS1MDSolverInterfaceTest.cpp +++ b/test/unit/coupling/interface/impl/ls1/LS1MDSolverInterfaceTest.cpp @@ -37,8 +37,8 @@ class LS1MDSolverInterfaceTest : public CppUnit::TestFixture { #else _ls1ConfigFileName = "../test/unit/coupling/interface/impl/ls1/ls1gridconfig.xml"; #endif - global_log = new Log::Logger(Log::None); - global_log->set_mpi_output_root(0); + Log::global_log = new Log::Logger(Log::None); + Log::global_log->set_mpi_output_root(0); coupling::interface::LS1StaticCommData::getInstance().setBoxOffsetAtDim(0, 0); coupling::interface::LS1StaticCommData::getInstance().setBoxOffsetAtDim(1, 0); coupling::interface::LS1StaticCommData::getInstance().setBoxOffsetAtDim(2, 0); @@ -165,44 +165,53 @@ class LS1MDSolverInterfaceTest : public CppUnit::TestFixture { void testGetCell() { // setup - // create interface with coupling cell size 10 and 2 linked cells per mac.cell per dimension, hence linked cells are size 5,5,5 + // create interface with coupling cell size 10 and 2 linked cells per coupling cell per dimension, hence linked cells are size 5,5,5 tarch::la::Vector<3, double> couplingCellSize(10.0); tarch::la::Vector<3, unsigned int> linkedCellsPerCouplingCell(2); // index converter tarch::la::Vector<3, unsigned int> globalNumberCells(4); // hence size becomes 40x40x40 tarch::la::Vector<3, unsigned int> numberProcesses(1); int rank = 0; + const unsigned dim = 3; #if (COUPLING_MD_PARALLEL == COUPLING_MD_YES) MPI_Comm_rank(MPI_COMM_WORLD, &rank); for (int i = 0; i < 3; i++) numberProcesses[i] = _domainGridDecomposition[i]; #endif - coupling::indexing::IndexingService<3>::getInstance().init(globalNumberCells, numberProcesses, coupling::paralleltopology::ZYX, 3, (unsigned int)rank); + coupling::interface::LS1MDSolverInterface interface(couplingCellSize, linkedCellsPerCouplingCell); - const coupling::IndexConversion<3> indexConversion(globalNumberCells, numberProcesses, rank, interface.getGlobalMDDomainSize(), - interface.getGlobalMDDomainOffset(), coupling::paralleltopology::ZYX); + IDXS.initWithMDSize( + interface.getGlobalMDDomainSize(), + interface.getGlobalMDDomainOffset(), + numberProcesses, + couplingCellSize, + coupling::paralleltopology::ZYX, + 3, + (unsigned int)rank + ); // first: try to get ghost cell, make sure there is error - CPPUNIT_ASSERT_THROW(interface.getLinkedCell({0, 0, 0}, {1, 1, 1}, {2, 2, 2}, indexConversion), std::runtime_error); + CPPUNIT_ASSERT_THROW(interface.getLinkedCell(I00{0}, {1, 1, 1}, {2, 2, 2}), std::runtime_error); // then: get an internal cell and check whether the bounds are as expected - for (unsigned int macX = 1; macX <= globalNumberCells[0] / numberProcesses[0]; macX++) { - for (unsigned int macY = 1; macY <= globalNumberCells[1] / numberProcesses[1]; macY++) { - for (unsigned int macZ = 1; macZ <= globalNumberCells[2] / numberProcesses[2]; macZ++) { + for (int coupX = 1; coupX <= (int)(globalNumberCells[0] / numberProcesses[0]); coupX++) { + for (int coupY = 1; coupY <= (int)(globalNumberCells[1] / numberProcesses[1]); coupY++) { + for (int coupZ = 1; coupZ <= (int)(globalNumberCells[2] / numberProcesses[2]); coupZ++) { for (unsigned int linkX = 0; linkX < linkedCellsPerCouplingCell[0]; linkX++) { for (unsigned int linkY = 0; linkY < linkedCellsPerCouplingCell[1]; linkY++) { for (unsigned int linkZ = 0; linkZ < linkedCellsPerCouplingCell[2]; linkZ++) { - ls1::LS1RegionWrapper cell = interface.getLinkedCell({macX, macY, macZ}, {linkX, linkY, linkZ}, linkedCellsPerCouplingCell, indexConversion); + I03 coupCell({coupX, coupY, coupZ}); + ls1::LS1RegionWrapper cell = interface.getLinkedCell(coupCell, {linkX, linkY, linkZ}, linkedCellsPerCouplingCell); tarch::la::Vector<3, double> receivedStart = {cell.getStartRegionAtDim(0), cell.getStartRegionAtDim(1), cell.getStartRegionAtDim(2)}; tarch::la::Vector<3, double> receivedEnd = {cell.getEndRegionAtDim(0), cell.getEndRegionAtDim(1), cell.getEndRegionAtDim(2)}; tarch::la::Vector<3, double> actualStart = { // hacked for 2x2x1 - ((macX - 1) * couplingCellSize[0]) + (linkX * couplingCellSize[0] / linkedCellsPerCouplingCell[0] + + ((coupX - 1) * couplingCellSize[0]) + (linkX * couplingCellSize[0] / linkedCellsPerCouplingCell[0] + ((rank / numberProcesses[0]) * couplingCellSize[0] * globalNumberCells[0] / numberProcesses[0])), - ((macY - 1) * couplingCellSize[1]) + (linkY * couplingCellSize[1] / linkedCellsPerCouplingCell[1] + + ((coupY - 1) * couplingCellSize[1]) + (linkY * couplingCellSize[1] / linkedCellsPerCouplingCell[1] + ((rank % numberProcesses[0]) * couplingCellSize[1] * globalNumberCells[1] / numberProcesses[1])), - ((macZ - 1) * couplingCellSize[2]) + (linkZ * couplingCellSize[2] / linkedCellsPerCouplingCell[2])}; + ((coupZ - 1) * couplingCellSize[2]) + (linkZ * couplingCellSize[2] / linkedCellsPerCouplingCell[2])}; tarch::la::Vector<3, double> actualEnd = {actualStart[0] + couplingCellSize[0] / linkedCellsPerCouplingCell[0], actualStart[1] + couplingCellSize[1] / linkedCellsPerCouplingCell[1], actualStart[2] + couplingCellSize[2] / linkedCellsPerCouplingCell[2]}; @@ -216,9 +225,9 @@ class LS1MDSolverInterfaceTest : public CppUnit::TestFixture { } // linkZ } // linkY } // linkX - } // macZ - } // macY - } // macX + } // coupZ + } // coupY + } // coupX } void testGetCellIterator() { @@ -230,35 +239,43 @@ class LS1MDSolverInterfaceTest : public CppUnit::TestFixture { tarch::la::Vector<3, unsigned int> globalNumberCells(4); // hence size becomes 40x40x40 tarch::la::Vector<3, unsigned int> numberProcesses(1); int rank = 0; + unsigned const int dim = 3; #if (COUPLING_MD_PARALLEL == COUPLING_MD_YES) MPI_Comm_rank(MPI_COMM_WORLD, &rank); for (int i = 0; i < 3; i++) numberProcesses[i] = _domainGridDecomposition[i]; #endif - coupling::indexing::IndexingService<3>::getInstance().init(globalNumberCells, numberProcesses, coupling::paralleltopology::ZYX, 3, (unsigned int)rank); coupling::interface::LS1MDSolverInterface interface(couplingCellSize, linkedCellsPerCouplingCell); - const coupling::IndexConversion<3> indexConversion(globalNumberCells, numberProcesses, rank, interface.getGlobalMDDomainSize(), - interface.getGlobalMDDomainOffset(), coupling::paralleltopology::ZYX); + IDXS.initWithMDSize( + interface.getGlobalMDDomainSize(), + interface.getGlobalMDDomainOffset(), + numberProcesses, + couplingCellSize, + coupling::paralleltopology::ZYX, + 3, + (unsigned int)rank + ); // first: try to get ghost cell, make sure there is error - CPPUNIT_ASSERT_THROW(interface.getLinkedCell({0, 0, 0}, {1, 1, 1}, {2, 2, 2}, indexConversion), std::runtime_error); + CPPUNIT_ASSERT_THROW(interface.getLinkedCell(I00{0}, {1, 1, 1}, {2, 2, 2}), std::runtime_error); // then: get internal cells and verify cell contents - for (unsigned int macX = 1; macX <= globalNumberCells[0] / numberProcesses[0]; macX++) { - for (unsigned int macY = 1; macY <= globalNumberCells[1] / numberProcesses[1]; macY++) { - for (unsigned int macZ = 1; macZ <= globalNumberCells[2] / numberProcesses[2]; macZ++) { + for (int coupX = 1; coupX <= (int)(globalNumberCells[0] / numberProcesses[0]); coupX++) { + for (int coupY = 1; coupY <= (int)(globalNumberCells[1] / numberProcesses[1]); coupY++) { + for (int coupZ = 1; coupZ <= (int)(globalNumberCells[2] / numberProcesses[2]); coupZ++) { for (unsigned int linkX = 0; linkX < linkedCellsPerCouplingCell[0]; linkX++) { for (unsigned int linkY = 0; linkY < linkedCellsPerCouplingCell[1]; linkY++) { for (unsigned int linkZ = 0; linkZ < linkedCellsPerCouplingCell[2]; linkZ++) { - ls1::LS1RegionWrapper cell = interface.getLinkedCell({macX, macY, macZ}, {linkX, linkY, linkZ}, linkedCellsPerCouplingCell, indexConversion); + I03 coupCell({coupX, coupY, coupZ}); + ls1::LS1RegionWrapper cell = interface.getLinkedCell(coupCell, {linkX, linkY, linkZ}, linkedCellsPerCouplingCell); double actualStart[3] = { // hacked for 2x2x1 - ((macX - 1) * couplingCellSize[0]) + (linkX * couplingCellSize[0] / linkedCellsPerCouplingCell[0] + + ((coupX - 1) * couplingCellSize[0]) + (linkX * couplingCellSize[0] / linkedCellsPerCouplingCell[0] + ((rank / numberProcesses[0]) * couplingCellSize[0] * globalNumberCells[0] / numberProcesses[0])), - ((macY - 1) * couplingCellSize[1]) + (linkY * couplingCellSize[1] / linkedCellsPerCouplingCell[1] + + ((coupY - 1) * couplingCellSize[1]) + (linkY * couplingCellSize[1] / linkedCellsPerCouplingCell[1] + ((rank % numberProcesses[0]) * couplingCellSize[1] * globalNumberCells[1] / numberProcesses[1])), - ((macZ - 1) * couplingCellSize[2]) + (linkZ * couplingCellSize[2] / linkedCellsPerCouplingCell[2])}; + ((coupZ - 1) * couplingCellSize[2]) + (linkZ * couplingCellSize[2] / linkedCellsPerCouplingCell[2])}; double actualEnd[3] = {actualStart[0] + couplingCellSize[0] / linkedCellsPerCouplingCell[0], actualStart[1] + couplingCellSize[1] / linkedCellsPerCouplingCell[1], actualStart[2] + couplingCellSize[2] / linkedCellsPerCouplingCell[2]}; @@ -284,9 +301,9 @@ class LS1MDSolverInterfaceTest : public CppUnit::TestFixture { } // linkZ } // linkY } // linkX - } // macZ - } // macY - } // macX + } // coupZ + } // coupY + } // coupX } void testMassSync() { diff --git a/test/unit/coupling/interface/impl/ls1/LS1MoleculeIteratorTest.cpp b/test/unit/coupling/interface/impl/ls1/LS1MoleculeIteratorTest.cpp index a144ea755..930697064 100644 --- a/test/unit/coupling/interface/impl/ls1/LS1MoleculeIteratorTest.cpp +++ b/test/unit/coupling/interface/impl/ls1/LS1MoleculeIteratorTest.cpp @@ -32,8 +32,8 @@ class LS1MoleculeIteratorTest : public CppUnit::TestFixture { #else _ls1ConfigFileName = "../test/unit/coupling/interface/impl/ls1/ls1gridconfig.xml"; #endif - global_log = new Log::Logger(Log::None); - global_log->set_mpi_output_root(0); + Log::global_log = new Log::Logger(Log::None); + Log::global_log->set_mpi_output_root(0); coupling::interface::LS1StaticCommData::getInstance().setBoxOffsetAtDim(0, 0); coupling::interface::LS1StaticCommData::getInstance().setBoxOffsetAtDim(1, 0); coupling::interface::LS1StaticCommData::getInstance().setBoxOffsetAtDim(2, 0); diff --git a/test/unit/coupling/interface/impl/ls1/LS1MoleculeTest.cpp b/test/unit/coupling/interface/impl/ls1/LS1MoleculeTest.cpp index f5504ae01..33d9c945a 100644 --- a/test/unit/coupling/interface/impl/ls1/LS1MoleculeTest.cpp +++ b/test/unit/coupling/interface/impl/ls1/LS1MoleculeTest.cpp @@ -20,8 +20,8 @@ class LS1MoleculeTest : public CppUnit::TestFixture { public: void setUp() { - global_log = new Log::Logger(Log::None); - global_log->set_mpi_output_root(0); + Log::global_log = new Log::Logger(Log::None); + Log::global_log->set_mpi_output_root(0); coupling::interface::LS1StaticCommData::getInstance().setBoxOffsetAtDim(0, 0); coupling::interface::LS1StaticCommData::getInstance().setBoxOffsetAtDim(1, 0); coupling::interface::LS1StaticCommData::getInstance().setBoxOffsetAtDim(2, 0); diff --git a/test/unit/coupling/interface/impl/ls1/LS1RegionWrapperTest.cpp b/test/unit/coupling/interface/impl/ls1/LS1RegionWrapperTest.cpp index ad498d05a..8b92e995b 100644 --- a/test/unit/coupling/interface/impl/ls1/LS1RegionWrapperTest.cpp +++ b/test/unit/coupling/interface/impl/ls1/LS1RegionWrapperTest.cpp @@ -34,8 +34,8 @@ class LS1RegionWrapperTest : public CppUnit::TestFixture { #else _ls1ConfigFileName = "../test/unit/coupling/interface/impl/ls1/ls1gridconfig.xml"; #endif - global_log = new Log::Logger(Log::None); - global_log->set_mpi_output_root(0); + Log::global_log = new Log::Logger(Log::None); + Log::global_log->set_mpi_output_root(0); coupling::interface::LS1StaticCommData::getInstance().setBoxOffsetAtDim(0, 0); coupling::interface::LS1StaticCommData::getInstance().setBoxOffsetAtDim(1, 0); coupling::interface::LS1StaticCommData::getInstance().setBoxOffsetAtDim(2, 0); diff --git a/test/unit/coupling/interface/impl/ls1/autopasemptyconfig.xml b/test/unit/coupling/interface/impl/ls1/autopasemptyconfig.xml index 6b0ad7cbb..02a5a036b 100644 --- a/test/unit/coupling/interface/impl/ls1/autopasemptyconfig.xml +++ b/test/unit/coupling/interface/impl/ls1/autopasemptyconfig.xml @@ -57,7 +57,7 @@ 0 0 0 30 30 30 - + diff --git a/test/unit/coupling/interface/impl/ls1/autopasgridconfig.xml b/test/unit/coupling/interface/impl/ls1/autopasgridconfig.xml index 4d520aed9..3f342c52f 100644 --- a/test/unit/coupling/interface/impl/ls1/autopasgridconfig.xml +++ b/test/unit/coupling/interface/impl/ls1/autopasgridconfig.xml @@ -57,7 +57,7 @@ 0 0 0 40 40 40 - + diff --git a/test/unit/coupling/interface/impl/ls1/ls1emptyconfig.xml b/test/unit/coupling/interface/impl/ls1/ls1emptyconfig.xml index aa3f57c03..0acf533f9 100644 --- a/test/unit/coupling/interface/impl/ls1/ls1emptyconfig.xml +++ b/test/unit/coupling/interface/impl/ls1/ls1emptyconfig.xml @@ -57,7 +57,7 @@ 0 0 0 30 30 30 - + diff --git a/test/unit/coupling/interface/impl/ls1/ls1gridconfig.xml b/test/unit/coupling/interface/impl/ls1/ls1gridconfig.xml index 0bbaf7139..251ee0c90 100644 --- a/test/unit/coupling/interface/impl/ls1/ls1gridconfig.xml +++ b/test/unit/coupling/interface/impl/ls1/ls1gridconfig.xml @@ -57,7 +57,7 @@ 0 0 0 40 40 40 - +