|
[Sponsors] |
September 4, 2023, 07:03 |
internalField issue!!
|
#1 |
Member
Eric Segalerba
Join Date: Dec 2021
Location: Italy
Posts: 31
Rep Power: 4 |
Hello everyone!
I'm trying to solve a problem with a gradient but I can't figure out how to get the value of a field, in this case Temperature, adjacent to a face. So far I wrote this: Code:
const scalarField& Tp = patch().lookupPatchField<volScalarField, scalar>("T"); const scalarField& Tc = patch().lookupPatchField<volScalarField, scalar>("T").internalField(); const scalarField& deltaInv = patch().deltaCoeffs(); const scalarField gradT_ = - (Tp-Tc)*deltaInv; I'm sure I'm doing something wrong with the "internalField()" member function, but ... what? Do you have an idea? Thank you! |
|
September 6, 2023, 20:12 |
|
#2 | |
Senior Member
Mark Olesen
Join Date: Mar 2009
Location: https://olesenm.github.io/
Posts: 1,714
Rep Power: 40 |
Quote:
I'll take a not-so-wild guess here and bet that your mesh has 8000 cells in it. In which case, the value returned by internalField() is correct. If you actually wanted the values of the internal field immediately next to the patch, that would be a different method call. Instead of providing a quick answer, I'd suggest you take a look at fvPatch.H to see what the first lookupPatchField is doing. After that, you'll probably (hopefully) be motivated to look at fvPatchFIeld.H for which method you actually wanted to use. This is the best way to understand which code to write. I am confident that you will find the answer - please post it when you find it. |
||
October 3, 2023, 06:51 |
|
#3 |
Member
Eric Segalerba
Join Date: Dec 2021
Location: Italy
Posts: 31
Rep Power: 4 |
Hi Mark, thank you for your reply and yes, I think I found a not very efficient solution to the problem, but it works! The code I wrote is:
Code:
// store in "Tp" the field of scalar temperature on the patch const scalarField& Tp(patch().lookupPatchField<volScalarField, scalar>("T")); // store in "Tc" the field of scalar temperature in the computational domain const scalarField& Tc(patch().lookupPatchField<volScalarField, scalar>("T").internalField()); //Info << "Size of Tc: " << Tc.size() << endl; // initialize cell's temperature variable scalarField Tcell(Tp.size(), Zero); // distance from the face center to the cell center on patch's cells const scalarField& deltaInv(patch().deltaCoeffs()); // separately calculate the homogenization coefficient "lambda_theta" const scalarField Coeff(kF_/kS_*solidThickness_*deltaInv); // store in "cells" the labels of the cells adjacent to the face const labelList cells(patch().faceCells()); // initialize the counter label cellN(0); forAll(cells, patchCell) { cellN = cells[patchCell]; Tcell[patchCell] = Tc[cellN]; } Code:
label cellN(0); forAll(cells, patchCell) { cellN = cells[patchCell]; Tcell[patchCell] = Tc[cellN]; } |
|
October 6, 2023, 05:53 |
|
#4 |
Senior Member
Mark Olesen
Join Date: Mar 2009
Location: https://olesenm.github.io/
Posts: 1,714
Rep Power: 40 |
If you look at polyPatch.H, you'll see there is a patchInternalList method that returns the values you are looking for.
|
|
Tags |
custom bc, programing |
|
|
Similar Threads | ||||
Thread | Thread Starter | Forum | Replies | Last Post |
internalField condition | mchehab2 | OpenFOAM Running, Solving & CFD | 14 | November 10, 2022 14:28 |
twoPhaseEulerFoam confined plunging jet simulation failed | ves | OpenFOAM Running, Solving & CFD | 2 | June 17, 2020 06:08 |
internalField nonuniform List<vector> and internalField nonuniform List <scalar> | Ferdinand | OpenFOAM Pre-Processing | 1 | January 3, 2020 13:20 |
ill defined primitiveEntry starting at keyword 'value' on line 197 ChangeDictionary | Struggle_Achieve | OpenFOAM Pre-Processing | 2 | December 20, 2017 04:58 |
Convergence issue in natural convection problem | chrisf90 | FLUENT | 5 | March 5, 2016 09:30 |