|
[Sponsors] |
How to obtain fluid shear stress (not only wall shear stress) in openFOAM |
![]() |
|
LinkBack | Thread Tools | Search this Thread | Display Modes |
![]() |
![]() |
#1 |
Member
Sourav Mandal
Join Date: Jul 2019
Posts: 54
Rep Power: 5 ![]() |
Dear All,
I want to calculate/visualise shear stress inside the fluid domain. I came through wallShearStress utility but as you know, it only calculates the shear stress at the wall. My model is very simple: a long pipe, with a non-Newtonian fluid simulated at a certain pressure difference between the inlet and the outlet, solved using simpleFoam. Surprisingly, I found no relevant documentation, although there is plenty of discussion regarding the shear stress at the wall. I came through this helpful post, which enabled me to calculate shear strain in the fluid domain but finding it hard to adopt the approach to obtain shear stress. Function object for strain rate tensor? I tried with the approach mentioned there, by making files named fluidShearStressSM.C etc. At the wmake stage it throws a lot of errors such as : Code:
g++ -std=c++11 -m64 -Dlinux64 -DWM_ARCH_OPTION=64 -DWM_DP -DWM_LABEL_SIZE=32 -Wall -Wextra -Wold-style-cast -Wnon-virtual-dtor -Wno-unused-parameter -Wno-invalid-offsetof -Wno-attributes -O3 -DNoRepository -ftemplate-depth-100 -I/opt/openfoam7/src/finiteVolume/lnInclude -I/opt/openfoam7/src/meshTools/lnInclude -I/opt/openfoam7/src/lagrangian/basic/lnInclude -I/opt/openfoam7/src/fileFormats/lnInclude -I/opt/openfoam7/src/sampling/lnInclude -I/opt/openfoam7/src/surfMesh/lnInclude -I/opt/openfoam7/src/thermophysicalModels/basic/lnInclude -I/opt/openfoam7/src/thermophysicalModels/solidThermo/lnInclude -I/opt/openfoam7/src/transportModels -I/opt/openfoam7/src/transportModels/compressible/lnInclude -I/opt/openfoam7/src/TurbulenceModels/turbulenceModels/lnInclude -I/opt/openfoam7/src/TurbulenceModels/incompressible/lnInclude -I/opt/openfoam7/src/TurbulenceModels/compressible/lnInclude -IlnInclude -I. -I/opt/openfoam7/src/OpenFOAM/lnInclude -I/opt/openfoam7/src/OSspecific/POSIX/lnInclude -fPIC -c fluidShearStressSM/fluidShearStressSM.C -o /opt/openfoam7/platforms/linux64GccDPInt32Opt/src/functionObjects/field/fluidShearStressSM/fluidShearStressSM.o fluidShearStressSM/fluidShearStressSM.C: In member function ‘virtual bool Foam::functionObjects::fluidShearStressSM::calc()’: fluidShearStressSM/fluidShearStressSM.C:65:13: error: expected primary-expression before ‘const’ 65 | const volTensorField& gradU = fvc::grad(U); | ^~~~~ fluidShearStressSM/fluidShearStressSM.C:68:43: error: ‘mu’ was not declared in this scope 68 | const volTensorField& tau = - mu * (gradU + gradU.T()); | ^~ fluidShearStressSM/fluidShearStressSM.C:68:49: error: ‘gradU’ was not declared in this scope 68 | const volTensorField& tau = - mu * (gradU + gradU.T()); | ^~~~~ fluidShearStressSM/fluidShearStressSM.C:69:9: error: expected primary-expression before ‘)’ token 69 | ); | ^ fluidShearStressSM/fluidShearStressSM.C:68:35: warning: unused variable ‘tau’ [-Wunused-variable] 68 | const volTensorField& tau = - mu * (gradU + gradU.T()); | ^~~ fluidShearStressSM/fluidShearStressSM.C: In constructor ‘Foam::functionObjects::fluidShearStressSM::fluidShearStressSM(const Foam::word&, const Foam::Time&, const Foam::dictionary&)’: fluidShearStressSM/fluidShearStressSM.C:90:5: error: type ‘Foam::functionObjects::fvMeshFunctionObject’ is not a direct base of ‘Foam::functionObjects::fluidShearStressSM’ 90 | fvMeshFunctionObject(name, runTime, dict), | ^~~~~~~~~~~~~~~~~~~~ fluidShearStressSM/fluidShearStressSM.C:91:5: error: class ‘Foam::functionObjects::fluidShearStressSM’ does not have any field named ‘logFiles’ 91 | logFiles(obr_, name), | ^~~~~~~~ fluidShearStressSM/fluidShearStressSM.C:92:5: error: class ‘Foam::functionObjects::fluidShearStressSM’ does not have any field named ‘writeLocalObjects’ 92 | writeLocalObjects(obr_, log), | ^~~~~~~~~~~~~~~~~ fluidShearStressSM/fluidShearStressSM.C:93:1: error: expected identifier before ‘{’ token 93 | { | ^ fluidShearStressSM/fluidShearStressSM.C:93:1: error: no matching function for call to ‘Foam::functionObjects::fieldExpression::fieldExpression()’ In file included from fluidShearStressSM/fluidShearStressSM.H:42, from fluidShearStressSM/fluidShearStressSM.C:26: lnInclude/fieldExpression.H:88:9: note: candidate: ‘Foam::functionObjects::fieldExpression::fieldExpression(const Foam::word&, const Foam::Time&, const Foam::dictionary&, const Foam::word&, const Foam::word&)’ 88 | fieldExpression | ^~~~~~~~~~~~~~~ lnInclude/fieldExpression.H:88:9: note: candidate expects 5 arguments, 0 provided fluidShearStressSM/fluidShearStressSM.C:95:5: error: ‘resetName’ was not declared in this scope; did you mean ‘resultName_’? 95 | resetName(typeName); | ^~~~~~~~~ | resultName_ fluidShearStressSM/fluidShearStressSM.C:96:5: error: ‘resetLocalObjectName’ was not declared in this scope 96 | resetLocalObjectName(typeName); | ^~~~~~~~~~~~~~~~~~~~ make: *** [/opt/openfoam7/wmake/rules/General/transform:26: /opt/openfoam7/platforms/linux64GccDPInt32Opt/src/functionObjects/field/fluidShearStressSM/fluidShearStressSM.o] Error 1 I am new to OpenFOAM & have no prior exposure to OOC++ coding. Any suggestion or pointers in the right direction would help me greatly in my research, with this nice open-source software. |
|
![]() |
![]() |
![]() |
![]() |
#2 |
Member
Join Date: Oct 2011
Posts: 47
Rep Power: 13 ![]() |
-Move to $FOAM_SRC/etc/caseDicts/postProcessing/fields
-make a copy of vorticity to strainRate, replace every occurance of vorticity with strainRate in the files -Move to $FOAM_SRC/functionObjects/field/make. Edit "files", add strainRate/strainRate.C after vorticity -copy the folder vorticity in $FOAM_SRC/functionObjects/field to strainRate -replace vorticity with strainRate in the copied filenames -in strainRate.C replace #fvcCurl.H with #fvcGrad.H, replace function calc() with Code:
bool Foam::functionObjects::strainRate::calc() { if (foundObject<volVectorField>(fieldName_)) { return store ( resultName_, sprt(2.0)*mag(symm(fvc::grad(lookupObject<volVectorField>(fieldName_)))) ); } return false; For non-Newtonian Liquids this formula is generally wrong. I could not find a better approach, yet. |
|
![]() |
![]() |
![]() |
![]() |
#3 | |
Member
Sourav Mandal
Join Date: Jul 2019
Posts: 54
Rep Power: 5 ![]() |
Quote:
BTW, the problem I am facing isn't with implementing strain rate (it works as that link says), rather with the shear stress in the entire fluid domain. Sorry, if I wasn't clear enough... |
||
![]() |
![]() |
![]() |
![]() |
#4 |
Member
Sourav Mandal
Join Date: Jul 2019
Posts: 54
Rep Power: 5 ![]() |
I found a workaround while fiddling with Swak4Foam. He files or commands that I used are as follow:
Code:
FoamFile { version 2.0; format ascii; instance "system"; local ""; class dictionary; object funkySetFieldsDict; } expressions ( setTau { field Tau; create true ; expression "mag(grad(U))*nu"; } );
The simulation is as such that the highest shear stress would be at the wall. So, I compare the maximum values of shear stress and wall shear stress (using the wallShearStress utility), it's hugely different. I am not sure now, which one is correct. Can anybody help me inferring where is the error? |
|
![]() |
![]() |
![]() |
![]() |
#5 |
Senior Member
Join Date: Jul 2019
Posts: 148
Rep Power: 5 ![]() |
Hi Sourav,
I am wondering if you managed to get a way to extract the correct stress tensor from the openFoam simulations. Thanks. |
|
![]() |
![]() |
![]() |
![]() |
#6 | |
Member
Sourav Mandal
Join Date: Jul 2019
Posts: 54
Rep Power: 5 ![]() |
Hello Bodo1993, if you haven't found it already there are two ways to achieve this.
First, with OpenFOAM version 8, you can just add these lines at the end of your controldict file: Code:
functions { //https://www.openfoam.com/documentation/guides/latest/doc/guide-function-objects.html #includeFunc shearStress; } Quote:
![]() Last edited by sourav90; December 10, 2020 at 12:46. Reason: update |
||
![]() |
![]() |
![]() |
![]() |
#7 | |
New Member
刘旭阳
Join Date: Feb 2022
Posts: 1
Rep Power: 0 ![]() |
I have a similar problem, would you like to ask if it is solved? If solved, can you share the code for calculating fluid shear stress? I would be very grateful and happy to share it. Thanks!
Quote:
|
||
![]() |
![]() |
![]() |
Tags |
fluid shear stress, function objects, post procesing, programming, runtime processing |
Thread Tools | Search this Thread |
Display Modes | |
|
|
![]() |
||||
Thread | Thread Starter | Forum | Replies | Last Post |
OpenFOAM v3.0+ ?? | SBusch | OpenFOAM | 22 | December 26, 2016 14:24 |
UDF for wall slipping | HFLUENT | Fluent UDF and Scheme Programming | 0 | April 27, 2011 12:03 |
Wall shear stress distributions | en51nm | STAR-CD | 2 | January 28, 2010 04:42 |
LES: mean wall shear stress | Francois | FLUENT | 0 | July 7, 2005 11:15 |
WALL SHEAR STRESS | Min-Hua Wang | CFX | 0 | April 3, 2002 17:40 |