Unknown character in name of output variable when using coded function object
1 Attachment(s)
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 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 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 |
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"); 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. |
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()’: Should I add something in my controlDict ? Here it is : Code:
application compressibleInterFoam; -Philomène |
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() |
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 Anyways, you've helped me a lot, thank you! |
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 |
All times are GMT -4. The time now is 14:56. |