CFD Online Logo CFD Online URL
www.cfd-online.com
[Sponsors]
Home > Forums > Software User Forums > OpenFOAM > OpenFOAM Pre-Processing

codedFixedValue boundary condition

Register Blogs Community New Posts Updated Threads Search

Like Tree7Likes

Reply
 
LinkBack Thread Tools Search this Thread Display Modes
Old   April 17, 2016, 04:49
Default
  #41
Senior Member
 
Join Date: Sep 2015
Location: Singapore
Posts: 102
Rep Power: 11
usv001 is on a distinguished road
Hi Bruno,

Thanks for replying once again. I actually have two versions of OF installed (2.1.1 & 2.4.1). I was able to run the incompressible/simpleFoam/pipeCyclic test case in both versions successfully. However, since my ParaView is linked to v2.1.1 only, I am able to view the results only when I run the solver using v2.1.1 but I can see that the swirl has been implemented in both version by looking at the result files.

At time=0, ParaView does not show the swirl boundary condition. So, you were right the first time: the BC is not reflected in ParaView at t=0 but passed to the solver during the first time step or during decomposePar.

[My Linux distribution information
Distributor ID: Ubuntu
Description: Ubuntu 12.04.5 LTS
Release: 12.04
Codename: precise

I tried to run my own case and I was able to run it without any problems in v2.4.1 (I'm using rhoCentralFoam). I checked the results by checking the results files and the code has been implemented. Just some observations:

(1)
Both...
Code:
operator == (200000);
and...
Code:
operator==(200000);
worked.

(2)
I removed the following statements since they were absent in the pipeCylic tutorial and it worked fine:
Code:
        codeInclude
        #{
        #include "fvCFD.H"
        #};

        codeOptions
        #{
        -I$(LIB_SRC)/finiteVolume/lnInclude
        #};
(3)
When I added the #include statements, I got the following error after the first iteration:
Code:
#0  Foam::error::printStack(Foam::Ostream&) in "/home/cae-usv/OpenFOAM/OpenFOAM-2.4.0/platforms/linux64GccDPOpt/lib/libOpenFOAM.so"
#1  Foam::sigSegv::sigHandler(int) in "/home/cae-usv/OpenFOAM/OpenFOAM-2.4.0/platforms/linux64GccDPOpt/lib/libOpenFOAM.so"
#2  ? in "/lib/x86_64-linux-gnu/libc.so.6"
#3  Foam::fixedValueFvPatchField<double>::gradientInternalCoeffs() const in "/home/cae-usv/OpenFOAM/OpenFOAM-2.4.0/platforms/linux64GccDPOpt/lib/libfiniteVolume.so"
#4  Foam::codedFixedValueFvPatchField<double>::evaluate(Foam::UPstream::commsTypes) in "/home/cae-usv/OpenFOAM/OpenFOAM-2.4.0/platforms/linux64GccDPOpt/lib/libfiniteVolume.so"
#5  Foam::GeometricField<double, Foam::fvPatchField, Foam::volMesh>::GeometricBoundaryField::evaluate() in "/home/cae-usv/OpenFOAM/OpenFOAM-2.4.0/platforms/linux64GccDPOpt/bin/rhoCentralFoam"
#6  ? in "/home/cae-usv/OpenFOAM/OpenFOAM-2.4.0/platforms/linux64GccDPOpt/bin/rhoCentralFoam"
#7  __libc_start_main in "/lib/x86_64-linux-gnu/libc.so.6"
#8  ? in "/home/cae-usv/OpenFOAM/OpenFOAM-2.4.0/platforms/linux64GccDPOpt/bin/rhoCentralFoam"
Segmentation fault (core dumped)
I am not too sure why this happens but would love to understand if anyone knows.

Many thanks to everyone and especially, Bruno.
usv001 is offline   Reply With Quote

Old   April 17, 2016, 15:48
Default
  #42
Retired Super Moderator
 
Bruno Santos
Join Date: Mar 2009
Location: Lisbon, Portugal
Posts: 10,981
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
Quick answers:
Quote:
Originally Posted by usv001 View Post
(1)
Both...
Code:
operator == (200000);
and...
Code:
operator==(200000);
worked.
Mmm... strange... I thought C++ demanded the operator methods to be written without spaces in their name, such as "operator==". Very strange.

Quote:
Originally Posted by usv001 View Post
(2)
I removed the following statements since they were absent in the pipeCylic tutorial and it worked fine:
Code:
        codeInclude
        #{
        #include "fvCFD.H"
        #};

        codeOptions
        #{
        -I$(LIB_SRC)/finiteVolume/lnInclude
        #};
(3)
When I added the #include statements, I got the following error after the first iteration:
Code:
#0  Foam::error::printStack(Foam::Ostream&) in "/home/cae-usv/OpenFOAM/OpenFOAM-2.4.0/platforms/linux64GccDPOpt/lib/libOpenFOAM.so"
#1  Foam::sigSegv::sigHandler(int) in "/home/cae-usv/OpenFOAM/OpenFOAM-2.4.0/platforms/linux64GccDPOpt/lib/libOpenFOAM.so"
#2  ? in "/lib/x86_64-linux-gnu/libc.so.6"
#3  Foam::fixedValueFvPatchField<double>::gradientInternalCoeffs() const in "/home/cae-usv/OpenFOAM/OpenFOAM-2.4.0/platforms/linux64GccDPOpt/lib/libfiniteVolume.so"
#4  Foam::codedFixedValueFvPatchField<double>::evaluate(Foam::UPstream::commsTypes) in "/home/cae-usv/OpenFOAM/OpenFOAM-2.4.0/platforms/linux64GccDPOpt/lib/libfiniteVolume.so"
#5  Foam::GeometricField<double, Foam::fvPatchField, Foam::volMesh>::GeometricBoundaryField::evaluate() in "/home/cae-usv/OpenFOAM/OpenFOAM-2.4.0/platforms/linux64GccDPOpt/bin/rhoCentralFoam"
#6  ? in "/home/cae-usv/OpenFOAM/OpenFOAM-2.4.0/platforms/linux64GccDPOpt/bin/rhoCentralFoam"
#7  __libc_start_main in "/lib/x86_64-linux-gnu/libc.so.6"
#8  ? in "/home/cae-usv/OpenFOAM/OpenFOAM-2.4.0/platforms/linux64GccDPOpt/bin/rhoCentralFoam"
Segmentation fault (core dumped)
I am not too sure why this happens but would love to understand if anyone knows.
"sigSegv" - segmentation fault, probably due to a bad memory access. It's even stranger that it happened within "gradientInternalCoeffs".

Did you change anything in the original source code files within OpenFOAM's source code?
wyldckat is offline   Reply With Quote

Old   April 18, 2016, 01:26
Default
  #43
Senior Member
 
Join Date: Sep 2015
Location: Singapore
Posts: 102
Rep Power: 11
usv001 is on a distinguished road
Hi Bruno,

No, I have not changed any original source code files.
usv001 is offline   Reply With Quote

Old   July 22, 2016, 16:01
Exclamation
  #44
New Member
 
Sam Salehian
Join Date: Jul 2016
Posts: 4
Rep Power: 10
SmokedJuggler is on a distinguished road
Hello All,

I am interested in applying an unsteady and non uniform boundary condition for inflow.

I want to define a function for the velocity profile such as:

U(x)=U_0*(exp(y)*sin(2*pi*freq*time))

where y is the vertical position of inflow patch in a channel. I want to avoid using groovy boundary condition.

I would appreciate if any one could also help me with this.

Regards

Last edited by SmokedJuggler; July 26, 2016 at 17:16.
SmokedJuggler is offline   Reply With Quote

Old   July 31, 2016, 02:16
Default
  #45
Senior Member
 
Join Date: Sep 2015
Location: Singapore
Posts: 102
Rep Power: 11
usv001 is on a distinguished road
Hi Sam,

I managed to get the code below working following what was suggested earlier on this thread. It is a parabolic velocity profile.

Code:
INLET
    {
        type            codedFixedValue;
	value 		uniform (0 0 0);
	redirectType	test; // user-defined name

	code
	#{
	const fvPatch& boundaryPatch = this->patch(); 
        const vectorField& Cf = boundaryPatch.Cf(); 

        vectorField& v = *this;
        scalar Uc = 1; // centerline velocity, U_max
	scalar R = 0.019; // inlet radius

	forAll(Cf,faceI)
	{
	    scalar x = Cf[faceI].x(), y = Cf[faceI].y(), rSq = x*x + y*y;
            v[faceI] = vector(0, 0, Uc*(1 - rSq/R/R));
	}
        #};
}
You can try modifying it. I think you can start with the following. I have not tried running though.

Code:
INLET
    {
        type            codedFixedValue;
	value 		uniform (0 0 0);
	redirectType	test; // user-defined name

	code
	#{
	const fvPatch& boundaryPatch = this->patch(); 
        const vectorField& Cf = boundaryPatch.Cf();
        const scalar &t = this->db().time().value();

        vectorField& v = *this;
        scalar U0 = 1; // centerline velocity
	scalar f = 1; // frequency

	forAll(Cf,faceI)
	{
	    scalar y = Cf[faceI].y();
            scalar u = U0*Foam::exp(y)*Foam::sin(Foam::constant::mathematical::twoPi*f*t);
            v[faceI] = vector(u, 0, 0);
	}
        #};
}
All the best!
makaveli_lcf and soheil_r7 like this.
usv001 is offline   Reply With Quote

Old   February 27, 2017, 05:30
Default coded fixed or coded mixed boundary condition
  #46
New Member
 
Sachin
Join Date: Sep 2016
Location: Poitiers,France
Posts: 17
Rep Power: 10
smodh is on a distinguished road
Hello Foamers,

I want to implement a boundary condition at electrode.

N_P= K * Efield * N_P


In this equation N_P and Efield " need to be taken from electrode at previous time step and K is dimensionedScalar fix value 1.

is there anyone know how to implemrnt this BC? should I have to used codedfixed BC or some other BC? I am using openfoam 4.0.

Thanks in advance.....
smodh is offline   Reply With Quote

Old   February 28, 2017, 09:10
Default coded fixed or coded mixed boundary condition
  #47
New Member
 
Sachin
Join Date: Sep 2016
Location: Poitiers,France
Posts: 17
Rep Power: 10
smodh is on a distinguished road
Hello Foamers,

I want to implement a boundary condition at electrode.

N_P= K * Efield * N_P


In this equation N_P and Efield " need to be taken from electrode at previous time step and K is dimensionedScalar fix value 1.

is there anyone know how to implemrnt this BC? should I have to used codedfixed BC or some other BC? I am using openfoam 4.0.

Thanks in advance.....
smodh is offline   Reply With Quote

Old   October 7, 2019, 06:34
Default Previous time step
  #48
Member
 
K
Join Date: Mar 2018
Posts: 34
Rep Power: 8
kuria is on a distinguished road
Thank you for the information on implementing time in the boundary condition!


I was wondering if someone has looked into how to import time step used by the solver while calculating the boundary condition using CodedFixedValue or Codedixed?


Thanks in advance
kuria is offline   Reply With Quote

Old   October 7, 2019, 07:54
Default
  #49
Senior Member
 
Join Date: Sep 2015
Location: Singapore
Posts: 102
Rep Power: 11
usv001 is on a distinguished road
Quote:
Originally Posted by kuria View Post
I was wondering if someone has looked into how to import time step used by the solver while calculating the boundary condition using CodedFixedValue or Codedixed?
Hi Kurian,

Simply use the following to obtain the time step.
Code:
const scalar &t = this->db().time().deltaTValue();
Best,
USV
usv001 is offline   Reply With Quote

Old   October 7, 2019, 07:59
Default
  #50
Member
 
K
Join Date: Mar 2018
Posts: 34
Rep Power: 8
kuria is on a distinguished road
Quote:
Originally Posted by usv001 View Post
Hi Kurian,

Simply use the following to obtain the time step.
Code:
const scalar &t = this->db().time().deltaTValue();
Best,
USV



Hey


Awesome, that was perfect!
Thank you
kuria is offline   Reply With Quote

Old   August 29, 2020, 05:46
Post calculate sphere velocity at each time step and apply it to inlet boundary condition
  #51
Member
 
Arash Mahboubidoust
Join Date: Jun 2013
Location: Iran
Posts: 58
Rep Power: 13
arashfluid is on a distinguished road
Send a message via Yahoo to arashfluid
Dear friends,
I am solving the flow around the sphere (as a particle) inside a channel. I want to calculate the integral of the drag force over the sphere at each time step to calculate the velocity of the sphere V2 (F=m.(V2-V1)/dt) and then applied the obtained velocity (V2) at each time step to the inlet boundary as a portion of velocity boundary condition (U-V2). How can I do this?
arashfluid 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
Domain Imbalance HMR CFX 5 October 10, 2016 06:57
Can anyone give me some hint on how to make traction free boundary condition? poplar OpenFOAM 3 January 14, 2015 03:37
Boundary Conditions Thomas P. Abraham Main CFD Forum 20 July 7, 2013 06:05
Setting outlet Pressure boundary condition using CAFFA code Mukund Pondkule Main CFD Forum 0 March 16, 2011 04:23
How to set boundary condition in Fluent for the fo Peiyong FLUENT 1 November 10, 2006 12:44


All times are GMT -4. The time now is 20:22.