|
[Sponsors] |
Unknown character in name of output variable when using coded function object |
|
LinkBack | Thread Tools | Search this Thread | Display Modes |
August 10, 2020, 06:05 |
Unknown character in name of output variable when using coded function object
|
#1 |
New Member
Philomène Vergnol
Join Date: Apr 2020
Posts: 11
Rep Power: 6 |
Hello everyone,
I work with OpenFOAM v7 and the solver compressibleInterFoam. I am studying a water/air flow in a cylinder. For the post-processing, I want to be able to visualize the dynamic viscosity (mu) on Paraview. When running the solver, there are multiple variables in the output directories, but mu isn't one of them. So I use a coded function object : Code:
myFunctionMu { type coded; libs ("libutilityFunctionObjects.so"); name writingMu; codeWrite #{ const volScalarField& mu = mesh().lookupObject<volScalarField>("thermo:mu"); mu().write(); #}; } This works, the mu files are written in the output directories. The problem is the name of those files, because they contain an unknown character (image is attached). If I try to copy it here it gives : thermomu It is a problem because I can't visualize them in Paraview, while I can with other objects I output (e.g. yPlus). I tried putting just "mu" instead of "thermo:mu", but when I run the solver there is an error message : Code:
request for volScalarField mu from objectRegistry region0 failed available objects of type volScalarField are 39 ( thermo:alpha.air alpha.air_0 thermo:mu alpha.water_0 thermo:alpha.water interfaceProperties:K thermo:psi nut K K_0 alpha.water yPlus p_rgh_0 T.air thermo:psi.water rho T.water p_rgh gh thermo:psi.air thermo:rho.water_0 delta enstrophy alphat thermo:rho.air rho_0 p T thermo:rho.water T_0 alpha.air thermo:mu.water e.air thermo:rho.air_0 Co (alpha.water*div(phi)) thermo:mu.air e.water thermo:alpha ) Code:
mu.write(); Is there a problem in my code ? If not, is this a bug ? If yes, is there a way to change the name of the output files to be able to read them in Paraview ? Additional question but relevant only if I solve the main (mu) problem first : Ideally, I also want to get the kinematic viscosity (nu) but it isn't in the list of the available volScalarField. Can I output them using a coded function object or an other type of function object dividing mu by rho ? Thank you in advance, -Philomène |
|
August 11, 2020, 18:06 |
|
#2 |
New Member
Wenyuan Fan
Join Date: Mar 2017
Posts: 27
Rep Power: 9 |
Hi Philomène,
Your code looks fine. It is weird that the colon symbol cannot be displayed properly, since it is a legal character for filenames in Linux. There are two ways you can try: 1. rename the file after running the simulation 2. change your code to Code:
const volScalarField& mu = mesh().lookupObject<volScalarField>("thermo:mu"); volScalarField Mu ( IOobject ( "mu", // any name you want runTime.timeName(), mesh, IOobject::NO_READ, IOobject::AUTO_WRITE ), mu ); Mu.write(); Regarding nu, you just need to find out rho as you did for mu, calculate mu/rho and then write it out using the code above. You can output both using a single function object. Just add more lines to the code section. |
|
August 12, 2020, 06:36 |
|
#3 |
New Member
Philomène Vergnol
Join Date: Apr 2020
Posts: 11
Rep Power: 6 |
Hello Wenyuan, thanks you for your help!
I am running OpenFoam on WSL (Windows Subsystem for Linux) and using Paraview on Windows 10, maybe the error comes from here. Renaming the files after running the simulation will indeed be my last option. I tried running the simulation with your code but I have an error message and I don't understand why : Code:
/mnt/c/Users/vergnol/Documents/liquid_piston/Simulations/SIMULATIONS_3D/SIMU_70_rho_mu/system/controlDict.functions.myFunctionMu: In member function ‘virtual bool Foam::writingMuFunctionObject::write()’: /mnt/c/Users/vergnol/Documents/liquid_piston/Simulations/SIMULATIONS_3D/SIMU_70_rho_mu/system/controlDict.functions.myFunctionMu:81:7: error: ‘runTime’ was not declared in this scope /mnt/c/Users/vergnol/Documents/liquid_piston/Simulations/SIMULATIONS_3D/SIMU_70_rho_mu/system/controlDict.functions.myFunctionMu:81:7: note: suggested alternative: ‘dimTime’ make: *** [Make/linux64GccDPInt32Opt/functionObjectTemplate.o] Error 1 [0] [0] [0] --> FOAM FATAL IO ERROR: [0] Failed wmake "dynamicCode/writingMu/platforms/linux64GccDPInt32Opt/lib/libwritingMu_33240e2602611f4d17313e6bfbc54de6c82bead9.so" [0] [0] [0] file: /mnt/c/Users/vergnol/Documents/liquid_piston/Simulations/SIMULATIONS_3D/SIMU_70_rho_mu/system/controlDict.functions.myFunctionMu from line 70 to line 74. [0] [0] From function void Foam::codedBase::createLibrary(Foam::dynamicCode&, const Foam::dynamicCodeContext&) const [0] in file db/dynamicLibrary/codedBase/codedBase.C at line 206. [0] FOAM parallel run exiting Should I add something in my controlDict ? Here it is : Code:
application compressibleInterFoam; startFrom latestTime; startTime 0; stopAt endTime; endTime 21; deltaT 0.001; writeControl timeStep; writeInterval 1; purgeWrite 0; writeFormat ascii; writePrecision 6; writeCompression off; timeFormat general; timePrecision 6; runTimeModifiable true; adjustTimeStep yes; maxCo 1; maxAlphaCo 0.4; maxDeltaT 0.01; functions { myFunctionMu { type coded; libs ("libutilityFunctionObjects.so"); name writingMu; codeWrite #{ const volScalarField& mu = mesh().lookupObject<volScalarField>("thermo:mu"); volScalarField Mu ( IOobject ( "mu", // any name you want runTime.timeName(), mesh, IOobject::NO_READ, IOobject::AUTO_WRITE ), mu ); Mu.write(); #}; } } -Philomène |
|
August 12, 2020, 06:57 |
|
#4 |
New Member
Wenyuan Fan
Join Date: Mar 2017
Posts: 27
Rep Power: 9 |
Hi Philomène,
Now the problem is clear to me since colon is an illegal character for Windows filename. Regarding the error, you can try Code:
mesh.time().timeName() |
|
August 12, 2020, 10:57 |
|
#5 |
New Member
Philomène Vergnol
Join Date: Apr 2020
Posts: 11
Rep Power: 6 |
Hi,
Yes you're right the problem occurs when naming the file on Windows! Thank you for helping me identify the source of the problem. I will run it with Ubuntu to solve this. There is still a message error when I try your code though : Code:
ln: ./lnInclude /mnt/c/Users/vergnol/Documents/liquid_piston/Simulations/SIMULATIONS_3D/SIMU_70_rho_mu/system/controlDict.functions.myFunctionMu: In member function ‘virtual bool Foam::writingMuFunctionObject::write()’: /mnt/c/Users/vergnol/Documents/liquid_piston/Simulations/SIMULATIONS_3D/SIMU_70_rho_mu/system/controlDict.functions.myFunctionMu:81:7: error: invalid use of member function ‘const Foam::fvMesh& Foam::writingMuFunctionObject::mesh() const’ (did you forget the ‘()’ ?) make: *** [Make/linux64GccDPInt32Opt/functionObjectTemplate.o] Error 1 [0] [0] [0] --> FOAM FATAL IO ERROR: [0] Failed wmake "dynamicCode/writingMu/platforms/linux64GccDPInt32Opt/lib/libwritingMu_d46f4e90ee27fdba7556000cf87a0f480bb19555.so" [0] [0] [0] file: /mnt/c/Users/vergnol/Documents/liquid_piston/Simulations/SIMULATIONS_3D/SIMU_70_rho_mu/system/controlDict.functions.myFunctionMu from line 70 to line 74. [0] [0] From function void Foam::codedBase::createLibrary(Foam::dynamicCode&, const Foam::dynamicCodeContext&) const [0] in file db/dynamicLibrary/codedBase/codedBase.C at line 206. [0] FOAM parallel run exiting [0] Anyways, you've helped me a lot, thank you! |
|
August 12, 2020, 14:29 |
|
#6 |
New Member
Wenyuan Fan
Join Date: Mar 2017
Posts: 27
Rep Power: 9 |
Hi,
I should have tested the code before posting. I am sorry for that. The following code works with OpenFOAM-v1906 at least Code:
codeWrite #{ if (mesh().time().writeTime()) { const volScalarField& mu = mesh().lookupObject<volScalarField>("thermo:mu"); volScalarField Mu ( IOobject ( "mu", // any name you want mesh().time().timeName(), mesh(), IOobject::NO_READ, IOobject::AUTO_WRITE ), mu ); Mu.write(); } #}; |
|
Tags |
codedfunctionobject, compressibleinterfoam |
Thread Tools | Search this Thread |
Display Modes | |
|
|
Similar Threads | ||||
Thread | Thread Starter | Forum | Replies | Last Post |
[Other] mesh airfoil NACA0012 | anand_30 | OpenFOAM Meshing & Mesh Conversion | 13 | March 7, 2022 18:22 |
emag beta feature: charge density | charlotte | CFX | 4 | March 22, 2011 10:14 |
Error with Wmake | skabilan | OpenFOAM Installation | 3 | July 28, 2009 01:35 |
Compilation error OF1.5-dev on Suse10.3 | darenyang | OpenFOAM Installation | 0 | April 29, 2009 05:55 |
[blockMesh] BlockMeshmergePatchPairs | hjasak | OpenFOAM Meshing & Mesh Conversion | 11 | August 15, 2008 08:36 |