Skip to content

Commit 3d0f31a

Browse files
Merge pull request #3 from hamidrezanorouzi/MPIdev
Mp idev
2 parents 74c2816 + ba8f307 commit 3d0f31a

48 files changed

Lines changed: 1485 additions & 268 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.
Lines changed: 63 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,63 @@
1+
2+
3+
#ifndef __AB2Kernels_hpp__
4+
#define __AB2Kernels_hpp__
5+
6+
#include "KokkosTypes.hpp"
7+
#include "types.hpp"
8+
9+
namespace pFlow::AB2Kernels
10+
{
11+
inline
12+
bool intAllActive(
13+
const word& name,
14+
real dt,
15+
rangeU32 activeRng,
16+
const deviceViewType1D<realx3>& y,
17+
const deviceViewType1D<realx3>& dy,
18+
const deviceViewType1D<realx3>& dy1
19+
)
20+
{
21+
Kokkos::parallel_for(
22+
name,
23+
deviceRPolicyStatic (activeRng.start(), activeRng.end()),
24+
LAMBDA_HD(uint32 i){
25+
y[i] += dt*(static_cast<real>(1.5) * dy[i] - static_cast<real>(0.5) * dy1[i]);
26+
dy1[i] = dy[i];
27+
});
28+
Kokkos::fence();
29+
30+
return true;
31+
}
32+
33+
inline
34+
bool intScattered
35+
(
36+
const word& name,
37+
real dt,
38+
const pFlagTypeDevice& activePoints,
39+
const deviceViewType1D<realx3>& y,
40+
const deviceViewType1D<realx3>& dy,
41+
const deviceViewType1D<realx3>& dy1
42+
)
43+
{
44+
45+
Kokkos::parallel_for(
46+
name,
47+
deviceRPolicyStatic (activePoints.activeRange().start(), activePoints.activeRange().end()),
48+
LAMBDA_HD(uint32 i){
49+
if( activePoints(i))
50+
{
51+
y[i] += dt*(static_cast<real>(1.5) * dy[i] - static_cast<real>(0.5) * dy1[i]);
52+
dy1[i] = dy[i];
53+
}
54+
});
55+
Kokkos::fence();
56+
57+
58+
return true;
59+
}
60+
61+
}
62+
63+
#endif
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: 55 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,55 @@
1+
#include "boundaryIntegration.hpp"
2+
#include "pointStructure.hpp"
3+
4+
5+
pFlow::boundaryIntegration::boundaryIntegration(
6+
const boundaryBase &boundary,
7+
const pointStructure &pStruct,
8+
const word &method,
9+
integration& intgrtn
10+
)
11+
:
12+
generalBoundary(boundary, pStruct, "", method),
13+
integration_(intgrtn)
14+
{}
15+
16+
pFlow::uniquePtr<pFlow::boundaryIntegration> pFlow::boundaryIntegration::create(
17+
const boundaryBase &boundary,
18+
const pointStructure &pStruct,
19+
const word &method,
20+
integration& intgrtn
21+
)
22+
{
23+
24+
word bType = angleBracketsNames2(
25+
"boundaryIntegration",
26+
boundary.type(),
27+
method);
28+
29+
word altBType{"boundaryIntegration<none>"};
30+
31+
if( boundaryBasevCtorSelector_.search(bType) )
32+
{
33+
pOutput.space(4)<<"Creating boundary "<< Green_Text(bType)<<
34+
" for "<<boundary.name()<<endl;
35+
return boundaryBasevCtorSelector_[bType](boundary, pStruct, method, intgrtn);
36+
}
37+
else if(boundaryBasevCtorSelector_.search(altBType))
38+
{
39+
pOutput.space(4)<<"Creating boundary "<< Green_Text(altBType)<<
40+
" for "<<boundary.name()<<endl;
41+
return boundaryBasevCtorSelector_[altBType](boundary, pStruct, method, intgrtn);
42+
}
43+
else
44+
{
45+
printKeys(
46+
fatalError << "Ctor Selector "<< bType<<
47+
" and "<< altBType << " do not exist. \n"
48+
<<"Avaiable ones are: \n",
49+
boundaryBasevCtorSelector_
50+
);
51+
fatalExit;
52+
}
53+
54+
return nullptr;
55+
}
Lines changed: 91 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,91 @@
1+
2+
#ifndef __boundaryIntegration_hpp__
3+
#define __boundaryIntegration_hpp__
4+
5+
6+
#include "generalBoundary.hpp"
7+
#include "virtualConstructor.hpp"
8+
#include "pointFields.hpp"
9+
10+
namespace pFlow
11+
{
12+
13+
class integration;
14+
15+
class boundaryIntegration
16+
:
17+
public generalBoundary
18+
{
19+
private:
20+
21+
const integration& integration_;
22+
23+
public:
24+
25+
TypeInfo("boundaryIntegration<none>");
26+
27+
boundaryIntegration(
28+
const boundaryBase& boundary,
29+
const pointStructure& pStruct,
30+
const word& method,
31+
integration& intgrtn);
32+
33+
~boundaryIntegration()override = default;
34+
35+
create_vCtor(
36+
boundaryIntegration,
37+
boundaryBase,
38+
(
39+
const boundaryBase& boundary,
40+
const pointStructure& pStruct,
41+
const word& method,
42+
integration& intgrtn
43+
),
44+
(boundary, pStruct, method, intgrtn)
45+
);
46+
47+
add_vCtor(
48+
boundaryIntegration,
49+
boundaryIntegration,
50+
boundaryBase
51+
);
52+
53+
bool hearChanges(
54+
real t,
55+
real dt,
56+
uint32 iter,
57+
const message &msg,
58+
const anyList &varList) override
59+
{
60+
return true;
61+
}
62+
63+
const integration& Integration()const
64+
{
65+
return integration_;
66+
}
67+
68+
virtual
69+
bool correct(real dt, const realx3PointField_D& y, const realx3PointField_D& dy)
70+
{
71+
return true;
72+
}
73+
74+
virtual
75+
bool correctPStruct(real dt, const realx3PointField_D& vel)
76+
{
77+
return true;
78+
}
79+
80+
static
81+
uniquePtr<boundaryIntegration> create(
82+
const boundaryBase& boundary,
83+
const pointStructure& pStruct,
84+
const word& method,
85+
integration& intgrtn);
86+
87+
};
88+
89+
}
90+
91+
#endif
Lines changed: 41 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,41 @@
1+
#include "boundaryIntegrationList.hpp"
2+
#include "integration.hpp"
3+
4+
pFlow::boundaryIntegrationList::boundaryIntegrationList(
5+
const pointStructure &pStruct,
6+
const word &method,
7+
integration &intgrtn
8+
)
9+
:
10+
ListPtr<boundaryIntegration>(6),
11+
boundaries_(pStruct.boundaries())
12+
{
13+
14+
for(uint32 i=0; i<6; i++)
15+
{
16+
this->set(
17+
i,
18+
boundaryIntegration::create(
19+
boundaries_[i],
20+
pStruct,
21+
method,
22+
intgrtn
23+
)
24+
);
25+
}
26+
27+
}
28+
29+
bool pFlow::boundaryIntegrationList::correct(real dt, realx3PointField_D &y, realx3PointField_D &dy)
30+
{
31+
for(auto& bndry:*this)
32+
{
33+
if(!bndry->correct(dt, y, dy))
34+
{
35+
fatalErrorInFunction;
36+
return false;
37+
}
38+
39+
}
40+
return true;
41+
}

0 commit comments

Comments
 (0)