CFD Online Discussion Forums

CFD Online Discussion Forums (http://www.cfd-online.com/Forums/)
-   OpenFOAM Programming & Development (http://www.cfd-online.com/Forums/openfoam-programming-development/)
-   -   Troubles when create a new volScalarField in my own library (http://www.cfd-online.com/Forums/openfoam-programming-development/119523-troubles-when-create-new-volscalarfield-my-own-library.html)

mxylondon June 19, 2013 04:44

Troubles when create a new volScalarField in my own library
 
Dear all,

I'm struggling to create a new volScalarField variable in my own function before compiling my own source code, the exactly same thing like pressure, density, viscosity, etc.
But failed again and again, any suggestion please?:confused:

nimasam June 19, 2013 04:50

fail? your question is too vague, atleast post your error line

mxylondon June 19, 2013 05:18

error: no matching function for call to ‘Foam::GeometricField<double, Foam::fvPatchField, Foam::volMesh>::GeometricField()’

nimasam June 19, 2013 08:10

would you mind!, add your pieces of code here too ;)

Bernhard June 19, 2013 10:48

Quote:

Originally Posted by mxylondon (Post 434787)
But failed again and again, any suggestion please?:confused:

Suggestion: copy existing code from a solver and rename the variables.

mxylondon June 19, 2013 12:26

Quote:

Originally Posted by nimasam (Post 434821)
would you mind!, add your pieces of code here too ;)

A very simple test, the header file (XXX.H) is:

#include "fvCFD.H"
#include "IOstream.H"
#include "messageStream.H"

namespace Foam
{
namespace Test
{
class Try
{
public:
volScalarField value1,value2;
static volScalarField newField( );
};
}
}

The implement file (XXX.C) is:

#include "XXX.H"

namespace Foam
{
namespace Test
{
volScalarField value1;
volScalarField Try::newField( );
volScalarField value2;
value2=value1;
return (value2);
}
}


To generate a new library, I have tried with some 'int' type functions and variables in this way, they can be compiled and work well to be called in a main program.
But when the variable type is 'volScalarField', did I miss something? Like other header files to include?

Bernhard June 20, 2013 02:42

As far as I can see, you are trying to call a volScalarField constructor without any arguments. There is no such constructor, see: http://foam.sourceforge.net/docs/cpp/a00776.html , to construct a volScalarField, you need at least a mesh somewhere.


All times are GMT -4. The time now is 09:01.