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

using codestream to initialize alpha domain with multiple ovals

Register Blogs Community New Posts Updated Threads Search

Reply
 
LinkBack Thread Tools Search this Thread Display Modes
Old   September 1, 2022, 08:18
Default using codestream to initialize alpha domain with multiple ovals
  #1
Member
 
Al
Join Date: May 2019
Posts: 37
Rep Power: 6
aliyah. is on a distinguished road
Hello

I am trying to use codestream to create several oval shapes in my alpha domains. These ovals are placed throughout the domain*at various x coordinates, each of which is determined by a for loop with j label, and here's my 0/alpha file.

Code:
dimensions      [0 0 0 0 0 0 0];


internalField    #codeStream
{
	codeInclude
	#{
		#include "fvCFD.H"
	#};
        
	codeOptions
	#{
		-I$(LIB_SRC)/finiteVolume/lnInclude \
		-I$(LIB_SRC)/meshTools/lnInclude
	#};

	codeLibs
	#{
		-lmeshTools \
		-lfiniteVolume
	#};
	code
	#{
    
    const IOdictionary& d = static_cast<const IOdictionary&>(dict);
	const fvMesh& mesh = refCast<const fvMesh>(d.db());
		
   scalarField alpha(mesh.nCells(), 0);

    for (label j=0; j <= 10; j++) 
    {

    scalar lambda =  2.29922953e-3;
    scalar he = j*lambda;
    scalar ke = 0.5*lambda;
    scalar ae = 0.2*lambda;
    scalar be = 0.1*lambda;

		forAll(alpha, i)
		{
			const scalar x = mesh.C()[i][0];
			const scalar y = mesh.C()[i][1];

			if (  pow(y-ke,2) <= ((1 - pow(x-he,2)/pow(ae,2) )*pow(be,2)) )
			{
				alpha[i] = 1;
			}
		}
		alpha.writeEntry("", os);
    }
	#}
    ;
};


boundaryField
{
    up
    {
        type            inletOutlet;
        inletValue      uniform 1;
        value           uniform 0;
    }
    "wall.*"
    {
        type            cyclic;
    }
    down
    {
        type            fixedValue;
        value           uniform 0;
    }
    frontAndBack
    {
        type            empty;
    }
}
}
However, only one oval is created (the one with j equal to 0), and the remaining ovals are not formed.

What is the problem here and what I should do? Thank you!
aliyah. is offline   Reply With Quote

Old   September 2, 2022, 02:57
Default
  #2
Member
 
Al
Join Date: May 2019
Posts: 37
Rep Power: 6
aliyah. is on a distinguished road
The problem with this codestream was the location of writeEntry. It should be right before #}.

So it will be like

Code:
internalField    #codeStream
{
	codeInclude
	#{
		#include "fvCFD.H"
	#};
        
	codeOptions
	#{
		-I$(LIB_SRC)/finiteVolume/lnInclude \
		-I$(LIB_SRC)/meshTools/lnInclude
	#};

	codeLibs
	#{
		-lmeshTools \
		-lfiniteVolume
	#};
	code
	#{
    
    const IOdictionary& d = static_cast<const IOdictionary&>(dict);
	const fvMesh& mesh = refCast<const fvMesh>(d.db());
		
   scalarField alpha(mesh.nCells(), 0);

    for (label j=0; j <= 10; j++) 
    {

    scalar lambda =  2.29922953e-3;
    scalar he = j*lambda;
    scalar ke = 0.5*lambda;
    scalar ae = 0.2*lambda;
    scalar be = 0.1*lambda;

		forAll(alpha, i)
		{
			const scalar x = mesh.C()[i][0];
			const scalar y = mesh.C()[i][1];

			if (  pow(y-ke,2) <= ((1 - pow(x-he,2)/pow(ae,2) )*pow(be,2)) )
			{
				alpha[i] = 1;
			}
		}
    }
		alpha.writeEntry("", os);
	#}
    ;
};
aliyah. 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 size influence in unbounded domains model Reoyo Main CFD Forum 10 May 4, 2018 08:30
multiple fluid domain Sumedh CFX 10 December 14, 2016 16:36
alphaEqn.H in twoPhaseEulerFoam cheng1988sjtu OpenFOAM Bugs 15 May 1, 2016 16:12
OpenFOAM static build on Cray XT5 asaijo OpenFOAM Installation 9 April 6, 2011 12:21
CFX Solver Memory Error mike CFX 1 March 19, 2008 07:22


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