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

Using fixedProfile to apply a sinusoidal temperature profile

Register Blogs Community New Posts Updated Threads Search

Reply
 
LinkBack Thread Tools Search this Thread Display Modes
Old   August 20, 2024, 17:37
Default Using fixedProfile to apply a sinusoidal temperature profile
  #1
New Member
 
Nils Tilton
Join Date: Aug 2024
Posts: 8
Rep Power: 2
NilsTilton is on a distinguished road
Dear OpenFoam Community,

As part of learning OpenFoam, I am solving a simple steady heat conduction problem using laplacianFoam, and I am systematically experimenting with different methods of applying nonuniform Dirichlet boundary conditions. From the OpenFoam documentation and online sources, I have grasped how to apply a polynomial temperature profile using "fixedProfile" and "polynomial." For example, along a patch named west, I can apply the temperature T =1 + 2y using the following entry in my 0/T file:

west
{
type fixedProfile;
profile polynomial
(
(1 0)
(2 1)
);
direction (0 1 0);
origin 0;
}

My question is the following. Can I use a similar approach to apply the condition T = cos(y) along the same west boundary? The online documentation for fixedProfile mentions that I can apply a <Function1<Type>> for profile. Meanwhile, I see in the source code files (src/OpenFOAM/primitives/functions/Function1/) that there is a cosine. However, the .H file for cosine seems to imply it's reserved for taking the cosine of time, and not a spatial coordinate. So in summary, is there a way to use "fixedProfile" and "cosine" to apply the condition, or am I barking up the wrong tree? I plan to explore using codeStream next, but didn't like this conceptual issue left hanging.
NilsTilton is offline   Reply With Quote

Old   August 21, 2024, 04:13
Default
  #2
Senior Member
 
Tom Fahner
Join Date: Mar 2009
Location: Breda, Netherlands
Posts: 646
Rep Power: 32
tomf will become famous soon enoughtomf will become famous soon enough
Send a message via MSN to tomf Send a message via Skype™ to tomf
Hi Nils,

If you are on the openfoam.com version, you may want to look into some examples of expressions.

Best regards,
Tom

Last edited by tomf; August 21, 2024 at 04:14. Reason: link instead of code
tomf is offline   Reply With Quote

Old   August 21, 2024, 11:23
Default
  #3
New Member
 
Nils Tilton
Join Date: Aug 2024
Posts: 8
Rep Power: 2
NilsTilton is on a distinguished road
Hi Tom,

Thanks for the link. It has some great info I was missing.

Best Wishes,
Nils
NilsTilton is offline   Reply With Quote

Old   August 23, 2024, 12:56
Default
  #4
New Member
 
Nils Tilton
Join Date: Aug 2024
Posts: 8
Rep Power: 2
NilsTilton is on a distinguished road
Hi All,

For those interested in applying general Dirichlet conditions, here are three ways of applying the sinusoidal temperature profile T=273+80*cos(4*pi*x/Lx) on a boundary patch called north. The first uses OpenFOAM's fixedProfile. The second uses fixedValue with codeStream. The third uses codedFixedProfile

Option 1 using fixedProfile with coded:

north
{
type fixedProfile;
profile coded
name CosineT;

codeInclude
#{
#include "mathematicalConstants.H"
#};

code
#{
scalar Lx = 1;
scalar pi = 3.141592653589793;
return scalar
(
273 + 80*cos(4.0*pi*x/Lx)
);
#};
direction (1 0 0);
origin 0;

}

Option 2 using fixedValue with codeStream:


north
{
type fixedValue;
value #codeStream
{

// optional include files
codeInclude
#{
#include "fvCFD.H"
#};

// optional compile options
codeOptions
#{
-I$(LIB_SRC)/finiteVolume/lnInclude \
-I$(LIB_SRC)/meshTools/lnInclude
#};

// optional libraries
codeLibs
#{
-lfiniteVolume \
-lmeshTools
#};


code
#{

//----------- required to access patch data ------------//
const IOdictionary& d = static_cast<const IOdictionary&>
(
dict.parent().parent()
);

const fvMesh& mesh = refCast<const fvMesh>(d.db());
const label id = mesh.boundary().findPatchID("north");
const fvPatch& patch = mesh.boundary()[id];
//------------------------------------------------------//


scalar pi = 3.141592653589793;
scalar Lx = 1;

scalarField TN(patch.size(), 0.0);
forAll(TN, i)
{
const scalar x = patch.Cf()[i][0];
TN[i] = 273 + 80*cos(4.0*pi*x/Lx);
}

TN.writeEntry("", os);


#};

};

}

Option 3 using codedFixedProfile:

north
{
type codedFixedValue;
value uniform 0; // optional
name CosineCondition;

// optional include files
codeInclude
#{
#include "fvCFD.H"
#};

// optional compile options
codeOptions
#{
-I$(LIB_SRC)/finiteVolume/lnInclude \
-I$(LIB_SRC)/meshTools/lnInclude
#};

// optional libraries
codeLibs
#{
-lfiniteVolume \
-lmeshTools
#};


code
#{
scalar Lx = 1.0;
scalar pi = 3.141592653589793;
vector xdir(1,0,0);
scalarField x( patch().Cf()&xdir );

operator==(
273 + 80*Foam::cos( 4.0*pi*x/Lx )
);

#};

}
NilsTilton is offline   Reply With Quote

Reply

Tags
boundary condition., cosine, fixedprofile, openfoam 12


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
Temperature profile with isothermal steady state simulation Procyon CFX 6 November 11, 2019 13:06
Calculation of the Governing Equations Mihail CFX 7 September 7, 2014 07:27
Please Help! Temperature profile UDF for 3D geometry subhankar_bhandari FLUENT 2 April 16, 2011 06:30
Please Help! Temperature profile UDF for 3D geometry subhankar_bhandari FLUENT 0 August 16, 2010 09:40
Help please! UDF for Temperature profile in 3D subhankar_bhandari Fluent UDF and Scheme Programming 2 August 16, 2010 09:37


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