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

how to write sampling of lines and surfaces during run time

Register Blogs Community New Posts Updated Threads Search

Like Tree1Likes
  • 1 Post By AlxB

Reply
 
LinkBack Thread Tools Search this Thread Display Modes
Old   September 5, 2022, 04:13
Default how to write sampling of lines and surfaces during run time
  #1
Member
 
Join Date: Apr 2021
Posts: 41
Rep Power: 4
AlxB is on a distinguished road
Dear Foamers,
I am on OFv2112 and I run multiphase transient simulation using interFoam.
I am able to post-process lines and surfaces after the run, using the postProcess command and writing them in the postProcessing directory.
However I am not able to do it during run time and I would like to know how to do it.
Here below are my sampling functions objects and controlDict files.

Please could you help me and let me know what could be wrong here ?
Many thanks in advance.

FOfreeSurface
Code:
/*--------------------------------*- C++ -*----------------------------------*\
| =========                 |                                                 |
| \\      /  F ield         | OpenFOAM: The Open Source CFD Toolbox           |
|  \\    /   O peration     | Version:  v2112                                 |
|   \\  /    A nd           | Website:  www.openfoam.com                      |
|    \\/     M anipulation  |                                                 |
\*---------------------------------------------------------------------------*/
FoamFile
{
    version         2.0;
    format          ascii;
    class           dictionary;
    location		system;
    object          sample;
}
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
type            surfaces;
libs            ("libsampling.so");

surfaceFormat	vtk; // stl;
fields			(alpha.water);
interpolationScheme cellPoint;

executeControl      writeTime;
writeControl        writeTime;

surfaces2
(
	topFreeSurface09
	{
		type    	isoSurface;
		isoField	alpha.water;
		isoValue	0.9;
		interpolate	true;
	}
	topFreeSurface10
	{
		type    	isoSurface;
		isoField	alpha.water;
		isoValue	1.0;
		interpolate	true;
	}
);
// ************************************************************************* //
FOlines
Code:
/*--------------------------------*- C++ -*----------------------------------*\
| =========                 |                                                 |
| \\      /  F ield         | OpenFOAM: The Open Source CFD Toolbox           |
|  \\    /   O peration     | Version:  v2112                                 |
|   \\  /    A nd           | Website:  www.openfoam.com                      |
|    \\/     M anipulation  |                                                 |
\*---------------------------------------------------------------------------*/
FoamFile
{
    version         2.0;
    format          ascii;
    class           dictionary;
    location		system;
    object          sample;
}
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //

type            sets;
libs            ("libsampling.so");

setFormat      	raw;
fields			(U alpha.water);
interpolationScheme 	cellPoint;

executeControl      writeTime;
writeControl        writeTime;

Npts			101;

xline1			0.1;
xline2			0.2;
yline			0.1;
zline			0.5;

sets2
(
	line1
	{
		type    uniform;
		axis    distance;
		start   ( $xline1 $yline 0 );
		end     ( $xline1 $yline $zline );
		nPoints $Npts;
	}
	line2
	{
		type    uniform;
		axis    distance;
		start   ( $xline2 $yline 0 );
		end     ( $xline2 $yline $zline );
		nPoints $Npts;
	}
);
// ************************************************************************* //
controlDict
Code:
/*--------------------------------*- C++ -*----------------------------------*\
| =========                 |                                                 |
| \\      /  F ield         | OpenFOAM: The Open Source CFD Toolbox           |
|  \\    /   O peration     | Version:  v2112                                 |
|   \\  /    A nd           | Website:  www.openfoam.com                      |
|    \\/     M anipulation  |                                                 |
\*---------------------------------------------------------------------------*/
FoamFile
{
    version     2.0;
    format      ascii;
    class       dictionary;
    object      controlDict;
}
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //

application     interFoam;

startFrom     	latestTime;

stopAt          endTime;
endTime         120.0;

deltaT          0.01;

writeControl    adjustableRunTime;
writeInterval   0.05;
purgeWrite      2;

writeFormat     ascii;
writePrecision  8;
writeCompression off;

timeFormat      general;
timePrecision   8;
runTimeModifiable yes;
adjustTimeStep  yes;

maxCo           0.65;
maxAlphaCo    0.65;
maxDeltaT      0.1;

functions
{
	#include "solverInfo"
	#include "FOlines"
	#include "FOfreeSurface"
}
// ************************************************************************* //
AlxB is offline   Reply With Quote

Old   September 5, 2022, 11:27
Default
  #2
Member
 
Al
Join Date: May 2019
Posts: 37
Rep Power: 6
aliyah. is on a distinguished road
Quote:
Originally Posted by AlxB View Post
Dear Foamers,
I am on OFv2112 and I run multiphase transient simulation using interFoam.
I am able to post-process lines and surfaces after the run, using the postProcess command and writing them in the postProcessing directory.
However I am not able to do it during run time and I would like to know how to do it.
Here below are my sampling functions objects and controlDict files.

Please could you help me and let me know what could be wrong here ?
Many thanks in advance.

FOfreeSurface
Code:
/*--------------------------------*- C++ -*----------------------------------*\
| =========                 |                                                 |
| \\      /  F ield         | OpenFOAM: The Open Source CFD Toolbox           |
|  \\    /   O peration     | Version:  v2112                                 |
|   \\  /    A nd           | Website:  www.openfoam.com                      |
|    \\/     M anipulation  |                                                 |
\*---------------------------------------------------------------------------*/
FoamFile
{
    version         2.0;
    format          ascii;
    class           dictionary;
    location		system;
    object          sample;
}
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
type            surfaces;
libs            ("libsampling.so");

surfaceFormat	vtk; // stl;
fields			(alpha.water);
interpolationScheme cellPoint;

executeControl      writeTime;
writeControl        writeTime;

surfaces2
(
	topFreeSurface09
	{
		type    	isoSurface;
		isoField	alpha.water;
		isoValue	0.9;
		interpolate	true;
	}
	topFreeSurface10
	{
		type    	isoSurface;
		isoField	alpha.water;
		isoValue	1.0;
		interpolate	true;
	}
);
// ************************************************************************* //
FOlines
Code:
/*--------------------------------*- C++ -*----------------------------------*\
| =========                 |                                                 |
| \\      /  F ield         | OpenFOAM: The Open Source CFD Toolbox           |
|  \\    /   O peration     | Version:  v2112                                 |
|   \\  /    A nd           | Website:  www.openfoam.com                      |
|    \\/     M anipulation  |                                                 |
\*---------------------------------------------------------------------------*/
FoamFile
{
    version         2.0;
    format          ascii;
    class           dictionary;
    location		system;
    object          sample;
}
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //

type            sets;
libs            ("libsampling.so");

setFormat      	raw;
fields			(U alpha.water);
interpolationScheme 	cellPoint;

executeControl      writeTime;
writeControl        writeTime;

Npts			101;

xline1			0.1;
xline2			0.2;
yline			0.1;
zline			0.5;

sets2
(
	line1
	{
		type    uniform;
		axis    distance;
		start   ( $xline1 $yline 0 );
		end     ( $xline1 $yline $zline );
		nPoints $Npts;
	}
	line2
	{
		type    uniform;
		axis    distance;
		start   ( $xline2 $yline 0 );
		end     ( $xline2 $yline $zline );
		nPoints $Npts;
	}
);
// ************************************************************************* //
controlDict
Code:
/*--------------------------------*- C++ -*----------------------------------*\
| =========                 |                                                 |
| \\      /  F ield         | OpenFOAM: The Open Source CFD Toolbox           |
|  \\    /   O peration     | Version:  v2112                                 |
|   \\  /    A nd           | Website:  www.openfoam.com                      |
|    \\/     M anipulation  |                                                 |
\*---------------------------------------------------------------------------*/
FoamFile
{
    version     2.0;
    format      ascii;
    class       dictionary;
    object      controlDict;
}
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //

application     interFoam;

startFrom     	latestTime;

stopAt          endTime;
endTime         120.0;

deltaT          0.01;

writeControl    adjustableRunTime;
writeInterval   0.05;
purgeWrite      2;

writeFormat     ascii;
writePrecision  8;
writeCompression off;

timeFormat      general;
timePrecision   8;
runTimeModifiable yes;
adjustTimeStep  yes;

maxCo           0.65;
maxAlphaCo    0.65;
maxDeltaT      0.1;

functions
{
	#include "solverInfo"
	#include "FOlines"
	#include "FOfreeSurface"
}
// ************************************************************************* //
Hello, I think your question is answered in the following thread.

Quick How-To: Sample like in sampleDict during runtime

Best,
aliyah. is offline   Reply With Quote

Old   September 5, 2022, 14:34
Default
  #3
Member
 
Join Date: Apr 2021
Posts: 41
Rep Power: 4
AlxB is on a distinguished road
Thanks.

In the meantime I found a simple solution by rewriting the function object as below:

FOfreeSurface
Code:
/*--------------------------------*- C++ -*----------------------------------*\
| =========                 |                                                 |
| \\      /  F ield         | OpenFOAM: The Open Source CFD Toolbox           |
|  \\    /   O peration     | Version:  v2112                                 |
|   \\  /    A nd           | Website:  www.openfoam.com                      |
|    \\/     M anipulation  |                                                 |
\*---------------------------------------------------------------------------*/







freeSurface
{
	type            surfaces;
	libs            ("libsampling.so");
	interpolationScheme cellPoint;
	surfaceFormat	vtk; // stl;
	fields			(alpha.water);

	executeControl  writeTime;
	executeInterval 1;
	writeControl    writeTime;
	writeInterval   1;

	surfaces
	(
		topFreeSurface09
		{
			type    	isoSurface;
			isoField	alpha.water;
			isoValue	0.9;
			interpolate	true;
		}
		topFreeSurface10
		{
			type    	isoSurface;
			isoField	alpha.water;
			isoValue	1.0;
			interpolate	true;
		}
	);
}
The same modification on the other sample function object worked as well
aliyah. likes this.
AlxB is offline   Reply With Quote

Old   September 6, 2022, 02:14
Default
  #4
Member
 
Al
Join Date: May 2019
Posts: 37
Rep Power: 6
aliyah. is on a distinguished road
That's great, The thread I addressed on this issue also included a similar approach and was using outputControl and outputInterval.
aliyah. 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
[DesignModeler] Cannot modify lines and surfaces in Ansys DesignModeler iancmlositano ANSYS Meshing & Geometry 0 March 16, 2017 23:32
run time error umar959 FLUENT 0 November 23, 2011 00:47
[Netgen] CalculiX can write now a ployMesh klaus OpenFOAM Meshing & Mesh Conversion 6 December 12, 2007 05:02


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