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

Coupling Patches

Register Blogs Community New Posts Updated Threads Search

Reply
 
LinkBack Thread Tools Search this Thread Display Modes
Old   January 26, 2018, 10:07
Default Coupling Patches
  #1
New Member
 
Join Date: Jan 2018
Posts: 3
Rep Power: 8
StefanP is on a distinguished road
Dear FOAMers,
i want to couple the mass flow of an outlet BC to the inlet BC, thus I modified the pressureInletVelocity BC.
My problem is that the scalar outflow doesn't work and I can't use it.

The code looks as follows:
{
if (updated())
{
return;
}

const surfaceScalarField& rhoPhi =
db().lookupObject<surfaceScalarField>("rhoPhi");

const volScalarField& rho =
db().lookupObject<volScalarField>("rho");

tmp<vectorField> n = patch().nf();

const fvMesh& mesh = patch().boundaryMesh().mesh();

label couplingPatchID = mesh.boundaryMesh().findPatchID(couplingPatchName_ );

const Field<scalar>& magS = patch().magSf();

const fvPatchField<scalar>& rho_Patch = patch().lookupPatchField<volScalarField, scalar>(rhoName_);


if (rhoPhi.dimensions() == dimVelocity*dimArea*dimDensity)
{
const fvsPatchField<scalar>& outflow = sum(rhoPhi.boundaryField()[couplingPatchID]);

const scalar S_patch = sum(magS);

operator==(n*outflow/S_patch);

Info<< "mass flux = " <<outflow << endl <<endl;
}
else
{
FatalErrorInFunction
<< "dimensions of phi are not correct"
<< "\n on patch " << this->patch().name()
<< " of field " << this->internalField().name()
<< " in file " << this->internalField().objectPath()
<< exit(FatalError);
}

fixedValueFvPatchVectorField::updateCoeffs();
}

Can anyone help me with that problem?

THANK YOU IN ADVANCE
StefanP is offline   Reply With Quote

Old   January 27, 2018, 11:50
Default
  #2
Senior Member
 
Nima Samkhaniani
Join Date: Sep 2009
Location: Tehran, Iran
Posts: 1,267
Blog Entries: 1
Rep Power: 25
nimasam is on a distinguished road
why don't you use cyclic boundary condition ?
__________________
My Personal Website (http://nimasamkhaniani.ir/)
Telegram channel (https://t.me/cfd_foam)
nimasam is offline   Reply With Quote

Old   January 29, 2018, 02:51
Default
  #3
New Member
 
Join Date: Jan 2018
Posts: 3
Rep Power: 8
StefanP is on a distinguished road
Thank you very much nimasam for your quick answer!
I think the way I wanted to tackle the problem was too complicated
StefanP is offline   Reply With Quote

Old   January 29, 2018, 07:03
Default
  #4
New Member
 
Join Date: Jan 2018
Posts: 3
Rep Power: 8
StefanP is on a distinguished road
But regardless of using cyclic boundary condition would be the better choice, what is the problem in my coded BC?
StefanP is offline   Reply With Quote

Old   January 29, 2018, 22:19
Default
  #5
New Member
 
Yuncheng Xu (Cloud)
Join Date: May 2011
Location: State College, PA
Posts: 20
Rep Power: 15
luther1990 is on a distinguished road
Quote:
Originally Posted by StefanP View Post
But regardless of using cyclic boundary condition would be the better choice, what is the problem in my coded BC?
What is couplingPatchName_?

First, you need to make sure couplingPatchID is correct.

Second, in the following code, outflow is defined as fvsPatchField, which is not a scalar. Also, sum(rhoPhi.boundaryField() makes no sense.
Code:
const fvsPatchField<scalar>& outflow = sum(rhoPhi.boundaryField()[couplingPatchID]);

const scalar S_patch = sum(magS);

operator==(n*outflow/S_patch);
I am not sure what version are you using, but in OF30x, it already implemented

Code:
    else if (phi.dimensions() == dimDensity*dimVelocity*dimArea)
    {
        const fvPatchField<scalar>& rhop =
            patch().lookupPatchField<volScalarField, scalar>(rhoName_);

        operator==(n*phip/(rhop*magS));
    }
Hope it can help you.
luther1990 is offline   Reply With Quote

Reply

Tags
boudary field, patch field


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
Foam::error::PrintStack almir OpenFOAM Running, Solving & CFD 92 May 21, 2024 08:56
Coupling patches in chtMultiRegionSimpleFoam Nkl OpenFOAM Running, Solving & CFD 17 May 19, 2023 10:23
Possible bug with stitchMesh and cyclics in OpenFoam Jack001 OpenFOAM Pre-Processing 0 May 21, 2016 09:00
[blockMesh] Merging edge patches Yosmcer OpenFOAM Meshing & Mesh Conversion 11 November 16, 2014 15:51
[swak4Foam] groovyBC for coupling of patches deniggo OpenFOAM Community Contributions 20 October 2, 2014 19:04


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