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

Different Results from codedMixed vs. codedFilxedValue

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

Reply
 
LinkBack Thread Tools Search this Thread Display Modes
Old   April 8, 2021, 00:52
Unhappy Different Results from codedMixed vs. codedFilxedValue
  #1
New Member
 
Join Date: Dec 2017
Posts: 5
Rep Power: 8
JSalami is on a distinguished road
Dear friends,

I am working with the chtMultiregionFoam and trying to modify the compressible::turbulentTemperatureCoupledBaffleMix ed BC with additional terms it cannot handle. I am using coded boundary conditions for convenience.

So I thought the first thing I should do is try to replicate the standard boundary condition using codedFixedValue (which is what I will eventually need) using the formulas explained by Bloerb in the post: Understanding temperature coupling BCs. I did this simply as follows:

Code:
//got references to patches, variables, etc..

scalarField valueFraction = kNbr*deltaNbr/(k*delta +  kNbr*deltaNbr);
operator==(valueFraction*Tnbr + (1-valueFraction)*T);
The code above gave results that are quite different from the original boundary condition.
So I decided to take a step back and instead use codedMixed as follows:

Code:
//got references to patches, variables, etc..

    this->refValue() = Tnbr;    
    this->refGrad() = 0.0;
    this->valueFraction() = kNbr*deltaNbr/(k*delta +  kNbr*deltaNbr);
which gave identical results to urbulentTemperatureCoupledBaffleMixed, as expected.

I looked at the codes of codedMixed and codedFixedValue and their base classes to try to figure out what is causing the difference to no avail.

What am I missing here? I would really appreciate any help! I'm using OF1912.

Last edited by JSalami; April 8, 2021 at 22:24.
JSalami is offline   Reply With Quote

Old   April 9, 2021, 05:12
Default
  #2
New Member
 
Join Date: May 2019
Posts: 16
Rep Power: 7
NiklasW is on a distinguished road
Hi,

could you show, how you specified the variables used in the codedFixedValue BC?
NiklasW is offline   Reply With Quote

Old   April 9, 2021, 22:04
Default
  #3
New Member
 
Join Date: Dec 2017
Posts: 5
Rep Power: 8
JSalami is on a distinguished road
Quote:
Originally Posted by NiklasW View Post
Hi,

could you show, how you specified the variables used in the codedFixedValue BC?
Hi Niklas,

Here's the full code(I use this same way to get the variables for both fixed and mixed coded BCs:

Code:
// Since we're inside initEvaluate/evaluate there might be processor
    // comms underway. Change the tag we use.
    int oldTag = UPstream::msgType();
    UPstream::msgType() = oldTag+1;
    
    //get this patch's mesh
    const fvMesh& mesh = patch().boundaryMesh().mesh();
 
    const label id = patch().index();
   
   //get mesh variables
    const volScalarField& TMesh = mesh.lookupObject<volScalarField>("T");
    const volScalarField& kappaMesh = mesh.lookupObject<volScalarField>("kappa");
    
    //get patch internal varialbes and delta
    const scalarField T         = TMesh.boundaryField().boundaryInternalField()[id];
    const scalarField kappa        = kappaMesh.boundaryField().boundaryInternalField()[id];
    const scalarField delta        = patch().deltaCoeffs();
    
    // Get the coupling information from the mappedPatchBase
    const mappedPatchBase& mpp = refCast<const mappedPatchBase>(patch().patch());
    const polyMesh& nbrMesh = mpp.sampleMesh();
    const label nbrid = mpp.samplePolyPatch().index();
    const fvPatch& nbrPatch = refCast<const fvMesh>(nbrMesh).boundary()[nbrid];
    
    //get neighbor mesh variable
     const volScalarField& Tnbrmesh = nbrMesh.lookupObject<volScalarField>("T");
     const volScalarField& kappanbrmesh = nbrMesh.lookupObject<volScalarField>("kappa");
    
     
     scalarField Tnbr(Tnbrmesh.boundaryField().boundaryInternalField()[nbrid]);
     scalarField kappanbr(kappanbrmesh.boundaryField().boundaryInternalField()[nbrid]);
     scalarField deltanbr(nbrPatch.deltaCoeffs());
     
    mpp.distribute(Tnbr);
    mpp.distribute(kappanbr);
    mpp.distribute(deltanbr);

scalarField valueFraction = kappanbr*deltanbr/(kappa*delta +  kappanbr*deltanbr);
operator==(valueFraction*Tnbr + (1-valueFraction)*T);

    //// Restore tag
    UPstream::msgType() = oldTag;
JSalami is offline   Reply With Quote

Old   April 13, 2021, 05:02
Default
  #4
New Member
 
Join Date: May 2019
Posts: 16
Rep Power: 7
NiklasW is on a distinguished road
Hi,

thanks for providing your code.
I copied it and tried a bit around with it in a simple test case.
I also got different results compared to the turbulentTemperatureCoupledBaffleMixed BC, but lowering time step or thermal conductivity made the difference much smaller. In case of low time step and low thermal conductivity the difference nearly vanishes.

Thus I don't think, there's a general mistake in your code, it's just more vulnerable to numerical errors.
If there's no way you can use a mixed BC, you should probably pay attention to a low diffusion number in your solid regions.
NiklasW is offline   Reply With Quote

Old   April 13, 2021, 21:24
Default
  #5
New Member
 
Join Date: Dec 2017
Posts: 5
Rep Power: 8
JSalami is on a distinguished road
Quote:
Originally Posted by NiklasW View Post
Hi,

thanks for providing your code.
I copied it and tried a bit around with it in a simple test case.
I also got different results compared to the turbulentTemperatureCoupledBaffleMixed BC, but lowering time step or thermal conductivity made the difference much smaller. In case of low time step and low thermal conductivity the difference nearly vanishes.

Thus I don't think, there's a general mistake in your code, it's just more vulnerable to numerical errors.
If there's no way you can use a mixed BC, you should probably pay attention to a low diffusion number in your solid regions.
Thanks for trying it out Niklas!

Unfortunately, the mixed boundary condition cannot help in this case since I am not really targeting temperature, but I'm using this for the "Magnetic Vector Potential", which requires additional terms besides the mixed boundary condition terms. Using temperature was a way for me to troubleshoot it.
It is very strange that these two give very different results.. There must be some missing operation needed to re-produce the mixed BC solution. I will try to do some digging and let you know if I find something.
JSalami is offline   Reply With Quote

Reply

Tags
chtmultiregionfoam, codedfixedvalue, codedmixed, openfoam1912

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
Different results using Swak and CodedMixed gionni OpenFOAM Programming & Development 2 March 12, 2021 06:22
Wrong results with Mechanical Ansys mesher used with codedMixed value boundary condit Nabeel Abed OpenFOAM Pre-Processing 0 November 8, 2020 06:31
lid driven cavity varying results yasmil OpenFOAM Running, Solving & CFD 2 October 6, 2016 21:42
interFoam simulation yields inconsistent results for alpha1 surface Ralinus OpenFOAM Running, Solving & CFD 8 January 13, 2014 08:54
CFX cylinder or sphere benchmark results Mel CFX 1 August 8, 2005 18:47


All times are GMT -4. The time now is 10:50.