|
[Sponsors] |
boundary condition that depends on another field |
|
LinkBack | Thread Tools | Search this Thread | Display Modes |
November 23, 2019, 18:46 |
boundary condition that depends on another field
|
#1 |
New Member
Join Date: Mar 2019
Posts: 8
Rep Power: 7 |
Hi everyone,
I have two volScalarFields, theta, and alpha.CO2. I want alpha.CO2 at a wall to have a value that depends on the value of theta at the wall. I've set theta as 0.5 everywhere at the boundary in the solver file at the end of the while loop: Code:
... while(pimple.correct()) { #include "pEqn.H" } if (pimple.turbCorr()) { turbulence.correct(); } } //End of while(pimple.loop()) //Set theta as 0.5 on the boundary forAll(mesh.boundary(), patchID){ forAll (mesh.boundary()[patchID],facei) { theta.boundaryFieldRef()[patchID][facei]=0.5; } } runTime.write(); Info<< "ExecutionTime = " << runTime.elapsedCpuTime() ... Code:
walls { type codedFixedValue; value uniform 0; name wallAdsorption; code #{ const fvPatch& boundaryPatch = patch(); const fvBoundaryMesh& boundaryMesh = boundaryPatch.boundaryMesh(); const fvMesh& mesh = boundaryMesh.mesh(); const vectorField& Cf = boundaryPatch.Cf(); scalarField& field = *this; field=patchInternalField(); const volScalarField& theta = mesh.lookupObject<volScalarField>("theta"); forAll(Cf, faceI){ field[faceI]=0.5+theta[faceI]; } #}; } Thanks! |
|
November 25, 2019, 03:38 |
|
#2 |
Member
Join Date: Dec 2018
Location: Darmstadt, Germany
Posts: 87
Rep Power: 7 |
Short answer: Issue seems to be your codedFixedValue code. You are accessing your volScalarField with a faceid and this will get you the cell value with the id faceid. The solution to that problem is already there (in your first code snippet. There, the boundary faces, no cells, are accessed correctly). Something like that could work:
Code:
const label patchid = mesh.boundaryField().findPatchID(this->name()); // could work, not sure though const volScalarField& theta(mesh.lookupObject<volScalarField>("theta")); const auto& thetaPatchField = theta.boundaryField()[patchid]; forAll(field, facei) // face loop { field[facei] = 0.5 + thetaPatchField[i]; } |
|
November 25, 2019, 14:13 |
|
#3 |
New Member
Join Date: Mar 2019
Posts: 8
Rep Power: 7 |
Thanks for the response! Unfortunately, I'm still having some issues.
I put your code into alpha.CO2: Code:
const fvPatch& boundaryPatch = patch(); const fvBoundaryMesh& boundaryMesh = boundaryPatch.boundaryMesh(); const fvMesh& mesh = boundaryMesh.mesh(); const vectorField& Cf = boundaryPatch.Cf(); scalarField& field = *this; field=patchInternalField(); const label patchid = mesh.boundaryField().findPatchID(this->name()); const volScalarField& theta((mesh.lookupObject<volScalarField>("theta"))); const auto& thetaPatchField = theta.boundaryField()[patchid]; forAll(field, facei) { field[facei] = 0.5+thetaPatchField[i]; } Code:
error: 'const class Foam::fvMesh' has no member named 'boundaryField' error: 'class Foam::wallAdsorptionFixedValueFvPatchScalarField' has no member named 'name' error: 'i' was not declared in this scope warning: unused variable 'Cf' Also, how should I fix the first two error messages? Should I be replacing "name" with something? |
|
November 26, 2019, 03:43 |
|
#4 |
Member
Join Date: Dec 2018
Location: Darmstadt, Germany
Posts: 87
Rep Power: 7 |
Hey,
which version of OF are you using? Yes, of course this is not compiling, my bad. Just wrote without compiling and thought you would only take the hints out of that pseudo-like code.. Try to use mesh.boundary().findPatchID(this->patch().name()) instead of mesh.boundaryField... and like you suggested 'i' is not defined in your code so replace it with 'facei' in the loop. (+ delete the line with Cf, it looks like it is not used anywhere, see compiler warning message). Cheers, RP |
|
|
|
Similar Threads | ||||
Thread | Thread Starter | Forum | Replies | Last Post |
Wind turbine simulation | Saturn | CFX | 60 | July 17, 2024 06:45 |
sliding mesh problem in CFX | Saima | CFX | 46 | September 11, 2021 08:38 |
Radiation in semi-transparent media with surface-to-surface model? | mpeppels | CFX | 11 | August 22, 2019 08:30 |
External Radiation Boundary Condition (Two sided wall), Grid Interface | CFD XUE | FLUENT | 0 | July 8, 2010 07:49 |
vorticity boundary condition | bearcharge | Main CFD Forum | 0 | May 14, 2010 12:32 |