|
[Sponsors] | |||||
|
|
|
#1 |
|
New Member
Join Date: Apr 2015
Posts: 3
Rep Power: 12 ![]() |
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]);
}
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;
}
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);
^ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
Best Regards, Bosse |
|
|
|
|
|
![]() |
| Thread Tools | Search this Thread |
| Display Modes | |
|
|
Similar Threads
|
||||
| Thread | Thread Starter | Forum | Replies | Last Post |
| Parallel solver for Poisson equation using PETSc | JackNapier | Main CFD Forum | 0 | July 5, 2012 17:53 |
| error message | cuteapathy | CFX | 14 | March 20, 2012 07:45 |
| Solving the poisson equation on collocated grids | Hooman | Main CFD Forum | 4 | June 29, 2010 13:27 |
| orlandi code for poisson equation with FFT ( paid tutorial) | HaKu | Main CFD Forum | 0 | June 29, 2009 16:40 |
| Poisson equation combined with transport equation | Se-Hee | CFX | 0 | December 27, 2007 02:00 |