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

Vector Center Face ---> Cells

Register Blogs Members List Search Today's Posts Mark Forums Read

Like Tree1Likes
  • 1 Post By anishtain4

Reply
 
LinkBack Thread Tools Search this Thread Display Modes
Old   November 7, 2016, 05:53
Exclamation Vector Center Face ---> Cells
  #1
Senior Member
 
FlyBob91's Avatar
 
Join Date: Mar 2016
Location: Bergamo
Posts: 157
Rep Power: 7
FlyBob91 is on a distinguished road
Hello to all,
i'm going to modify the equations at the boundary to run an adjoint simulation.
One of these equations includes a term r which is defined as the position vector starting from the center of the outlet surface.
I know the face center can be accessed by the function Cf() but i don't know how to set it for the entire outlet boundary and for the single cell.
Could someone help me defyning it?

Thanks for help,
Roberto
FlyBob91 is offline   Reply With Quote

Old   November 9, 2016, 10:21
Default
  #2
Senior Member
 
FlyBob91's Avatar
 
Join Date: Mar 2016
Location: Bergamo
Posts: 157
Rep Power: 7
FlyBob91 is on a distinguished road
Sorry for Bump,
i have not resolved the problem yet

here my equation:

Code:
u_tw = 1/(v_n - nu/h)*(-nu/h*u_(tw-1) + 2*(n x r)/|| r x v_t ||^(3) )
and here what i implemented

Code:
void Foam::adjointOutletVelocityFvPatchVectorField::updateCoeffs()
{
    if (updated())
    {
        return;
    }

//    const fvsPatchField<scalar>& phiap =
//        patch().lookupPatchField<surfaceScalarField, scalar>("phia");

    const fvPatchField<vector>& Up =
        patch().lookupPatchField<volVectorField, vector>("U");

    const fvPatchField<vector>& Uap =
        patch().lookupPatchField<volVectorField, vector>("Ua");

    const scalarField& deltainv = patch().deltaCoeffs(); // Distance^(-1)

    vectorField Uaneigh   = Uap.patchInternalField();               // Vettore
    vectorField Uaneigh_n = (Uaneigh & patch().nf())*patch().nf();  // Normale
    vectorField Uaneigh_t = Uaneigh - Uaneigh_n;                    // Tangente 

    vectorField Up_n = (Up & patch().nf())*patch().nf();  // Normale
    vectorField Up_t = Up - Up_n;                         // Tangente

    scalarField U_t = mag(Up_t);
    scalarField U_n = mag(Up_n);

    vectorField n = patch().nf();

 
    scalar nu = readScalar(db().lookupObject<IOdictionary>("transportProperties").lookup  
    ("nu"));

    vectorField :: operator = (1 /(U_n - nu * deltainv) * (-nu * Uaneigh_t * deltainv + 2*(n^Uaneigh) / pow (mag(Uaneigh ^ Up_t),3)));

    fixedValueFvPatchVectorField::updateCoeffs();
}

I have only to define r
FlyBob91 is offline   Reply With Quote

Old   November 10, 2016, 06:39
Default
  #3
Senior Member
 
FlyBob91's Avatar
 
Join Date: Mar 2016
Location: Bergamo
Posts: 157
Rep Power: 7
FlyBob91 is on a distinguished road
Hi again,

Can i use something like this? Is it right for my scope?

Code:
vectorField r = patch().Cf()-(10 15 30);
Where
Code:
patch().Cf()
is the face cell center (if i understood the command) coordinates and (10 15 30) the center coordinates of my boundary. Unfortunately it gives me an error i think it could derived from how i define the vector (10 15 30);


Regards,
Roberto
FlyBob91 is offline   Reply With Quote

Old   November 14, 2016, 14:41
Default
  #4
Senior Member
 
Mahdi Hosseinali
Join Date: Apr 2009
Location: NB, Canada
Posts: 272
Rep Power: 15
anishtain4 is on a distinguished road
Hi,
To get the center of the patch try using a bounding box, then average the limits. it would be your center. For the code you have up there, change it to this:

Quote:
vectorField r = patch().Cf()-vector(10 15 30);
FlyBob91 likes this.
anishtain4 is offline   Reply With Quote

Old   November 15, 2016, 06:29
Default
  #5
Senior Member
 
FlyBob91's Avatar
 
Join Date: Mar 2016
Location: Bergamo
Posts: 157
Rep Power: 7
FlyBob91 is on a distinguished road
Hi Mahdi, thanks for your reply.
Your solution is almost perfect but it's necessary to insert a comma between the elements vectors.

Code:
vectorField r = patch().Cf()-vector(10,15,30);
Many thanks.

Best Regards,
Roberto
FlyBob91 is offline   Reply With Quote

Reply

Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

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
channelFoam for a 3D pipe AlmostSurelyRob OpenFOAM 3 June 24, 2011 14:06
[snappyHexMesh] external flow with snappyHexMesh chelvistero OpenFOAM Meshing & Mesh Conversion 11 January 15, 2010 20:43
fluent add additional zones for the mesh file SSL FLUENT 2 January 26, 2008 12:55
[blockMesh] Axisymmetrical mesh Rasmus Gjesing (Gjesing) OpenFOAM Meshing & Mesh Conversion 10 April 2, 2007 15:00


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