CFD Online Logo CFD Online URL
www.cfd-online.com
[Sponsors]
Home > Forums > Software User Forums > OpenFOAM > OpenFOAM Programming & Development

Time-varying boundary condition

Register Blogs Community New Posts Updated Threads Search

Like Tree17Likes

Reply
 
LinkBack Thread Tools Search this Thread Display Modes
Old   October 5, 2014, 21:28
Lightbulb
  #1
Senior Member
 
maysmech's Avatar
 
Join Date: Jan 2010
Posts: 347
Blog Entries: 2
Rep Power: 17
maysmech is on a distinguished road
Hello
I need varying BC for interstitialInletVelocity which can be found in DPMFoam/Goldschemidt. Using table for fixed value:
Code:
    
bottom
{
    type uniformFixedValue;
    uniformValue table
    (
        (0 (0 0 1))
        (0.001 (0 0 2))
        (0.002 (0 0 3))
        (0.003 (0 0 4))
    );
    }
the run starts without error. But for interstitialInletVelocity"
The default is:
Code:
    bottom
    {
        type            interstitialInletVelocity;
        inletVelocity   uniform (0 0 1);
        value           uniform (0 0 1);
        phi             phi.air;
        alpha           alpha.air;
    }
trying to time varying it by:
Code:
    bottomSB
    {
        type            interstitialInletVelocity;
        inletVelocity   uniformFixedValue;
    uniformValue table
(
        (0 (0 0 1))
        (0.001 (0 0 2))
        (0.002 (0 0 3))
        (0.003 (0 0 4))
);

        value           table
(
        (0 (0 0 1))
        (0.001 (0 0 2))
        (0.002 (0 0 3))
        (0.003 (0 0 4))
); 
        phi             phi.air;
        alpha           alpha.air;
    }
gives this error:
Code:
--> FOAM FATAL IO ERROR: 
expected keyword 'uniform' or 'nonuniform', found table

file: /home/user/OpenFOAM/user-2.3.0/run/tutorials/lagrangian/DPMFoam/test/0/U.air.boundaryField.bottom from line 52 to line 70.

    From function Field<Type>::Field(const word& keyword, const dictionary&, const label)
    in file /home/user/OpenFOAM/OpenFOAM-2.3.0/src/OpenFOAM/lnInclude/Field.C at line 304.

FOAM exiting
Change of second "table" to "nonuniform" also gives error:
Code:
--> FOAM FATAL IO ERROR: 
wrong token type - expected Scalar, found on line 64 the punctuation token '('

file: /home/user/OpenFOAM/user-2.3.0/run/tutorials/lagrangian/DPMFoam/test/0/U.air.boundaryField.bottom.value at line 64.

    From function operator>>(Istream&, Scalar&)
    in file lnInclude/Scalar.C at line 93.

FOAM exiting
I checked other changes by "Banana" trick debugging but it doesn't work. This boundary condition is suitable for two phase flows because It consider the inlet porosity so we will sure about fixed value of inlet flow rate. It is not possible to use simple fixed value BC and should use interstitialInletVelocity instead. If anyone know about time varying this BC please share here.
Best,
maysmech is offline   Reply With Quote

Old   October 12, 2014, 12:47
Default
  #2
Retired Super Moderator
 
Bruno Santos
Join Date: Mar 2009
Location: Lisbon, Portugal
Posts: 10,975
Blog Entries: 45
Rep Power: 128
wyldckat is a name known to allwyldckat is a name known to allwyldckat is a name known to allwyldckat is a name known to allwyldckat is a name known to allwyldckat is a name known to all
Greetings to all!

@Maysam: Unfortunately I don't have enough time to give the whole solution, but I think I can still give information on why that didn't work and what can be done to fix the problem.

  1. "uniformFixedValue" is a special boundary condition, derived from "fixedValue". This is the reason why it's possible to use it to define values based on tables and polynomials and so on: http://www.openfoam.org/version2.1.0...conditions.php - and as explained on that page, this feature is possible thanks to another new feature they added in OpenFOAM 2.1.0, namely the "DataEntry" class.
  2. "interstitialInletVelocity" is similar to "fixedValue". Which is why it's not able to handle the time-based tables.
  3. The solution is to create a new boundary condition derived from "interstitialInletVelocity", almost the same way that "uniformFixedValue" is derived from "fixedValue". Online you can find the source code folders for these 3 BCs (in OpenFOAM 2.3.x):
  4. Instructions on how to create a new BC... there are several online... just Google:
    Code:
    openfoam create new boundary condition
    and you'll find several links.
Best regards,
Bruno
Chanikya_Valeti likes this.
__________________
wyldckat is offline   Reply With Quote

Old   October 12, 2014, 23:04
Question
  #3
Senior Member
 
maysmech's Avatar
 
Join Date: Jan 2010
Posts: 347
Blog Entries: 2
Rep Power: 17
maysmech is on a distinguished road
Thanks Bruno, Do you know what is the difference between "inletVelocity" and "value" in this BC?
fixedValue and uniformFixedValue value need one velocity but this on needs two.
maysmech is offline   Reply With Quote

Old   October 18, 2014, 14:55
Default
  #4
Retired Super Moderator
 
Bruno Santos
Join Date: Mar 2009
Location: Lisbon, Portugal
Posts: 10,975
Blog Entries: 45
Rep Power: 128
wyldckat is a name known to allwyldckat is a name known to allwyldckat is a name known to allwyldckat is a name known to allwyldckat is a name known to allwyldckat is a name known to all
Hi Maysam,

Quote:
Originally Posted by maysmech View Post
Do you know what is the difference between "inletVelocity" and "value" in this BC?
If you learn a bit about C++ and reading OpenFOAM source code, you could easily see the following details:
  1. If you look at the file "src/finiteVolume/fields/fvPatchFields/derived/interstitialInletVelocity/interstitialInletVelocityFvPatchVectorField.C": https://github.com/OpenFOAM/OpenFOAM...hVectorField.C
  2. Then look at this part of the code in that file:
    Quote:
    Code:
    void Foam::interstitialInletVelocityFvPatchVectorField::updateCoeffs()
    {
        if (updated())
        {
            return;
        }
    
        const fvPatchField<scalar>& alphap =
            patch().lookupPatchField<volScalarField, scalar>(alphaName_);
    
        operator==(inletVelocity_/alphap);
        fixedValueFvPatchVectorField::updateCoeffs();
    }
  3. You'll see that the "value" field isn't directly used during the simulation. In fact, the value in "value" should be the result of "inletVelocity_/alphap"... therefore, "value" acts as the current representation of the velocity field for the current time instance or iteration.
  4. "inletVelocity" is the actual desired velocity for this inlet
Best regards,
Bruno
enthusiast likes this.
__________________
wyldckat is offline   Reply With Quote

Old   October 19, 2014, 01:06
Default
  #5
Senior Member
 
maysmech's Avatar
 
Join Date: Jan 2010
Posts: 347
Blog Entries: 2
Rep Power: 17
maysmech is on a distinguished road
Hi Bruno,
I know the difference between u and U, the actual and superficial velocity with relation of U=alpha*u.
This is the main advantage of "interstitialInletVelocity" to "fixedValue" and "uniformFixedaValue". My question was about why there are two entries in 0/U.air
Quote:
bottom
{
type interstitialInletVelocity;
inletVelocity uniform (0 0 1.875);
value uniform (0 0 1.875);
phi phi.air;
alpha alpha.air;
}
However I found the answer. The second entry is a dummy value for 0 value reading in paraView. So I should try to use table for first entry "inletVelocity uniform (0 0 1.875);" and modify the source code. I have started to create the new boundary condition based on your comment but have faced to some problems because of C++ knowledge. I will bring the modifications to share with others to write the time varying interstitialInletVelocity BC.
wyldckat likes this.
maysmech is offline   Reply With Quote

Old   October 21, 2014, 17:26
Default
  #6
Senior Member
 
maysmech's Avatar
 
Join Date: Jan 2010
Posts: 347
Blog Entries: 2
Rep Power: 17
maysmech is on a distinguished road
We want use available boundary conditions of fixedValue (BC1), uniformFixedValue (BC2) and interstitialInletVelocity (BC3) to write own myInterstitialInletVelocity (BC4).
BC4 will have advantages of BC3 (which accounts alpha to have constant mass flow rate in multiphase flows) and BC2 (which accepts table to apply time varying air velocity).

The first step is compiling BC in user directory.

1- Copying BC3 from source to user directory and renaming it to my0InterstitialInletVelocity.
Code:
$FOAM_SRC/finiteVolume/fields/fvPatchFields/derived/interstitialInletVelocity
to
$WM_PROJECT_USER_DIR/src/finiteVolume/fields/fvPatchFields/derived/my0interstitialInletVelocity
2- Modifying .H and .C files with new name.
3- Writing an appropriate Make/files and options and then compiling it in:
Code:
$WM_PROJECT_USER_DIR/src/finiteVolume/
4- Adding this dictionary to controlDict:
Code:
libs ("libmyFiniteVolume.so");
In these links the src folder and a test case are available. After extracting it in user directory it needs compile by wmake.
The link of GoldschemidtBC contains my0InterstitialInletVelocity BC in 0/U.air and dictionary in it is controlDict.
The src link contains BC1 to BC4. but is compiled for "my0InterstitialInletVelocity".
The BC4 doesn't work which will be discussed later.
Code:
https://www.dropbox.com/s/b54r786b167bmxw/src.tar.gz?dl=0
https://www.dropbox.com/s/8fpj3os65a8hnp9/GoldschmidtBC.tar.gz?dl=0


The next step is doing modification in
myInterstitialInletVelocity (BC4) to possible accepting table.

The difference of BC2 to BC1 are:
1- BC2 has a new parameter definition:
Code:
const Field<Type>& fld
which I think it is for the new variable:
Code:
uniformValue_()
I define uniformInletVelocity_ in BC4 too
2- BC1 uses mapper (which I don't know what does it do):

Code:
fixedValueFvPatchField<Type>::fixedValueFvPatchField
(
    const fixedValueFvPatchField<Type>& ptf,
    const fvPatch& p,
    const DimensionedField<Type, volMesh>& iF,
    const fvPatchFieldMapper& mapper
)
:
    fvPatchField<Type>(ptf, p, iF, mapper)
{
    if (&iF && mapper.hasUnmapped())
    {
        WarningIn
        (
            "fixedValueFvPatchField<Type>::fixedValueFvPatchField\n"
            "(\n"
            "    const fixedValueFvPatchField<Type>&,\n"
            "    const fvPatch&,\n"
            "    const DimensionedField<Type, volMesh>&,\n"
            "    const fvPatchFieldMapper&\n"
            ")\n"
        )   << "On field " << iF.name() << " patch " << p.name()
            << " patchField " << this->type()
            << " : mapper does not map all values." << nl
            << "    To avoid this warning fully specify the mapping in derived"
            << " patch fields." << endl;
    }
}
but BC2 uses bypass mapper with the new variable of uniformValue_ :

Code:
template<class Type>
uniformFixedValueFvPatchField<Type>::uniformFixedValueFvPatchField
(
    const uniformFixedValueFvPatchField<Type>& ptf,
    const fvPatch& p,
    const DimensionedField<Type, volMesh>& iF,
    const fvPatchFieldMapper& mapper
)
:
    fixedValueFvPatchField<Type>(p, iF),  // bypass mapper
    uniformValue_(ptf.uniformValue_().clone().ptr())
{
    // Evaluate since value not mapped
    const scalar t = this->db().time().timeOutputValue();
    fvPatchField<Type>::operator==(uniformValue_->value(t));
}
I think it uses bypass mapper of BC1 and doesn't rewrite it here. However what we are seeking is seen here (time).

3- we see time again in next class. In this one, it is looking for value or table:
Code:
template<class Type>
uniformFixedValueFvPatchField<Type>::uniformFixedValueFvPatchField
(
    const fvPatch& p,
    const DimensionedField<Type, volMesh>& iF,
    const dictionary& dict
)
:
    fixedValueFvPatchField<Type>(p, iF),
    uniformValue_(DataEntry<Type>::New("uniformValue", dict))
{
    if (dict.found("value"))
    {
        fvPatchField<Type>::operator==(Field<Type>("value", dict, p.size()));
    }
    else
    {
        const scalar t = this->db().time().timeOutputValue();
        fvPatchField<Type>::operator==(uniformValue_->value(t));
    }
}
4- The last difference is "clone" which is added to BC2 and again I don't know what it is.

However, I tried many different tries and errors by adding classes to BC4 but not possible to compile it successfully.

Two possibles for errors are:
1- mistakes in defining parameters
2- two "operator== ..." in updateCoeff of BC4:
Code:
void Foam::myInterstitialInletVelocityFvPatchVectorField::updateCoeffs()
{

Info << "Banana1" <<endl;
    if (updated())
    {
        return;
    }
    const scalar t = this->db().time().timeOutputValue();             //
    fvPatchField<vector>::operator==(uniformInletVelocity_->value(t));  //

   // fixedValueFvPatchField<Type>::updateCoeffs();                     //

    const fvPatchField<scalar>& alphap =
        patch().lookupPatchField<volScalarField, scalar>(alphaName_);

    operator==(uniformInletVelocity_/alphap);
    fixedValueFvPatchVectorField::updateCoeffs();
}
It needs to check two things for update: alpha and uniformInletVelocity. Again I tried different configurations (separated, together, ...) but it doesn't compile at all

Sorry for this long post and thanks in advance for any suggestion.
Sakun likes this.

Last edited by maysmech; October 21, 2014 at 21:08.
maysmech is offline   Reply With Quote

Old   November 5, 2014, 16:31
Question
  #7
New Member
 
Charlie
Join Date: May 2014
Posts: 9
Rep Power: 12
mechem is on a distinguished road
Quote:
Originally Posted by maysmech View Post
We want use available boundary conditions of fixedValue (BC1), uniformFixedValue (BC2) and interstitialInletVelocity (BC3) to write own myInterstitialInletVelocity (BC4).
BC4 will have advantages of BC3 (which accounts alpha to have constant mass flow rate in multiphase flows) and BC2 (which accepts table to apply time varying air velocity).
Hi maysmech,
This is what exactly I need for finding minimum fluidization velocity.
I need a gradually increase in fluidization velocity.
I used table with fixed value but the results was mistake because of inlet porosity is not considered in fixedValue.
Did you find any solution? Please share it if you have found.
Best regards.
mechem is offline   Reply With Quote

Reply


Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are Off
Pingbacks are On
Refbacks are On


Similar Threads
Thread Thread Starter Forum Replies Last Post
Time dependant pressure boundary condition yosuke1984 OpenFOAM Verification & Validation 3 May 6, 2015 06:16
plot over time fferroni OpenFOAM Post-Processing 7 June 8, 2012 07:56
External Radiation Boundary Condition (Two sided wall), Grid Interface CFD XUE FLUENT 0 July 8, 2010 06:49
vorticity boundary condition bearcharge Main CFD Forum 0 May 14, 2010 11:32
Time Varying Boundary Conditon ashish CFX 3 February 15, 2005 06:21


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