|
[Sponsors] |
December 26, 2013, 08:43 |
Replacing Uniform BC with zeroGradient
|
#1 |
Member
Join Date: Aug 2013
Posts: 60
Rep Power: 13 |
Hello,
I have a problem when writing a scalar field into the time folders. The field is initially specified as: volScalarField mu("mu", E/(2.0*(1.0 + nu))); Where E and nu are obtained from the test case mechanical properties file. I have used the following code to write the scalar field mu inside each time folder so that I can view the results in para view: Code:
if(runTime.outputTime()) { mu.write(); } Code:
...LIST OF VALUES FOR EACH CELL ABOVE HERE 1.27941e+07 1.27941e+07 1.27941e+07 1.27941e+07 1.27941e+07 1.27941e+07 1.27941e+07 ); boundaryField { walls { type calculated; value uniform 9.79413e+06; } frontAndBack { type empty; } } If not, would it be possible for me to create a bash script (such as Allrun) in which a for loop and sed command is used to go through each time directory inside of the case and replace the BC with the required zeroGradient? Thanks. |
|
January 4, 2014, 04:39 |
|
#2 |
Senior Member
Niels Gjoel Jacobsen
Join Date: Mar 2009
Location: Copenhagen, Denmark
Posts: 1,902
Rep Power: 37 |
Hallo,
If you create your field in the following manner, you should obtain the effect that you are looking for: Code:
volScalarField mu ( IOobject ( "mu", mesh.time().timeName(), mesh, IOobject::NO_READ, IOobject::AUTO_WRITE ), mesh, dimensionedScalar("null", E.dimensions(), 0.0), "zeroGradient" ); mu.internalField() = E.internalField()/(2.0*(1.0 + nu.internalField())); mu.correctBoundaryConditions(); Code:
mu.correctBoundaryConditions(); Kind regards Niels
__________________
Please note that I do not use the Friend-feature, so do not be offended, if I do not accept a request. |
|
January 4, 2014, 17:13 |
|
#3 |
Member
Join Date: Aug 2013
Posts: 60
Rep Power: 13 |
Thank you so much for your help Niel, I was getting a volScalarField re-deceleration error but when I deleted the equation from the other header file where it was initialy defined the solver compiled fine.
Could you please help me with one more problem? Inside of my main .C file I have made the variable "mu" temperature dependant and made it change in the time loop in the following way: Code:
if(mu.internalField()[cellI]<(1.27941e+07+(deltaLame*3))){ mu.internalField()[cellI]+=deltaLame; mu.correctBoundaryConditions();} if(mu.internalField()[cellI]<(mu+(deltaLame*3))) I get errors, I also tried to replace mu with: E.internalField()/(2.0*(1.0 + nu.internalField())) But again I got a long list of errors. Could you please suggest a method for defining mu here so that I do not have to manually replace and recompile the solver when I change the variable it is dependant on? Your help is greatly appreciated. Thank you. |
|
January 5, 2014, 04:24 |
|
#4 |
Senior Member
Niels Gjoel Jacobsen
Join Date: Mar 2009
Location: Copenhagen, Denmark
Posts: 1,902
Rep Power: 37 |
Good morning,
You could merely create another volScalarField called muLimit, and then make the comparison in the if-statement on a cell per cell basis. This would also allow you to have a spatially varying limit. Kind regards, Niels
__________________
Please note that I do not use the Friend-feature, so do not be offended, if I do not accept a request. |
|
February 9, 2014, 12:25 |
|
#5 |
Member
Join Date: Aug 2013
Posts: 60
Rep Power: 13 |
I am now adding a time and temperature dependant thermal conductivity, I have modified the code in the main .C file and it works as expected however, I now have the same problem with DT in the readThermalProperties file as I did for mu and lambda, I mean in the output file in the time step folder the boundary field value is set as uniform at the wall as shown in the first post above.
I have the following code in the readThermalProperties file: Code:
volScalarField DT ( IOobject ( "DT", runTime.timeName(), mesh, IOobject::NO_READ, IOobject::AUTO_WRITE ), mesh, dimensionedScalar("0", dimensionSet(0, 2, -1 , 0, 0), 0.0) ); Code:
..................... IOobject::AUTO_WRITE ), mesh, dimensionedScalar("0", dimensionSet(0, 2, -1 , 0, 0), 0.0) "zeroGradient" ); Code:
sk@sk-VirtualBox:~/OpenFOAM/sk-2.2.2/applications/solvers/cureFoam$ wmake Making dependency list for source file cureFoam.C SOURCE=cureFoam.C ; g++ -m32 -Dlinux -DWM_DP -Wall -Wextra -Wno-unused-parameter -Wold-style-cast -O3 -DNoRepository -ftemplate-depth-100 -I/opt/openfoam222/src/finiteVolume/lnInclude -ItractionDisplacement/lnInclude -IlnInclude -I. -I/opt/openfoam222/src/OpenFOAM/lnInclude -I/opt/openfoam222/src/OSspecific/POSIX/lnInclude -fPIC -c $SOURCE -o Make/linuxGccDPOpt/cureFoam.o In file included from cureFoam.C:50:0: readThermalProperties.H: In function ‘int main(int, char**)’: readThermalProperties.H:44:5: error: expected ‘)’ before string constant readSolidDisplacementFoamControls.H:3:11: warning: unused variable ‘nCorr’ [-Wunused-variable] readSolidDisplacementFoamControls.H:5:8: warning: unused variable ‘convergenceTolerance’ [-Wunused-variable] make: *** [Make/linuxGccDPOpt/cureFoam.o] Error 1 Thank you. |
|
February 9, 2014, 14:08 |
|
#6 |
Senior Member
Niels Gjoel Jacobsen
Join Date: Mar 2009
Location: Copenhagen, Denmark
Posts: 1,902
Rep Power: 37 |
Hallo,
You get an error, because you lack a ",", before the "zeroGradient" part. Kind regards, Niels
__________________
Please note that I do not use the Friend-feature, so do not be offended, if I do not accept a request. |
|
|
|
Similar Threads | ||||
Thread | Thread Starter | Forum | Replies | Last Post |
Inlet patch problems | martyn88 | OpenFOAM Running, Solving & CFD | 6 | April 21, 2017 19:34 |
T Junction Stability | ignacio | OpenFOAM Running, Solving & CFD | 5 | May 2, 2013 11:44 |
[swak4Foam] Air Conditioned room groovyBC | Sebaj | OpenFOAM Community Contributions | 7 | October 31, 2012 15:16 |
Need help with boundary conditions: open to atmosphere | Wolle | OpenFOAM | 2 | April 11, 2011 08:32 |
Pressure instability with rhoSimpleFoam | daniel_mills | OpenFOAM Running, Solving & CFD | 44 | February 17, 2011 18:08 |