-
-
Notifications
You must be signed in to change notification settings - Fork 88
/
Copy pathTemperatureGradient.C
73 lines (61 loc) · 2.02 KB
/
TemperatureGradient.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
73
#include "TemperatureGradient.H"
#include "mixedFvPatchFields.H"
using namespace Foam;
preciceAdapter::FF::TemperatureGradient::TemperatureGradient(
const Foam::fvMesh& mesh,
const std::string nameT)
: T_(
const_cast<volScalarField*>(
&mesh.lookupObject<volScalarField>(nameT)))
{
dataType_ = scalar;
}
std::size_t preciceAdapter::FF::TemperatureGradient::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 Temperature gradient boundary patch
const scalarField gradientPatch((T_->boundaryFieldRef()[patchID])
.snGrad());
// For every cell of the patch
forAll(gradientPatch, i)
{
// Copy the Temperature gradient into the buffer
buffer[bufferIndex++] =
gradientPatch[i];
}
}
return bufferIndex;
}
void preciceAdapter::FF::TemperatureGradient::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 Temperature gradient boundary patch
scalarField& gradientPatch =
refCast<fixedGradientFvPatchScalarField>(
T_->boundaryFieldRef()[patchID])
.gradient();
// For every cell of the patch
forAll(gradientPatch, i)
{
// Set the Temperature gradient as the buffer value
gradientPatch[i] =
-buffer[bufferIndex++];
}
}
}
bool preciceAdapter::FF::TemperatureGradient::isLocationTypeSupported(const bool meshConnectivity) const
{
return (this->locationType_ == LocationType::faceCenters);
}
std::string preciceAdapter::FF::TemperatureGradient::getDataName() const
{
return "TemperatureGradient";
}