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

OpenFOAM not recognize custom library (decomp method)

Register Blogs Community New Posts Updated Threads Search

Reply
 
LinkBack Thread Tools Search this Thread Display Modes
Old   May 8, 2024, 19:31
Default OpenFOAM not recognize custom library (decomp method)
  #1
New Member
 
Erik Nijkamp
Join Date: Dec 2023
Posts: 5
Rep Power: 3
ErikNij is on a distinguished road
Hi all,



I am struggling with adding a custom decomp method to OpenFOAM. This library successfully complies to a .o object, and further to a .so object. However, it does not show up as an option when using DecomposePar. Perhaps its relevant that I am using foam-extend4.1.


For simplicity, I was just trying to get a new decomp method called metisDecomp2, which is just the same as metisDecomp, but I just want to show that something new can be added. So I copied the metisDecomp/ folder, renamed it to metisDecomp2/, and renamed all the files, and moved it to the $FOAM_USER_LIBBIN


I crtl+F metisDecomp and replaced it with metisDecomp2 in the C and H file, to make the new class. I updated the Make/files, Make/options, and CMakeLists.txt as shown below.




Make/files:

Code:
metisDecomp2.C

LIB = $(FOAM_USER_LIBBIN)/libmetisDecomp2

Make/options:
Code:
EXE_INC = \
    -I$(METIS_INCLUDE_DIR) \
    -I$(FOAM_SRC)/decompositionMethods/lnInclude \
    -I$(FOAM_SRC)/scotchDecomp/lnInclude

LIB_LIBS = \
    -ldecompositionMethods \
    -L$(FOAM_LIBBIN)/dummy \
    -L$(METIS_LIB_DIR) -lmetis

and the CMakeLists.txt
Code:
list(APPEND SOURCES
  metisDecomp2.C
)

add_foam_library(metisDecomp2 SHARED ${SOURCES})

target_link_libraries(metisDecomp2 PUBLIC decompositionMethods metis2)

After I do all this, and put the option metis2, it says:
Code:
Unknown decompositionMethod metis2

Valid decompositionMethods are : 

8
(
engineScotch
hierarchical
manual
metis
parMetis
patchConstrained
scotch
simple
)

I assume that I am missing something small and simple. I have never added my own custom lib. Thanks for your time looking over my question. If you need any more clarification, please let me know.



Best,
Erik
ErikNij is offline   Reply With Quote

Old   May 21, 2024, 16:27
Default
  #2
Senior Member
 
Klaus
Join Date: Mar 2009
Posts: 281
Rep Power: 22
klausb will become famous soon enough
I had a look at the decomposePar.C... sources and Make files, according to that "EXE = $(FOAM_APPBIN)/decomposePar" it's meant to be an application, not a library.


The best way to start developing new things in OpenFOAM is to copy the most similar application or library, change the name compile and run it under the new name, if that works, make your changes and compile your new application or library. For applications use wmake and wclean, for libraries use wmake libso and wclean libso. Custom libraries need to be added to the control dictionary as follows:



Code:
/*--------------------------------*- C++ -*----------------------------------*\
| =========                 |                                                 |
| \\      /  F ield         | OpenFOAM: The Open Source CFD Toolbox           |
|  \\    /   O peration     | Version:  v2312                                 |
|   \\  /    A nd           | Website:  www.openfoam.com                      |
|    \\/     M anipulation  |                                                 |
\*---------------------------------------------------------------------------*/
FoamFile
{
    version     2.0;
    format      ascii;
    class       dictionary;
    object      controlDict;
}
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //

libs ("libMyLibraryName.so");

...
klausb is offline   Reply With Quote

Old   May 23, 2024, 03:16
Default
  #3
Senior Member
 
Mark Olesen
Join Date: Mar 2009
Location: https://olesenm.github.io/
Posts: 1,715
Rep Power: 40
olesen has a spectacular aura aboutolesen has a spectacular aura about
Quote:
Originally Posted by ErikNij View Post
Hi all,

For simplicity, I was just trying to get a new decomp method called metisDecomp2, which is just the same as metisDecomp, but I just want to show that something new can be added. So I copied the metisDecomp/ folder, renamed it to metisDecomp2/, and renamed all the files, and moved it to the $FOAM_USER_LIBBIN


...


I assume that I am missing something small and simple. I have never added my own custom lib. Thanks for your time looking over my question. If you need any more clarification, please let me know.

It is indeed relatively simple. You have compiled a new library (libmetisDecomp2) and presumably also included the addToRunTimeSelectionTable interface in the code (otherwise none of this will work).
The missing piece of the puzzle is that this library actually needs to be loaded when the application runs. You don't see this most of the time, since the library dependencies are usually defined when compiling the application (see decomposePar/Make/options).
In your case, you need to specify the library loading.
You can either quickly add a "libs" entry into your case controlDict, but it is usually easier just to use the '-lib' option, which is available for all OpenFOAM applications (eg, blockMesh -help-full for usage). To check that your library can actually load OK, without missing other dependencies, use the foamhasLibrary utility.
olesen is offline   Reply With Quote

Old   October 7, 2024, 10:58
Default
  #4
New Member
 
Join Date: Oct 2024
Posts: 3
Rep Power: 2
NonGaussianWind is on a distinguished road
Hi,

I have a somewhat related issue.

I am trying to use decomposePar OpenFOAM utility.
However, at run, I get:
Code:
--> FOAM FATAL ERROR: (openfoam-2406)
Attempted to use <metis> without the metisDecomp library loaded.
This message is from the dummy metisDecomp stub library instead.

Please install <metis> and ensure libmetis.so is in LD_LIBRARY_PATH.
The metisDecomp library can then be built from src/parallel/decompose/metisDecomp.
Dynamically loading or linking this library will add <metis> as a decomposition method.
.

Following the message's suggestion, I then go in src/parallel/decompose/metisDecomp, run wmake, but get:
Code:
In file included from metisDecomp.C:29:
metisDecomp.H:66:10: fatal error: metisLikeDecomp.H: No such file or directory
   66 | #include "metisLikeDecomp.H"
      |          ^~~~~~~~~~~~~~~~~~~
compilation terminated.
Can someone please explain a bit more in detail what is going on?
It would be very much appreciated.

Many thanks.
NonGaussianWind is offline   Reply With Quote

Reply

Tags
decomposepar methods, libbin


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 Off
Pingbacks are On
Refbacks are On


Similar Threads
Thread Thread Starter Forum Replies Last Post
Reading rigidBody motion state from custom library katiuskas OpenFOAM Programming & Development 2 November 21, 2023 06:49
Duplicate library entries when running a solver with custom library francescomarra OpenFOAM Programming & Development 3 May 17, 2022 09:37
"Missing" files when implementing OpenFOAM dictionaries referenced in custom solver markdeluca OpenFOAM Programming & Development 0 December 2, 2018 17:58
HopeFOAM-0.1(Discontinuous Galerkin Method Extension of OpenFOAM) is released online! ExerciseGroup OpenFOAM Announcements from Other Sources 3 December 11, 2017 15:26
Building a custom solver on OpenFOAM 2.0 wschosta OpenFOAM Programming & Development 1 July 8, 2011 16:07


All times are GMT -4. The time now is 16:10.