-
-
Notifications
You must be signed in to change notification settings - Fork 106
Small offset when reading gradients (fluid-fluid coupling specific) #93
Description
As presented in the 14th OpenFOAM Conference, when reading gradients we end up with a minor increase in the respective quantity.
We observed this in fluid-fluid coupling (see #60) when coupling {pressure} with {velocity, pressure gradient} and using a coarse mesh. However, this problem also appears in CHT cases (reading heat flux), but we hadn't noticed until now since we are always using very fine meshes there.
In the following figure you can see this error when coupling gradients. When coupling only velocity and pressure, this problem does not appear, although we still get an oscillation around the interface.
We currently suspect a technical problem in the way we read and write gradients, or some other numerical issue.
openfoam-adapter/FF/PressureGradient.C
Lines 21 to 75 in 857f18c
| void preciceAdapter::FF::PressureGradient::write(double * buffer) | |
| { | |
| 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<fixedValueFvPatchScalarField> | |
| ( | |
| p_->boundaryFieldRef()[patchID] | |
| ).snGrad(); | |
| // For every cell of the patch | |
| forAll(gradientPatch, i) | |
| { | |
| // Copy the pressure gradient into the buffer | |
| buffer[bufferIndex++] | |
| = | |
| -gradientPatch[i]; | |
| } | |
| } | |
| } | |
| void preciceAdapter::FF::PressureGradient::read(double * buffer) | |
| { | |
| 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++]; | |
| } | |
| } | |
| } |
You can try this in our pipe-pipe tutorial.
