|
[Sponsors] |
January 4, 2024, 11:42 |
Time varying BCs changed inside the code
|
#1 |
New Member
Eva
Join Date: Jan 2024
Posts: 3
Rep Power: 2 |
Hi all,
I am solving a problem for which I need to update the boundary conditions in each iteration based on the same terms that the internal field uses. The variable is: volScalarField& Ui = Um[i]; I tried to change the boundary conditions (to a dummy value = 0.25) as: /************************************************** *******/ forAll(Um[0].boundaryField(), patchi) { if(Um[0].boundaryField()[patchi].type() == "uniformFixedValue" ) { forAll(Ui.boundaryFieldRef()[patchi], facei) //update Ui.boundaryFieldRef()[patchi][facei] = 0.25; } } Ui.boundaryFieldRef().updateCoeffs(); .... UiEqn.boundaryManipulate(Ui.boundaryFieldRef()); UiEqn.relax(); fvConstraints.constrain(UiEqn); UiEqn.solve("Ui"); fvConstraints.constrain(Ui); /************************************************** *******/ Even if Ui.boundaryField() is the desired during the "solve" part, the fvMatrix does not take into account this value but the value from the initialitation in the 0/Umdefault file. I tried with "fixedValue" and "uniformFixedValue" boundary conditions but the result doesn't change. Can anyone give me insights of how I can force my new boundary condition values in the fvMatrix UiEqn? Thanks you all, Eva |
|
January 6, 2024, 11:05 |
|
#2 |
Senior Member
Mark Olesen
Join Date: Mar 2009
Location: https://olesenm.github.io/
Posts: 1,714
Rep Power: 40 |
You are partly there but you need to adjust the boundary condition value with in boundary condition itself, not in the solver.
Probably best to use a uniformFixedValue as you have done, but use a coded type for the PatchFunction1 value. There are a few examples in the tutorials (you'll need to look). Your boundary condition may also lend itself to an expression for the PatchFunction1. |
|
January 12, 2024, 04:47 |
|
#3 | |
New Member
Eva
Join Date: Jan 2024
Posts: 3
Rep Power: 2 |
Quote:
As I needed to use terms that were on the Eqn itself but the BC of Ui can not be imposed on the code, I solved it by creating an auxiliary variable. That way, I imposed the BC I wanted for Ui in the variable aux_Ui, and I impose in the BC of Ui that it has to match the values of aux_Ui: ////////////////// code #{ const fvPatch& boundaryPatch = patch(); const fvBoundaryMesh& boundaryMesh = boundaryPatch.boundaryMesh(); const fvMesh& mesh = patch().boundaryMesh().mesh(); const vectorField& Cf = boundaryPatch.Cf(); const label patchid = mesh.boundary().findPatchID(this->patch().name()); const volScalarField& aux_Ui((mesh.lookupObject<volScalarField>("aux_Um0 "))); scalarField& field = *this; forAll(Cf,faceI){ field[faceI]=aux_Ui.boundaryField()[patchid][faceI]; } #}; //////////////// Thanks a lot for your valuable help |
||
Tags |
boundary conditions, fvmatrix, internal field, time varying bcs |
Thread Tools | Search this Thread |
Display Modes | |
|
|
Similar Threads | ||||
Thread | Thread Starter | Forum | Replies | Last Post |
bash script for pseudo-parallel usage of reconstructPar | kwardle | OpenFOAM Post-Processing | 42 | May 7, 2024 23:17 |
AMI speed performance | danny123 | OpenFOAM | 21 | October 24, 2020 04:13 |
Extrusion with OpenFoam problem No. Iterations 0 | Lord Kelvin | OpenFOAM Running, Solving & CFD | 8 | March 28, 2016 11:08 |
Help for the small implementation in turbulence model | shipman | OpenFOAM Programming & Development | 25 | March 19, 2014 10:08 |
mixerVesselAMI2D's mass is not balancing | sharonyue | OpenFOAM Running, Solving & CFD | 6 | June 10, 2013 09:34 |