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

compiling a solver

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

Reply
 
LinkBack Thread Tools Display Modes
Old   January 25, 2012, 18:43
Default compiling a solver
  #1
Member
 
Join Date: Nov 2011
Posts: 44
Rep Power: 5
fferroni is on a distinguished road
Hello.

I need to compile a solver, and I've never done this before.

I have a .C file for a new solver. I suppose I need to create a "createFields.H" file. I tried creating one, and then doing wmake. However, these are errors I get.

DNSsolverMHD.C:27:27: error: 'B0' was not declared in this scope
DNSsolverMHD.C:31:54: error: 'PotE' was not declared in this scope
In file included from DNSsolverMHD.C:37:0:
/Users/MacbookPro/OpenFOAM/OpenFOAM-2.0.x/src/finiteVolume/lnInclude/CourantNo.H:39:29: error: 'phi' was not declared in this scope
DNSsolverMHD.C:39:29: error: 'PotElnCorr' was not declared in this scope
DNSsolverMHD.C:47:22: error: 'phi' was not declared in this scope
DNSsolverMHD.C:98:30: error: 'PotERefCell' was not declared in this scope
DNSsolverMHD.C:98:43: error: 'PotERefValue' was not declared in this scope


I need to declare these, but where?

Kind Regards,

Francesco
fferroni is offline   Reply With Quote

Old   January 25, 2012, 19:39
Default
  #2
Super Moderator
 
Bruno Santos
Join Date: Mar 2009
Location: Lisbon, Portugal
Posts: 8,258
Blog Entries: 34
Rep Power: 84
wyldckat is just really nicewyldckat is just really nicewyldckat is just really nicewyldckat is just really nice
Greetings Francesco,

I suggest that you first see the following tutorial and do the steps shown there: http://openfoamwiki.net/index.php/Ho...ure_to_icoFoam
That way you can get a better grasp of what is needed and what you should look for And when in doubt: see the code that already exists in OpenFOAM!

Best regards,
Bruno
wyldckat is offline   Reply With Quote

Old   January 26, 2012, 18:02
Default
  #3
Member
 
Join Date: Nov 2011
Posts: 44
Rep Power: 5
fferroni is on a distinguished road
Hello.

I read the tutorial and still have some questions (and errors)

1. I have a vector B0 and would like to find it's direction. So:

const vector nB = B0.value()/mag(B0.value())

However, I get that:

EpotFoam.C:27:30: error: 'struct Foam::volVectorField' has no member named 'value'.
I'm not sure why this is happening.


2. For the equation:
volVectorField lorentz = sigma * (-fvc::grad(PotE) ^ B0) + sigma * ((U ^ B0) ^ B0);

I add to the createFields.H, following the tutorial, the following:

Info<< "Reading field PotE\n" << endl;
volVectorField PotE
(
IOobject
(
"PotE",
runTime.timeName(),
mesh,
IOobject::MUST_READ,
IOobject::AUTO_WRITE
),
mesh
);

Similarly for B0, and phi etc. but I get errors like:

EpotFoam.C:31:90: error: conversion from 'Foam::tmp<Foam::GeometricField<Foam::Tensor<doubl e>, Foam::fvPatchField, Foam::volMesh> >' to non-scalar type 'Foam::volVectorField' requested

Does this mean I am not defining the class of the field correctly?

Basically, what I'm trying to achieve is reconstruct current density and potential field from a magnetic field...

Kind Regards,

Francesco
fferroni is offline   Reply With Quote

Old   January 28, 2012, 03:52
Default
  #4
Super Moderator
 
Bruno Santos
Join Date: Mar 2009
Location: Lisbon, Portugal
Posts: 8,258
Blog Entries: 34
Rep Power: 84
wyldckat is just really nicewyldckat is just really nicewyldckat is just really nicewyldckat is just really nice
Hi Francesco,

Quote:
Originally Posted by fferroni View Post
Hello.

I read the tutorial and still have some questions (and errors)

1. I have a vector B0 and would like to find it's direction. So:

const vector nB = B0.value()/mag(B0.value())

However, I get that:

EpotFoam.C:27:30: error: 'struct Foam::volVectorField' has no member named 'value'.
I'm not sure why this is happening.
Well, the compiler isn't wrong... there is no "value" method for "volVectorField". You can search for it on the code documentation, namely here: http://foam.sourceforge.net/docs/cpp/
I don't know the solution , but looking at more OpenFOAM code might help you

Quote:
Originally Posted by fferroni View Post
2. For the equation:
volVectorField lorentz = sigma * (-fvc::grad(PotE) ^ B0) + sigma * ((U ^ B0) ^ B0);

I add to the createFields.H, following the tutorial, the following:

Info<< "Reading field PotE\n" << endl;
volVectorField PotE
(
IOobject
(
"PotE",
runTime.timeName(),
mesh,
IOobject::MUST_READ,
IOobject::AUTO_WRITE
&nbsp,
mesh
);

Similarly for B0, and phi etc. but I get errors like:

EpotFoam.C:31:90: error: conversion from 'Foam::tmp<Foam::GeometricField<Foam::Tensor<doubl e>, Foam::fvPatchField, Foam::volMesh> >' to non-scalar type 'Foam::volVectorField' requested

Does this mean I am not defining the class of the field correctly?
When in more doubt, check the code documentation. For example: http://foam.sourceforge.net/docs/cpp...ce.html#l00055
Basically, the problem is that "volVectorField" is of this type (Line 55 of volFieldsFwd.H):
Code:
typedef GeometricField<vector, fvPatchField, volMesh> volVectorField;
AFAIK, the conversion fails because "tensor" and "vector" are not compatible. So it looks like something on the equation is not working as you would expect. So you better check the types of each item and operation on the equation.

Quote:
Originally Posted by fferroni View Post
Basically, what I'm trying to achieve is reconstruct current density and potential field from a magnetic field...
I'm not 100% certain about this, but "applications/solvers/electromagnetics/magneticFoam" might have what you need or at least give you some more ideas.

If anyone else has more experience than me here on the forum, please do reply!

Best regards,
Bruno
wyldckat is offline   Reply With Quote

Old   January 28, 2012, 09:20
Default
  #5
Member
 
Join Date: Nov 2011
Posts: 44
Rep Power: 5
fferroni is on a distinguished road
Thanks that was very useful.
Managed to iron out most of the errors by understanding the required classes.

However, there is one that I don't understand.

EpotFoam.C:96:44: error: no matching function for call to 'laplacian(Foam::scalar&, Foam::volScalarField&)'

I have:
fvm::laplacian(consist,PotE) == consist * fvc::div(psiub)

where consist is defined as a scalar, and PotE as a volScalarField.

From the Programmers Guide,
laplacian(Gamma,phi)
it seems to say that Gamma can be a scalar, and phi can be a volScalarField... so I don't see why it gives me an error...

Any ideas?

Kind Regards,

Francesco
fferroni is offline   Reply With Quote

Old   January 28, 2012, 10:05
Default
  #6
Super Moderator
 
Bruno Santos
Join Date: Mar 2009
Location: Lisbon, Portugal
Posts: 8,258
Blog Entries: 34
Rep Power: 84
wyldckat is just really nicewyldckat is just really nicewyldckat is just really nicewyldckat is just really nice
Hi Francesco,

You gotta be cautious with what is written on the Programmers Guide, because it hasn't been properly reviewed for quite a while: http://www.openfoam.org/archive/1.6/docs/

But according to the source code documentation, on the "Foam::fvm Namespace Reference" (here), the closest I can find are these two:
Code:
template<class Type , class GType >  tmp< fvMatrix< Type > > laplacian (const dimensioned< GType > &gamma, const GeometricField< Type, fvPatchField, volMesh > &vf, const word &name)
template<class Type , class GType >  tmp< fvMatrix< Type > > laplacian (const dimensioned< GType > &gamma, const GeometricField< Type, fvPatchField, volMesh > &vf)
Basically, when Gamma is a "dimensioned< GType >".

Best regards,
Bruno
wyldckat is offline   Reply With Quote

Old   January 28, 2012, 18:24
Default
  #7
Member
 
Join Date: Nov 2011
Posts: 44
Rep Power: 5
fferroni is on a distinguished road
Yay. It compiles now... dimensionedScalar seems to have done the trick. Thank you!


I now have another n00b question..*sigh*

When I run the solver, it gives me an IO error because I haven't given it sufficient boundary conditions.
There are some variables however that I have had to define in define.H that I don't know the boundary conditions. It's just calculated from some other term which I know... I tried doing

inlet
{
type calculated;
}
but it doesn't seem to be working. Do you know how to write this correctly?

Cheers,

Francesco
fferroni is offline   Reply With Quote

Old   January 28, 2012, 20:25
Default
  #8
Super Moderator
 
Bruno Santos
Join Date: Mar 2009
Location: Lisbon, Portugal
Posts: 8,258
Blog Entries: 34
Rep Power: 84
wyldckat is just really nicewyldckat is just really nicewyldckat is just really nicewyldckat is just really nice
Hi Francesco,

As with any boundary conditions, you need to know what kind of simulation you are doing, so you can have a better understanding of the necessary boundary conditions. But failing that, you can always try the usual suspects: fixed value, zero gradient and calculated. And alternate around each patch, in an attempt to have a viable solver functionality. For example, inlet with fixed value and outlet with zero gradient and then vice-versa.

But when in doubt, the best thing to do is to reduce the problem to the smallest thing you can do math yourself, such as 2D case with an inlet and an outlet. Pretty much one of those unit tests of comparing the simulation results with the analytical/theoretical solutions.

Good luck!
Bruno
wyldckat 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
Creating New Solver: For particle-laden compressible jets sankarv OpenFOAM Running, Solving & CFD 17 December 3, 2014 20:41
Working directory via command line Luiz CFX 4 March 6, 2011 21:02
why the solver reject it? Anyone with experience? bearcat CFX 6 April 28, 2008 14:08
Problems about compiling a new solver fw407 OpenFOAM Running, Solving & CFD 1 December 27, 2007 14:52
Problems about compiling a new solver fw407 OpenFOAM Bugs 0 December 23, 2007 18:03


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