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

Poisson equation with forcing

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

Reply
 
LinkBack Thread Tools Search this Thread Display Modes
Old   April 6, 2015, 07:54
Default Poisson equation with forcing
  #1
New Member
 
Join Date: Apr 2015
Posts: 3
Rep Power: 11
ohiagree is on a distinguished road
Hi all,
from the simple case I will present below, I guess you'll understand that I'm new to OF.

I trying to create a solver for the equation:
laplacian(p) = f
where e.g.
f = cos(pi*x)*cos(pi*y).

I'm not quite sure how to create the forcing function. In createFields.H I'm trying something like
Code:
Info<< "Reading field pressure\n" << endl;
volScalarField p(
	IOobject(
		"p",
		runTime.timeName(),
		mesh,
		IOobject::MUST_READ,
		IOobject::AUTO_WRITE
	),
	mesh
);

Info<< "Reading field forcing\n" << endl;
volScalarField f(
	IOobject(
	"f",
	runTime.timeName(),
	mesh,
	IOobject::MUST_READ,
	IOobject::AUTO_WRITE
	),
	mesh
);
	
	volScalarField yPos = mesh.C().component(vector::Y);
	volScalarField xPos = mesh.C().component(vector::X); 
	
	forAll(f, counter) 
	{ 
	f[counter] = foam::cos(3.14*xPos[counter])*cos(3.14*yPos[counter]); 
	}
And also, an extract from poissonCustom.C looks something like
Code:
#include "fvCFD.H"

// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
// Main program:

int main(int argc, char *argv[])
{
    #include "setRootCase.H"
    #include "createTime.H"
	#include "createMesh.H"
	#include "createFields.H"
	// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
	
	solve ( fvm::laplacian(p) == f );
	
	runTime++;
	p.write();
	f.write();

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

    Info<< "\nEnd\n" << endl;
    return 0;
}
This creates the following errors when compiling the solver
Code:
./createFields.H:26:17: error: conversion from 'tmp<GeometricField<cmptType, fvPatchField, Foam::volMesh> >' to
      'volScalarField' (aka 'GeometricField<scalar, fvPatchField, Foam::volMesh>') is ambiguous
        volScalarField yPos = mesh.C().component(vector::Y); 
                       ^      ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
Any ideas?

Best Regards,
Bosse
ohiagree is offline   Reply With Quote

Reply

Thread Tools Search this Thread
Search this Thread:

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


Similar Threads
Thread Thread Starter Forum Replies Last Post
Parallel solver for Poisson equation using PETSc JackNapier Main CFD Forum 0 July 5, 2012 16:53
error message cuteapathy CFX 14 March 20, 2012 06:45
Solving the poisson equation on collocated grids Hooman Main CFD Forum 4 June 29, 2010 12:27
orlandi code for poisson equation with FFT ( paid tutorial) HaKu Main CFD Forum 0 June 29, 2009 15:40
Poisson equation combined with transport equation Se-Hee CFX 0 December 27, 2007 01:00


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