|
[Sponsors] |
January 25, 2012, 18:43 |
compiling a solver
|
#1 |
Member
Join Date: Nov 2011
Posts: 44
Rep Power: 15 |
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 |
|
January 25, 2012, 19:39 |
|
#2 |
Retired Super Moderator
Bruno Santos
Join Date: Mar 2009
Location: Lisbon, Portugal
Posts: 10,981
Blog Entries: 45
Rep Power: 128 |
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
__________________
|
|
January 26, 2012, 18:02 |
|
#3 |
Member
Join Date: Nov 2011
Posts: 44
Rep Power: 15 |
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 |
|
January 28, 2012, 03:52 |
|
#4 | |||
Retired Super Moderator
Bruno Santos
Join Date: Mar 2009
Location: Lisbon, Portugal
Posts: 10,981
Blog Entries: 45
Rep Power: 128 |
Hi Francesco,
Quote:
I don't know the solution , but looking at more OpenFOAM code might help you Quote:
Basically, the problem is that "volVectorField" is of this type (Line 55 of volFieldsFwd.H): Code:
typedef GeometricField<vector, fvPatchField, volMesh> volVectorField; Quote:
If anyone else has more experience than me here on the forum, please do reply! Best regards, Bruno
__________________
|
||||
January 28, 2012, 09:20 |
|
#5 |
Member
Join Date: Nov 2011
Posts: 44
Rep Power: 15 |
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 |
|
January 28, 2012, 10:05 |
|
#6 |
Retired Super Moderator
Bruno Santos
Join Date: Mar 2009
Location: Lisbon, Portugal
Posts: 10,981
Blog Entries: 45
Rep Power: 128 |
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) Best regards, Bruno
__________________
|
|
January 28, 2012, 18:24 |
|
#7 |
Member
Join Date: Nov 2011
Posts: 44
Rep Power: 15 |
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 |
|
January 28, 2012, 20:25 |
|
#8 |
Retired Super Moderator
Bruno Santos
Join Date: Mar 2009
Location: Lisbon, Portugal
Posts: 10,981
Blog Entries: 45
Rep Power: 128 |
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
__________________
|
|
|
|
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 15: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 |