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

modify pimpleFoam to write sampled fields on a patch each runtime

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

Reply
 
LinkBack Thread Tools Display Modes
Old   August 19, 2017, 15:17
Default modify pimpleFoam to write sampled fields on a patch each runtime
  #1
New Member
 
mohafarmani
Join Date: Aug 2015
Location: shiraz
Posts: 14
Rep Power: 4
moh-farmani is on a distinguished road
Dear Foamers;

I have added the following lines to pimpleFoam to write U at inlet boundary at each time step.
Code:
#include "fvCFD.H"
#include "singlePhaseTransportModel.H"
#include "turbulenceModel.H"
#include "pimpleControl.H"
#include "fvIOoptionList.H"
#include "IOporosityModelList.H"
#include "IOMRFZoneList.H"
#include "fixedFluxPressureFvPatchScalarField.H"
#include "AverageIOField.H"


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

int main(int argc, char *argv[])
{
    #include "setRootCase.H"
    #include "createTime.H"
    #include "createMesh.H"
    #include "createFields.H"
    #include "createFvOptions.H"
    #include "initContinuityErrs.H"


    pimpleControl pimple(mesh);

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

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

    while (runTime.run())
    {
        #include "readTimeControls.H"
        #include "CourantNo.H"
        #include "setDeltaT.H"
	#include "AverageIOField.H"

        runTime++;

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

        // --- Pressure-velocity PIMPLE corrector loop
        while (pimple.loop())
        {
            #include "UEqn.H"

            // --- Pressure corrector loop
            while (pimple.correct())
            {
                #include "pEqn.H"
            }

            if (pimple.turbCorr())
            {
                turbulence->correct();
            }
        }
	word patchName = "inlet";
	label patchID = mesh.boundary().findPatchID(patchName);    
   
       	 AverageIOField<vector> U2
		(
    		IOobject
    			(
        		"U",
        		mesh.time().timeName(),
        		mesh,
        		IOobject::NO_READ,
        		IOobject::NO_WRITE
   			 ),
    		U.boundaryField()[ patchID ]
		);

		U2.write();

        runTime.write();

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

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

    return 0;
}
When I compile it, some error messages appear:
Code:
apadana@apadana-To-be-filled-by-O-E-M:~/OpenFOAM/apadana-2.4.0/applications/solvers/pimpleFoamSampled$ wmake
SOURCE=my_pimpleFoam.C ;  g++ -m64 -Dlinux64 -DWM_DP -Wall -Wextra -Wno-unused-parameter -Wold-style-cast -Wnon-virtual-dtor -O3  -DNoRepository -ftemplate-depth-100 -I/opt/openfoam240/src/turbulenceModels/incompressible/turbulenceModel -I/opt/openfoam240/src/transportModels -I/opt/openfoam240/src/transportModels/incompressible/singlePhaseTransportModel -I/opt/openfoam240/src/finiteVolume/lnInclude -I/opt/openfoam240/src/meshTools/lnInclude -I/opt/openfoam240/src/fvOptions/lnInclude -I/opt/openfoam240/src/sampling/lnInclude -IlnInclude -I. -I/opt/openfoam240/src/OpenFOAM/lnInclude -I/opt/openfoam240/src/OSspecific/POSIX/lnInclude   -fPIC -c $SOURCE -o Make/linux64GccDPOpt/my_pimpleFoam.o
my_pimpleFoam.C: In function ‘int main(int, char**)’:
my_pimpleFoam.C:107:3: error: no matching function for call to ‘Foam::AverageIOField<Foam::Vector<double> >::AverageIOField(Foam::IOobject, Foam::fvPatchField<Foam::Vector<double> >&)’
   );
   ^
my_pimpleFoam.C:107:3: note: candidates are:
In file included from /opt/openfoam240/src/finiteVolume/lnInclude/AverageIOField.H:114:0,
                 from my_pimpleFoam.C:45:
/opt/openfoam240/src/finiteVolume/lnInclude/AverageIOField.C:58:1: note: Foam::AverageIOField<Type>::AverageIOField(const Foam::IOobject&, const Type&, const Foam::Field<Type>&) [with Type = Foam::Vector<double>]
 Foam::AverageIOField<Type>::AverageIOField
 ^
/opt/openfoam240/src/finiteVolume/lnInclude/AverageIOField.C:58:1: note:   candidate expects 3 arguments, 2 provided
/opt/openfoam240/src/finiteVolume/lnInclude/AverageIOField.C:45:1: note: Foam::AverageIOField<Type>::AverageIOField(const Foam::IOobject&, Foam::label) [with Type = Foam::Vector<double>; Foam::label = int]
 Foam::AverageIOField<Type>::AverageIOField
 ^
/opt/openfoam240/src/finiteVolume/lnInclude/AverageIOField.C:45:1: note:   no known conversion for argument 2 from ‘Foam::fvPatchField<Foam::Vector<double> >’ to ‘Foam::label {aka int}’
/opt/openfoam240/src/finiteVolume/lnInclude/AverageIOField.C:31:1: note: Foam::AverageIOField<Type>::AverageIOField(const Foam::IOobject&) [with Type = Foam::Vector<double>]
 Foam::AverageIOField<Type>::AverageIOField
 ^
/opt/openfoam240/src/finiteVolume/lnInclude/AverageIOField.C:31:1: note:   candidate expects 1 argument, 2 provided
In file included from my_pimpleFoam.C:45:0:
/opt/openfoam240/src/finiteVolume/lnInclude/AverageIOField.H:51:7: note: Foam::AverageIOField<Foam::Vector<double> >::AverageIOField(const Foam::AverageIOField<Foam::Vector<double> >&)
 class AverageIOField
       ^
/opt/openfoam240/src/finiteVolume/lnInclude/AverageIOField.H:51:7: note:   candidate expects 1 argument, 2 provided
make: *** [Make/linux64GccDPOpt/my_pimpleFoam.o] Error 1
I am not a C++ expert so I have no idea how to solve this problem.
Any kind of help is well appreciated .

kind Regards,
Moha
moh-farmani 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
Problem with cyclic boundaries in Openfoam 1.5 fs82 OpenFOAM 36 January 7, 2015 01:31
mesh file for flow over a circular cylinder Ardalan Main CFD Forum 6 April 17, 2010 23:40
StarToFoam error Kart OpenFOAM Meshing & Mesh Conversion 1 February 4, 2010 05:38
Write interpolated patch data of coarse mesh braennstroem OpenFOAM Running, Solving & CFD 0 June 4, 2009 13:55
Multicomponent fluid Andrea CFX 2 October 11, 2004 05:12


All times are GMT -4. The time now is 22:26.