CFD Online Discussion Forums

CFD Online Discussion Forums (https://www.cfd-online.com/Forums/)
-   OpenFOAM Programming & Development (https://www.cfd-online.com/Forums/openfoam-programming-development/)
-   -   BC which interpolate from an existing solution (https://www.cfd-online.com/Forums/openfoam-programming-development/118825-bc-interpolate-existing-solution.html)

Sylv June 5, 2013 04:59

BC which interpolate from an existing solution
 
Dear foamer,

I try to create a boundary condition which interpolate the volumic velocity field of an existing case (sourceCase) to the inlet patch of a running case (runCase).

To do this, I use the interpolate static method include in surfaceInterpolation.H.

Here is a piece of code included in the "updateCoeff" member function of my boundary:
Code:

fileName sourceRootDir = "path/to/source";
fileName sourceCaseDir = "sourceCase";
fileName sourceTime = "1000";

Time runTimeSource
    (
        Time::controlDictName,
        sourceRootDir,
        sourceCaseDir
    );
fvMesh meshSource
    (
        IOobject
        (
            sourceRegion,
            runTimeSource.timeName(),
            runTimeSource
        )
    );
volVectorField Usource
    (
        IOobject
        (
            "U",
            sourceTime,
            meshSource,
            IOobject::MUST_READ,
            IOobject::NO_WRITE
        ),
        meshSource
    );

// do the interpolation
operator==(fvc::interpolate(Usource));
fixedValueFvPatchField<vector>::updateCoeffs();

The code compiles properly but during the solver run, I have the following message:
Code:

--> FOAM FATAL IO ERROR:
keyword interpolate(U) is undefined in dictionary "/path/to/source/sourceCase/system/fvSchemes.interpolationSchemes"

file: /path/to/source/sourceCase/system/fvSchemes.interpolationSchemes

    From function dictionary::lookupEntry(const word&, bool, bool) const
    in file db/dictionary/dictionary.C at line 402.

FOAM exiting

This error appears even if the line "interpolate(U) linear" is included in fvSchemes like this:
Code:

interpolationSchemes
{
    interpolate(U)  linear;
}

Should I load fvSchemes with an IOobject? Is there a way to know if my boundary reads properly the fvSchemes file included in the source case?

Anne Lincke July 10, 2013 06:06

Dear Marcel,
I have the same problem, did you find a solution?

Kind Regards
Anne

Sylv July 11, 2013 05:14

Quote:

Originally Posted by Anne Lincke (Post 438889)
Dear Marcel,
I have the same problem, did you find a solution?

Kind Regards
Anne

Hello Anne,

I fixed the error "interpolate(U)" by just adding one line in the IOobject of meshSource
Code:

fvMesh meshSource
    (
        IOobject
        (
            sourceRegion,
            runTimeSource.timeName(),
            runTimeSource,
            IOobject::MUST_READ  //this makes all the difference...
        )
    );

Now the solver runs, but the interpolation is still wrong. Lets assume my source simulation has 1000 cells and my target simulation 500 cells and 100 faces at inlet. When I run the target case with my new boundary condition, the target U file has 1000 values for the inlet, not 100! Somehow, there is no interpolation, just a transfer of the source cell values into the inlet face values of the target :confused:.

In the meantime, I used a different approach, but let me know if you have a working boundary!

Cheers,
Marcel


All times are GMT -4. The time now is 10:38.