CFD Online Logo CFD Online URL
www.cfd-online.com
[Sponsors]
Home > Forums > OpenFOAM Programming & Development

Edit linear solver

Register Blogs Members List Search Today's Posts Mark Forums Read

Like Tree4Likes

Reply
 
LinkBack Thread Tools Display Modes
Old   May 11, 2013, 14:57
Default Edit linear solver
  #1
Member
 
Hassan
Join Date: Oct 2012
Location: Iran
Posts: 62
Rep Power: 4
luckycfd is on a distinguished road
Hi all,
How can i edit linear solvers (PCG,PBICG,...) of openfoam, then compile them?
Regards.
luckycfd is offline   Reply With Quote

Old   May 14, 2013, 15:34
Default
  #2
Senior Member
 
kmooney's Avatar
 
Kyle Mooney
Join Date: Jul 2009
Location: Amherst, MA USA - San Diego, CA USA
Posts: 277
Rep Power: 9
kmooney is on a distinguished road
Its open source so you can really do whatever you please with the linear solvers.

You might be better of starting with simpler OpenFOAM programming before diving into the linear solvers, it sounds like you are really just getting started...
kmooney is offline   Reply With Quote

Old   June 6, 2013, 04:19
Default
  #3
Member
 
Hassan
Join Date: Oct 2012
Location: Iran
Posts: 62
Rep Power: 4
luckycfd is on a distinguished road
ok tanx for your attention, but please help me how can i do it?
i copy the linear solver, for example PBC directory, in my home then compile this by wmake, but there is not exist Make directory in the PCG directory for compiling!
luckycfd is offline   Reply With Quote

Old   June 10, 2013, 12:53
Default compile openfoam linear solver
  #4
Member
 
Hassan
Join Date: Oct 2012
Location: Iran
Posts: 62
Rep Power: 4
luckycfd is on a distinguished road
hi all,
how an i compile linear solver of openfoam?
for example, i copy PCG directory in my home then compile this by wmake, but there is not exist Make directory in the PCG directory for compiling! please help me. (i want edit this linear solver.)
luckycfd is offline   Reply With Quote

Old   June 10, 2013, 13:30
Default
  #5
Super Moderator
 
Bruno Santos
Join Date: Mar 2009
Location: Lisbon, Portugal
Posts: 8,301
Blog Entries: 34
Rep Power: 84
wyldckat is just really nicewyldckat is just really nicewyldckat is just really nicewyldckat is just really nice
Greetings Hassan,

Please study the following pages, before continuing to try and modify a linear solver:
The last one is the one that gives the closest instructions to the changes you want to make, but these intermediate steps are very important, so that you can understand better how to build and change OpenFOAM source code!

Good luck! Best regards,
Bruno
luckycfd likes this.
wyldckat is offline   Reply With Quote

Old   July 18, 2013, 18:16
Default openfoam linear solver
  #6
Member
 
Hassan
Join Date: Oct 2012
Location: Iran
Posts: 62
Rep Power: 4
luckycfd is on a distinguished road
Hi,

In order to create and use the new linear solver myPBiCG:
  1. cp –r $FOAM_SRC/OpenFOAM/matrices/lduMatrix/solvers/PBiCG $FOAM_RUN/myPBiCG
  2. Replace all occurences of PBiCG inside PBiCG.H/.C with myPBiCG and rename these files to myPBiCG.H/.C.
  3. create the directory structure : myPBiCG/Make, and create files and options in it.
files:
myPBiCG.C
LIB = $(FOAM_USER_LIBBIN)/libmyPBiCG


options:
EXE_INC = -I$(OBJECTS_DIR)
LIB_LIBS = \
$(FOAM_LIBBIN)/libOSspecific.o \
-L$(FOAM_LIBBIN)/dummy -lPstream \
-lz
  1. wmake libso
  2. then switched into cavity test case, added libs(“libmyPBiCG.so”); to controlDict in the cavity/system directory and edited system/fvSolution to use myPBiCG instead of PBiCG.


But when I run the cavity by icoFoan, I recevie this error at the end of running the case:
Segmentation fault”
Why? what is this error? how can i solve this error?
luckycfd is offline   Reply With Quote

Old   July 19, 2013, 16:10
Default Hi all
  #7
Member
 
Hassan
Join Date: Oct 2012
Location: Iran
Posts: 62
Rep Power: 4
luckycfd is on a distinguished road
any body? please help me?
luckycfd is offline   Reply With Quote

Old   July 20, 2013, 18:49
Default
  #8
Member
 
Hassan
Join Date: Oct 2012
Location: Iran
Posts: 62
Rep Power: 4
luckycfd is on a distinguished road
friends? please
luckycfd is offline   Reply With Quote

Old   July 21, 2013, 05:07
Default
  #9
Super Moderator
 
Bruno Santos
Join Date: Mar 2009
Location: Lisbon, Portugal
Posts: 8,301
Blog Entries: 34
Rep Power: 84
wyldckat is just really nicewyldckat is just really nicewyldckat is just really nicewyldckat is just really nice
Greetings Hassan,

People that usually can help here in the forum, only do it when they have some spare time. So, please be patient

I followed your steps and as far as I can figure out, the only problem could be that you added too many things to the file "Make/options".

Since I had the trouble to follow your steps and to create both the library and the test case, attached are both ready for testing. I used OpenFOAM 2.2.x, but should work fine on any 2.2.

edit: next time you post code, please use the "[CODE]" marker, as exemplified in the second link on my signature.

Best regards,
Bruno
Attached Files
File Type: gz luckycfd.tar.gz (4.0 KB, 12 views)
luckycfd likes this.

Last edited by wyldckat; July 21, 2013 at 05:07. Reason: see "edit:"
wyldckat is offline   Reply With Quote

Old   July 21, 2013, 07:48
Smile
  #10
Member
 
Hassan
Join Date: Oct 2012
Location: Iran
Posts: 62
Rep Power: 4
luckycfd is on a distinguished road
Greetings Bruno,
thank you very much
Best regards,
Hassan.
luckycfd is offline   Reply With Quote

Old   August 18, 2013, 14:00
Default edit precontitioner
  #11
Member
 
Hassan
Join Date: Oct 2012
Location: Iran
Posts: 62
Rep Power: 4
luckycfd is on a distinguished road
Hi,

After compile the new preconditioner(myDILUPreconditioner) Successfully in the same way for adding the new linear solver library(myPBiCG).
I add to controlDict in the cavity/system directory:
libs("libmyDILUPreconditioner.so");
and edite system/fvSolution to use myDILU instead of DILU.
But I recevie this error:
Code:
--> FOAM FATAL IO ERROR:  
 Unknown asymmetric matrix preconditioner myDILUPreconditioner
 
 
 Valid asymmetric matrix preconditioners :
 
 
 4
 (
 DILU
 GAMG
 diagonal
 none
 )
 
 
  file:  
 
 
     From function lduMatrix::preconditioner::New(const solver&, const dictionary&)
     in file matrices/lduMatrix/lduMatrix/lduMatrixPreconditioner.C at line 123.
 
 
 FOAM exiting
please guide me how can I use my preconditioner?


Best regards,
Hassan.
luckycfd is offline   Reply With Quote

Old   August 18, 2013, 14:04
Default
  #12
Super Moderator
 
Bruno Santos
Join Date: Mar 2009
Location: Lisbon, Portugal
Posts: 8,301
Blog Entries: 34
Rep Power: 84
wyldckat is just really nicewyldckat is just really nicewyldckat is just really nicewyldckat is just really nice
Hi Hassan,

Go into the folder where you have the "myDILUPreconditioner" source code and run:
Code:
wclean all
Then compress the folder of the source code "myDILUPreconditioner" and attach the compressed file on your next post.

This way I'm able to tell you what you forgot to do.

Best regards,
Bruno
wyldckat is offline   Reply With Quote

Old   August 18, 2013, 14:11
Default
  #13
Member
 
Hassan
Join Date: Oct 2012
Location: Iran
Posts: 62
Rep Power: 4
luckycfd is on a distinguished road
thank you,
source file is attached.
Attached Files
File Type: gz wyldckat.tar.gz (24.9 KB, 1 views)
luckycfd is offline   Reply With Quote

Old   August 18, 2013, 14:35
Default
  #14
Super Moderator
 
Bruno Santos
Join Date: Mar 2009
Location: Lisbon, Portugal
Posts: 8,301
Blog Entries: 34
Rep Power: 84
wyldckat is just really nicewyldckat is just really nicewyldckat is just really nicewyldckat is just really nice
Hi Hassan,

It's simple. Notice these two lines in the header file "*.H"?
Code:
    //- Runtime type information
    TypeName("DILU");
You should change it to:
Code:
    //- Runtime type information
    TypeName("myDILU");
Best regards,
Bruno
luckycfd likes this.
wyldckat is offline   Reply With Quote

Old   August 18, 2013, 14:43
Default
  #15
Member
 
Hassan
Join Date: Oct 2012
Location: Iran
Posts: 62
Rep Power: 4
luckycfd is on a distinguished road
Mr. Bruno
It,s OK!
Thank You very very much

best regards,
Hassan
luckycfd is offline   Reply With Quote

Old   August 22, 2013, 03:10
Default myPBiCG/Make/options
  #16
Member
 
Hassan
Join Date: Oct 2012
Location: Iran
Posts: 62
Rep Power: 4
luckycfd is on a distinguished road
Greetings Bruno,

Why the options file of myPBiCG can be empty? I use two diffrence form of options file, but both of them seems true! What is the difference between options_1 and options_2 files that is attached?

Best regards,
Hassan.
Attached Files
File Type: gz wyldckat_2.tar.gz (2.9 KB, 2 views)
luckycfd is offline   Reply With Quote

Old   August 22, 2013, 05:47
Default
  #17
Super Moderator
 
Bruno Santos
Join Date: Mar 2009
Location: Lisbon, Portugal
Posts: 8,301
Blog Entries: 34
Rep Power: 84
wyldckat is just really nicewyldckat is just really nicewyldckat is just really nicewyldckat is just really nice
Hi Hassan,

There are two details you need to check:
  1. After changing the "options" file, did you run the following command?
    Code:
    wclean libso
  2. When you run:
    Code:
    wmake libso
    you have to look at the output and look for the lines that start with "SOURCE", then see what occurrences there are of "-I", which indicate which folders have headers files that should be added to the search list for the file being currently compiled.
    • The default option usually is to always include the "$(FOAM_SRC)/OpenFOAM/lnInclude" folder.
    • In this case, it's possible that myPBiCG doesn't need anything from the "finiteVolume" header files.
Best regards,
Bruno
wyldckat is offline   Reply With Quote

Old   August 22, 2013, 08:38
Default
  #18
Member
 
Hassan
Join Date: Oct 2012
Location: Iran
Posts: 62
Rep Power: 4
luckycfd is on a distinguished road
Thank you Mr. Bruno,


Yes, I run
Code:
wmake libso
then
Code:
wmake libso
.
In the output, lines that start with "SOURCE", show occurrences that I added in the options file, but how can I find out which folders have headers files that should be added to the search list for the file being currently compiled?


Best regards,
Hassan
luckycfd is offline   Reply With Quote

Old   August 22, 2013, 08:55
Default
  #19
Super Moderator
 
Bruno Santos
Join Date: Mar 2009
Location: Lisbon, Portugal
Posts: 8,301
Blog Entries: 34
Rep Power: 84
wyldckat is just really nicewyldckat is just really nicewyldckat is just really nicewyldckat is just really nice
Well, whenever the compiler complains about not finding a header file, you can use the find command like this:
Code:
find $FOAM_SRC -name the_name_of_the_header_file.H
Usually you should include the entries for the "lnInclude" folders.
luckycfd likes this.
wyldckat is offline   Reply With Quote

Old   August 22, 2013, 10:16
Default
  #20
Member
 
Hassan
Join Date: Oct 2012
Location: Iran
Posts: 62
Rep Power: 4
luckycfd is on a distinguished road
Thank you Mr. Bruno
luckycfd is offline   Reply With Quote

Reply

Tags
compile, linear solver, openfoam

Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On


Similar Threads
Thread Thread Starter Forum Replies Last Post
How to avoid checkerboard? dohnie OpenFOAM Programming & Development 7 January 26, 2015 04:12
Fatal overflow in linear solver (RSM) Luis CFX 9 May 24, 2013 06:19
ERROR #004100018; Fatal overflow in linear solver Attila CFX 1 April 13, 2012 22:22
ParaView Compilation jakaranda OpenFOAM Installation 3 October 27, 2008 12:46
free C code for large sparse matrix linear solver ztdep Main CFD Forum 7 May 24, 2007 14:14


All times are GMT -4. The time now is 22:57.