Skip to content

Commit

Permalink
Merge branch 'master' into container-docu
Browse files Browse the repository at this point in the history
  • Loading branch information
Thinkpiet authored Aug 9, 2024
2 parents b16babe + 572f0b7 commit 1511bdd
Show file tree
Hide file tree
Showing 11 changed files with 77 additions and 55 deletions.
1 change: 1 addition & 0 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -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()
Expand Down
30 changes: 17 additions & 13 deletions coupling/interface/impl/ls1/LS1StaticCommData.h
Original file line number Diff line number Diff line change
Expand Up @@ -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<int, 3> getDomainGridDecomp() { return domainGridDecomp; }
void setDomainGridDecompAtDim(int dim, int breakdown) { _domainGridDecomp[dim] = breakdown; }
const int getDomainGridDecompAtDim(int dim) { return _domainGridDecomp[dim]; }
std::array<int, 3> getDomainGridDecomp() { return _domainGridDecomp; }

void setSubdomainWeights(std::array<std::vector<unsigned int>, 3> subdomainWeights) { _subdomainWeights = subdomainWeights; }
const std::array <std::vector<unsigned int> ,3> getSubdomainWeights() { return _subdomainWeights; }
#endif

private:
LS1StaticCommData() {}
std::string ls1ConfigFilename;
std::array<double, 3> boxoffset; // temporary till ls1 offset is natively supported
std::string _ls1ConfigFilename;
std::array<double, 3> _boxoffset; // temporary till ls1 offset is natively supported
#if (COUPLING_MD_PARALLEL == COUPLING_MD_YES)
MPI_Comm localComm;
std::array<int, 3> domainGridDecomp;
MPI_Comm _localComm;
std::array<int, 3> _domainGridDecomp;
std::array<std::vector<unsigned int> ,3 >_subdomainWeights;
#endif
};
} // namespace interface
Expand Down
2 changes: 1 addition & 1 deletion ls1
Submodule ls1 updated 329 files
79 changes: 48 additions & 31 deletions test/unit/coupling/interface/impl/ls1/LS1MDSolverInterfaceTest.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand Down Expand Up @@ -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]};
Expand All @@ -216,9 +225,9 @@ class LS1MDSolverInterfaceTest : public CppUnit::TestFixture {
} // linkZ
} // linkY
} // linkX
} // macZ
} // macY
} // macX
} // coupZ
} // coupY
} // coupX
}

void testGetCellIterator() {
Expand All @@ -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]};
Expand All @@ -284,9 +301,9 @@ class LS1MDSolverInterfaceTest : public CppUnit::TestFixture {
} // linkZ
} // linkY
} // linkX
} // macZ
} // macY
} // macX
} // coupZ
} // coupY
} // coupX
}

void testMassSync() {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand Down
4 changes: 2 additions & 2 deletions test/unit/coupling/interface/impl/ls1/LS1MoleculeTest.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -57,7 +57,7 @@
<lower> <x>0</x> <y>0</y> <z>0</z> </lower>
<upper> <x>30</x> <y>30</y> <z>30</z> </upper>
</object>
<velocityAssigner type="EqualVelocityDistribution" enableRandomSeed="0"></velocityAssigner>
<velocityAssigner type="EqualVelocityDistribution" enableRandomSeed="false"></velocityAssigner>
</objectgenerator>
</generator>
</phasespacepoint>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -57,7 +57,7 @@
<lower> <x>0</x> <y>0</y> <z>0</z> </lower>
<upper> <x>40</x> <y>40</y> <z>40</z> </upper>
</object>
<velocityAssigner type="EqualVelocityDistribution" enableRandomSeed="0"></velocityAssigner>
<velocityAssigner type="EqualVelocityDistribution" enableRandomSeed="false"></velocityAssigner>
</objectgenerator>
</generator>
</phasespacepoint>
Expand Down
2 changes: 1 addition & 1 deletion test/unit/coupling/interface/impl/ls1/ls1emptyconfig.xml
Original file line number Diff line number Diff line change
Expand Up @@ -57,7 +57,7 @@
<lower> <x>0</x> <y>0</y> <z>0</z> </lower>
<upper> <x>30</x> <y>30</y> <z>30</z> </upper>
</object>
<velocityAssigner type="EqualVelocityDistribution" enableRandomSeed="0"></velocityAssigner>
<velocityAssigner type="EqualVelocityDistribution" enableRandomSeed="false"></velocityAssigner>
</objectgenerator>
</generator>
</phasespacepoint>
Expand Down
2 changes: 1 addition & 1 deletion test/unit/coupling/interface/impl/ls1/ls1gridconfig.xml
Original file line number Diff line number Diff line change
Expand Up @@ -57,7 +57,7 @@
<lower> <x>0</x> <y>0</y> <z>0</z> </lower>
<upper> <x>40</x> <y>40</y> <z>40</z> </upper>
</object>
<velocityAssigner type="EqualVelocityDistribution" enableRandomSeed="0"></velocityAssigner>
<velocityAssigner type="EqualVelocityDistribution" enableRandomSeed="false"></velocityAssigner>
</objectgenerator>
</generator>
</phasespacepoint>
Expand Down

0 comments on commit 1511bdd

Please sign in to comment.