-
-
Notifications
You must be signed in to change notification settings - Fork 88
/
Copy pathPressureGradient.C
72 lines (60 loc) · 1.96 KB
/
PressureGradient.C
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
#include "PressureGradient.H"
using namespace Foam;
preciceAdapter::FF::PressureGradient::PressureGradient(
const Foam::fvMesh& mesh,
const std::string nameP)
: p_(
const_cast<volScalarField*>(
&mesh.lookupObject<volScalarField>(nameP)))
{
dataType_ = scalar;
}
std::size_t preciceAdapter::FF::PressureGradient::write(double* buffer, bool meshConnectivity, const unsigned int dim)
{
int bufferIndex = 0;
// For every boundary patch of the interface
for (uint j = 0; j < patchIDs_.size(); j++)
{
int patchID = patchIDs_.at(j);
// Get the pressure gradient boundary patch
const scalarField gradientPatch((p_->boundaryFieldRef()[patchID])
.snGrad());
// For every cell of the patch
forAll(gradientPatch, i)
{
// Copy the pressure gradient into the buffer
buffer[bufferIndex++] =
-gradientPatch[i];
}
}
return bufferIndex;
}
void preciceAdapter::FF::PressureGradient::read(double* buffer, const unsigned int dim)
{
int bufferIndex = 0;
// For every boundary patch of the interface
for (uint j = 0; j < patchIDs_.size(); j++)
{
int patchID = patchIDs_.at(j);
// Get the pressure gradient boundary patch
scalarField& gradientPatch =
refCast<fixedGradientFvPatchScalarField>(
p_->boundaryFieldRef()[patchID])
.gradient();
// For every cell of the patch
forAll(gradientPatch, i)
{
// Set the pressure gradient as the buffer value
gradientPatch[i] =
buffer[bufferIndex++];
}
}
}
bool preciceAdapter::FF::PressureGradient::isLocationTypeSupported(const bool meshConnectivity) const
{
return (this->locationType_ == LocationType::faceCenters);
}
std::string preciceAdapter::FF::PressureGradient::getDataName() const
{
return "PressureGradient";
}