|
[Sponsors] |
January 29, 2018, 11:14 |
wallDist
|
#1 |
New Member
Join Date: Mar 2015
Posts: 10
Rep Power: 11 |
Dear Forum,
I would like to get (and use) the information about the distance to the next wall within fvOptions. I've seen that there is something called wallDist in the OpenFoam code: https://github.com/OpenFOAM/OpenFOAM...ist/wallDist.H My code within fvOptions was the following: volScalarField WallDistant ( IOobject ( "WallDistant", mesh_.time().timeName(), mesh_, IOobject::NO_READ, IOobject::AUTO_WRITE ), mesh_, dimensionedScalar("WallDistant", dimensionSet(0,1,0,0,0,0,0), 0) ); WallDistant = wallDist(mesh).y(); But my attempt was not successful. I got the following error message: /manni/data/stw/OpenFoamRuns/TH2_42/constant/fvOptions.massSource.scalarCodedSourceCoeffs: In member function ‘virtual void Foam::fv::sourceMassFvOptionscalarSource::addSup(F oam::fvMatrix<double>&, Foam::label)’: /manni/data/stw/OpenFoamRuns/TH2_42/constant/fvOptions.massSource.scalarCodedSourceCoeffs:100:3 0: error: invalid use of non-static member function /manni/data/stw/OpenFoamRuns/TH2_42/constant/fvOptions.massSource.scalarCodedSourceCoeffs: In member function ‘virtual void Foam::fv::sourceMassFvOptionscalarSource::addSup(c onst volScalarField&, Foam::fvMatrix<double>&, Foam::label)’: /manni/data/stw/OpenFoamRuns/TH2_42/constant/fvOptions.massSource.scalarCodedSourceCoeffs:100:3 0: error: invalid use of non-static member function make: *** [Make/linux64GccDPInt32Opt/codedFvOptionTemplate.o] Error 1 --> FOAM FATAL IO ERROR: Failed wmake "dynamicCode/sourceMass/platforms/linux64GccDPInt32Opt/lib/libsourceMass_3da197f3cc357d741f1a55ea5ea42bbaf0e3 83a5.so" Could someone please give me a hint how to get the wall distance information within my fvOptions code? Thanks, R. |
|
January 29, 2018, 23:59 |
|
#2 |
New Member
Yuncheng Xu (Cloud)
Join Date: May 2011
Location: State College, PA
Posts: 20
Rep Power: 15 |
try
Code:
WallDistant = wallDist(mesh_).y(); |
|
January 30, 2018, 06:28 |
|
#3 |
New Member
Join Date: Mar 2015
Posts: 10
Rep Power: 11 |
Dear Luther,
thanks for your answer! It works now with your solution. But first I have to include #include "wallDist.H" in my code. Regards, R. |
|
June 2, 2019, 01:27 |
|
#4 |
Member
Join Date: Oct 2015
Posts: 63
Rep Power: 11 |
Hi,
I see that you want the nearest distance from the wall for each cell in the mesh. Is it possible to get the distance from a particular cell in the mesh to the wall using wallDist() without computing this distance for other cells? I have the cellID for the cell. But wallDist(mesh_(celli)).y() gives an error. Is there a way to get this distance for a particular cell? Thanks! Best, Scram_1 |
|
July 16, 2019, 19:05 |
|
#5 |
Senior Member
Andrea
Join Date: Feb 2012
Location: Leeds, UK
Posts: 179
Rep Power: 16 |
Hi Researcher23,
could you share a complete example with your solution? Where exactly did you include "wallDist.H" in your code? Many thanks, Andrea |
|
July 17, 2019, 04:12 |
Hi Andrea
|
#6 |
New Member
Join Date: Mar 2015
Posts: 10
Rep Power: 11 |
I used it in fvOptions as a scalarCodedSource.
The code in fvOptions was: #include "wallDist.H" volScalarField WallDistance ( IOobject ( "WallDistance", mesh_.time().timeName(), mesh_, IOobject::NO_READ, IOobject::AUTO_WRITE ), mesh_, dimensionedScalar("WallDistance", dimensionSet(0,1,0,0,0,0,0), 0) ); WallDistance = wallDist(mesh_).y(); I have to add in fvSchemes: wallDist { method meshWave; } |
|
July 17, 2019, 14:25 |
|
#7 |
Senior Member
Andrea
Join Date: Feb 2012
Location: Leeds, UK
Posts: 179
Rep Power: 16 |
Thanks for the quick reply.
This is what I have been trying to do but I have just realised I was mispelling the name of the header file |
|
November 10, 2021, 13:28 |
errors using wallDist
|
#8 |
New Member
Join Date: Jan 2019
Posts: 12
Rep Power: 7 |
I want to use wallDist to create a velocity profile on a non-planar surface. I copied this solution to my fvOptions file and get the following errors:
1) Cannot open include file ".../wallDist.H" while reading dictionary ".../fvOptions" 2) if I comment #include wallDist.H I get: "ill defined primitiveEntry starting at keyword 'volScalarField' on line 19 and ending at line 35" [0] [0] file: .../fvOptions at line 35. [0] [0] From void Foam:rimitiveEntry::readEntry(const Foam::dictionary&, Foam::Istream&) [0] in file db/dictionary/primitiveEntry/primitiveEntryIO.C at line 236. Any suggestions? |
|
November 10, 2021, 13:51 |
|
#9 |
Member
Join Date: Aug 2017
Location: Algeria
Posts: 98
Rep Power: 9 |
If you are using OpenFOAM ESI version (e.g. v2106) no need to compile any code or use the fvOptions framework. You simply run:
Code:
checkMesh -writeAllFields |
|
November 10, 2021, 15:52 |
|
#10 |
New Member
Join Date: Jan 2019
Posts: 12
Rep Power: 7 |
Thanks for the quick reply. I have now in 0/wallDistance and want to use it for the inlet boundary in U as an expression:
expression #{ vector(Uref/log(zRef/z0)*log(wallDistance/z0), 0, 0) #}; but Object wallDistance does not exist Any Ideas how to use the new volScalarField? |
|
November 5, 2022, 12:28 |
|
#11 |
Senior Member
|
In case someone is still looking for a simple solution, here's an example function object to put in the functions{...} section of your controlDict:
Code:
wallDist1 { type coded; libs (utilityFunctionObjects); name wallDistance; executeControl timeStep; executeInterval 4; writeControl none; codeInclude #{ #include "wallDist.H" #}; codeExecute #{ auto* wallDistancePtr = mesh().getObjectPtr<volScalarField>("wallDistance"); if (!wallDistancePtr) { Info<< "Create wallDistance field" << nl; wallDistancePtr = new volScalarField ( IOobject ( "wallDistance", mesh().time().timeName(), mesh(), IOobject::NO_READ, IOobject::AUTO_WRITE ), mesh(), dimensionedScalar("wallDistance", dimensionSet(0,1,0,0,0,0,0), 0) ); } regIOobject::store(wallDistancePtr); auto& wallDistance = *wallDistancePtr; Info<< "Computing wallDistance field\n" << endl; wallDistance = wallDist::New(mesh()).y(); #}; } |
|
January 17, 2023, 15:59 |
|
#12 | |
New Member
andrew
Join Date: Oct 2015
Posts: 11
Rep Power: 11 |
Quote:
Excellent code... But #1 There seems to be a quirk (or a bug). In cyclic BC it seems to give up. bug.jpg In this case left and right are cyclicAMI bc's. In the left the distance seems to be 0. It should not be 0 and even better it should wrap around. Probably it is because of the computation of the walldistance method... #2 Can this code be implemented in a solver directly? I tried to implement it to openFoam2112 and laplacianFoam but I get errors. Obviously a copy/paste would not work. Can you point to a way to implement it? Andrew |
||
January 17, 2023, 16:05 |
|
#13 |
Senior Member
|
Hi,
whether it works or not depends on which function you used to compute the wall distance, (fvSchemes), I used meshWave you may be able to implement that in a solver, but you may have to access the pointer from the turbulence model which in turn gives you the distance.. i don't recommend trying this unless you know c++ and OpenFOAM or have a lot of time to try around |
|
January 17, 2023, 16:48 |
|
#14 |
New Member
andrew
Join Date: Oct 2015
Posts: 11
Rep Power: 11 |
I used meshwave in fvSchemes
C++ well ok but not that much... Well my guess was that meshWave can calculate distances regardless of turbulence etc. That it is a piece of code that can be used independently. Therefore it could be used for creating a distance field for any other use. bug2.jpg In this case left and right are patches (not cyclicAMI). The distance is calculated correctly and is not 0 at the left border. There seems to be a bug here in the presence of cyclic borders. |
|
January 18, 2023, 03:43 |
|
#15 |
Senior Member
|
the patches are walls?
|
|
January 18, 2023, 11:53 |
|
#16 |
New Member
andrew
Join Date: Oct 2015
Posts: 11
Rep Power: 11 |
The internal boundaries are set as walls. The distance does not work with common patches. It needs walls because it is used in turbulence and turbulence needs walls to work.
Meshwave does not make the cut. I switched to Poisson and since it uses a solver the cyclic boundaries are respected. So problem solved! (https://www.openfoam.com/documentati...e-poisson.html) bug4.jpg I would like to ask two more things. #1. How can I make the field at the beginning of the simulation before any other iteration? right now I use these settings in controlDict Code:
startFrom startTime; startTime 0; stopAt endTime; endTime 30; deltaT 1; writeControl adjustableRunTime; writeInterval 1; .... executeControl timeStep; executeInterval 1000; writeControl timeStep; timeStart 0; #2 After the #1 how can I use it inside the solver? My plan is to use this field to calculate a coefficient based on distance. Any help would be greatly appreciated |
|
January 18, 2023, 15:51 |
|
#17 |
New Member
andrew
Join Date: Oct 2015
Posts: 11
Rep Power: 11 |
ok. Finally I made it
Based on the above code from louisgag I added it as a field in a solver (laplacianFoam) first a new field was added: TDist in createFields.H. This will be a new field and it will be used as a variable coefficient taking the place of the old fixed coefficient DT. It will be calculated as a value*distance instead of a fixed value before the change. The distance will be the distance from the walls and the value will be defined in transportProperties with the name DDT. It will have the same units of the old coefficient DT in the code so its units are [0 2 -1 0 ...] Code:
volScalarField TDist ( IOobject ( "TDist", runTime.timeName(), mesh, IOobject::NO_READ, IOobject::AUTO_WRITE ), mesh, dimensionedScalar(dimensionSet(0,2,-1,0,0,0,0), 0) ); Code:
volScalarField DDT ( IOobject ( "DDT", runTime.timeName(), mesh, IOobject::READ_IF_PRESENT, IOobject::AUTO_WRITE ), mesh, dimensionedScalar(dimensionSet(0,1,-1,0,0,0,0), Zero) ); After that I changed the rest of DT to DDT in createfields.H Then in laplacianFoam.C the #include section becomes Code:
#include "wallDist.H" // added line #include "fvCFD.H" #include "fvOptions.H" #include "simpleControl.H" Code:
TDist = DDT*wallDist::New(mesh).y(); while (simple.correctNonOrthogonal()) { fvScalarMatrix TEqn ( fvm::ddt(T) - fvm::laplacian(TDist, T) == fvOptions(T) ); fvOptions.constrain(TEqn); TEqn.solve(); fvOptions.correct(T); } #include "write.H" Code:
DDT DDT [ 0 1 -1 0 0 0 0 ] 10; bug5.jpg Simple as that! |
|
|
|
Similar Threads | ||||
Thread | Thread Starter | Forum | Replies | Last Post |
wallDist error in OF-1.5.x | elisabet | OpenFOAM Bugs | 15 | May 21, 2020 10:50 |
porousSimpleFoam - keyword wallDist undefined | anon_j | OpenFOAM Running, Solving & CFD | 5 | October 31, 2019 07:42 |
calculating wall distance wallDist | volker | OpenFOAM Programming & Development | 12 | December 28, 2017 12:29 |
WallDist is undefined in fvschemes for new boundary condition | crazzy.pirate43 | OpenFOAM Pre-Processing | 3 | July 14, 2017 07:27 |
problem with wallDist on yPlus | jms | OpenFOAM | 1 | October 14, 2011 02:55 |