CFD Online Discussion Forums

CFD Online Discussion Forums (http://www.cfd-online.com/Forums/)
-   OpenFOAM Programming & Development (http://www.cfd-online.com/Forums/openfoam-programming-development/)
-   -   finite area method (http://www.cfd-online.com/Forums/openfoam-programming-development/93415-finite-area-method.html)

lulo October 14, 2011 11:47

finite area method
 
Hi all.

I am trying to use the finite area method. I need to calculate the divergence of a boundary field q_b.

I am trying to initialize my areaVectorField without success:

Code:

 
    areaVectorField q_bed
    (
        IOobject
        (
            "q_bed",
            runTime.timeName(),
            faMesh,
            IOobject::MUST_READ,
            IOobject::AUTO_WRITE
        ),
        faMesh
    );

then (from what i understand) i would need an internal field which is an interpolation of my boundary field q_b:

Code:

    q_bed.internalField() = volSurfaceMapping.mapToSurface(q_b.boundaryField());
So I could finally obtain the divergence of q_bed:

Code:

  volScalarField dh_dt  =  fam::div ( q_bed.boundaryField() )
Can anyone help me writing these lines in the correct way? I know there are many errors :(

Thanks

kmooney October 17, 2011 11:40

What kind of errors are being thrown? This would help get to the bottom of your issues.

lulo October 18, 2011 06:10

Ok.

I am trying to declare volSurfaceMupping:
Code:

volSurfaceMapping vsm(aMesh);
and got this error:
Code:

undefined reference to `Foam::faMesh::faMesh(Foam::polyMesh const&)'

Arnoldinho October 18, 2011 07:25

It depends on where your error is located/comes from.

But it seems as if you are mixing aMesh and faMesh? Give it the same "name" everywhere. Also, did you include the necessary libraries in your options file (Make folder)?

kathrin_kissling October 18, 2011 08:14

Hi Guys,

the problem starts with your initialization:
Code:

areaVectorField q_bed
    (
        IOobject
        (
            "q_bed",
            runTime.timeName(),
            faMesh,
            IOobject::MUST_READ,
            IOobject::AUTO_WRITE
        ),
        faMesh
    );

As Arnoldinho already pointed out, don't mix class names and the name of your variables.

Code:

areaVectorField q_bed
    (
        IOobject
        (
            "q_bed",
            runTime.timeName(),
            aMesh,
            IOobject::MUST_READ,
            IOobject::AUTO_WRITE
        ),
        aMesh
    );

This will still not work!
The second more important point is, that faMeshes are not directly connected to the objectRegistry, because in contrary to fvMesh it is not derived from polyMesh but from GeoMesh<polyMesh>. The first is derived from the objectRegistry the latter not. Because of that you need to use

Code:

areaVectorField q_bed
    (
        IOobject
        (
            "q_bed",
            runTime.timeName(),
            aMesh.thisDb(),
            IOobject::MUST_READ,
            IOobject::AUTO_WRITE
        ),
        aMesh
    );

Hope this helps to get your initialization running.

Best

Kathrin

Arnoldinho October 18, 2011 08:27

Thanks Kathrin,

Quote:

aMesh.thisDb
is new to me, but also gives an error:

Quote:

error: no matching function for call to ‘Foam::IOobject::IOobject(const char [6], Foam::word, <unresolved overloaded function type>, Foam::IOobject::readOption, Foam::IOobject::writeOption)’
Using

Code:

areaVectorField q_bed
    (
        IOobject
        (
            "q_bed",
            runTime.timeName(),
            mesh,
            IOobject::NO_READ,
            IOobject::AUTO_WRITE
        ),
        aMesh,
        dimensionedVector ("q_bed", dimensionSet(0, 2, -1, 0, 0, 0, 0), vector::zero)
    );

I have not had any problems (at least what I have seen so far). What do you think?

Arne

kathrin_kissling October 18, 2011 08:30

Sorry,

a () was missing

aMesh.thisDB();

works for me! And now the data is registered where it belongs to: the faMesh. Otherwise you register it to the fvMesh, what is not wrong, but imagine you come to a point, where there is no fvMesh present. That what has happened to me.

Best

Kathrin

PS: I will edit the previous snippet

Arnoldinho October 18, 2011 08:34

Ok, it compiles. As I guess you already had some experience with faMeshes and the objectRegistry, could you tell me a bit more about differences of using "mesh" and "aMesh.thisDb()" in IOobject? This would be great.

Arne

Edit: Ok. In the meantime you already answered my question ;-) Thanks. That sounds reasonable.

lulo October 18, 2011 09:07

Which are the library needed for this?

I added:
Code:

#include "faCFD.H" 
#include "createFaMesh.H"

and still got the same error.

ngj October 18, 2011 09:25

You would also need:

Code:

#include "faMesh.H"
Kind regards,

Niels

lulo October 18, 2011 10:36

Thanks

I added that one as well. still, I can see that the error appear when I introduce
Code:

#include "createFaMesh.H"
the error is :
Code:

pimpleMyDyMFoam.C:(.text+0x5346): undefined reference to `Foam::faMesh::faMesh(Foam::polyMesh const&)'

ngj October 18, 2011 10:46

Have you remembered to add the necessary lines in Make/options for you to work with FAM?

kathrin_kissling October 18, 2011 11:53

Hi Nils,

i think the latter is more important, since the faMesh.H is already introduced by faCFD.H

@lulo
By the way is this your first error in the line?

lulo October 19, 2011 06:46

Thanks to all of you!

I have compiled it correctly.
Now I have solved the exner equation:
Code:

  areaVectorField q_bed
    (
        IOobject
        (
            "q_bed",
            runTime.timeName(),
            aMesh.thisDb(),
            IOobject::READ_IF_PRESENT,
            IOobject::NO_WRITE
        ),
        aMesh,
        dimensionedVector ("q_bed", dimensionSet(0, 2, -1, 0, 0, 0, 0), vector::zero)
    );

volSurfaceMapping vsm(aMesh);
q_bed.internalField() = vsm.mapToSurface(q_b_slide.boundaryField());

areaScalarField dh_dt = - fac::div(q_bed) * 1.0/ (1-n);

now I need to interpolate the areaScalarField to obtain a tetPointVectorField for the MotionU file.

I could see that there are some interpolation method in src/finiteArea/interpolation.
I think I should use edgeInterpolation and I tried:
Code:

edgeInterpolation interpolateE(aMesh);
pointScalarField dh_dt_points_1 = interpolateE.edgeInterpolation(dh_dt); // This is of course wrong

Do you know how to correct this?

Fanfei October 15, 2014 10:41

Quote:

Originally Posted by ngj (Post 328427)
You would also need:

Code:

#include "faMesh.H"
Kind regards,

Niels

Hi Niels:
I want to use FAM to solve Exner equation. my of version is foam-extend-3.1. Before the FAM used, everything is ok. However, as the q_bed of volMesh mapping to areaMesh and faCFD.H creatfamesh.H famesh.H are introduce, some errors occured, as below:

Code:

In file included from /home/administrator/foam/foam-extend-3.1/src/foam/lnInclude/MeshObject.H:39:0,
                from /home/administrator/foam/foam-extend-3.1/src/finiteArea/lnInclude/faMesh.H:40,
                from /home/administrator/foam/foam-extend-3.1/src/finiteArea/lnInclude/faCFD.H:7,
                from pimpFoam.C:49:
/home/administrator/foam/foam-extend-3.1/src/foam/lnInclude/meshObjectBase.H: In function ‘int main(int, char**)’:
/home/administrator/foam/foam-extend-3.1/src/foam/lnInclude/meshObjectBase.H:45:1: error: ‘namespace’ definition is not allowed here
 namespace Foam
 ^
In file included from /home/administrator/foam/foam-extend-3.1/src/finiteArea/lnInclude/faMesh.H:40:0,
                from /home/administrator/foam/foam-extend-3.1/src/finiteArea/lnInclude/faCFD.H:7,
                from pimpFoam.C:49:
/home/administrator/foam/foam-extend-3.1/src/foam/lnInclude/MeshObject.H:44:1: error: ‘namespace’ definition is not allowed here
 namespace Foam
 ^
In file included from /home/administrator/foam/foam-extend-3.1/src/foam/lnInclude/MeshObject.H:139:0,
                from /home/administrator/foam/foam-extend-3.1/src/finiteArea/lnInclude/faMesh.H:40,
                from /home/administrator/foam/foam-extend-3.1/src/finiteArea/lnInclude/faCFD.H:7,
                from pimpFoam.C:49:
/home/administrator/foam/foam-extend-3.1/src/foam/lnInclude/MeshObject.C:31:1: error: a template declaration cannot appear at block scope
 template<class Mesh, class Type>
 ^
/home/administrator/foam/foam-extend-3.1/src/foam/lnInclude/MeshObject.C:55:1: error: expected ‘;’ before ‘template’
 template<class Mesh, class Type>
 ^
In file included from pimpFoam.C:48:0:
/home/administrator/foam/foam-extend-3.1/src/finiteVolume/lnInclude/initContinuityErrs.H:37:8: warning: unused variable ‘sumLocalContErr’ [-Wunused-variable]
 scalar sumLocalContErr = 0;
        ^
/home/administrator/foam/foam-extend-3.1/src/finiteVolume/lnInclude/initContinuityErrs.H:38:8: warning: unused variable ‘globalContErr’ [-Wunused-variable]
 scalar globalContErr = 0;
        ^
/home/administrator/foam/foam-extend-3.1/src/finiteVolume/lnInclude/initContinuityErrs.H:39:8: warning: unused variable ‘cumulativeContErr’ [-Wunused-variable]
 scalar cumulativeContErr = 0;
        ^
pimpFoam.C:292:1: error: expected ‘}’ at end of input
 }
 ^
make: *** [Make/linux64GccDPOpt/pimpFoam.o] 错误 1

could you give me some hints, what's wrong with it.
the options file is
Code:

EXE_INC = \
    -I$(LIB_SRC)/turbulenceModels/incompressible/turbulenceModel \
    -I$(LIB_SRC)/transportModels \
    -I$(LIB_SRC)/turbulenceModels \
    -I$(LIB_SRC)/turbulenceModels/incompressible/RAS/RASModel \
    -I$(LIB_SRC)/transportModels/incompressible/singlePhaseTransportModel \
    -I$(LIB_SRC)/finiteVolume/lnInclude\
    -I$(LIB_SRC)/finiteArea/lnInclude\
    -I$(LIB_SRC)/sampling/lnInclude

EXE_LIBS = \
    -lincompressibleTransportModels \
    -lincompressibleTurbulenceModel \
    -lincompressibleRASModels \
    -lincompressibleLESModels \
    -lfiniteVolume \
    -lfiniteArea \
    -lmeshTools \
    -llduSolvers

Best regards

Fan Fei

Fanfei October 15, 2014 10:57

Hi everyone:
This problem have solved. The # include "faCFD.H" sholud be as a global variable, add it before the main program.

Best regards
Fan Fei

Fanfei December 8, 2014 05:36

1 Attachment(s)
Quote:

Originally Posted by ngj (Post 328448)
Have you remembered to add the necessary lines in Make/options for you to work with FAM?

Hi ngi:
I have a question about the faMesh and dynamicMesh. in openfoam extend 3.1. there are two solvers use famesh and dynamicMesh. The location is tutorials/surfaceTracking/interTrackFoam and bubbleInlerTrackFoam. as below picture. however the code of interTrackFoam is:
-----------------------------------
Quote:

#include "fvCFD.H"
#include "dynamicFvMesh.H"
#include "freeSurface.H"


// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //

int main(int argc, char *argv[])
{
# include "setRootCase.H"

# include "createTime.H"

# include "createDynamicFvMesh.H"

# include "createFields.H"

# include "initContinuityErrs.H"

// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //

Info << "\nStarting time loop\n" << endl;
my question is why the code don't have "faCFD.H" and "createfaMesh.H" .

Best regards
Fan fei


All times are GMT -4. The time now is 15:30.