|
[Sponsors] |
How to update Boundary Condition in the loop with #codeStream? |
|
LinkBack | Thread Tools | Search this Thread | Display Modes |
October 20, 2024, 03:56 |
How to update Boundary Condition in the loop with #codeStream?
|
#1 |
New Member
Teddy Liu
Join Date: May 2024
Posts: 5
Rep Power: 2 |
Hi, everyone!
I'm trying to update the boundary condition as the mesh moves using #codeStream, here is a more detailed description for my problem: I managed to make my own outlet poiseuille flow boundary condition, which gives a parabolic velocity distribution using #codeStream, the codes are like this in 0/U: Code:
outlet { type fixedValue; value #codeStream { codeInclude #{ #include "fvCFD.H" #}; codeOptions #{ -I$(LIB_SRC)/finiteVolume/lnInclude \ -I$(LIB_SRC)/meshTools/lnInclude #}; codeLibs #{ -lmeshTools \ -lfiniteVolume #}; code #{ const IOdictionary& d = static_cast<const IOdictionary&> ( dict.parent().parent() ); const fvMesh& mesh = refCast<const fvMesh>(d.db()); label id = mesh.boundary().findPatchID("outlet"); if (id ==-1) { FatalError << "patch not found!" << exit(FatalError); } const fvPatch& patch = refCast<const fvPatch>(mesh.boundary()[id]); vectorField NF(patch.nf()); vectorField U(NF); const scalar pi = constant::mathematical::pi; const vector patch_Center = vector(1,0.25,0); const scalar patch_R = 0.1; const scalar flow_Flux = 0.1; const scalar U_max = 2 * flow_Flux / (pi * pow(patch_R,4)); forAll(U, i) { const scalar x = patch.Cf()[i][0]; const scalar y = patch.Cf()[i][1]; U[i] = (U_max*(pow(patch_R,2)-pow(x-patch_Center[0],2)-pow(y-patch_Center[1],2)))*NF[i]; } const scalarField area = patch.magSf(); vectorField pointed_area = patch.Sf(); scalar areaTotal = gSum(area); scalar realize_Flux = mag(gSum((U & pointed_area)())); vectorField U_fix(U); forAll(U_fix, i) { U_fix[i] = U_fix[i] - ((flow_Flux - realize_Flux)/areaTotal)*NF[i]; } U_fix.writeEntry("", os); #}; }; } The problem occurred when I tried to set the whole mesh to an oscillatingRotatingMotion centered at the outlet patch center. I monitored the outlet flow from the outlet patch, and it gave a sinusoidal curve in a period: flux.png which means that the velocity at the patch is no longer normal to the patch face. I checked it in paraView, and it obviously is not normal to the patch according to a closer look around the outlet patch: detail.png So the problem here is: How can I set this boundary condition to get a parabolic velocity field at the patch that is always normal to the patch face? I firstly wanted to realize it with #codeStream, or do I have to use high-level programming? Because I noticed there is a function called "updateCoeffs()" I wondered if it has anything to do with my problem. This is my first thread here, and sorry for this long story. And any suggestions will be appreciated! Regards, Teddy |
|
Tags |
boundary condition, codestream, dynamic mesh |
|
|
Similar Threads | ||||
Thread | Thread Starter | Forum | Replies | Last Post |
UDF for Automatic Solution Initialization for previous case data file | gartz89 | Fluent UDF and Scheme Programming | 6 | March 30, 2020 08:38 |
My radial inflow turbine | Abo Anas | CFX | 27 | May 11, 2018 02:44 |
Out File does not show Imbalance in % | Mmaragann | CFX | 5 | January 20, 2017 11:20 |
External Radiation Boundary Condition (Two sided wall), Grid Interface | CFD XUE | FLUENT | 0 | July 8, 2010 07:49 |
NACA0012 geometry/design software needed | Franny | Main CFD Forum | 13 | July 7, 2007 16:57 |