|
[Sponsors] |
July 17, 2021, 07:38 |
Saving data from codedMixed BC
|
#1 |
New Member
Raoul
Join Date: Apr 2021
Posts: 16
Rep Power: 5 |
Hi everyone,
I am dealing with codedMixed BC and I need to check the value of the variables that are used within the calculation. I wanted to save the values to post-process them and check if the bc are calculated in the correct way. I do not care how they are saved, as long as I am able to access them. However I am not managing to store such information, I have tried with ofstream inside the bc code, to save the variables as a CSV, but it does not work. Any advice? |
|
July 19, 2021, 16:30 |
|
#2 |
Senior Member
Carlos Rubio Abujas
Join Date: Jan 2018
Location: Spain
Posts: 127
Rep Power: 9 |
I think that the problem may be that you're executing the code when correcting the boundary condition insted of when you're writting. It would be interesting to see the code though.
If you want to have better control to when is the information written you may try a codedFunctionObject instead. Code:
coded { libs ("libutilityFunctionObjects.so"); type coded; name codedFunction; codeWrite #{ word timeName(mesh().time().timeName()); fileName outputFile (timeName/"mimimi"); OFstream os(outputFile); const scalarField& V = mesh().V(); const volVectorField& C = mesh().C(); label patchID = mesh().boundaryMesh().findPatchID("outlet"); const volVectorField& U = mesh().lookupObject<volVectorField>("U"); const vectorField& patch = C.boundaryField()[patchID]; const vectorField& Upatch = U.boundaryField()[patchID]; os << "# This is the header of the CSV" << nl << "# X , Y, Z, UX, UY, UZ" << nl; forAll(patch, facei) { os << patch[facei].x() << "," << patch[facei].y() << "," << patch[facei].z() << "," << Upatch[facei][0] << "," << Upatch[facei][1] << "," << Upatch[facei][2] << nl ; } os << endl; #}; } An alternative may be to write a custom boundary condition and modify the write() method in there. Give it a try and let's hope it works for you as well. |
|
July 19, 2021, 17:47 |
|
#3 | |
Member
Join Date: Mar 2021
Posts: 39
Rep Power: 5 |
Quote:
Will this be useful? https://www.openfoam.com/documentati...bcs-mixed.html Code:
"(Patch1|Patch2)" { type codedMixed; refValue uniform 0; refGradient uniform 0; valueFraction uniform 0; name test; code #{ forAll(this->patch(), faceI) { CodeGoes in here } Info << (this->refValue()*this->valueFraction() ) + (1-this->valueFraction())*(this->patchInternalField() + this->refGrad()/this->patch().deltaCoeffs()) << endl; #}; } |
||
Tags |
codedmixed, storing data |
|
|
Similar Threads | ||||
Thread | Thread Starter | Forum | Replies | Last Post |
[General] Extracting ParaView Data into Python Arrays | Jeffzda | ParaView | 30 | November 6, 2023 22:00 |
Run OpenFoam in 2 nodes of a cluster | WhiteW | OpenFOAM Running, Solving & CFD | 16 | December 20, 2016 01:51 |
Fuse Mesh Zone not Saving / Reopening in Case and data | jagpreetw | FLUENT | 0 | July 27, 2015 03:59 |
[Commercial meshers] fluentMeshToFoam multidomain mesh conversion problem | Attesz | OpenFOAM Meshing & Mesh Conversion | 12 | May 2, 2013 11:52 |
Urgent : Saving the plot data to a file | ck1973 | FLUENT | 1 | July 14, 2006 08:44 |