|
[Sponsors] |
June 26, 2015, 19:09 |
|
#21 | |
Super Moderator
Philip Cardiff
Join Date: Mar 2009
Location: Dublin, Ireland
Posts: 1,093
Rep Power: 34 |
Quote:
Code:
newPatchValues[i] = -T.boundaryField()[patchID].snGrad()[i]; Code:
newPatchValues[i] = -T.boundaryField()[patchID].snGrad()()[i]; Code:
const scalarField patchTSnGrad = T.boundaryField()[patchID].snGrad(); forAll(newPatchValues, i) { newPatchValues[i] = -patchTSnGrad[i]; } |
||
June 26, 2015, 20:05 |
|
#22 |
Senior Member
Alejandro
Join Date: Jan 2014
Location: Argentina
Posts: 128
Rep Power: 12 |
Thank you very much. I have some more questions.
1) If I need to perform mathematical operations (like log, exp, etc) to calculate new T from grad and old T. I have errors because of the different kind of variables. How can i solve it? 2) wich solver I have to select in order to verify the convergence of the BC?. Or the only change is modifying while (simple.correct Non Orthogonal())? |
|
June 26, 2015, 20:09 |
|
#23 | ||
Super Moderator
Philip Cardiff
Join Date: Mar 2009
Location: Dublin, Ireland
Posts: 1,093
Rep Power: 34 |
Quote:
Quote:
Philip |
|||
June 26, 2015, 21:41 |
|
#24 | |
Senior Member
Alejandro
Join Date: Jan 2014
Location: Argentina
Posts: 128
Rep Power: 12 |
Quote:
I am learning from laplacianFoam in steady state (the easy way). My question it is not referred to verification, instead I want to know an easy way to control convergence when BC change after each iteration. In laplacianFoam, the new nonlinear BC iterate only a number of times given by: simple.correct Non Orthogonal() setting in fvSolution Last edited by ancolli; June 28, 2015 at 18:41. |
||
November 12, 2015, 00:06 |
|
#25 |
Member
methma Rajamuni
Join Date: Jul 2015
Location: Victoria, Australia
Posts: 40
Rep Power: 11 |
hi Pillip,
Your posts on updating boundary condition on each iteration was very helpful to me. I am implementing a new solver using the icoFoam solver to handle the fluid-solid interaction (Vortex induced vibration). The vibration of the solid is taken into the account by assuming the fluid is in a non-inertial frame vibrate on opposite to the solid motion while the solid stay still. The solid motion due to the fluid forces are solve inside the solver and update the boundary condition accordingly in each iteration. My question: Since fluid is in a non-inertial frame the acceleration of the frame needs to add into the navier stokes equations. For that I defined a field variable ddy. This accelaration is a uniform value across the fluid. I can update the boundary condition as you said. Can you please tell me how to update the internal field as well? I have defined the internal field initially as a uniform value. Many thanks, Methma |
|
September 23, 2016, 03:33 |
|
#26 |
Member
Suman Chakraborty
Join Date: Sep 2014
Location: Mumbai, India
Posts: 42
Rep Power: 12 |
Hi,
This is an old thread but am trying to do the same thing, so posting my doubt here. I am using OpenFOAM 2.4.0 and using pisoFoam solver. I want to change the fixedGradient B.C at each time loop. So I followed what was suggested here: Code:
fixedGradientFvPatchVectorField& wallPatch = refCast<fixedGradientFvPatchVectorField>(U.boundaryField()[patchID]); wallPatch.gradient() = dU_dy; dU_dy is some "double" variable for which I calculate something. But I get this error: "fixedGradientFvPatchVectorField’ was not declared in this scope" Please suggest where am I going wrong. Thank you. |
|
September 23, 2016, 07:02 |
|
#27 | |
Assistant Moderator
Bernhard Gschaider
Join Date: Mar 2009
Posts: 4,225
Rep Power: 51 |
Quote:
__________________
Note: I don't use "Friend"-feature on this forum out of principle. Ah. And by the way: I'm not on Facebook either. So don't be offended if I don't accept your invitation/friend request |
||
September 23, 2016, 07:47 |
|
#28 |
Member
Suman Chakraborty
Join Date: Sep 2014
Location: Mumbai, India
Posts: 42
Rep Power: 12 |
Hi Bernhard,
I have in included in myfile: #include "fixedGradientFvPatchField.H" Still am gettinhe the error. Just for your reference an pasting the start part of my file here. insertModification.H is where I am trying my thing. Code:
#include "fvCFD.H" #include "singlePhaseTransportModel.H" #include "turbulenceModel.H" #include "fixedGradientFvPatchField.H" // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // int main(int argc, char *argv[]) { #include "setRootCase.H" #include "createTime.H" #include "createMesh.H" #include "createFields.H" #include "initContinuityErrs.H" // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // Info<< "\nStarting time loop\n" << endl; while (runTime.loop()) { Info<< "Time = " << runTime.timeName() << nl << endl; #include "readPISOControls.H" #include "CourantNo.H" #include "insertModification.H" // Pressure-velocity PISO corrector { // Momentum predictor fvVectorMatrix UEqn ( fvm::ddt(U) + fvm::div(phi, U) + turbulence->divDevReff(U) ); |
|
September 23, 2016, 08:55 |
|
#29 |
Assistant Moderator
Bernhard Gschaider
Join Date: Mar 2009
Posts: 4,225
Rep Power: 51 |
Fields.H not Field.H. The "s" is important
__________________
Note: I don't use "Friend"-feature on this forum out of principle. Ah. And by the way: I'm not on Facebook either. So don't be offended if I don't accept your invitation/friend request |
|
September 23, 2016, 09:06 |
|
#30 | |
Super Moderator
Philip Cardiff
Join Date: Mar 2009
Location: Dublin, Ireland
Posts: 1,093
Rep Power: 34 |
Quote:
Can you post your code segment? I think the problem is "snGrad()" returns a "tmp" of a field, so either you modify the code to be: Code:
newPatchValues[i] = -T.boundaryField()[patchID].snGrad()()[i]; Code:
const scalarField TsnGrad= T.boundaryField()[patchID].snGrad(); forAll(newPatchValues, i) { newPatchValues[i] = -TsnGrad[i]; } Philip |
||
September 23, 2016, 14:51 |
|
#31 |
Member
Suman Chakraborty
Join Date: Sep 2014
Location: Mumbai, India
Posts: 42
Rep Power: 12 |
Hi Bernhard,
It is working. Was indeed a spell typo. Thanks a lot for your help. Hi Philip, It seems the error was because of a typo. Here is a section of my code: Code:
label patchID = mesh.boundaryMesh().findPatchID("channelWall"); label nFaces = mesh.boundaryMesh()[patchID].size(); for(int facei = 0 ; facei<nFaces; facei++) { // doing some calculations here .... const fixedGradientFvPatchVectorField& wallPatch = refCast<fixedGradientFvPatchVectorField>(U.boundaryField()[patchID]); wallPatch.gradient()[facei] == vector(0, dU_dy, 0); Thank you. |
|
September 26, 2016, 10:19 |
|
#32 |
Member
Suman Chakraborty
Join Date: Sep 2014
Location: Mumbai, India
Posts: 42
Rep Power: 12 |
Hi,
I have a doubt related to my last post. Code:
const fixedGradientFvPatchVectorField& wallPatch = refCast<fixedGradientFvPatchVectorField>(U.boundaryField()[patchID]); for(int facei = 0 ; facei<nFaces; facei++) { /**** calculation of some gradient ***/ Info<<" Gradient of face number "<< facei << " Before changing is "<<endl; Info<< wallPatch.gradient()[facei]<<endl; wallPatch.gradient()[facei] == vector(du_dy, 0, 0); Info<<" After changing is "<<endl; Info<< wallPatch.gradient()[facei]<<endl; } Code:
Face number 0 du_dy -0.00022415 Gradient of face number 0 Before changing is (0 0 0) After changing is (0 0 0) Face number 1 du_dy -0.00022415 Gradient of face number 1 Before changing is (0 0 0) After changing is (0 0 0) Face number 2 du_dy -0.00022415 Gradient of face number 2 Before changing is (0 0 0) After changing is (0 0 0) Face number 3 du_dy -0.00022415 Gradient of face number 3 Before changing is (0 0 0) After changing is (0 0 0) |
|
September 26, 2016, 11:28 |
|
#33 | |
Super Moderator
Philip Cardiff
Join Date: Mar 2009
Location: Dublin, Ireland
Posts: 1,093
Rep Power: 34 |
Quote:
The "==" operator is just necessary when assigning the value to an entire fixedValue-type boundary condition. Philip |
||
September 27, 2016, 03:56 |
|
#34 |
Member
Suman Chakraborty
Join Date: Sep 2014
Location: Mumbai, India
Posts: 42
Rep Power: 12 |
Hi Philip,
Thank you so much for the reply. I changed '==' to '=', then it gave me the following error: Code:
error: passing ‘const Foam::Vector<double>’ as ‘this’ argument discards qualifiers [-fpermissive] wallPatch.gradient()[facei] = vector(du_dy, 0, 0); Code:
fixedGradientFvPatchVectorField& wallPatch = refCast<fixedGradientFvPatchVectorField>(U.boundaryField()[patchID]); Suman |
|
October 12, 2016, 14:17 |
Modified pisoFoam for pitzDaily - solver blowing up !!
|
#35 |
Member
Suman Chakraborty
Join Date: Sep 2014
Location: Mumbai, India
Posts: 42
Rep Power: 12 |
Hi there,
Am having some problem in solving flow over backward facing step in OpenFOAM. I am using LES and Smagorinsky Model. At start it all goes well but after some time utau values at the wall starts increasing and the deltaT of simulation goes on decreasing (till if falls to 10^-12 or so order). I cannot detect what is the problem. I have modified the pisoFoam solver so impose stress boundary condition using the 'fixedGradient' feature of OpenFOAM. Am attaching my required files here. Please have a look and suggest where am I going wrong. Will be waiting for a reply. solver.tar.gz TestCase.tar.gz |
|
October 13, 2016, 03:42 |
|
#36 |
Member
Suman Chakraborty
Join Date: Sep 2014
Location: Mumbai, India
Posts: 42
Rep Power: 12 |
Hi there,
I think the problems are coming with the pressure solver settings. At t=0.01 pressure values are about -120 at the inlet and then increases linearly to close to zero at the outlet. But at T=0.05, it falls down to -4000 approx. Obviously in an incompressible flow, the absolute value of pressure does not matter, it is the gradient that matters. But what I am not understanding are such low values. Considering inlet velocity has a magnitude of 10 in the x direction (which is max amongst all 3 directions), a value of -50 to -70 may still be understandable but -4000, am not getting at all. Not understanding why the pressure field is behaving such. Maybe that is triggering the problem. |
|
October 26, 2016, 10:36 |
|
#37 |
Member
Suman Chakraborty
Join Date: Sep 2014
Location: Mumbai, India
Posts: 42
Rep Power: 12 |
Hi,
Back again with an update on this same issue. So to start with, setting the gradient at the wall was not so much of a good idea it seems. Somehow the wall normal velocity was being calculated to be a non zero value at the wall. This might be one of the reasons for the solver to blow up in that manner. The modified code I am using now, uses fixedValue (0 0 0) as a boundary condition at the wall and in the modified solver, I calculate the velocity at the wall using the gradient and set the velocity. The solver now runs properly and does not blow up. The only issue am facing with this is, the reynolds stress when calculated comes out to be very less; flow is not becoming turbulent only. Am wondering if it's an issue with the gradient schemes being used or not. If anyone has any views on this, it will be really helpful. So the question is, what is the best gradient scheme to be used for solving incompressible turbulent flow (using LES) in openFOAM? Sorry for maintaining two threads for the same topic. I will from now on post the updates on one particular thread itself: Link: http://www.cfd-online.com/Forums/ope...tml#post623038 |
|
May 29, 2017, 12:50 |
|
#38 | ||||
New Member
Simone Colucci
Join Date: Mar 2016
Location: Pisa (Italy)
Posts: 23
Rep Power: 10 |
Dear Suman,
I have a similar problem, that is my piece of code Quote:
Quote:
error: no match for ‘operator==’ (operand types are ‘const Foam::fvPatchField<double>’ and ‘Foam::scalarField {aka Foam::Field<double>}’) Index[0][0].boundaryField()[patchi] == newPatchValues; If I substitute Quote:
Quote:
error: passing ‘const Foam::fvPatchField<double>’ as ‘this’ argument of ‘void Foam::fvPatchField<Type>:perator=(const Foam::UList<T>&) [with Type = double]’ discards qualifiers [-fpermissive] Index[0][0].boundaryField()[patchi] = newPatchValues; It seems to be the same problem as you, but I do not have any const! Any idea? Simone |
|||||
May 29, 2017, 13:14 |
|
#39 | ||||
New Member
Simone Colucci
Join Date: Mar 2016
Location: Pisa (Italy)
Posts: 23
Rep Power: 10 |
Dear Philip,
I post here the same problem that I posted in an other thread since here it is older but seems more appropriate ... I have a similar problem, that is my piece of code Quote:
Quote:
error: no match for ‘operator==’ (operand types are ‘const Foam::fvPatchField<double>’ and ‘Foam::scalarField {aka Foam::Field<double>}’) Index[0][0].boundaryField()[patchi] == newPatchValues; If I substitute Quote:
Quote:
error: passing ‘const Foam::fvPatchField<double>’ as ‘this’ argument of ‘void Foam::fvPatchField<Type>:perator=(const Foam::UList<T>&) [with Type = double]’ discards qualifiers [-fpermissive] Index[0][0].boundaryField()[patchi] = newPatchValues; It seems to be the same problem as you, but I do not have any const! Any idea? Simone |
|||||
May 29, 2017, 15:10 |
|
#40 |
Super Moderator
Philip Cardiff
Join Date: Mar 2009
Location: Dublin, Ireland
Posts: 1,093
Rep Power: 34 |
Hi Simone,
This error: Code:
error: passing ‘const Foam::fvPatchField<double>’ as ‘this’ argument of ‘void Foam::fvPatchField<Type>::operator=(const Foam::UList<T>&) [with Type = double]’ discards qualifiers [-fpermissive] From this code: Code:
PtrList<PtrList<volScalarField> > Index(yindex.size()); Index.set(0, new PtrList<volScalarField>(2)); Index[0].set ( 0, new volScalarField ( IOobject ( "Index.pressure" , this->pair_.phase1().time().timeName(), this->pair_.phase1().mesh(), IOobject::NO_READ, IOobject::NO_WRITE ), Np_[0]*(p - one_p*pmin_[0])/( one_p*pmax_[0] - one_p*pmin_[0] ) ) ); // correct internalField forAll(Index[0][0],celli) { Index[0][0][celli] = floor(Index[0][0][celli]); } // correct BC forAll(Index[0][0].boundaryField(), patchi) { scalarField newPatchValues(Index[0][0].boundaryField()[patchi].size(),scalar(0)); forAll(Index[0][0].boundaryField()[patchi],i) { newPatchValues[i] = floor(Index[0][0].boundaryField()[patchi][i]); } Index[0][0].boundaryField()[patchi] == newPatchValues; } Are you sure this is the code you are compiling? did you, for example, post "simplified" code? If possible I would suggest making a very simple OpenFOAM utility that shows this compilation problem and then upload this for others to try. Philip Last edited by bigphil; May 29, 2017 at 15:11. Reason: remove leftover quote code |
|
|
|
Similar Threads | ||||
Thread | Thread Starter | Forum | Replies | Last Post |
Impinging Jet Boundary Conditions | Anindya | Main CFD Forum | 25 | February 27, 2016 13:58 |
OpenFOAM Variable Velocity Boundary Conditions | NickolasPl | OpenFOAM Programming & Development | 2 | May 19, 2011 06:37 |
Concentric tube heat exchanger (Air-Water) | Young | CFX | 5 | October 7, 2008 00:17 |
[Commercial meshers] Trimmed cell and embedded refinement mesh conversion issues | michele | OpenFOAM Meshing & Mesh Conversion | 2 | July 15, 2005 05:15 |
A problem about setting boundary conditions | lyang | Main CFD Forum | 0 | September 19, 1999 19:29 |