CFD Online Logo CFD Online URL
www.cfd-online.com
[Sponsors]
Home > Forums > OpenFOAM

Writing a function object

Register Blogs Members List Search Today's Posts Mark Forums Read

Reply
 
LinkBack Thread Tools Display Modes
Old   July 31, 2014, 05:44
Default Writing a function object
  #1
Senior Member
 
Samuele Z
Join Date: Oct 2009
Location: Mozzate - Co - Italy
Posts: 493
Rep Power: 11
samiam1000 is on a distinguished road
Dear Foamers,

I am writing a function object and I do have some issues to be solved. I hope someone can help:

I am attaching a very simple case. Could you have a look?

I case: Enter the case directory and launch: "scalarTransportFoam"
Everything is ok. In the 10 dir I have the T*2 field.

II case: Enter the case directory and launch: "scalarTransportFoam -noFunctionObjects" and as a post processing run "execFlowFunctionObjects -noZero -latestTime" I get this error:
Code:
samuele@pc-zampini:~/Documenti/PhD/02tesiDomenico/workingDirLocal/dummyCase/passiveScalarBaseGeometry$ execFlowFunctionObjects -noZero -latestTime
/*---------------------------------------------------------------------------*\
| =========                 |                                                 |
| \\      /  F ield         | OpenFOAM: The Open Source CFD Toolbox           |
|  \\    /   O peration     | Version:  2.3.0                                 |
|   \\  /    A nd           | Web:      www.OpenFOAM.org                      |
|    \\/     M anipulation  |                                                 |
\*---------------------------------------------------------------------------*/
Build  : 2.3.0-f5222ca19ce6
Exec   : execFlowFunctionObjects -noZero -latestTime
Date   : Jul 31 2014
Time   : 10:53:20
Host   : "pc-zampini"
PID    : 21188
Case   : /home/samuele/Documenti/PhD/02tesiDomenico/workingDirLocal/dummyCase/passiveScalarBaseGeometry
nProcs : 1
sigFpe : Enabling floating point exception trapping (FOAM_SIGFPE).
fileModificationChecking : Monitoring run-time modified files using timeStampMaster
allowSystemOperations : Allowing user-supplied system call operations

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

Create mesh for time = 10

Using dynamicCode for functionObject difference at line 57 in "/home/samuele/Documenti/PhD/02tesiDomenico/workingDirLocal/dummyCase/passiveScalarBaseGeometry/system/controlDict.functions.difference"
Time = 10
    Reading phi
    Reading U
    Reading p
--> FOAM Warning : 
--> FOAM FATAL IO ERROR: 
cannot find file

file: /home/samuele/Documenti/PhD/02tesiDomenico/workingDirLocal/dummyCase/passiveScalarBaseGeometry/10/p at line 0.

    From function regIOobject::readStream()
    in file db/regIOobject/regIOobjectRead.C at line 73.

samuele@pc-zampini:~/Documenti/PhD/02tesiDomenico/workingDirLocal/dummyCase/passiveScalarBaseGeometry$
Hence, I copy a "p" file in the 10 directory. Nevertheless, I get this:
Code:
samuele@pc-zampini:~/Documenti/PhD/02tesiDomenico/workingDirLocal/dummyCase/passiveScalarBaseGeometry$ execFlowFunctionObjects -noZero -latestTime
/*---------------------------------------------------------------------------*\
| =========                 |                                                 |
| \\      /  F ield         | OpenFOAM: The Open Source CFD Toolbox           |
|  \\    /   O peration     | Version:  2.3.0                                 |
|   \\  /    A nd           | Web:      www.OpenFOAM.org                      |
|    \\/     M anipulation  |                                                 |
\*---------------------------------------------------------------------------*/
Build  : 2.3.0-f5222ca19ce6
Exec   : execFlowFunctionObjects -noZero -latestTime
Date   : Jul 31 2014
Time   : 10:52:07
Host   : "pc-zampini"
PID    : 21126
Case   : /home/samuele/Documenti/PhD/02tesiDomenico/workingDirLocal/dummyCase/passiveScalarBaseGeometry
nProcs : 1
sigFpe : Enabling floating point exception trapping (FOAM_SIGFPE).
fileModificationChecking : Monitoring run-time modified files using timeStampMaster
allowSystemOperations : Allowing user-supplied system call operations

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

Create mesh for time = 10

Using dynamicCode for functionObject difference at line 57 in "/home/samuele/Documenti/PhD/02tesiDomenico/workingDirLocal/dummyCase/passiveScalarBaseGeometry/system/controlDict.functions.difference"
Time = 10
    Reading phi
    Reading U
    Reading p
Looking up field T



--> FOAM FATAL ERROR: 

    request for volScalarField T from objectRegistry region0 failed
    available objects of type volScalarField are
1(p)

    From function objectRegistry::lookupObject<Type>(const word&) const
    in file /home/samuele/OpenFOAM/OpenFOAM-2.3.0/src/OpenFOAM/lnInclude/objectRegistryTemplates.C at line 198.

FOAM aborting

#0  Foam::error::printStack(Foam::Ostream&) in "/home/samuele/OpenFOAM/OpenFOAM-2.3.0/platforms/linux64GccDPOpt/lib/libOpenFOAM.so"
#1  Foam::error::abort() in "/home/samuele/OpenFOAM/OpenFOAM-2.3.0/platforms/linux64GccDPOpt/lib/libOpenFOAM.so"
#2  Foam::GeometricField<double, Foam::fvPatchField, Foam::volMesh> const& Foam::objectRegistry::lookupObject<Foam::GeometricField<double, Foam::fvPatchField, Foam::volMesh> >(Foam::word const&) const in "/home/samuele/OpenFOAM/OpenFOAM-2.3.0/platforms/linux64GccDPOpt/lib/libincompressibleRASModels.so"
#3  Foam::mixingEvaluationFunctionObject::write() at /usr/include/c++/4.7/bits/basic_string.h:536
#4  Foam::OutputFilterFunctionObject<Foam::mixingEvaluationFunctionObject>::execute(bool) at ~/OpenFOAM/OpenFOAM-2.3.0/src/OpenFOAM/lnInclude/OutputFilterFunctionObject.C:173
#5  Foam::functionObjectList::execute(bool) in "/home/samuele/OpenFOAM/OpenFOAM-2.3.0/platforms/linux64GccDPOpt/lib/libOpenFOAM.so"
#6  
 in "/home/samuele/OpenFOAM/OpenFOAM-2.3.0/platforms/linux64GccDPOpt/bin/execFlowFunctionObjects"
#7  
 in "/home/samuele/OpenFOAM/OpenFOAM-2.3.0/platforms/linux64GccDPOpt/bin/execFlowFunctionObjects"
#8  __libc_start_main in "/lib/x86_64-linux-gnu/libc.so.6"
#9  
 in "/home/samuele/OpenFOAM/OpenFOAM-2.3.0/platforms/linux64GccDPOpt/bin/execFlowFunctionObjects"
Annullato
samuele@pc-zampini:~/Documenti/PhD/02tesiDomenico/workingDirLocal/dummyCase/passiveScalarBaseGeometry$
Could anyone help?

Also, one more question: how abaout if I want to get an average on each section?

Thanks a lot,
Samuele
Attached Files
File Type: gz passiveScalar.tar.gz (66.4 KB, 5 views)
samiam1000 is offline   Reply With Quote

Old   July 31, 2014, 09:53
Default
  #2
Senior Member
 
Bernhard
Join Date: Sep 2009
Location: Delft
Posts: 790
Rep Power: 14
Bernhard is on a distinguished road
You also need to -noFlow flag for execFlowFunctionObjects. All variables will then be loaded.
Bernhard is offline   Reply With Quote

Old   July 31, 2014, 10:13
Default
  #3
Senior Member
 
Samuele Z
Join Date: Oct 2009
Location: Mozzate - Co - Italy
Posts: 493
Rep Power: 11
samiam1000 is on a distinguished road
Hi Bernard and thanks for helping.

Also, about my secondo issue, I was thinking about exploiting the sample function and then to average it.

The point is that I would insert a loop in the sampleDict. Is that possible?

I wrote something like:

Code:
/*--------------------------------*- C++ -*----------------------------------*\
| =========                 |                                                 |
| \\      /  F ield         | OpenFOAM: The Open Source CFD Toolbox           |
|  \\    /   O peration     | Version:  2.3.0                                 |
|   \\  /    A nd           | Web:      www.OpenFOAM.org                      |
|    \\/     M anipulation  |                                                 |
\*---------------------------------------------------------------------------*/
FoamFile
{
    version         2.0;
    format          ascii;
    class           dictionary;
    location        "system";
    object          sampleDict;
}

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

interpolationScheme cellPoint; 
   
  surfaceFormat       foamFile; 
points = 100;
L = 3000;

dx = $points/$L;

for i = 1:$points
{   
  surfaces 
  ( 
      plane%d, i
      { 
		  type	plane;
          basePoint (0.0001 -0.0016+($dx*%i)  0.0001); 
          normalVector (0 1 0); 
      }
 
  ); 
}
end
   
fields          ( U );
Any idea?

Thanks again.
samiam1000 is offline   Reply With Quote

Old   July 31, 2014, 11:46
Default
  #4
Senior Member
 
Samuele Z
Join Date: Oct 2009
Location: Mozzate - Co - Italy
Posts: 493
Rep Power: 11
samiam1000 is on a distinguished road
I tryed the following solution:
Code:
/*--------------------------------*- C++ -*----------------------------------*\
| =========                 |                                                 |
| \\      /  F ield         | OpenFOAM: The Open Source CFD Toolbox           |
|  \\    /   O peration     | Version:  2.2.0                                 |
|   \\  /    A nd           | Web:      www.OpenFOAM.org                      |
|    \\/     M anipulation  |                                                 |
\*---------------------------------------------------------------------------*/
FoamFile
{
    version     2.0;
    format      ascii;
    class       dictionary;
    location    "system";
    object      controlDict;
}
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //

application     scalarTransportFoam;

startFrom       latestTime;

startTime       0;

stopAt          endTime;

endTime         10; 		// T = 7.5e-3

deltaT          1;

writeControl    adjustableRunTime;

writeInterval   1;

purgeWrite      0;

writeFormat     ascii;

writePrecision  6;

writeCompression off;

timeFormat      general;

timePrecision   6;

runTimeModifiable true;

adjustTimeStep	yes;

maxCo			0.9;


functions
{
new_planes
{
    type            faceSource;
    functionObjectLibs ("libfieldFunctionObjects.so");
    enabled         true;
    outputControl   timeStep;
    log             true;
    valueOutput     true;
    source          sampledSurface;
    surfaceFormat   vtk;

	sampledSurfaceDict
	{
		type            plane;
		basePoint       (0.0001 -0.00115 0.0001);
		normalVector    (0 1 0);
	}

	sampledSurfaceDict
	{
		type            plane;
		basePoint       (0.0001 -0.00065 0.0001);
		normalVector    (0 1 0);
	}

    operation       areaAverage;
	fields
	(
		T
	);
}
The point is that it does not allow me to write more than one value of T. How can I do this?
samiam1000 is offline   Reply With Quote

Reply

Thread Tools
Display Modes

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


Similar Threads
Thread Thread Starter Forum Replies Last Post
foamToTecplot360 thomasduerr OpenFOAM Post-Processing 115 October 11, 2016 12:21
error message with modeling a cube with a hold at the center hsingtzu OpenFOAM Native Meshers: blockMesh 2 March 14, 2012 10:56
latest OpenFOAM-1.6.x from git failed to compile phsieh2005 OpenFOAM Bugs 25 February 9, 2010 05:37
Error with Wmake skabilan OpenFOAM Installation 3 July 28, 2009 00:35
Droplet Evaporation Christian Main CFD Forum 2 February 27, 2007 07:27


All times are GMT -4. The time now is 23:07.