|
[Sponsors] |
problem in label patchID = mesh.boundaryMesh()[patchi]; |
|
LinkBack | Thread Tools | Search this Thread | Display Modes |
September 7, 2019, 10:49 |
problem in label patchID = mesh.boundaryMesh()[patchi];
|
#1 | ||
Senior Member
Hojatollah Gholami
Join Date: Jan 2019
Posts: 171
Rep Power: 7 |
Dear All
I want to assign Ta value to boundaryField via internalField. I defined a Ta in only internalField. Then need to assign the center or surface value of near cells of boundary to its boundaryField, I used code Quote:
Quote:
regards, Hojatollah Last edited by Hgholami; September 7, 2019 at 13:07. |
|||
September 7, 2019, 15:52 |
|
#2 |
Senior Member
Daniel
Join Date: Mar 2013
Location: Noshahr, Iran
Posts: 348
Rep Power: 21 |
Dear Hgholami,
I think you need to see a few examples of how to use loops in OpenFOAM as the code you have posted doesn't make any sense apart from that error! I will describe a few basic information so you can try and make use of them in your code (I wrote these codes for the explanation purpose and you may find a few typos): 1- Loop over the cell centers of a volScalarField variable, e.g. Ta Code:
scalarField& TaInternal = Ta.internalField(); // loops over cell centers of Ta forAll (TaInternal, cellI) { TaInternal[cellI] = ...; // make your changes here } Code:
vectorField& TaInternal = Ta.internalField(); // loops over cell centers of Ta forAll (TaInternal, cellI) { TaInternal[cellI].x() = ...; // make your changes here TaInternal[cellI].y() = ...; // make your changes here TaInternal[cellI].z() = ...; // make your changes here // or directly with a vector TaInternal[cellI] = vector::zero; } Code:
// loops over boundary patches which depend on your case forAll (Ta.boundaryField(), patchI) { fvPatchScalarField& pTa = Ta.boundaryField()[patchI]; // This now loops over the faces of the corresponding boundary forAll (pTa, faceI) { pTa[faceI] = ...; // make your changes here } } Code:
// loops over boundary patches which depend on your case forAll (Ta.boundaryField(), patchI) { fvPatchVectorField& pTa = Ta.boundaryField()[patchI]; // This now loops over the faces of the corresponding boundary forAll (pTa, faceI) { pTa[faceI].x() = ...; // make your changes here pTa[faceI].y() = ...; // make your changes here pTa[faceI].z() = ...; // make your changes here } } Code:
label patchID = mesh.boundaryMesh().findPatchID("name_of_your_desired_patch"); Regards, D. Khazaei |
|
September 9, 2019, 13:01 |
|
#3 | ||
Senior Member
Hojatollah Gholami
Join Date: Jan 2019
Posts: 171
Rep Power: 7 |
Dear Khazaei
Yes. I think the above code had different types and it make the error. As my variable is scalar, so I use your third code and it compiled successfully. For check the solution, I use "Info" for print position of face center for a case. Quote:
Quote:
Last edited by Hgholami; September 9, 2019 at 15:33. |
|||
October 3, 2019, 12:36 |
|
#4 |
Member
Fabien Robaux
Join Date: Oct 2016
Posts: 51
Rep Power: 10 |
If you iterate over a patch, faceI will cover the indices of the PATCH faces. (from 0 to nFaces)
You either need to print the pTb_ faces or convert the local indice into global indice! What you do is you print mesh.Cf() , which returns the center of the MESH faces. (So the 117 first faces of the mesh) Code:
forAll(pTb_, faceI) { Info << pTb_[faceI] <<" face indice: "<< faceI <<" patch indice:"<<patchI<< endl; } (Look at the first output of each new patch : Code:
(0.01 0.00076882 0.0075)positionx0:4 (0.01 0.00076882 0.0075)positionx0:5 |
|
|
|
Similar Threads | ||||
Thread | Thread Starter | Forum | Replies | Last Post |
[blockMesh] Internal walls of zero thickness | anger | OpenFOAM Meshing & Mesh Conversion | 23 | February 6, 2020 19:25 |
BuoyantBoussinesqSimpleFoam_Facing problem | Mondal131211 | OpenFOAM Running, Solving & CFD | 1 | April 10, 2019 20:41 |
Gambit - meshing over airfoil wrapping (?) problem | JFDC | FLUENT | 1 | July 11, 2011 06:59 |
natural convection problem for a CHT problem | Se-Hee | CFX | 2 | June 10, 2007 07:29 |
Adiabatic and Rotating wall (Convection problem) | ParodDav | CFX | 5 | April 29, 2007 20:13 |