|
[Sponsors] |
Tabulated viscosity data, viscosity vs cell centers |
|
LinkBack | Thread Tools | Search this Thread | Display Modes |
June 16, 2017, 14:22 |
Tabulated viscosity data, viscosity vs cell centers
|
#1 |
New Member
Pedro
Join Date: Feb 2016
Location: United States
Posts: 23
Rep Power: 10 |
Dear FOAMERS,
I have been trying to implement a non-Newtonian fluid for which no constitutive relation is developed yet. In other words, I have a data set of nu_t (y). I was wondering how I can have OpenFoam read the data from this dataset. Any help is greatly appreciated. Pedram Last edited by pedramtx; June 19, 2017 at 19:28. |
|
June 21, 2017, 18:42 |
|
#2 | |
New Member
Pedro
Join Date: Feb 2016
Location: United States
Posts: 23
Rep Power: 10 |
Quote:
Last edited by pedramtx; July 9, 2017 at 13:34. |
||
July 9, 2017, 13:30 |
Tabulated viscosity data, viscosity vs cell centers
|
#3 |
New Member
Pedro
Join Date: Feb 2016
Location: United States
Posts: 23
Rep Power: 10 |
Hello Foamers,
First, I should confess that I am not that expert in coding with OF. I have been trying to make OpenFOAM read viscosity from a list of values with respect to y (cell centers) values instead of dictating a constant value in transportproperties. The values of viscosity with respect to y are already available from some precursor simulation. After browsing the net, I found something similar. The library (Spline) is developed for non-Newtonian flow properties, which means it reads viscosity with respect to strain rate. However, my purpose is to read viscosity with respect to cell centers. If you can guide me through implementing this idea, I would greatly appreciate it. Even similar codes which relate to this type of implementation would be really helpful. By the way, the link to Spline model is: Custom viscosity model Thanks, Pedram |
|
July 10, 2017, 09:02 |
|
#4 |
Super Moderator
Tobias Holzmann
Join Date: Oct 2010
Location: Bad Wörishofen
Posts: 2,711
Blog Entries: 6
Rep Power: 52 |
Hi Pedram,
without thinking about the physical meaning of your implementation, you can achieve it as follow. I am assuming that you have a list of values (for the viscosity) and a list of points (for the cell center information). If you have both together in one list, you can use some bash scripts to extract the data to make two files (or excel or whatever you would like to have). In addition I am sure that there are better ways to do that than my suggestion but out of the box it is the first one that I can tell you: The data list of the files should look like that (just for completeness; guess you know that): Code:
/*--------------------------------*- C++ -*----------------------------------*\ | ========= | | | \\ / F ield | OpenFOAM: The Open Source CFD Toolbox | | \\ / O peration | Version: dev | | \\ / A nd | Web: www.OpenFOAM.org | | \\/ M anipulation | | \*---------------------------------------------------------------------------*/ FoamFile { version 2.0; format ascii; class dictionary; location "constant"; object cellZoneValuesDict; } // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // 2 ( 3 1 ); // ************************************************************************* // You can read this list by using the following command: Code:
const IOList<label> values ( IOobject ( "valuesDict", runTime.constant(), mesh, IOobject::MUST_READ, IOobject::NO_WRITE ) ); Code:
const IOList<point> points ( IOobject ( "pointsDict", runTime.constant(), mesh, IOobject::MUST_READ, IOobject::NO_WRITE ) ); Code:
//- Get the cell centers of the field (including boundaries) const volVectorField& cellCenters = mesh.C(); //- Just internal field (if needed) const vectorField& cellCentersInternal = cellCenters.internalField(); //- Loop through all internal cells forAll(cellCentersInternal, cellI) { //- Needed if no viscosity found bool found = false; //- Loop through the list of points available (read in) to find the // corresponding viscosity. forAll in a forAll loop might be not // the best solution. maybe there is a better solution but if this // is only done once at the beginning of a simulation it is fine. forAll(points, pI) { //- Get the point const point pointPosition = points[pI]; if (mesh.pointInCell(pointPosition, cellI) { //- Set viscosity mu[cellI] = values[pI] found = true; break; } } if (!found) { //- No viscosity found - error or maybe some default one? } }
__________________
Keep foaming, Tobias Holzmann |
|
July 14, 2017, 19:28 |
|
#5 |
New Member
Pedro
Join Date: Feb 2016
Location: United States
Posts: 23
Rep Power: 10 |
Tobias,
I really appreciate your help. I will implement your idea and will let you know if it works. Pedram Last edited by pedramtx; July 18, 2017 at 19:38. |
|
July 18, 2017, 19:38 |
|
#6 | |
New Member
Pedro
Join Date: Feb 2016
Location: United States
Posts: 23
Rep Power: 10 |
Quote:
I implemented your idea in my solver. Unfortunately, I am running into the error: Code:
Create mesh for time = 0 Reading transportProperties --> FOAM FATAL IO ERROR: wrong token type - expected int, found on line 20 the doubleScalar 8.074e-12 file: /scratch/user/ptazraei/tobi/constant/valuesDict at line 20. From function operator>>(Istream&, int&) in file primitives/ints/int/intIO.C at line 68. FOAM exiting I added the following part to the .C file of the solver. Code:
const volVectorField& cellCenters = mesh.C(); const vectorField& cellCentersInternal = cellCenters.internalField(); forAll(cellCentersInternal, cellI) { bool found = false; forAll(points, pI) { const point pointPosition = points[pI]; if (mesh.pointInCell(pointPosition, cellI)) { nut[cellI] = values[pI]; found = true; break; } } if (!found) { return false; } } volScalarField nuEff(0.5*(nut)+nu); fvVectorMatrix UEqn ( fvm::ddt(U) + fvm::div(phi, U) -fvm::laplacian(nuEff, U) == vector(1,0,0) * gradP ); ...... Code:
const IOList<label> values ( IOobject ( "valuesDict", runTime.constant(), mesh, IOobject::MUST_READ, IOobject::NO_WRITE ) ); const IOList<point> points ( IOobject ( "pointsDict", runTime.constant(), mesh, IOobject::MUST_READ, IOobject::NO_WRITE ) ); The format of valuesDict and pointsDict is like this: Code:
/*--------------------------------*- C++ -*----------------------------------*\ | ========= | | | \\ / F ield | OpenFOAM: The Open Source CFD Toolbox | | \\ / O peration | Version: dev | | \\ / A nd | Web: www.OpenFOAM.org | | \\/ M anipulation | | \*---------------------------------------------------------------------------*/ FoamFile { version 2.0; format ascii; class dictionary; location "constant"; object valuesDict; } // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // 99 ( 0.000000000008074 0.000000000082256 0.000000000748006 0.000000004486520 0.000000019307300 0.000000065185300 0.000000182306000 0.000000436471000 0.000000914311000 0.000001705110000 0.000002877430000 0.000004465330000 0.000006471050000 0.000008877830000 0.000011662600000 0.000014803500000 . . . ); // ************************************************************************* // Code:
/*--------------------------------*- C++ -*----------------------------------*\ | ========= | | | \\ / F ield | OpenFOAM: The Open Source CFD Toolbox | | \\ / O peration | Version: dev | | \\ / A nd | Web: www.OpenFOAM.org | | \\/ M anipulation | | \*---------------------------------------------------------------------------*/ FoamFile { version 2.0; format ascii; class dictionary; location "constant"; object pointsDict; } // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // 99 ( 0.001321090000000 0.004052960000000 0.006970310000000 0.010085800000000 0.013412700000000 0.016965600000000 0.020759700000000 0.024811400000000 0.029138100000000 0.033758700000000 0.038693000000000 0.043962300000000 0.049589400000000 0.055598600000000 0.062015700000000 0.068868600000000 0.076186700000000 0.084001700000000 . . . ); // ************************************************************************* // Pedram Last edited by wyldckat; August 27, 2017 at 15:25. Reason: Added [CODE][/CODE] markers |
||
July 19, 2017, 04:05 |
|
#7 |
Super Moderator
Tobias Holzmann
Join Date: Oct 2010
Location: Bad Wörishofen
Posts: 2,711
Blog Entries: 6
Rep Power: 52 |
Please make use of the code tags. As it is stated in the message, FOAM searches an integer:
Code:
const IOList<label> values ( IOobject ( "valuesDict", runTime.constant(), mesh, IOobject::MUST_READ, IOobject::NO_WRITE ) ); Code:
--> FOAM FATAL IO ERROR: wrong token type - expected int, found on line 20 the doubleScalar 8.074e-12 file: /scratch/user/ptazraei/tobi/constant/valuesDict at line 20.
__________________
Keep foaming, Tobias Holzmann |
|
July 19, 2017, 12:22 |
|
#8 | |
New Member
Pedro
Join Date: Feb 2016
Location: United States
Posts: 23
Rep Power: 10 |
Quote:
I am grateful for your help. I implemented the change you suggested. Last edited by pedramtx; July 20, 2017 at 00:19. |
||
July 19, 2017, 19:46 |
|
#9 | |
New Member
Pedro
Join Date: Feb 2016
Location: United States
Posts: 23
Rep Power: 10 |
Quote:
Dear Tobias, I am afraid if I have explained the case clearly! The eddy viscosity list that I want to be read is only for one cross section (x), meaning nut is just a function of wall distance (y). Since we have 100 grids in the normal direction, the total number of cell centers for which nut is saved would be 99. Now, I want to use these data for the whole modeling process. Knowing that the simulation is 3D. After implementing your suggestion regarding scalar and label and starting the simulation, this error shows up! And I think this is because Openfoam is seeking all the cell centers of the flow domain in the list, while I just want the cell centers in the normal direction, with respect to which nut is known, to be called. -> FOAM FATAL IO ERROR: Expected a '(' while reading VectorSpace<Form, Cmpt, nCmpt>, found on line 20 the doubleScalar 0.00132109 file: /scratch/user/ptazraei/tobi/constant/pointsDict at line 20. From function Istream::readBegin(const char*) in file db/IOstreams/IOstreams/Istream.C at line 94. Last edited by pedramtx; July 20, 2017 at 00:23. |
||
August 27, 2017, 15:28 |
|
#10 |
Retired Super Moderator
Bruno Santos
Join Date: Mar 2009
Location: Lisbon, Portugal
Posts: 10,982
Blog Entries: 45
Rep Power: 128 |
Greetings to all!
@pedramtx: I've come looking for posts of yours on this topic, following a PM you sent me on the 26th of June 2017. I don't know if you have finally solved this issue, but if you haven't, then please provide a simple test case and an example dictionary file that we can use to try and implement this. Best regards, Bruno
__________________
|
|
August 29, 2017, 07:12 |
|
#11 |
New Member
Lucas Gasparino
Join Date: Jul 2017
Location: Swansea, UK
Posts: 23
Rep Power: 9 |
In truth, you can't: constitutive laws enter the equations through viscous stresses, themselves a function of flow variables. If you had a continuous relationship, then I'd suggest an initial step in the loop where it generates tau_ij at that step to be used in the momentum eqn. Still, it would need to be triaxial data (all 6 components of the tensor). Now, with piecewise data, not sure how it would work: somehow, you'd need to implement the rheology at this step. Try looking at the way they deal with simpler models, might give you a hint.in truth though, I'd say it's better to implement the law, otherwise your desired phenomena may not be modelled. Even in solids, when you have test data, you have to select a base material model, like Mooney-Rivlin or Ogden, before setting up your data, since the model's coefficients will be calculated by curve fitting; can you do something similar in your case? Is there a material with similar behaviour?
Sent from my XT1635-02 using CFD Online Forum mobile app |
|
Tags |
cell center data, funkysetfields, setfield, tabulated format, viscosity model |
|
|
Similar Threads | ||||
Thread | Thread Starter | Forum | Replies | Last Post |
[Other] refineWallLayer Error | Yuby | OpenFOAM Meshing & Mesh Conversion | 2 | November 11, 2021 12:04 |
[OpenFOAM] How to get the coordinates of velocity data at all cells and at all times | vidyadhar | ParaView | 9 | May 20, 2020 21:06 |
FvMatrix coefficients | shrina | OpenFOAM Running, Solving & CFD | 10 | October 3, 2013 15:38 |
How to read tabulated data in Fluent | Siddhartha Pal | FLUENT | 0 | August 30, 2007 06:18 |
Warning 097- | AB | Siemens | 6 | November 15, 2004 05:41 |