CFD Online Discussion Forums

CFD Online Discussion Forums (https://www.cfd-online.com/Forums/)
-   OpenFOAM Running, Solving & CFD (https://www.cfd-online.com/Forums/openfoam-solving/)
-   -   twoPhaseEulerFoam BC calculated from wall shear and alpha (https://www.cfd-online.com/Forums/openfoam-solving/142652-twophaseeulerfoam-bc-calculated-wall-shear-alpha.html)

potac October 6, 2014 08:08

twoPhaseEulerFoam BC calculated from wall shear and alpha
 
I would like to define point-wise mesh deformation boundary condition for my dynamic mesh twoPhaseEulerFoam (OF 2.3) where the mesh displacement is calculated from values of concentration at cells adjacent to the wall and wall shear stress. For simplification, let's say the displacements = alpha*tau.
I have found angularOscillatingDisplacement source code to be probably suitable template to introduce my variables in.
Firstly, I have focused on calculation of wall shear stress. I found discussion on correcting the calculation of wall shear stress
Since my C++ knowledge is limited, I have been struggling to implement the code to obtain the shear stress. So far, I have started with code below but not sure it is the right start.
Code:

void surfaceDisplacementPointPatchVectorField::updateCoeffs()
{
    if (this->updated())
    {
        return;
    }
// * * * * * * * * * * * * * * * Wall shear  * * * * * * * * * * * * * //
   
    const fvMesh& mesh,
    const Time& runTime,
    const volVectorField& U,
    volVectorField& shear2,
    volVectorField& wallShearStress,
    volVectorField& nn
   
    #include "createPhi.H"

    singlePhaseTransportModel laminarTransport(U, phi);

    autoPtr<incompressible::RASModel> model
    (
        incompressible::RASModel::New(U, phi, laminarTransport)
    );

    const volSymmTensorField Reff(model->devReff());

    forAll(wallShearStress.boundaryField(), patchI)
    {
        wallShearStress.boundaryField()[patchI] =
        (
          -mesh.Sf().boundaryField()[patchI]
          /mesh.magSf().boundaryField()[patchI]
        ) & Reff.boundaryField()[patchI];
    }

    forAll(nn.boundaryField(), patchI)
    {
        nn.boundaryField()[patchI] =
          -mesh.Sf().boundaryField()[patchI]
          /mesh.magSf().boundaryField()[patchI];
    }

    forAll(shear2.boundaryField(), patchI)
    {
        shear2.boundaryField()[patchI]=wallShearStress.boundaryField()[patchI]-(wallShearStress.boundaryField()[patchI] &
        nn.boundaryField()[patchI])*nn.boundaryField()[patchI];
    }
   
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
    const polyMesh& mesh = this->dimensionedInternalField().mesh()();
    const Time& t = mesh.time();

    scalar angle = angle0_ + amplitude_*sin(omega_*t.value());
    vector axisHat = axis_/mag(axis_);
    vectorField p0Rel(p0_ - origin_);

    vectorField::operator=
    (
        p0Rel*(cos(angle) - 1)
      + (axisHat ^ p0Rel*sin(angle))
      + (axisHat & p0Rel)*(1 - cos(angle))*axisHat
    );

    fixedValuePointPatchField<vector>::updateCoeffs();
}

In next step, I would like to call boundary field alpha. But cannot find an example easy to follow and getting lost in code lines.
Any suggestions and hints would be helpful.
J.


All times are GMT -4. The time now is 08:30.