CFD Online Discussion Forums

CFD Online Discussion Forums (http://www.cfd-online.com/Forums/)
-   OpenFOAM Programming & Development (http://www.cfd-online.com/Forums/openfoam-programming-development/)
-   -   Coupling velocity between two mesh regions (http://www.cfd-online.com/Forums/openfoam-programming-development/121071-coupling-velocity-between-two-mesh-regions.html)

haze_1986 July 21, 2013 01:52

Coupling velocity between two mesh regions
 
Hi all, I am getting stuck with 2 way couple between two different solvers on different meshes and one of the face from each mesh I am require to match their velocities at the boundaries at the start of every timestep. I am not adept in programming so would appreciate if anyone could point me in the right direction to read up and carry on from here.

Thanks in advanced.

haze_1986 July 21, 2013 23:38

I have confirmed that
Code:

vectorField nFPatchVelocity =
        interpolatorFN.faceInterpolate
        (
            U.boundaryField()[fFPatchID]
        );

produces something that varies with time and at one timestep, I have this
20
(
(0.0885345 -6.79536e-08 0)
(0.0885345 -6.79536e-08 0)
(0.0885345 -6.79536e-08 0)
(0.0885345 -6.79536e-08 0)
(0.0885345 -6.79536e-08 0)
(0.0885345 -6.79536e-08 0)
(0.0885345 -6.79536e-08 0)
(0.0885345 -6.79536e-08 0)
(0.0885345 -6.79536e-08 0)
(0.0885345 -6.79536e-08 0)
(0 0 0)
(0 0 0)
(0 0 0)
(0 0 0)
(0 0 0)
(0 0 0)
(0 0 0)
(0 0 0)
(0 0 0)
(0 0 0)
)

I am required to put these dynamic values as boundary condtions to the second part of the solver. I am not sure what I should include for my 0/U file
inlet
{
type ?
value ?
}

Would groovyBC fix this or I need some other methods? Please advise, thanks.

ARTem July 22, 2013 06:48

Hi, haze_1986.
Yes, groovyBC will do the trick.
I don't know all of opportunities of groovy, I just tell you the way I would do it.

So, we need 3 fields:
U_source (mesh1), U_dependent(mesh2), U_helper(mesh2).
U_source will be as you like it to be.

U_dependent will use groovyBC type at boundary:
Code:

        type                  groovyBC;
        valueExpression        "U_helper";

U_helper goes with calculated type with some value:
Code:

        type          calculated;
        value        uniform (0 0 0);

Next, go to code. After computing U_source we should put it boundary values to U_helper.
Actually, I don't know will or will not numeration of patch faces be the same, so I will use robust method.

Code:

label transBC1 = 0; // number of transition boundary in mesh1
label transBC2 = 1; // number of transition boundary in mesh2; number is taken for example
forAll(mesh1.boundary()[transBC1]; facei1)
{
  forAll(mesh1.boundary()[transBC2]; facei2)
  {
    // If we are talking about same point in space
    if( mag(mesh1.C().boundaryField()[transBC1][facei1] -
              mesh2.C().boundaryField()[transBC2][facei2]) < SMALL)
    {
          U_helper.boundaryField()[transBC2][facei2] = U_source.boundaryField()[transBC1][facei1];
    }
  }
}

Of course, you can minimize cycles by creating labelList containing once computed indexes. If you want I will show you how to do that.


All times are GMT -4. The time now is 05:18.