Skip to content

Small offset when reading gradients (fluid-fluid coupling specific) #93

@MakisH

Description

@MakisH

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.

error

We currently suspect a technical problem in the way we read and write gradients, or some other numerical issue.

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.

Metadata

Metadata

Assignees

No one assigned

    Labels

    FFFluid-fluid couplingbugUnexpected problems (crashes, numerical issues, etc)

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions