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

codedMixed boundary condition for switching between no-slip and slip

Register Blogs Community New Posts Updated Threads Search

Reply
 
LinkBack Thread Tools Search this Thread Display Modes
Old   May 27, 2021, 05:28
Default codedMixed boundary condition for switching between no-slip and slip
  #1
Member
 
Join Date: Mar 2021
Posts: 39
Rep Power: 5
trailer is on a distinguished road
Hello,


I would like to create a mixed boundary condition where based, on a switch, I change the boundary from no-slip to slip.


Let's assume that after 1s of simulation the walls go from no slip to slip.



For the time being I have:


Code:
myPatch
    {
        type            codedMixed;
        refValue        uniform (0 0 0);
        refGradient     uniform (0 0 0);
        valueFraction   uniform 0;

        name    myBC;   

        code
        #{

        // Access the current value of time
        const Time& time = mesh.time();

        const scalar t = time.value();

        // Loop over the patch
       forAll(patch(), faceI)
        {   

              if(t < 1)
              {
                // Imposes no-slip boundary condition
                  this->refValue()[faceI] = vector::zero; 
                  this->valueFraction()[faceI] = scalar(1); 
              }
              else
              {
                // Imposes slip boundary condition

                 ?Help needed here?

              }
          
        }
      #};
     }

However, I am quite new at this and would appreciate the help.
trailer is offline   Reply With Quote

Old   May 27, 2021, 05:48
Default
  #2
New Member
 
Giovanni Luddeni
Join Date: Jan 2021
Posts: 14
Rep Power: 5
gionni is on a distinguished road
Hi, I have a few suggetsions for you, hoping to be of help:

1) I would put the for loop inside the if clause, since this way you have one evaluation of the if and one loop, otherwise you are evaluation the if clause multiple times, with lower performance;

2) From what I understand, the initial setup is not representing a no slip, since the fraction is 0 (you are starting with a zeroGradient basically, the flow can penetrate the wall!). You should start with a Dirichlet imposing zero velocity:

Code:
type            codedMixed;
        refValue        uniform (0 0 0);
        valueFraction   uniform 1;

        name    myBC;
(Actually you can implement a more correct no slip, which doesn't imply the stress tensor to be isotropic: you can find a detailed explanation of the theory in Moukalled's book about finite volume, at chapter 18; since that chapter is exactly about implementation of coded BCs in openfoam you could find it even more useful.

3) About your question, there are several ways you can follow to implement a slip condition, which is the equation you would like to use?

4) I don't know if you care, but you can express the switch threshold in the properties dict in the constant folder, this is an example where i get a variable called q from a dict called physicalProperties (which is defined in the solver, you could have transportProperties or something like that):
Code:
const dictionary& physicalProperties = db().lookupObject<IOdictionary>("physicalProperties");
scalar& q     = dimensionedScalar(physicalProperties.lookup("q")).value();
This way you don't need to recompile the BC to change the switch. I just put it here cause I know it takes a while to find info about codedBC, I hope it's useful.
gionni is offline   Reply With Quote

Old   May 27, 2021, 05:50
Default
  #3
New Member
 
Giovanni Luddeni
Join Date: Jan 2021
Posts: 14
Rep Power: 5
gionni is on a distinguished road
I forgot to mention the silly solution:
you can put no slip and solve till 1s, then change in the 1 folder the bc to slip and start again the simulation from 1.
This could avoid the use of a codedBC.
gionni is offline   Reply With Quote

Old   May 27, 2021, 05:59
Default
  #4
Member
 
Join Date: Mar 2021
Posts: 39
Rep Power: 5
trailer is on a distinguished road
Quote:
Originally Posted by gionni View Post
I forgot to mention the silly solution:
you can put no slip and solve till 1s, then change in the 1 folder the bc to slip and start again the simulation from 1.
This could avoid the use of a codedBC.

Thanks for the reply! But the purpose if to actually use the mixedCoded boundary.


Regarding the slip boundary. I would expect it to be the same as implemented in OF where the basicSymmetryFvPatchField is called. However, I do not know how to input this into the codedMixed
trailer is offline   Reply With Quote

Old   May 27, 2021, 07:00
Default
  #5
New Member
 
Giovanni Luddeni
Join Date: Jan 2021
Posts: 14
Rep Power: 5
gionni is on a distinguished road
I took a look to the code of the Bc you mention, the interesting part would be this

Code:
tmp<vectorField> nHat = this->patch().nf();

    const Field<Type> iF(this->patchInternalField());

    Field<Type>::operator=
    (
        (iF + transform(I - 2.0*sqr(nHat), iF))/2.0
    );

    transformFvPatchField<Type>::evaluate();
Honestly I can't understand what it does, since I don't know the transform function.

I guess imposing a symmetry you would need to put the orthogonal component of the velocity to zero; I don't think this would be a completely correct way, but you can try it to test the codedBC, waiting for someone else to explain the right interpretation of the BC.
At the end of the day it would be an approximation similar to no slip -> v=0, so you're basically imposing the no-penetrating condition rather than the whole symmetry.
If you decide to try this, the BC would be something like:

Code:
myPatch
    {
        type            codedMixed;
        refValue        uniform (0 0 0);
        valueFraction   uniform 1;

        name    myBC;   

        code
        #{

        // Access the current value of time
        const Time& time = mesh.time();

        const scalar t = time.value();
	vector currentVelocity;
        // Loop over the patch
       if(t < 1)
       {
			forAll(patch(), faceI)
			{   

                // Imposes no-slip boundary condition
                  this->refValue()[faceI] = vector::zero; 
			}
	}
	else
       {
			forAll(patch(), faceI)
			{   

                // no penetration only
				
				currentVelocity = this->refValue()[faceI];
				this->refValue()[faceI] = currentVelocity - (currentVelocity&patch().nf()[f])&patch().nf()[f] ;
			}
	}
      #};
     }
I can't test the code so there might be some mistakes. What I'd do is simply assign the velocity vector minus the component orthogonal to the wall (patch().nf()[f] is the face normal versor). I used the currentVelocity vector to make it more clear.
I hope it helps.
gionni 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
Table bounds warnings at: END OF TIME STEP CFXer CFX 4 July 16, 2020 23:44
Radiation in semi-transparent media with surface-to-surface model? mpeppels CFX 11 August 22, 2019 07:30
Radiation interface hinca CFX 15 January 26, 2014 17:11
Question about heat transfer coefficient setting for CFX Anna Tian CFX 1 June 16, 2013 06:28
Error finding variable "THERMX" sunilpatil CFX 8 April 26, 2013 07:00


All times are GMT -4. The time now is 07:49.