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

using setValues and creating a UList for argument

Register Blogs Community New Posts Updated Threads Search

Like Tree1Likes
  • 1 Post By Michael@UW

Reply
 
LinkBack Thread Tools Search this Thread Display Modes
Old   January 29, 2019, 00:33
Default using setValues and creating a UList for argument
  #1
Member
 
Ashish Magar
Join Date: Jul 2016
Location: Mumbai, India
Posts: 81
Rep Power: 9
ashishmagar600 is on a distinguished road
Hello everyone.

I was trying to impose a fixed velocity(cell by cell) to a cellZone, by using setValues from fvMatrix.

I created a labelList of cells from their IDs, however I am stuck as how to proceed further.

Can anyone help ..?

Thank you.
ashishmagar600 is offline   Reply With Quote

Old   January 29, 2019, 02:51
Default
  #2
Member
 
Ashish Magar
Join Date: Jul 2016
Location: Mumbai, India
Posts: 81
Rep Power: 9
ashishmagar600 is on a distinguished road
Anyway Solved..!!
ashishmagar600 is offline   Reply With Quote

Old   January 19, 2022, 20:15
Default Can you help me out?
  #3
Senior Member
 
Join Date: Jan 2019
Posts: 125
Blog Entries: 1
Rep Power: 0
Michael@UW is on a distinguished road
Quote:
Originally Posted by ashishmagar600 View Post
Anyway Solved..!!
Dear Ashish,

Can you explain how you get it solved?

I use the following code to change the velocity if the cells are in the cylinder centered at a specific point. I observe the U is changed around the point but it is not 0 as specified.

I have been stuck in this for a while. Can you please point out the errors? Thanks in advance!

Code:
FoamFile
{
    version     2.0;
    format      ascii;
    class       dictionary;
    location    "system";
    object      fvOptions;
}
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
codedSource
{
    type            vectorCodedSource;
    selectionMode   all;

    fields          (U);
    name            codedSource;
	
    codeConstrain
    #{  
                
        const vector& pt = vector(0.1, 0, 0.01) ;
        const vectorField center = mesh().C();

        labelList cells;

		forAll(center, i)
		{
			const vector ds = pt - center[i];
			scalar d = sqrt(ds.x() * ds.x() + ds.y() * ds.y());
			if (d <= 0.009)
			{

				Info << "I=" << i << endl;

				cells.append(i);                
			}    
		};

		vectorField values(cells.size());
		Info << "Cells selected: " << cells << endl;
		values = vector(0, 0, 0);
		eqn.setValues(cells, values);                 
    #};
    
    codeCorrect
    #{
    #};
    codeAddSup
    #{
    #};  
    code
    #{
            $codeInclude
            $codeCorrect
            $codeAddSup
            $codeSetValue
    #};
}
Michael@UW is offline   Reply With Quote

Old   January 22, 2022, 07:55
Default
  #4
Member
 
Ashish Magar
Join Date: Jul 2016
Location: Mumbai, India
Posts: 81
Rep Power: 9
ashishmagar600 is on a distinguished road
This was tricky. I did modify interFoam-> Ueqn.H as that suited my purpose.

I had to call setValues once again after the pressure correction was done and that solved my problem.
ashishmagar600 is offline   Reply With Quote

Old   January 22, 2022, 10:42
Default
  #5
Senior Member
 
Join Date: Jan 2019
Posts: 125
Blog Entries: 1
Rep Power: 0
Michael@UW is on a distinguished road
Thank you for your reply! I guess the U field is corrected by the silver due to conservation. In my case, I tried to fix the velocities of a chunk of fluid cells which does not make sense in practice( just for testing). If I just fix one cell of some separate cells, it is possible to adjust the flow field to satisfy the mass and momentum conservation to fix the velocity at these cells.

So it makes sense you setValue again after the pressure correction which seems not possible in fvOptions.
ashishmagar600 likes this.
Michael@UW 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



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