|
[Sponsors] |
November 24, 2020, 09:51 |
Filling cells with values
|
#1 |
New Member
Join Date: Sep 2020
Posts: 28
Rep Power: 6 |
Hello!
I have created the body with blockMesh. I suggest that there are cells within the body. My problem is to create own solver by which I fill each cell by certain value, for example, temperature = 5. I have created initial conditions for T in the "0" file and created the "createFields.H" file, where defined values of field are read, it looks like: Code:
volScalarField T ( IOobject ( "T", runTime.timeName(), mesh, IOobject::MUST_READ, IOobject::AUTO_WRITE ), mesh ); Code:
forAll(T, i) { ... } What should I do for see these values (fields) in paraview? |
|
November 24, 2020, 10:07 |
|
#2 |
Senior Member
Join Date: Dec 2019
Location: Cologne, Germany
Posts: 369
Rep Power: 8 |
why don't you just use setFieldsDict?
it would be more flexible. |
|
November 24, 2020, 10:17 |
|
#3 |
New Member
Join Date: Sep 2020
Posts: 28
Rep Power: 6 |
||
November 24, 2020, 10:45 |
|
#4 |
Senior Member
Join Date: Dec 2019
Location: Cologne, Germany
Posts: 369
Rep Power: 8 |
i see.
after defining your zone in topoSet you need to access the cells: word myZone = "nameGivenInTopoSetDict"; label zoneID = mesh.cellZones().findZoneID(myZone); const labelList& cells = mesh.cellZones()[zoneID]; forAll(cells, i) { const label cell = cells[i]; T[cell] = yourValue; //keep in mind that you need to match Unit also! } //repeat for other zones! |
|
November 24, 2020, 10:59 |
|
#5 | |
New Member
Join Date: Sep 2020
Posts: 28
Rep Power: 6 |
Quote:
Could you give me another advice what should I write in the solver that is responsible for sending cells to paraview? (Create "Cell Arrays" under "Mesh regions"). ParaView doesn't see new partial temperatures ( "T(partial)" ), but see created cellZones. They're represented by different colours. I can choose old T(partial) only which shows zero values at each cells (when "internalMesh" is chosen"). I have attached paraView interface: https://ibb.co/DrNqG8V. In addition to this, I've noticed that new time has appeared (1 sec). How can I avoid this? Last edited by Reptider; November 24, 2020 at 14:57. |
||
November 25, 2020, 03:26 |
|
#6 |
Senior Member
Join Date: Dec 2019
Location: Cologne, Germany
Posts: 369
Rep Power: 8 |
look at this T-object:
volScalarField T ( IOobject ( "T", runTime.timeName(), mesh, IOobject::MUST_READ, IOobject::AUTO_WRITE ), mesh ); if you create a volScalarField as IOobject it means it is an input-output object, which means the solver can read and/or write data, so paraview can find it in the time-directories. if you write AUTO_WRITE it will create a T-file in every output directory that you can open with paraview, the files will be updated when your solver calls the function runTime.write(). you decide in controlDict under writeInterval when runtime.write() should be called. if you change your T-field in the solver manually with cellZones and later on let the solver update the field by solving an equation you will see the field which is provided by the result of the equation for T. if you initialize your T-field in the 0-directory with 0-entries for the internal mesh it is normal that in the old timestep which is time=0 sec that paraview shows only 0 Kelvin. |
|
November 25, 2020, 10:41 |
|
#7 | |
New Member
Join Date: Sep 2020
Posts: 28
Rep Power: 6 |
Quote:
I've got that code: Code:
word one_sec = "1"; while (runTime.loop()) { Info<< "Time = " << runTime.timeName() << endl; if ( runTime.timeName() == one_sec ) { Info<< "\nSet up certain values for cellZones\n" << endl; word myZone1 = "cs1"; label zoneID1 = mesh.cellZones().findZoneID(myZone1); const labelList& cells1 = mesh.cellZones()[zoneID1]; forAll(cells1, i) { const label cell = cells1[i]; T[cell] = 5; } word myZone2 = "cs2"; label zoneID2 = mesh.cellZones().findZoneID(myZone2); const labelList& cells2 = mesh.cellZones()[zoneID2]; forAll(cells2, j) { const label cell = cells2[j]; T[cell] = 25; } word myZone3 = "cs3"; label zoneID3 = mesh.cellZones().findZoneID(myZone3); const labelList& cells3 = mesh.cellZones()[zoneID3]; forAll(cells3, k) { const label cell = cells3[k]; T[cell] = 100; } runTime.write(); } } |
||
|
|
Similar Threads | ||||
Thread | Thread Starter | Forum | Replies | Last Post |
[snappyHexMesh] snappyHexMesh sticking point | natty_king | OpenFOAM Meshing & Mesh Conversion | 11 | February 20, 2024 10:12 |
How to cell field values to cells in setFields | upuli | OpenFOAM Running, Solving & CFD | 3 | January 23, 2017 11:32 |
[ICEM] Problem with prism cells | sidharath | ANSYS Meshing & Geometry | 0 | September 1, 2015 08:09 |
[snappyHexMesh] No layers in a small gap | bobburnquist | OpenFOAM Meshing & Mesh Conversion | 6 | August 26, 2015 10:38 |
snappyhexmesh remove blockmesh geometry | philipp1 | OpenFOAM Running, Solving & CFD | 2 | December 12, 2014 11:58 |