Skip to content

Commit 90a8fff

Browse files
authored
Merge pull request #226 from PhasicFlow/local-MPI
Local mpi
2 parents d7479cf + 0053ef0 commit 90a8fff

46 files changed

Lines changed: 6014 additions & 28 deletions

File tree

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

cmake/bashrc

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@ export pFlow_SRC_DIR="$pFlow_PROJECT_DIR/src"
1919

2020
export Kokkos_DIR="$kokkosDir"
2121

22-
export Zoltan_DIR="$projectDir/Zoltan"
22+
#export Zoltan_DIR="$projectDir/Zoltan"
2323

2424
# Cleanup variables (done as final statement for a clean exit code)
2525
unset projectDir

cmake/zoltanInstallCheck.cmake

Lines changed: 44 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,44 @@
1+
# Macro to check for Zoltan installation and build it if needed
2+
# Usage: zoltan_find_or_build(ZOLTAN_DIR)
3+
# Returns: ZOLTAN_INCLUDE_DIR, ZOLTAN_LIBRARY
4+
5+
macro(zoltan_find_or_build ZOLTAN_DIR)
6+
# Set the Zoltan directory
7+
set(ZOLTAN_PREFIX "${ZOLTAN_DIR}" CACHE STRING "Zoltan install directory")
8+
message(STATUS "Zoltan install directory is ${ZOLTAN_PREFIX}")
9+
10+
# Check if the Zoltan library is already built
11+
find_path(ZOLTAN_INCLUDE_DIR zoltan.h PATHS "${ZOLTAN_PREFIX}/include")
12+
message(STATUS "Zoltan include path: ${ZOLTAN_INCLUDE_DIR}")
13+
14+
find_library(ZOLTAN_LIBRARY zoltan PATHS "${ZOLTAN_PREFIX}/lib")
15+
message(STATUS "Zoltan lib path: ${ZOLTAN_LIBRARY}")
16+
17+
# Check if Zoltan library exists, if not compile it using buildlib script
18+
if(NOT ZOLTAN_LIBRARY)
19+
message(STATUS "Zoltan library not found. Compiling from source using buildlib script...")
20+
21+
# Execute the buildlib bash script
22+
execute_process(
23+
COMMAND bash ${ZOLTAN_PREFIX}/buildlib
24+
WORKING_DIRECTORY ${ZOLTAN_PREFIX}
25+
RESULT_VARIABLE ZOLTAN_BUILD_RESULT
26+
OUTPUT_VARIABLE ZOLTAN_BUILD_OUTPUT
27+
ERROR_VARIABLE ZOLTAN_BUILD_ERROR
28+
)
29+
30+
if(NOT ZOLTAN_BUILD_RESULT EQUAL 0)
31+
message(FATAL_ERROR "Failed to build Zoltan library using buildlib script. Error: ${ZOLTAN_BUILD_ERROR}")
32+
endif()
33+
34+
# Try to find the library again after building
35+
find_library(ZOLTAN_LIBRARY zoltan PATHS "${ZOLTAN_PREFIX}/lib" NO_DEFAULT_PATH)
36+
find_path(ZOLTAN_INCLUDE_DIR zoltan.h PATHS "${ZOLTAN_PREFIX}/include" NO_DEFAULT_PATH)
37+
38+
if(NOT ZOLTAN_LIBRARY)
39+
message(FATAL_ERROR "Failed to locate Zoltan library after building")
40+
endif()
41+
42+
message(STATUS "Successfully built Zoltan library at ${ZOLTAN_LIBRARY}")
43+
endif()
44+
endmacro()
Lines changed: 71 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,71 @@
1+
#include "processorAB2BoundaryIntegration.hpp"
2+
#include "AdamsBashforth2.hpp"
3+
#include "AB2Kernels.hpp"
4+
#include "boundaryConfigs.hpp"
5+
6+
pFlow::processorAB2BoundaryIntegration::processorAB2BoundaryIntegration(
7+
const boundaryBase &boundary,
8+
const pointStructure &pStruct,
9+
const word &method,
10+
integration& intgrtn
11+
)
12+
:
13+
boundaryIntegration(boundary, pStruct, method, intgrtn)
14+
{}
15+
16+
bool pFlow::processorAB2BoundaryIntegration::correct(
17+
real dt,
18+
const realx3PointField_D& y,
19+
const realx3PointField_D& dy
20+
)
21+
{
22+
23+
#ifndef BoundaryModel1
24+
if(this->isBoundaryMaster())
25+
{
26+
const uint32 thisIndex = thisBoundaryIndex();
27+
const auto& AB2 = static_cast<const AdamsBashforth2&>(Integration());
28+
const auto& dy1View = AB2.BoundaryField(thisIndex).neighborProcField().deviceView();
29+
const auto& dyView = dy.BoundaryField(thisIndex).neighborProcField().deviceView();
30+
const auto& yView = y.BoundaryField(thisIndex).neighborProcField().deviceView();
31+
const rangeU32 aRange(0u, dy1View.size());
32+
return AB2Kernels::intAllActive(
33+
"AB2Integration::correct."+this->boundaryName(),
34+
dt,
35+
aRange,
36+
yView,
37+
dyView,
38+
dy1View
39+
);
40+
}
41+
#endif //BoundaryModel1
42+
43+
44+
return true;
45+
}
46+
47+
bool pFlow::processorAB2BoundaryIntegration::correctPStruct(real dt, const realx3PointField_D &vel)
48+
{
49+
50+
#ifndef BoundaryModel1
51+
if(this->isBoundaryMaster())
52+
{
53+
const uint32 thisIndex = thisBoundaryIndex();
54+
const auto& AB2 = static_cast<const AdamsBashforth2&>(Integration());
55+
const auto& dy1View = AB2.BoundaryField(thisIndex).neighborProcField().deviceView();
56+
const auto& velView = vel.BoundaryField(thisIndex).neighborProcField().deviceView();
57+
const auto& xposView = boundary().neighborProcPoints().deviceView();
58+
const rangeU32 aRange(0u, dy1View.size());
59+
return AB2Kernels::intAllActive(
60+
"AB2Integration::correctPStruct."+this->boundaryName(),
61+
dt,
62+
aRange,
63+
xposView,
64+
velView,
65+
dy1View
66+
);
67+
}
68+
#endif //BoundaryModel1
69+
70+
return true;
71+
}
Lines changed: 51 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,51 @@
1+
2+
3+
#ifndef __processorAB2BoundaryIntegration_hpp__
4+
#define __processorAB2BoundaryIntegration_hpp__
5+
6+
#include "boundaryIntegration.hpp"
7+
8+
namespace pFlow
9+
{
10+
11+
class processorAB2BoundaryIntegration
12+
:
13+
public boundaryIntegration
14+
{
15+
public:
16+
17+
TypeInfo("boundaryIntegration<processor,AdamsBashforth2>");
18+
19+
processorAB2BoundaryIntegration(
20+
const boundaryBase& boundary,
21+
const pointStructure& pStruct,
22+
const word& method,
23+
integration& intgrtn
24+
);
25+
26+
~processorAB2BoundaryIntegration()override=default;
27+
28+
29+
bool correct(
30+
real dt,
31+
const realx3PointField_D& y,
32+
const realx3PointField_D& dy)override;
33+
34+
35+
36+
bool correctPStruct(real dt, const realx3PointField_D& vel)override;
37+
38+
39+
add_vCtor(
40+
boundaryIntegration,
41+
processorAB2BoundaryIntegration,
42+
boundaryBase
43+
);
44+
45+
46+
47+
};
48+
49+
}
50+
51+
#endif
Lines changed: 111 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,111 @@
1+
/*------------------------------- phasicFlow ---------------------------------
2+
O C enter of
3+
O O E ngineering and
4+
O O M ultiscale modeling of
5+
OOOOOOO F luid flow
6+
------------------------------------------------------------------------------
7+
Copyright (C): www.cemf.ir
8+
email: hamid.r.norouzi AT gmail.com
9+
------------------------------------------------------------------------------
10+
Licence:
11+
This file is part of phasicFlow code. It is a free software for simulating
12+
granular and multiphase flows. You can redistribute it and/or modify it under
13+
the terms of GNU General Public License v3 or any other later versions.
14+
15+
phasicFlow is distributed to help others in their research in the field of
16+
granular and multiphase flows, but WITHOUT ANY WARRANTY; without even the
17+
implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
18+
19+
-----------------------------------------------------------------------------*/
20+
21+
#include "processorBoundaryContactSearch.hpp"
22+
#include "contactSearch.hpp"
23+
#include "particles.hpp"
24+
//#include "pointStructure.hpp"
25+
//#include "geometry.hpp"
26+
27+
28+
void pFlow::processorBoundaryContactSearch::setSearchBox()
29+
{
30+
31+
auto l = boundary().neighborLength();
32+
auto n = boundary().boundaryPlane().normal();
33+
auto pp1 = boundary().boundaryPlane().parallelPlane(l);
34+
auto pp2 = boundary().boundaryPlane().parallelPlane(-l);
35+
36+
realx3 minP1 = min(min(min(pp1.p1(), pp1.p2()), pp1.p3()), pp1.p4());
37+
realx3 maxP1 = max(max(max(pp1.p1(), pp1.p2()), pp1.p3()), pp1.p4());
38+
39+
realx3 minP2 = min(min(min(pp2.p1(), pp2.p2()), pp2.p3()), pp2.p4());
40+
realx3 maxP2 = max(max(max(pp2.p1(), pp2.p2()), pp2.p3()), pp2.p4());
41+
42+
auto minP = min(minP1, minP2) - l*(realx3(1.0)-abs(n));
43+
auto maxP = max(maxP1, maxP2) + l*(realx3(1.0)-abs(n));
44+
45+
searchBox_={minP, maxP};
46+
}
47+
48+
pFlow::processorBoundaryContactSearch::processorBoundaryContactSearch(
49+
const dictionary &dict,
50+
const boundaryBase &boundary,
51+
const contactSearch &cSearch)
52+
:
53+
boundaryContactSearch(dict, boundary, cSearch),
54+
diameter_(cSearch.Particles().boundingSphere()),
55+
masterSearch_(this->isBoundaryMaster()),
56+
sizeRatio_(dict.getVal<real>("sizeRatio"))
57+
{
58+
59+
if(masterSearch_)
60+
{
61+
setSearchBox();
62+
63+
real minD;
64+
real maxD;
65+
cSearch.Particles().boundingSphereMinMax(minD, maxD);
66+
67+
ppContactSearch_ = makeUnique<twoPartContactSearch>(
68+
searchBox_,
69+
maxD,
70+
sizeRatio_);
71+
}
72+
else
73+
{
74+
searchBox_={{0,0,0},{0,0,0}};
75+
}
76+
}
77+
78+
bool pFlow::processorBoundaryContactSearch::broadSearch
79+
(
80+
uint32 iter,
81+
real t,
82+
real dt,
83+
csPairContainerType &ppPairs,
84+
csPairContainerType &pwPairs,
85+
bool force
86+
)
87+
{
88+
if(masterSearch_)
89+
{
90+
const auto thisPoints = boundary().thisPoints();
91+
const auto& neighborProcPoints = boundary().neighborProcPoints();
92+
const auto& bDiams = diameter_.BoundaryField(thisBoundaryIndex());
93+
const auto thisDiams = bDiams.thisField();
94+
const auto& neighborProcDiams = bDiams.neighborProcField();
95+
96+
ppContactSearch_().broadSearchPP(
97+
ppPairs,
98+
thisPoints,
99+
thisDiams,
100+
neighborProcPoints,
101+
neighborProcDiams,
102+
boundaryName()
103+
);
104+
//pOutput<<"ppSize "<< ppPairs.size()<<endl;
105+
return true;
106+
107+
}else
108+
{
109+
return true;
110+
}
111+
}
Lines changed: 76 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,76 @@
1+
/*------------------------------- phasicFlow ---------------------------------
2+
O C enter of
3+
O O E ngineering and
4+
O O M ultiscale modeling of
5+
OOOOOOO F luid flow
6+
------------------------------------------------------------------------------
7+
Copyright (C): www.cemf.ir
8+
email: hamid.r.norouzi AT gmail.com
9+
------------------------------------------------------------------------------
10+
Licence:
11+
This file is part of phasicFlow code. It is a free software for simulating
12+
granular and multiphase flows. You can redistribute it and/or modify it under
13+
the terms of GNU General Public License v3 or any other later versions.
14+
15+
phasicFlow is distributed to help others in their research in the field of
16+
granular and multiphase flows, but WITHOUT ANY WARRANTY; without even the
17+
implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
18+
19+
-----------------------------------------------------------------------------*/
20+
#ifndef __processorBoundaryContactSearch_hpp__
21+
#define __processorBoundaryContactSearch_hpp__
22+
23+
#include "boundaryContactSearch.hpp"
24+
#include "pointFields.hpp"
25+
#include "twoPartContactSearch.hpp"
26+
27+
namespace pFlow
28+
{
29+
30+
class processorBoundaryContactSearch : public boundaryContactSearch
31+
{
32+
private:
33+
34+
box searchBox_;
35+
36+
uniquePtr<twoPartContactSearch> ppContactSearch_ = nullptr;
37+
38+
const realPointField_D& diameter_;
39+
40+
bool masterSearch_;
41+
42+
real sizeRatio_;
43+
44+
void setSearchBox();
45+
46+
public:
47+
48+
TypeInfo("boundaryContactSearch<MPI,processor>")
49+
50+
processorBoundaryContactSearch(
51+
const dictionary& dict,
52+
const boundaryBase& boundary,
53+
const contactSearch& cSearch
54+
);
55+
56+
~processorBoundaryContactSearch() override = default;
57+
58+
add_vCtor(
59+
boundaryContactSearch,
60+
processorBoundaryContactSearch,
61+
boundaryBase
62+
);
63+
64+
bool broadSearch(
65+
uint32 iter,
66+
real t,
67+
real dt,
68+
csPairContainerType& ppPairs,
69+
csPairContainerType& pwPairs,
70+
bool force = false
71+
) override;
72+
};
73+
74+
}
75+
76+
#endif //__processorBoundaryContactSearch_hpp__

0 commit comments

Comments
 (0)