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

Unable to apply fvConstraints in custom solver

Register Blogs Community New Posts Updated Threads Search

Like Tree1Likes
  • 1 Post By potentialToto

Reply
 
LinkBack Thread Tools Search this Thread Display Modes
Old   August 18, 2023, 05:49
Default Unable to apply fvConstraints in custom solver
  #1
New Member
 
Join Date: Aug 2023
Posts: 2
Rep Power: 0
potentialToto is on a distinguished road
Hello everyone, I'm new here and have little experience with OpenFOAM so please bear with me.

I am working on a custom solver, which is conceptually very similar to potentialFoam. I have to apply some constraints to the solver, which I'm trying to do through the fvConstraints dictionary specifications.

The custom solver compiles correctly, however upon execution an error will be raised when calling "createFvConstraints.H", which looks like:

Code:
Creating fvConstraints from "system/fvConstraints"

Selecting finite volume constraint type limitVelocity
#0  Foam::error::printStack(Foam::Ostream&) at ??:?
#1  Foam::sigSegv::sigHandler(int) at ??:?
#2  ? in "/lib/x86_64-linux-gnu/libc.so.6"
#3  Foam::fvConstraint::New(Foam::word const&, Foam::dictionary const&, Foam::fvMesh const&) at ??:?
#4  Foam::fvConstraints::fvConstraints(Foam::fvMesh const&) at ??:?
#5  ? in "/home/admin/OpenFOAM/admin-10/platforms/linux64GccDPInt32Opt/bin/fcrFoam"
#6  ? in "/home/admin/OpenFOAM/admin-10/platforms/linux64GccDPInt32Opt/bin/fcrFoam"
#7  ? in "/lib/x86_64-linux-gnu/libc.so.6"
#8  __libc_start_main in "/lib/x86_64-linux-gnu/libc.so.6"
#9  ? in "/home/admin/OpenFOAM/admin-10/platforms/linux64GccDPInt32Opt/bin/fcrFoam"
Segmentation fault (core dumped)
I'm using OpenFOAM 10.

Here is a more detailed example of what I've tried:
Let's say I make a custom solver using potentialFoam as prototype: "myPotentialFoam". I will only modify it to include the fvConstraints specifications. So what I do is:

In myPotentialFoam.C, include fvConstraints.H at the beginning:

Code:
#include "fvCFD.H"
#include "nonOrthogonalSolutionControl.H"
#include "fvConstraints.H"
In createFields.H, include createFvConstraints.H at the end:

Code:
#include "createMRF.H"
#include "createFvConstraints.H"
This compiles correctly using wclean and wmake. Then I copy the case from the tutorials/basic/potentialFoam/cylinder, and I add a system/fvConstraints dictionary file:

Code:
/*--------------------------------*- C++ -*----------------------------------*\
  =========                 |
  \\      /  F ield         | OpenFOAM: The Open Source CFD Toolbox
   \\    /   O peration     | Website:  https://openfoam.org
    \\  /    A nd           | Version:  10
     \\/     M anipulation  |
\*---------------------------------------------------------------------------*/
FoamFile
{
    format      ascii;
    class       dictionary;
    location    "system";
    object      fvConstraints;
}
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //

limitU
{
    type limitVelocity;
    active yes;

    selectionMode all;
    max 75.0;
}


// ************************************************************************* //
Inside it is defined a simple limitVelocity constraint. I know that I did not call fvConstraints.constrain() at any point in myPotentialfoam.C, so this wouldn't do anything anyway. But, the error occurs before the solver loop even starts. Also, I've tried using fixedValueConstraint instead of limitVelocity, but the problem is the same. When I execute:

Code:
./Allclean
blockMesh
myPotentialFoam
I get the said error. What am I doing wrong? I'm adding the minimal working example as attachment.

Any tip would be appreciated, thank you in advance for your help!
Attached Files
File Type: zip myPotentialFoam.zip (10.9 KB, 1 views)
potentialToto is offline   Reply With Quote

Old   August 21, 2023, 03:26
Default
  #2
New Member
 
Join Date: Aug 2023
Posts: 2
Rep Power: 0
potentialToto is on a distinguished road
In the end, I figured it out by myself.

For anyone interested, the solution was to add an entry in Make/options so that the fvConstraints library is linked.

Effectively, modifying Make/options from:

Code:
EXE_INC = \
    -I$(LIB_SRC)/finiteVolume/lnInclude \
    -I$(LIB_SRC)/meshTools/lnInclude

EXE_LIBS = \
    -lfiniteVolume \
    -lmeshTools
to:

Code:
EXE_INC = \
    -I$(LIB_SRC)/finiteVolume/lnInclude \
    -I$(LIB_SRC)/meshTools/lnInclude

EXE_LIBS = \
    -lfiniteVolume \
    -lmeshTools \
    -lfvModels \
    -lfvConstraints
solves the issue.
maguirre likes this.
potentialToto is offline   Reply With Quote

Reply


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
CPUs vs GPUs for CFD? hami11 Hardware 22 July 23, 2024 16:59
[OpenFOAM.org] Compile OF 2.3 on Mac OS X .... the patch gschaider OpenFOAM Installation 225 August 25, 2015 20:43
how to apply an sudden displacement or Force of a cylinder with solid solver? allenfieldin OpenFOAM Running, Solving & CFD 11 February 15, 2015 21:37
flow solver won't recognize custom library hakonbar OpenFOAM Programming & Development 2 April 7, 2014 09:09
[Commercial meshers] ST_Malloc: out of memory.malloc_storage: unable to malloc Velocity SA, cfdproject OpenFOAM Meshing & Mesh Conversion 0 April 14, 2009 16:45


All times are GMT -4. The time now is 04:32.