|
[Sponsors] |
![]() |
![]() |
#1 |
New Member
Diego Bindoni
Join Date: Oct 2022
Posts: 17
Rep Power: 4 ![]() |
Good morning,
i'm writing you to ask for help on the coding environment in OpenFOAMv12. I need to set up a vertical profile of temperature inside my 3D simulations using setFields, but i struggle into coding it. It doesn't exactly look like when you code for creating new applications or boundary conditions, and the tutorials doesn't give me help into calling the cell points in my code. Could you please give me help through this? Thanks in advance Up to know, i wrote something like this (which clearly doesn't work ![]() regions ( boxToCell { box (0-1530) (90150); fieldValues #codeStream ( codeInclude #{ #include"pointField.H" #}; code #{ const scalar T_min =300; // Minimum temperature (K) const scalar T_max =500; // Maximum temperature (K) const scalar z_min =0; // Minimum z-coordinate const scalar z_max =30; // Maximum z-coordinate const scalar Tz = T_min + (T_max - T_min) * (pos.z() - z_min) / (z_max - z_min); os <<"volScalarFieldValue T "<< Tz <<";"; #}; ); } ); |
|
![]() |
![]() |
![]() |
![]() |
#2 |
New Member
Join Date: Jan 2024
Posts: 2
Rep Power: 0 ![]() |
Hi Diego,
What I've found out, that it is easier with codedFixedValue, that bother with setFields. I'm not sure how to translate it to the third dimension, so I'm just sending you my boundary condition for 'p_rgh' in my simulation Code:
outlet { type codedFixedValue; value nonuniform List<scalar> 464 () ; name analyticalPressure; codeInclude #{ #include "fvCFD.H" #}; code #{ const scalar a = -0.0007823694306168533; const scalar b = 0.03970155682347252; const scalar c = 0.695209026448578; const scalar d = 0.4115774379106153; // Accessing the patch and field in OpenFOAM v2406 const fvPatch& patch = this->patch(); // Access the boundary patch scalarField& field = *this; // Access the field // Loop over all face centers (Cf) on the patch forAll(patch.Cf(), i) { scalar y = patch.Cf()[i].y(); // Get the y-coordinate of the face center field[i] = a + b * erf(c * y + d); // Apply the error function and assign to field } #}; codeOptions #{ -I$(LIB_SRC)/finiteVolume/lnInclude #}; } It imposes an error function on the outlet pressure. It also throws a warning about lnInlude, but I didn't bother to remove it. I hope this helps you! Best regards, Endre |
|
![]() |
![]() |
![]() |
Thread Tools | Search this Thread |
Display Modes | |
|
|
![]() |
||||
Thread | Thread Starter | Forum | Replies | Last Post |
Openfoam chtMultiRegionSimpleFoam Starting Issue - Help Needed | OldUnixGuy49 | Main CFD Forum | 1 | December 2, 2024 09:52 |
Help sought on axial compressor simulation | jyotir | OpenFOAM Running, Solving & CFD | 0 | November 17, 2021 11:49 |
Cannot run the code properly: very large time step continuity error | crst15 | OpenFOAM Running, Solving & CFD | 9 | December 14, 2014 19:17 |
Moving mesh | Niklas Wikstrom (Wikstrom) | OpenFOAM Running, Solving & CFD | 122 | June 15, 2014 07:20 |
Micro Scale Pore, icoFoam | gooya_kabir | OpenFOAM Running, Solving & CFD | 2 | November 2, 2013 14:58 |