compiling a solver
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?
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!
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;
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...
I don't know the solution :(, but looking at more OpenFOAM code might help you :)
Basically, the problem is that "volVectorField" is of this type (Line 55 of volFieldsFwd.H):
If anyone else has more experience than me here on the forum, please do reply!
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&)'
fvm::laplacian(consist,PotE) == consist * fvc::div(psiub)
where consist is defined as a scalar, and PotE as a volScalarField.
From the Programmers Guide,
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...
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:
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
but it doesn't seem to be working. Do you know how to write this correctly?
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.
|All times are GMT -4. The time now is 12:28.|