How to modify discrete scheme
Dear all,
If I developed a new scheme of Laplacian, may I know how to add the c++ code into openFoam so that I can call it like "fvm::Laplacian()"? Many thanks! Crammer008 |
Supplement of the above problem
Dear all,
I'd like to give a simple example to demonstrate my problem. Assume the new scheme is quite simple. Based on two nodes (i and j), the scheme is dF/dx = ( F(i) - F(j) ) / ( x(i) - x(j) ) May I know how to append such a simple sheme to openFoam so that I can call this scheme by "fvm::Laplacian()"? Many thanks and looking forward to your guidance:) Crammer008 |
I suggest finding the fvm::lapl operator, copying the files, and making the modifications according to your new scheme and changing the name to Laplacian. Not sure if that's all there's to it but that would be a way to start.
|
How to fine the source file?
Dear Akidess,
Thanks a lot for your guidance:) Would you please tell me how to find the file related to the detailed description of fvm::lapl? It seems that there are a lot of files including fvm::lapl but all of them are not related to the algorithm level. May I know what kind of file is related to the bottom code? Many thanks! Crammer008 |
I'm guessing it's this: http://foam.sourceforge.net/docs/cpp...cianScheme.php
|
Dear Akidess,
Thanks a lot for your guidance:) It seems that there are tons of materials. I will read them carefully. Hope to get your further guidance. Best regards, Crammer008 |
Is is possible to see code of algorithm?
Dear OpenFoam expert,
As aforesaid, I am trying to find the bottom code related to algorithm. I read almost all the *.H and *.c files related to Laplacian or divScheme from OpenFoam source. However, I found the original point of the Laplacian or divergence operator is limited to member function. For example, disScheme is realized by two functions mesh_ and tinterpScheme_ (look at the code below). If you dig further, you'll never find how these two functions are realized. May I know whether OpenFoam does not provide the bottom code related to the algorithm realization? For example, OpenFoam just tells you how to use a member function add(a,b) but it never tells you that the add is realized by a+b. Is it the current status of OpenFoam? If so, think OpenFoam is just a blackbox for me. Looking forward to your guidance Thanks a lot Luo Chao -------------------------------------- 00108 //- Construct from mesh 00109 divScheme(const fvMesh& mesh) 00110 : 00111 mesh_(mesh), 00112 tinterpScheme_(new linear<Type>(mesh)) 00113 {} ----------------------------------------------------- |
Dear OpenFoam expert,
Is there anybody who can help answer the above problem? Many thanks crammer008 |
Quote:
See an article on it here: http://openfoamwiki.net/index.php/Op...tion_mechanism When it comes to things like schemes, boundary conditions, solvers - anything that varies depending on what the user puts into the case dictionary files - you can't tell by looking at the code what is actually going to be constructed. Luckily for you, there is only one divScheme and one LaplacianScheme... at least in my version. Look for the subdirectories under src/finiteVolume/finiteVolume/laplacianSchemes and divSchemes. laplacianSchemes has "gaussLaplacianScheme" and divSchemes has "gaussDivScheme". The source for the algorithms you want are in there. As for tinterpScheme_, this is also runTimeSelectable, but it seems to be hard-coded to "linear". mesh_ is a reference to the mesh, which comes from the parameter mesh. Sometimes you will find other functions that do not appear to be defined in the source code. For instance try to find the definition of exp(scalar)... exp is a standard C++ function, but there is no scalar in standard C++. Many of the primitive functions are defined in macros... so reading the full definition of something like this requires some macro reconstruction. For exp(scalar), it is defined in Scalar.H: transFunc(exp) And the definition of this macro is in doubleScalar.H (or floatScalar.H): Code:
#define transFunc(func) \ inline Scalar func(const Scalar s) \ { \ return ::func(s); \ } To write your own custom laplacianScheme, here's a rough list of what you need to do: 1- Copy the gaussLaplacianScheme folder to a new name customLaplacianScheme 2- Rename all the files in the folder to "customLaplacianScheme"... one file needs to end in 's'. Delete the .dep file. 3- Open each file and do a text search and replace for "gaussLaplacianScheme" with "customLaplacianScheme" 4- In gaussLaplacianScheme.H you'll find a line that says Code:
TypeName("Gauss") 5- Edit the custom scheme to whatever you want. 6- Edit the file src/finiteVolume/Make/files 7- Search for "gaussLaplacianScheme" 8- Add a new line for your custom scheme. Remember the "s" on the end. 9- Compile the finiteVolume library (go to src/finiteVolume, and type wmake libso) Good luck! |
Is OpenFoam a completely open source?
Dear Marupio,
Thanks a lot for your great guidance:) Under your statement, I begin to realize that OpenFoam may not be a completely open source. I have the following statement about your reply. Hope to get your further guidance:) Many thanks Crammer008 Quote:
|
Quote:
Code:
ddtSchemes Code:
ddtSchemes Quote:
Quote:
Code:
fvm.upper() = deltaCoeffs.internalField()*gammaMagSf.internalField(); When dealing with implicit calculations, the schemes are all about filling in the coefficients of the discretization matrix. See this article here: http://openfoamwiki.net/index.php/Op...es_in_OpenFOAM Good luck! |
All times are GMT -4. The time now is 20:44. |