CFD Online Discussion Forums

CFD Online Discussion Forums (http://www.cfd-online.com/Forums/)
-   OpenFOAM Running, Solving & CFD (http://www.cfd-online.com/Forums/openfoam-solving/)
-   -   Moving Heat Source on a CV (http://www.cfd-online.com/Forums/openfoam-solving/120210-moving-heat-source-cv.html)

Tomster0815 July 2, 2013 12:57

Moving Heat Source on a CV
 
Hello together,

I'm completely new in using OpenFoam and faced with a (I hope simple) problem I don't know how to continue.

My case is to simulate a simple heat conduction welding process where I want to simulate in a first step a moving heat source (Point source or circle) on the surface of a control volume (CV). I've chosen the laplacianFOAM solver because I don't want to consider any convective parts.
For that issue. I've implemented a source term q in the standard laplacianFOAM solver and boundaries.

But how is the approach for using this term as a moving source?
Do I need a moving "meshgrid" on the CV or maybe inside (Volume source) or can I solve this by boundary conditions?

Thanks a lot for answers.

Tomster

Tomster0815 July 3, 2013 14:21

Update: Maybe fvOptions as a solution?
 
Hello again,

after one more day of searching on a lot of sites I found an approach for my problem using the fvOptions framework.
I'll try it with the simpleScalarFOAM because the solver includes a fvOptions (T) - source-term.

Anyway - does anybody have a good conclusion or an idea where I can find a "manual" how I've to set der fvOptions dictionary file to create a moving heat source?

Thanks again for any reply.

ahmmedshakil July 3, 2013 21:42

Hi Tomster,
It's easy to model the moving heat source. If your heat source is a surface heat source, then you can impose it as a boundary condition, then groovyBC [http://openfoamwiki.net/index.php/Contrib_groovyBC] will be more helpful for you. Just look at the groovyBC sites.
In case of volumetric heat source, you can easily use "expressionSource"- which comes with the swak4Foam [http://openfoamwiki.net/index.php/Contrib/swak4Foam].
So, what you need to construct the expression for moving source, then use the method that comply your need.
Cheers!

Tomster0815 July 8, 2013 12:00

How to implement something from swak4Foam?
 
Hey Ahmmedshakil,

thanks a lot for you suggestion!
I'm completely new in OpenFoam and I have after a couple of days reading no idea how I have to implement this function :( I'm sorry, but the structure of OF is not easy to understand...

In the first step, I've downloaded and compiled swak4foam (with ./Allwmake). But where and how do I have to implement the Code? I want to use your suggested expressionSource.H for adding a moving volumetric heat source.

- Is the source itself (size, moving parameters) described in a library in the run/case-folder?
- Do I have to change something in the laplacianFoam.C?
- Should I add something in the ./Make/files oder options-file?
- What is to to in the case-folder?

Thank you for answering my noob-questions ;)

Greetings, Tomster

ahmmedshakil July 9, 2013 02:40

Hi Tomster,
For using expressionSource, there is a example done in swak4Foam-->Examples-->interFoamWithSources. And you can easily take help from this post: http://www.cfd-online.com/Forums/ope...urce-term.html.

Cheers!

Tomster0815 July 9, 2013 09:10

How does it work?
 
Hello Ahmmedshakil,

thank you again for replying my post. Unfortunately it does not work :(
I'll now exactly describe what I've done from the beginning - maybe you find my mistake:

- I've downloaded the swak4Foam files (Version 0.2.3) from http://openfoamwiki.net/index.php/Contrib/swak4Foam as a *.tar-file and unpacked it in the $HOME/swak4foam directory (and stayed the files later here)

- As mentioned, I commented out the
#define FOAM_LOOKUPCLASS_NO_CONST
in the Libraries/swak4FoamParsers/include/swak.H file

- I compiled swak4Foam with ./Allwmake (It took around 10 Minutes!?)

- For my case, I followed the instructions from gschaider in this post: http://www.cfd-online.com/Forums/ope...urce-term.html

- Now these are my files:
createFields.H
Code:

Info<< "Reading field T\n" << endl;
    volScalarField T
    (
        IOobject
        (
            "T",
            runTime.timeName(),
            mesh,
            IOobject::MUST_READ,
            IOobject::AUTO_WRITE
        ),
        mesh
    );
 
//----NEUE WAERMEQUELLE HINZUFUEGEN----
 expressionSource<scalar> heaterSource
 (
 IOdictionary
 (
        IOobject
        (
            "heaterSourceDict",
            runTime.constant(),
            mesh,
            IOobject::MUST_READ,
            IOobject::NO_WRITE
 )
        ),
        mesh
    );
//--------------------------------
    Info<< "Reading transportProperties\n" << endl;
    IOdictionary transportProperties
    (
        IOobject
        (
            "transportProperties",
            runTime.constant(),
            mesh,
            IOobject::MUST_READ_IF_MODIFIED,
            IOobject::NO_WRITE
        )
    );
 
    Info<< "Reading diffusivity DT\n" << endl;
    dimensionedScalar DT
    (
        transportProperties.lookup("DT")
    );

laplacianFoam.C
Code:

\*---------------------------------------------------------------------------*/
#include "fvCFD.H"
#include "simpleControl.H"
#include "expressionSource.H"
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
int main(int argc, char *argv[])
{
    #include "setRootCase.H"
    #include "createTime.H"
    #include "createMesh.H"
    #include "createFields.H"
    simpleControl simple(mesh);
    // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
    Info<< "\nCalculating temperature distribution\n" << endl;
    while (simple.loop())
    {
        Info<< "Time = " << runTime.timeName() << nl << endl;
        while (simple.correctNonOrthogonal())
        {
            solve
            (
  //Original: fvm::ddt(T) - fvm::laplacian(DT, T)
                  fvm::ddt(T)
  - fvm::laplacian(DT, T)
  ==
  heaterSource()
            );
        }
        #include "write.H"
        Info<< "ExecutionTime = " << runTime.elapsedCpuTime() << " s"
            << "  ClockTime = " << runTime.elapsedClockTime() << " s"
            << nl << endl;
    }
    Info<< "End\n" << endl;
    return 0;
}

and the ./Make/options
Code:

EXE_INC = \
          -I$(LIB_SRC)/finiteVolume/lnInclude \
          -I$HOME/swak4Foam/Libraries/swakSourceFields/InInclude
EXE_LIBS = \
    -lfiniteVolume \
          -L$FOAM_USER_LIBBIN

- I've tried to compile it with wmake but it didn't work (Error Message: expressionSource.H not found). Is my "link" in the options file incorrect written or where do I have to copy the EXE- and LIB-Files from swak4Foam?

Another Problem is that I can't run the suggested Example in ./interFoamWithSources. What do I have to do that it will work?

Thank you again very much - I hope my questions will help other noobs in understanding OpenFoam with swak4Foam :rolleyes:
(Afer success I'll publish my code here).

Greetings

ahmmedshakil July 9, 2013 21:25

Hi Tomster,
The error message :(Error Message: expressionSource.H not found)--- so you have problem in the linking file i.e.

EXE_INC = \
-I$(LIB_SRC)/finiteVolume/lnInclude \
-I$HOME/swak4Foam/Libraries/swakSourceFields/InInclude
(PLEASE CHECK HERE)
EXE_LIBS = \
-lfiniteVolume \
-L$FOAM_USER_LIBBIN

The same thing is true for the example running.... I'm sure now you can run the solver.
cheers!!

Kumudu November 3, 2013 04:30

transient heat source
 
Hi,

Where u defined the heatSourceDict and how. I am new to OpenFoam and please tell me the step you follow to add the transient heat source into LaplacianFoam.

Kumudu









Quote:

Originally Posted by Tomster0815 (Post 438683)
Hello Ahmmedshakil,

thank you again for replying my post. Unfortunately it does not work :(
I'll now exactly describe what I've done from the beginning - maybe you find my mistake:

- I've downloaded the swak4Foam files (Version 0.2.3) from http://openfoamwiki.net/index.php/Contrib/swak4Foam as a *.tar-file and unpacked it in the $HOME/swak4foam directory (and stayed the files later here)

- As mentioned, I commented out the
#define FOAM_LOOKUPCLASS_NO_CONST
in the Libraries/swak4FoamParsers/include/swak.H file

- I compiled swak4Foam with ./Allwmake (It took around 10 Minutes!?)

- For my case, I followed the instructions from gschaider in this post: http://www.cfd-online.com/Forums/ope...urce-term.html

- Now these are my files:
createFields.H
Code:

Info<< "Reading field T\n" << endl;
    volScalarField T
    (
        IOobject
        (
            "T",
            runTime.timeName(),
            mesh,
            IOobject::MUST_READ,
            IOobject::AUTO_WRITE
        ),
        mesh
    );
 
//----NEUE WAERMEQUELLE HINZUFUEGEN----
 expressionSource<scalar> heaterSource
 (
 IOdictionary
 (
        IOobject
        (
            "heaterSourceDict",
            runTime.constant(),
            mesh,
            IOobject::MUST_READ,
            IOobject::NO_WRITE
 )
        ),
        mesh
    );
//--------------------------------
    Info<< "Reading transportProperties\n" << endl;
    IOdictionary transportProperties
    (
        IOobject
        (
            "transportProperties",
            runTime.constant(),
            mesh,
            IOobject::MUST_READ_IF_MODIFIED,
            IOobject::NO_WRITE
        )
    );
 
    Info<< "Reading diffusivity DT\n" << endl;
    dimensionedScalar DT
    (
        transportProperties.lookup("DT")
    );

laplacianFoam.C
Code:

\*---------------------------------------------------------------------------*/
#include "fvCFD.H"
#include "simpleControl.H"
#include "expressionSource.H"
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
int main(int argc, char *argv[])
{
    #include "setRootCase.H"
    #include "createTime.H"
    #include "createMesh.H"
    #include "createFields.H"
    simpleControl simple(mesh);
    // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
    Info<< "\nCalculating temperature distribution\n" << endl;
    while (simple.loop())
    {
        Info<< "Time = " << runTime.timeName() << nl << endl;
        while (simple.correctNonOrthogonal())
        {
            solve
            (
  //Original: fvm::ddt(T) - fvm::laplacian(DT, T)
                  fvm::ddt(T)
  - fvm::laplacian(DT, T)
  ==
  heaterSource()
            );
        }
        #include "write.H"
        Info<< "ExecutionTime = " << runTime.elapsedCpuTime() << " s"
            << "  ClockTime = " << runTime.elapsedClockTime() << " s"
            << nl << endl;
    }
    Info<< "End\n" << endl;
    return 0;
}

and the ./Make/options
Code:

EXE_INC = \
          -I$(LIB_SRC)/finiteVolume/lnInclude \
          -I$HOME/swak4Foam/Libraries/swakSourceFields/InInclude
EXE_LIBS = \
    -lfiniteVolume \
          -L$FOAM_USER_LIBBIN

- I've tried to compile it with wmake but it didn't work (Error Message: expressionSource.H not found). Is my "link" in the options file incorrect written or where do I have to copy the EXE- and LIB-Files from swak4Foam?

Another Problem is that I can't run the suggested Example in ./interFoamWithSources. What do I have to do that it will work?

Thank you again very much - I hope my questions will help other noobs in understanding OpenFoam with swak4Foam :rolleyes:
(Afer success I'll publish my code here).

Greetings


Kumudu November 3, 2013 05:10

Transient heat source
 
Hi Tomster0815,

I did exactly what you said. But I got this error. Please tell me how to fix this.

Kumudu

kumudu21688@kumudu21688-Inspiron-N5040:~/OpenFOAM/kumudu21688-2.1.1/run/myheatsource$ mylaplacianFoam
/*---------------------------------------------------------------------------*\
| ========= | |
| \\ / F ield | OpenFOAM: The Open Source CFD Toolbox |
| \\ / O peration | Version: 2.1.1 |
| \\ / A nd | Web: www.OpenFOAM.org |
| \\/ M anipulation | |
\*---------------------------------------------------------------------------*/
Build : 2.1.1-221db2718bbb
Exec : mylaplacianFoam
Date : Nov 03 2013
Time : 11:01:29
Host : "kumudu21688-Inspiron-N5040"
PID : 4536
Case : /home/kumudu21688/OpenFOAM/kumudu21688-2.1.1/run/myheatsource
nProcs : 1
sigFpe : Enabling floating point exception trapping (FOAM_SIGFPE).
fileModificationChecking : Monitoring run-time modified files using timeStampMaster
allowSystemOperations : Disallowing user-supplied system call operations

// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
Create time

Create mesh for time = 0

Reading field T

Reading transportProperties

Reading diffusivity DT


SIMPLE: no convergence criteria found. Calculations will run for 15 steps.


Calculating temperature distribution

swak4Foam: Allocating new repository for sampledSets


--> FOAM FATAL IO ERROR:
Attempt to return dictionary entry as a primitive

file: /home/kumudu21688/OpenFOAM/kumudu21688-2.1.1/run/myheatsource/system/controlDict::functions::theSensor::setName from line 59 to line 63.

From function ITstream& primitiveEntry::stream() const
in file db/dictionary/dictionaryEntry/dictionaryEntry.C at line 82.

FOAM aborting

#0 Foam::error::printStack(Foam::Ostream&) in "/opt/openfoam211/platforms/linux64GccDPOpt/lib/libOpenFOAM.so"
#1 Foam::IOerror::abort() in "/opt/openfoam211/platforms/linux64GccDPOpt/lib/libOpenFOAM.so"
#2 Foam::dictionaryEntry::stream() const in "/opt/openfoam211/platforms/linux64GccDPOpt/lib/libOpenFOAM.so"
#3 Foam::SetsRepository::getSet(Foam::dictionary const&, Foam::polyMesh const&) in "/home/kumudu21688/OpenFOAM/kumudu21688-2.1.1/platforms/linux64GccDPOpt/lib/libswak4FoamParsers.so"
#4 Foam::createSampledSet::createSampledSet(Foam::wor d const&, Foam::objectRegistry const&, Foam::dictionary const&, bool) in "/home/kumudu21688/OpenFOAM/kumudu21688-2.1.1/platforms/linux64GccDPOpt/lib/libswakFunctionObjects.so"
#5 Foam::OutputFilterFunctionObject<Foam::createSampl edSet>::allocateFilter() in "/home/kumudu21688/OpenFOAM/kumudu21688-2.1.1/platforms/linux64GccDPOpt/lib/libswakFunctionObjects.so"
#6 Foam::OutputFilterFunctionObject<Foam::createSampl edSet>::start() in "/home/kumudu21688/OpenFOAM/kumudu21688-2.1.1/platforms/linux64GccDPOpt/lib/libswakFunctionObjects.so"
#7 Foam::functionObjectList::read() in "/opt/openfoam211/platforms/linux64GccDPOpt/lib/libOpenFOAM.so"
#8 Foam::Time::run() const in "/opt/openfoam211/platforms/linux64GccDPOpt/lib/libOpenFOAM.so"
#9 Foam::Time::loop() in "/opt/openfoam211/platforms/linux64GccDPOpt/lib/libOpenFOAM.so"
#10 Foam::simpleControl::loop() in "/opt/openfoam211/platforms/linux64GccDPOpt/lib/libfiniteVolume.so"
#11
in "/opt/openfoam211/platforms/linux64GccDPOpt/bin/mylaplacianFoam"
#12 __libc_start_main in "/lib/x86_64-linux-gnu/libc.so.6"
#13
in "/opt/openfoam211/platforms/linux64GccDPOpt/bin/mylaplacianFoam"
Aborted (core dumped)






Quote:

Originally Posted by Tomster0815 (Post 438683)
Hello Ahmmedshakil,

thank you again for replying my post. Unfortunately it does not work :(
I'll now exactly describe what I've done from the beginning - maybe you find my mistake:

- I've downloaded the swak4Foam files (Version 0.2.3) from http://openfoamwiki.net/index.php/Contrib/swak4Foam as a *.tar-file and unpacked it in the $HOME/swak4foam directory (and stayed the files later here)

- As mentioned, I commented out the
#define FOAM_LOOKUPCLASS_NO_CONST
in the Libraries/swak4FoamParsers/include/swak.H file

- I compiled swak4Foam with ./Allwmake (It took around 10 Minutes!?)

- For my case, I followed the instructions from gschaider in this post: http://www.cfd-online.com/Forums/ope...urce-term.html

- Now these are my files:
createFields.H
Code:

Info<< "Reading field T\n" << endl;
    volScalarField T
    (
        IOobject
        (
            "T",
            runTime.timeName(),
            mesh,
            IOobject::MUST_READ,
            IOobject::AUTO_WRITE
        ),
        mesh
    );
 
//----NEUE WAERMEQUELLE HINZUFUEGEN----
 expressionSource<scalar> heaterSource
 (
 IOdictionary
 (
        IOobject
        (
            "heaterSourceDict",
            runTime.constant(),
            mesh,
            IOobject::MUST_READ,
            IOobject::NO_WRITE
 )
        ),
        mesh
    );
//--------------------------------
    Info<< "Reading transportProperties\n" << endl;
    IOdictionary transportProperties
    (
        IOobject
        (
            "transportProperties",
            runTime.constant(),
            mesh,
            IOobject::MUST_READ_IF_MODIFIED,
            IOobject::NO_WRITE
        )
    );
 
    Info<< "Reading diffusivity DT\n" << endl;
    dimensionedScalar DT
    (
        transportProperties.lookup("DT")
    );

laplacianFoam.C
Code:

\*---------------------------------------------------------------------------*/
#include "fvCFD.H"
#include "simpleControl.H"
#include "expressionSource.H"
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
int main(int argc, char *argv[])
{
    #include "setRootCase.H"
    #include "createTime.H"
    #include "createMesh.H"
    #include "createFields.H"
    simpleControl simple(mesh);
    // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
    Info<< "\nCalculating temperature distribution\n" << endl;
    while (simple.loop())
    {
        Info<< "Time = " << runTime.timeName() << nl << endl;
        while (simple.correctNonOrthogonal())
        {
            solve
            (
  //Original: fvm::ddt(T) - fvm::laplacian(DT, T)
                  fvm::ddt(T)
  - fvm::laplacian(DT, T)
  ==
  heaterSource()
            );
        }
        #include "write.H"
        Info<< "ExecutionTime = " << runTime.elapsedCpuTime() << " s"
            << "  ClockTime = " << runTime.elapsedClockTime() << " s"
            << nl << endl;
    }
    Info<< "End\n" << endl;
    return 0;
}

and the ./Make/options
Code:

EXE_INC = \
          -I$(LIB_SRC)/finiteVolume/lnInclude \
          -I$HOME/swak4Foam/Libraries/swakSourceFields/InInclude
EXE_LIBS = \
    -lfiniteVolume \
          -L$FOAM_USER_LIBBIN

- I've tried to compile it with wmake but it didn't work (Error Message: expressionSource.H not found). Is my "link" in the options file incorrect written or where do I have to copy the EXE- and LIB-Files from swak4Foam?

Another Problem is that I can't run the suggested Example in ./interFoamWithSources. What do I have to do that it will work?

Thank you again very much - I hope my questions will help other noobs in understanding OpenFoam with swak4Foam :rolleyes:
(Afer success I'll publish my code here).

Greetings



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