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/)
-   -   Custom Boundary Condition with OpenFOAM (https://www.cfd-online.com/Forums/openfoam-programming-development/72434-custom-boundary-condition-openfoam.html)

ChrisWe April 17, 2015 05:37

Hi FOAMers,

I want to implement a new BC in OpenFOAM, based on the "mapped" BC which is used in the pitzDailyMapped tutorial.

To start, I use the "mapped" BC from:
PHP Code:

     .../OpenFOAM-2.3.0/src/finiteVolume/fvMesh/fvPatches/derived/mapped 

and copy the mappedFvPatch.C and mappedFvPatch.H to:
PHP Code:

     .../user-2.3.0/src/finiteVolume/fvMesh/fvPatches/derived/mapped 

After renaming the files to chrismappedFvPatch.C and chrismappedFvPatch.H, I replaced all "mapped"-commands by "chrismapped" in both files (for example "mappedFvPatch.H" by "chrismappedFvPatch.H") and created a Make/files file:

Code:

chrismappedFvPatch.C

LIB = $(FOAM_USER_LIBBIN)/libchrismapped

and a Make/options file:
Code:

EXE_INC = \
-I$(LIB_SRC)/finiteVolume/lnInclude \
-I$(LIB_SRC)/meshTools/lnInclude

EXE_LIBS =

Compiling my new BC with "wmake libso" does not show any errors.


After copying the pitzDailyMapped tutorial to my run-folder, I changed the boundaryField in 0/U to:

Code:

...
inlet
    {
        type                chrismapped; //instead of "mapped";
        value              uniform (10 0 0);
        interpolationScheme cell;
        setAverage          true;
        average            (10 0 0);
    }
...

The settings in the blockMeshDict are kept unchanged:

Code:

...
boundary
(
    inlet
    {
        type mappedPatch;      //no change
        offset          ( 0.0495 0 0 );
        sampleRegion    region0;
        sampleMode      nearestCell;
        samplePatch    none;

        faces
        (
            (0 22 23 1)
            (1 23 24 2)
            (2 24 25 3)
        );
    }
...

and in the controlDict file I added the

Code:

libs ("libchrismapped.so");
command.

Running the case with pisoFoam, OF shows Fatal IO ERROR

Code:

...
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
Create time

Duplicate entry mappedPatch in runtime selection table fvPatch
...

Reading field U

--> FOAM FATAL IO ERROR:
Unknown patchField type chrismapped for patch type mappedPatch

Valid patchField types are :
...

When I change mappedPatch in the blockMeshDict to chrismappedPatch

Code:

...
boundary
(
    inlet
    {
        type chrismappedPatch;      //instead of mappedPatch
        offset          ( 0.0495 0 0 );
        sampleRegion    region0;
        sampleMode      nearestCell;
        samplePatch    none;

        faces
        (
            (0 22 23 1)
            (1 23 24 2)
            (2 24 25 3)
        );
    }
...

I get the following error

Code:

...
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
Create time

Duplicate entry mappedPatch in runtime selection table fvPatch
...

--> FOAM FATAL IO ERROR:
Unknown patchField type chrismapped for patch type genericPatch

Is there anybody who knows where my problem is? The described method for customizing BCs worked perfect for the parabolicVelocity type.

Thank you,
Christoph

--------------------------------------------------------------------------------------------------------------------------------------------
SOLVED:

You have to change the name of the BC in the header file to:

TypeName("chrismapped");

Then everything is working fine!

bassamdjedi April 18, 2015 17:33

I am doing simulation using open-foam on 2D aerofoil. I used komega model and put all boundary conditions and started the simulation. However, at Time= 26 i receive an error, I hope i can get help with this issue.
Thank you
#0 Foam::error::printStack(Foam::Ostream&) at ??:?
#1 Foam::sigFpe::sigHandler(int) at ??:?
#2 in "/lib/x86_64-linux-gnu/libc.so.6"
#3 Foam::GaussSeidelSmoother::smooth(Foam::word const&, Foam::Field<double>&, Foam::lduMatrix const&, Foam::Field<double> const&, Foam::FieldField<Foam::Field, double> const&, Foam::UPtrList<Foam::lduInterfaceField const> const&, unsigned char, int) at ??:?
#4 Foam::GaussSeidelSmoother::smooth(Foam::Field<doub le>&, Foam::Field<double> const&, unsigned char, int) const at ??:?
#5 Foam::smoothSolver::solve(Foam::Field<double>&, Foam::Field<double> const&, unsigned char) const at ??:?
#6 Foam::fvMatrix<double>::solveSegregated(Foam::dict ionary const&) at ??:?
#7 Foam::fvMatrix<double>::solve(Foam::dictionary const&) at ??:?
#8 Foam::SolverPerformance<double> Foam::solve<double>(Foam::tmp<Foam::fvMatrix<doubl e> > const&) at ??:?
#9 Foam::incompressible::RASModels::kOmega::correct() at ??:?
#10
at ??:?
#11 __libc_start_main in "/lib/x86_64-linux-gnu/libc.so.6"
#12
at ??:?
Floating point exception (core dumped)

shrawasti sahare May 29, 2016 12:50

hi sean,

after compilation my new BC is not recognised by solver. i have input relevant lines referring to newly created shared object library. But still new BC is not recognised.

can you help please?

thanks

gouravjee January 16, 2018 05:12

Hii everyone
I am making a new custom boundary condition and i am getting following error can anyone suggest where do i need to modify the code?




"ill defined primitiveEntry starting at keyword 'libs(' on line 48 and ending at line 77"

file: /home/gourav/OpenFOAM/gourav-4.1/run/mode_two_temperature/system/controlDict at line 77.

From function void Foam::primitiveEntry::readEntry(const Foam::dictionary&, Foam::Istream&)
in file db/dictionary/primitiveEntry/primitiveEntryIO.C at line 189.

FOAM exiting

mv: cannot stat '/polyMesh': No such file or directory
rm: cannot remove '[1-9]*': No such file or directory
Running darcyTemperatureFoam on /home/gourav/OpenFOAM/gourav-4.1/run/mode_two_temperature







Here is my ControlDictfile code::

/*--------------------------------*- C++ -*----------------------------------*\
| ========= | |
| \\ / F ield | OpenFOAM: The Open Source CFD Toolbox |
| \\ / O peration | Version: 2.3.0 |
| \\ / A nd | Web: www.OpenFOAM.org |
| \\/ M anipulation | |
\*---------------------------------------------------------------------------*/
FoamFile
{
version 2.0;
format ascii;
class dictionary;
location "system";
object controlDict;
}
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //

application darcyTemperatureFoam;

startFrom latestTime;

startTime 0;

stopAt endTime;

endTime 600;

deltaT 10;

writeControl runTime;

writeInterval 5;

purgeWrite 0;

writeFormat ascii;

writePrecision 6;

writeCompression off;

timeFormat general;

timePrecision 6;

runTimeModifiable true;

libs("ldarcyGradPressure.so");

functions
{
probes
{
type probes;
functionObjectLibs ("libsampling.so");
enabled true;
writeControl timeStep;
writeInterval 1;

fields
(
Ts
Tf
);

probeLocations
(
( 2 0.05 0.05) // Probe 1
( 5 0.05 0.05) // Probe 2
( 9 0.05 0.05) // Probe 3
);
}
}

// ************************************************** *********************** //

marupio January 16, 2018 22:39

You need a space between 'libs' and '('.

Pavithra October 11, 2019 04:04

Hello Everyone,

I want to implement the following boundary condition on the horizontal walls of a 2-D square cavity.

\beta \frac{du_x}{dy} = (1-\beta)u_x


u_y = 0

The value of \beta varies from 0 to 1 in steps of 0.25.

I understand that when \beta = 0, the boundary condition becomes u_x = 0 and u_y = 0.

Also, when \beta = 1, the boundary condition becomes \frac{du_x}{dy} = 0 and u_y = 0.

I am able to achieve the above two cases using directionMixed boundary condition.

But I am unable to figure out how to set the boundary condition when \beta takes a value such as 0.25, 0.5 or 0.75.

For instance, when \beta = 0.25, it becomes \frac{du_x}{dy}=3u_x.

Kindly please give me some directions to implement this boundary condition.

Thank You.

With Thanks
Pavithra.


All times are GMT -4. The time now is 21:45.