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/)
-   -   activating field Averages (http://www.cfd-online.com/Forums/openfoam-solving/79518-activating-field-averages.html)

m.maneshi August 26, 2010 02:49

activating field Averages
 
Hello all

there are some field averaging subroutines for example on MDTOOLS on
src/lagrangian/molecularDynamics/molecule/mdTools
which are not in effect in the tutorial files and i found no clue who to make them work. has anyone got any idea what to do?

thanks in advance.

Erik August 27, 2010 03:15

Hello Mehdi,

To get the field averaging working I included the following header files in the main solver file i.e. mdFoam.C:

# include "createMDFields.H"
# include "calculateMDFields.H"
# include "averageMDFields.H"
# include "resetMDFields.H"

in the following places:


#include "fvCFD.H"
#include "md.H"

int main(int argc, char *argv[])
{

# include "setRootCase.H"
# include "createTime.H"
# include "createMesh.H"

potential pot(mesh);

moleculeCloud molecules(mesh, pot);

# include "temperatureAndPressureVariables.H"

label nAveragingSteps = 0;

# include "createMDFields.H"

Info << "\nStarting time loop\n" << endl;

while (runTime.loop())
{

nAveragingSteps++;

Info << "Time = " << runTime.timeName() << endl;

molecules.evolve();

# include "meanMomentumEnergyAndNMols.H"

# include "temperatureAndPressure.H"

# include "calculateMDFields.H"
# include "averageMDFields.H"
# include "resetMDFields.H"

runTime.write();

if (runTime.outputTime())
{
nAveragingSteps = 0;
}

Info << "ExecutionTime = " << runTime.elapsedCpuTime() << " s"
<< " ClockTime = " << runTime.elapsedClockTime() << " s"
<< nl << endl;
}

Info << "End\n" << endl;

return 0;
}

Cheers,
Erik

m.maneshi August 27, 2010 03:40

Thanks alot . i will test it ASAP.

m.maneshi August 27, 2010 08:26

Did so and all seems to be going all well , isn't there any need to call the functions in the Control Dict or any other places ? why isnt there any new variables added to data like Density , bulk velocity and so forth ?? plus is it needed to re make the edited solver file ? Can the averaging parameters such as bin sizes and so on be changed for a run ?

Erik August 28, 2010 11:38

HI Mehdi,

After you added these lines did you compile the solver by running "wclean" and then "wmake" in the same folder as you have the Make directory. This needs to be done in order for any changes to be made. If this does not work then maybe you need to compile the molecule library as well by running "wclean libso" and then "wmake libso".

cheers,
Erik

m.maneshi August 28, 2010 13:20

i did the wclean libso and wmake libso after wards in the folder relating to mdfoam.c and here is the result :
HTML Code:

cd /home/mehdi/OpenFOAM/OpenFOAM-1.6/applications/solvers/discreteMethods/molecularDynamics/mdFoam/
mehdi@mehdi-laptop:~/OpenFOAM/OpenFOAM-1.6/applications/solvers/discreteMethods/molecularDynamics/mdFoam$ wclean libso
wclean ./
mehdi@mehdi-laptop:~/OpenFOAM/OpenFOAM-1.6/applications/solvers/discreteMethods/molecularDynamics/mdFoam$ wmake libso
wmakeLnInclude: linking include files to ./lnInclude
Making dependency list for source file mdFoam.C
SOURCE=mdFoam.C ;  g++ -m32 -Dlinux -DWM_DP -Wall -Wno-strict-aliasing -Wextra -Wno-unused-parameter -Wold-style-cast -O3  -DNoRepository -ftemplate-depth-40 -I/home/mehdi/OpenFOAM/OpenFOAM-1.6/src/lagrangian/molecularDynamics/molecule/lnInclude -I/home/mehdi/OpenFOAM/OpenFOAM-1.6/src/lagrangian/molecularDynamics/potential/lnInclude -I/home/mehdi/OpenFOAM/OpenFOAM-1.6/src/lagrangian/molecularDynamics/molecularMeasurements/lnInclude -I/home/mehdi/OpenFOAM/OpenFOAM-1.6/src/finiteVolume/lnInclude -I/home/mehdi/OpenFOAM/OpenFOAM-1.6/src/lagrangian/basic/lnInclude -I/home/mehdi/OpenFOAM/OpenFOAM-1.6/src/meshTools/lnInclude -IlnInclude -I. -I/home/mehdi/OpenFOAM/OpenFOAM-1.6/src/OpenFOAM/lnInclude -I/home/mehdi/OpenFOAM/OpenFOAM-1.6/src/OSspecific/POSIX/lnInclude  -fPIC -c $SOURCE -o Make/linuxGccDPOpt/mdFoam.o
In file included from mdFoam.C:50:
/home/mehdi/OpenFOAM/OpenFOAM-1.6/src/lagrangian/molecularDynamics/molecule/lnInclude/createMDFields.H: In function ‘int main(int, char**)’:
/home/mehdi/OpenFOAM/OpenFOAM-1.6/src/lagrangian/molecularDynamics/molecule/lnInclude/createMDFields.H:5: error: ‘class Foam::moleculeCloud’ has no member named ‘potential’
/home/mehdi/OpenFOAM/OpenFOAM-1.6/src/lagrangian/molecularDynamics/molecule/lnInclude/createMDFields.H:11: error: ‘class Foam::moleculeCloud’ has no member named ‘potential’
/home/mehdi/OpenFOAM/OpenFOAM-1.6/src/lagrangian/molecularDynamics/molecule/lnInclude/createMDFields.H:17: error: ‘class Foam::moleculeCloud’ has no member named ‘potential’
/home/mehdi/OpenFOAM/OpenFOAM-1.6/src/lagrangian/molecularDynamics/molecule/lnInclude/createMDFields.H:23: error: ‘class Foam::moleculeCloud’ has no member named ‘potential’
/home/mehdi/OpenFOAM/OpenFOAM-1.6/src/lagrangian/molecularDynamics/molecule/lnInclude/createMDFields.H:37: error: ‘class Foam::moleculeCloud’ has no member named ‘potential’
/home/mehdi/OpenFOAM/OpenFOAM-1.6/src/lagrangian/molecularDynamics/molecule/lnInclude/createMDFields.H:43: error: ‘class Foam::moleculeCloud’ has no member named ‘potential’
/home/mehdi/OpenFOAM/OpenFOAM-1.6/src/lagrangian/molecularDynamics/molecule/lnInclude/createMDFields.H:52: error: ‘class Foam::moleculeCloud’ has no member named ‘potential’
/home/mehdi/OpenFOAM/OpenFOAM-1.6/src/lagrangian/molecularDynamics/molecule/lnInclude/createMDFields.H:92: error: ‘class Foam::moleculeCloud’ has no member named ‘potential’
/home/mehdi/OpenFOAM/OpenFOAM-1.6/src/lagrangian/molecularDynamics/molecule/lnInclude/createMDFields.H:98: error: ‘class Foam::moleculeCloud’ has no member named ‘potential’
/home/mehdi/OpenFOAM/OpenFOAM-1.6/src/lagrangian/molecularDynamics/molecule/lnInclude/createMDFields.H:107: error: ‘class Foam::moleculeCloud’ has no member named ‘potential’
/home/mehdi/OpenFOAM/OpenFOAM-1.6/src/lagrangian/molecularDynamics/molecule/lnInclude/createMDFields.H:147: error: ‘class Foam::moleculeCloud’ has no member named ‘potential’
/home/mehdi/OpenFOAM/OpenFOAM-1.6/src/lagrangian/molecularDynamics/molecule/lnInclude/createMDFields.H:153: error: ‘class Foam::moleculeCloud’ has no member named ‘potential’
/home/mehdi/OpenFOAM/OpenFOAM-1.6/src/lagrangian/molecularDynamics/molecule/lnInclude/createMDFields.H:162: error: ‘class Foam::moleculeCloud’ has no member named ‘potential’
/home/mehdi/OpenFOAM/OpenFOAM-1.6/src/lagrangian/molecularDynamics/molecule/lnInclude/createMDFields.H:221: error: ‘class Foam::moleculeCloud’ has no member named ‘potential’
/home/mehdi/OpenFOAM/OpenFOAM-1.6/src/lagrangian/molecularDynamics/molecule/lnInclude/createMDFields.H:227: error: ‘class Foam::moleculeCloud’ has no member named ‘potential’
/home/mehdi/OpenFOAM/OpenFOAM-1.6/src/lagrangian/molecularDynamics/molecule/lnInclude/createMDFields.H:236: error: ‘class Foam::moleculeCloud’ has no member named ‘potential’
/home/mehdi/OpenFOAM/OpenFOAM-1.6/src/lagrangian/molecularDynamics/molecule/lnInclude/createMDFields.H:277: error: ‘class Foam::moleculeCloud’ has no member named ‘potential’
/home/mehdi/OpenFOAM/OpenFOAM-1.6/src/lagrangian/molecularDynamics/molecule/lnInclude/createMDFields.H:283: error: ‘class Foam::moleculeCloud’ has no member named ‘potential’
/home/mehdi/OpenFOAM/OpenFOAM-1.6/src/lagrangian/molecularDynamics/molecule/lnInclude/createMDFields.H:292: error: ‘class Foam::moleculeCloud’ has no member named ‘potential’
In file included from mdFoam.C:67:
/home/mehdi/OpenFOAM/OpenFOAM-1.6/src/lagrangian/molecularDynamics/molecule/lnInclude/calculateMDFields.H:13: error: ‘class Foam::molecule’ has no member named ‘U’
/home/mehdi/OpenFOAM/OpenFOAM-1.6/src/lagrangian/molecularDynamics/molecule/lnInclude/calculateMDFields.H:17: error: ‘class Foam::molecule’ has no member named ‘mass’
In file included from mdFoam.C:69:
/home/mehdi/OpenFOAM/OpenFOAM-1.6/src/lagrangian/molecularDynamics/molecule/lnInclude/resetMDFields.H:5: error: ‘class Foam::moleculeCloud’ has no member named ‘potential’
/home/mehdi/OpenFOAM/OpenFOAM-1.6/src/lagrangian/molecularDynamics/molecule/lnInclude/resetMDFields.H:11: error: ‘class Foam::moleculeCloud’ has no member named ‘potential’
/home/mehdi/OpenFOAM/OpenFOAM-1.6/src/lagrangian/molecularDynamics/molecule/lnInclude/resetMDFields.H:17: error: ‘class Foam::moleculeCloud’ has no member named ‘potential’
/home/mehdi/OpenFOAM/OpenFOAM-1.6/src/lagrangian/molecularDynamics/molecule/lnInclude/resetMDFields.H:23: error: ‘class Foam::moleculeCloud’ has no member named ‘potential’
make: *** [Make/linuxGccDPOpt/mdFoam.o] Error 1

what point am i missing already ?

Erik August 28, 2010 13:28

in the folder of mdFoam.C you should only type "wclean" and then "wmake" the commands "wclean libso" and "wmake libso" should only be used in case you are compiling a library e.g. the molecule library.

m.maneshi August 28, 2010 13:39

ok did that in the mdfoam directory and here is the result :
HTML Code:

mehdi@mehdi-laptop:~/OpenFOAM/OpenFOAM-1.6/applications/solvers/discreteMethods/molecularDynamics/mdFoam$ wclean
mehdi@mehdi-laptop:~/OpenFOAM/OpenFOAM-1.6/applications/solvers/discreteMethods/molecularDynamics/mdFoam$ wmake
Making dependency list for source file mdFoam.C
SOURCE=mdFoam.C ;  g++ -m32 -Dlinux -DWM_DP -Wall -Wno-strict-aliasing -Wextra -Wno-unused-parameter -Wold-style-cast -O3  -DNoRepository -ftemplate-depth-40 -I/home/mehdi/OpenFOAM/OpenFOAM-1.6/src/lagrangian/molecularDynamics/molecule/lnInclude -I/home/mehdi/OpenFOAM/OpenFOAM-1.6/src/lagrangian/molecularDynamics/potential/lnInclude -I/home/mehdi/OpenFOAM/OpenFOAM-1.6/src/lagrangian/molecularDynamics/molecularMeasurements/lnInclude -I/home/mehdi/OpenFOAM/OpenFOAM-1.6/src/finiteVolume/lnInclude -I/home/mehdi/OpenFOAM/OpenFOAM-1.6/src/lagrangian/basic/lnInclude -I/home/mehdi/OpenFOAM/OpenFOAM-1.6/src/meshTools/lnInclude -IlnInclude -I. -I/home/mehdi/OpenFOAM/OpenFOAM-1.6/src/OpenFOAM/lnInclude -I/home/mehdi/OpenFOAM/OpenFOAM-1.6/src/OSspecific/POSIX/lnInclude  -fPIC -c $SOURCE -o Make/linuxGccDPOpt/mdFoam.o
In file included from mdFoam.C:50:
/home/mehdi/OpenFOAM/OpenFOAM-1.6/src/lagrangian/molecularDynamics/molecule/lnInclude/createMDFields.H: In function ‘int main(int, char**)’:
/home/mehdi/OpenFOAM/OpenFOAM-1.6/src/lagrangian/molecularDynamics/molecule/lnInclude/createMDFields.H:5: error: ‘class Foam::moleculeCloud’ has no member named ‘potential’
/home/mehdi/OpenFOAM/OpenFOAM-1.6/src/lagrangian/molecularDynamics/molecule/lnInclude/createMDFields.H:11: error: ‘class Foam::moleculeCloud’ has no member named ‘potential’
/home/mehdi/OpenFOAM/OpenFOAM-1.6/src/lagrangian/molecularDynamics/molecule/lnInclude/createMDFields.H:17: error: ‘class Foam::moleculeCloud’ has no member named ‘potential’
/home/mehdi/OpenFOAM/OpenFOAM-1.6/src/lagrangian/molecularDynamics/molecule/lnInclude/createMDFields.H:23: error: ‘class Foam::moleculeCloud’ has no member named ‘potential’
/home/mehdi/OpenFOAM/OpenFOAM-1.6/src/lagrangian/molecularDynamics/molecule/lnInclude/createMDFields.H:37: error: ‘class Foam::moleculeCloud’ has no member named ‘potential’
/home/mehdi/OpenFOAM/OpenFOAM-1.6/src/lagrangian/molecularDynamics/molecule/lnInclude/createMDFields.H:43: error: ‘class Foam::moleculeCloud’ has no member named ‘potential’
/home/mehdi/OpenFOAM/OpenFOAM-1.6/src/lagrangian/molecularDynamics/molecule/lnInclude/createMDFields.H:52: error: ‘class Foam::moleculeCloud’ has no member named ‘potential’
/home/mehdi/OpenFOAM/OpenFOAM-1.6/src/lagrangian/molecularDynamics/molecule/lnInclude/createMDFields.H:92: error: ‘class Foam::moleculeCloud’ has no member named ‘potential’
/home/mehdi/OpenFOAM/OpenFOAM-1.6/src/lagrangian/molecularDynamics/molecule/lnInclude/createMDFields.H:98: error: ‘class Foam::moleculeCloud’ has no member named ‘potential’
/home/mehdi/OpenFOAM/OpenFOAM-1.6/src/lagrangian/molecularDynamics/molecule/lnInclude/createMDFields.H:107: error: ‘class Foam::moleculeCloud’ has no member named ‘potential’
/home/mehdi/OpenFOAM/OpenFOAM-1.6/src/lagrangian/molecularDynamics/molecule/lnInclude/createMDFields.H:147: error: ‘class Foam::moleculeCloud’ has no member named ‘potential’
/home/mehdi/OpenFOAM/OpenFOAM-1.6/src/lagrangian/molecularDynamics/molecule/lnInclude/createMDFields.H:153: error: ‘class Foam::moleculeCloud’ has no member named ‘potential’
/home/mehdi/OpenFOAM/OpenFOAM-1.6/src/lagrangian/molecularDynamics/molecule/lnInclude/createMDFields.H:162: error: ‘class Foam::moleculeCloud’ has no member named ‘potential’
/home/mehdi/OpenFOAM/OpenFOAM-1.6/src/lagrangian/molecularDynamics/molecule/lnInclude/createMDFields.H:221: error: ‘class Foam::moleculeCloud’ has no member named ‘potential’
/home/mehdi/OpenFOAM/OpenFOAM-1.6/src/lagrangian/molecularDynamics/molecule/lnInclude/createMDFields.H:227: error: ‘class Foam::moleculeCloud’ has no member named ‘potential’
/home/mehdi/OpenFOAM/OpenFOAM-1.6/src/lagrangian/molecularDynamics/molecule/lnInclude/createMDFields.H:236: error: ‘class Foam::moleculeCloud’ has no member named ‘potential’
/home/mehdi/OpenFOAM/OpenFOAM-1.6/src/lagrangian/molecularDynamics/molecule/lnInclude/createMDFields.H:277: error: ‘class Foam::moleculeCloud’ has no member named ‘potential’
/home/mehdi/OpenFOAM/OpenFOAM-1.6/src/lagrangian/molecularDynamics/molecule/lnInclude/createMDFields.H:283: error: ‘class Foam::moleculeCloud’ has no member named ‘potential’
/home/mehdi/OpenFOAM/OpenFOAM-1.6/src/lagrangian/molecularDynamics/molecule/lnInclude/createMDFields.H:292: error: ‘class Foam::moleculeCloud’ has no member named ‘potential’
In file included from mdFoam.C:67:
/home/mehdi/OpenFOAM/OpenFOAM-1.6/src/lagrangian/molecularDynamics/molecule/lnInclude/calculateMDFields.H:13: error: ‘class Foam::molecule’ has no member named ‘U’
/home/mehdi/OpenFOAM/OpenFOAM-1.6/src/lagrangian/molecularDynamics/molecule/lnInclude/calculateMDFields.H:17: error: ‘class Foam::molecule’ has no member named ‘mass’
In file included from mdFoam.C:69:
/home/mehdi/OpenFOAM/OpenFOAM-1.6/src/lagrangian/molecularDynamics/molecule/lnInclude/resetMDFields.H:5: error: ‘class Foam::moleculeCloud’ has no member named ‘potential’
/home/mehdi/OpenFOAM/OpenFOAM-1.6/src/lagrangian/molecularDynamics/molecule/lnInclude/resetMDFields.H:11: error: ‘class Foam::moleculeCloud’ has no member named ‘potential’
/home/mehdi/OpenFOAM/OpenFOAM-1.6/src/lagrangian/molecularDynamics/molecule/lnInclude/resetMDFields.H:17: error: ‘class Foam::moleculeCloud’ has no member named ‘potential’
/home/mehdi/OpenFOAM/OpenFOAM-1.6/src/lagrangian/molecularDynamics/molecule/lnInclude/resetMDFields.H:23: error: ‘class Foam::moleculeCloud’ has no member named ‘potential’
make: *** [Make/linuxGccDPOpt/mdFoam.o] Error 1

seems there is a problem with moleculeCloud ??

m.maneshi August 28, 2010 13:58

there seems nothing especial happens after compiling the solver and library and when i run the mdFoam for my problem there goes the same as before and no averaging or volume field or etc is calculated :confused:

Erik August 28, 2010 15:06

Ok, sorry I forgot that some changes need to be made to the molecule library. You therefore need to go to the directory:
$(LIB_SRC)/lagrangian/molecularDynamics/molecule

and do the following changes:

in createMDfields.H and resetMDfields.H you need to search and replace potential() with pot().

in calculateMDfields.H the representation of velocity U is now represented by v and the mass is no longer a molecular attribute but a property defined in the molecularPropertiesDict:
therefore, in the same file, you need to replace:
allSpeciesM_RU[molId][cell] += mol->mass();

with the two lines:

const molecule::constantProperties& constProp = molecules.constProps(molId);
allSpeciesM_RU[molId][cell] += constProp.mass();

After this you get to use commands "wclean libso" and then "wmake libso" to compile the library. Then navigate to the directory of the solver and compile using wclean and wmake.

It is neater however if you copy the solver and and molecule directories to your user folder and make the changes there. That way you preserve the original OF the default way. For this later issue I would consult the userguide.

good luck,
Erik

m.maneshi August 29, 2010 11:03

Quote:


in calculateMDfields.H the representation of velocity U is now represented by v and the mass is no longer a molecular attribute but a property defined in the molecularPropertiesDict:
therefore, in the same file, you need to replace:
allSpeciesM_RU[molId][cell] += mol->mass();

with the two lines:

const molecule::constantProperties& constProp = molecules.constProps(molId);
allSpeciesM_RU[molId][cell] += constProp.mass();

did so but the U as you siad is still a problem

HTML Code:

In file included from mdFoam.C:67:
/home/mehdi/OpenFOAM/OpenFOAM-1.6/src/lagrangian/molecularDynamics/molecule/lnInclude/calculateMDFields.H: In function ‘int main(int, char**)’:
/home/mehdi/OpenFOAM/OpenFOAM-1.6/src/lagrangian/molecularDynamics/molecule/lnInclude/calculateMDFields.H:13: error: ‘class Foam::molecule’ has no member named ‘U’
make: *** [Make/linuxGccDPOpt/mdFoam.o] Error 1

have you got any ideas ?

Erik August 29, 2010 12:08

Hi,

The error message that you show says that U is unknown still. So you should replace U with v.

m.maneshi August 29, 2010 12:23

hi , thanks for your replies.

so i did the replacement

the calculateMDFiels.H now is like this
HTML Code:

const List<DynamicList<molecule*> >& cellOccupancy = molecules.cellOccupancy();

forAll(cellOccupancy, cell)
{
    const List<molecule*>& molsInCell = cellOccupancy[cell];

    forAll(molsInCell, mIC)
    {
        molecule* mol = molsInCell[mIC];

        const label molId = mol->id();

        const vector& molU = mol->v();

        allSpeciesN_RU[molId][cell]++;

        const molecule::constantProperties& constProp = molecules.constProps(molId);

    allSpeciesM_RU[molId][cell] += constProp.mass();

        allSpeciesVelocitySum_RU[molId][cell] += molU;

        allSpeciesVelocityMagSquaredSum_RU[molId][cell] += molU & molU;
    }
}

is it all right ? or molU and others shall be like molv and so forth ? are the replacements limited to this header file only ?

Erik August 29, 2010 12:55

No worries,

It should work now. molU can remain molU since it is declared and used locally.

m.maneshi August 29, 2010 13:08

so as i perform wclean and subsequently wmake here is the result :confused:
HTML Code:

/usr/lib/crt1.o: In function `_start':
/build/buildd/glibc-2.9/csu/../sysdeps/i386/elf/start.S:115: undefined reference to `main'
collect2: ld returned 1 exit status
make: *** [OpenFOAM.out] Error 1


Erik August 29, 2010 13:44

I think you are trying to use wclean and wmake commands for compiling the molecule class. This does not work since it does not have main in it. The molecule class should be compiled using wclean libso and then wmake libso. Then navigate to the solver and use the wclean and wmake commands.

m.maneshi August 29, 2010 16:03

Thanks alot. it finally solve the problem. just one other question to ask . is it possible to change the binning size for the calculation of average values ?

Erik August 29, 2010 16:37

No problem. The averaging is done cell wise so these bins sizes are determined from the blockMeshDict file.

m.maneshi September 8, 2010 13:29

followed your leads and all seems to work fine . there remains but two questions of you could help i would be most grateful.

First of all when modeling a simple nano pressure driven channel with a gravity like .5 along the channel and periodic inlet / outlet the simulation never reaches a steady state even after 5*10^-11 seconds. why is it so ?

Second is that averages Calculated for run are very mesh size dependent as anticipated but there seems to be no appropriate mesh size to create smooth profiles for density , velocity and so forth ? what is wrong wish cell averaging ? must i resume with some other methods ?

Thanks in advance .


All times are GMT -4. The time now is 12:25.