volScalarField
HI all,
I have a little problem with a volScalarField, I have create that field in a class where is not defined the runTime object, but I want create a volScalarField that than I fill in that way: __________________________________________________ ______ volScalarField alfa ( IOobject ( "alfa", fileName(), mesh_, IOobject::NO_READ, IOobject::NO_WRITE ), mesh_ ); forAll(cells, i) { label lab=cells[i]; if(IntCell_[lab]) alfa.internalField()[lab]=1; else alfa.internalField()[lab]=0; } __________________________________________________ ______ All can be compiled but when I run the solver that use that class I have that error: __________________________________________________ ______ /*---------------------------------------------------------------------------*\ | ========= | | | \\ / F ield | OpenFOAM: The Open Source CFD Toolbox | | \\ / O peration | Version: 1.7.x | | \\ / A nd | Web: www.OpenFOAM.com | | \\/ M anipulation | | \*---------------------------------------------------------------------------*/ Build : 1.7.x-a654f2c8b4fb Exec : MYMRFSimpleFoam Date : Nov 17 2010 Time : 15:30:43 Host : salaria PID : 11695 Case : /home/diego/OpenFOAM/diego-1.7.x/run/VerificaMRF/SimplePropeller nProcs : 1 SigFpe : Enabling floating point exception trapping (FOAM_SIGFPE). // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // Create time Create mesh for time = 0 Reading field p Reading field U Reading/calculating face flux field phi Selecting incompressible transport model Newtonian Selecting RAS turbulence model kOmegaSST kOmegaSSTCoeffs { alphaK1 0.85034; alphaK2 1; alphaOmega1 0.5; alphaOmega2 0.85616; gamma1 0.5532; gamma2 0.4403; beta1 0.075; beta2 0.0828; betaStar 0.09; a1 0.31; c1 10; } Starting time loop Time = 1 --> FOAM FATAL ERROR: NO_READ specified for read-constructor of object alfa of class IOobject From function regIOobject::readStream() in file db/regIOobject/regIOobjectRead.C at line 46. FOAM aborting #0 Foam::error::printStack(Foam::Ostream&) in "/home/diego/OpenFOAM/OpenFOAM-1.7.x/lib/linux64GccDPOpt/libOpenFOAM.so" #1 Foam::error::abort() in "/home/diego/OpenFOAM/OpenFOAM-1.7.x/lib/linux64GccDPOpt/libOpenFOAM.so" #2 Foam::regIOobject::readStream() in "/home/diego/OpenFOAM/OpenFOAM-1.7.x/lib/linux64GccDPOpt/libOpenFOAM.so" #3 Foam::regIOobject::readStream(Foam::word const&) in "/home/diego/OpenFOAM/OpenFOAM-1.7.x/lib/linux64GccDPOpt/libOpenFOAM.so" #4 Foam::GeometricField<double, Foam::fvPatchField, Foam::volMesh>::GeometricField(Foam::IOobject const&, Foam::fvMesh const&) in "/home/diego/OpenFOAM/diego-1.7.x/applications/bin/linux64GccDPOpt/MYMRFSimpleFoam" #5 Foam::MRFZone::correctVelocityEquation(Foam::fvMat rix<Foam::Vector<double> >&, Foam::GeometricField<double, Foam::fvsPatchField, Foam::surfaceMesh>&, Foam::GeometricField<double, Foam::fvsPatchField, Foam::surfaceMesh>&) const in "/home/diego/OpenFOAM/diego-1.7.x/applications/bin/linux64GccDPOpt/MYMRFSimpleFoam" #6 Foam::regIOobject::writeObject(Foam::IOstream::str eamFormat, Foam::IOstream::versionNumber, Foam::IOstream::compressionType) const in "/home/diego/OpenFOAM/diego-1.7.x/applications/bin/linux64GccDPOpt/MYMRFSimpleFoam" #7 main in "/home/diego/OpenFOAM/diego-1.7.x/applications/bin/linux64GccDPOpt/MYMRFSimpleFoam" #8 __libc_start_main in "/lib/libc.so.6" #9 Foam::regIOobject::writeObject(Foam::IOstream::str eamFormat, Foam::IOstream::versionNumber, Foam::IOstream::compressionType) const in "/home/diego/OpenFOAM/diego-1.7.x/applications/bin/linux64GccDPOpt/MYMRFSimpleFoam" Aborted __________________________________________________ ______ Someone have an idea on which is the problem? |
ur ioDic difinition is ill, use something like this:
volScalarField alfa ( IOobject ( "alfa", fileName(), mesh_, IOobject::NO_READ, // when u use no read u should initialize ur variable IOobject::NO_WRITE ), mesh_, dimensionScalar ("alfa",dimensionSet (0,0,....), 0) // this is just for initializing ); ok? ;) |
Thank you very much nima,
Now it's work well. |
Hi all,
I have another question to this topic. In createField.H I create a volScalarField Code:
volScalarField kappa Code:
tmp<volScalarField> compressibleTwoPhaseMixture::kappa() const Code:
tmp<volScalarField> compressibleTwoPhaseMixture::kappa() const 1) Does the first implementation allocate a new memory block for the whole volScalarField, even if the volScalarField kappa already exists? I would waste memory if so. 2) Where and why the IOobject::AUTO_WRITE is being overwritten? 3) Is the second implementation write? Does it have any drawbacks? Best regards, Ilya |
1) Yes. Not only that, it creates a totally independent object that contains only the initial values of kappa. These values will never change throughout your simulation.
2) Probably gets overwritten in the GeometricField constructor. You can look through the list of constructors and choose one that suits you. 3) ? What are you trying to achieve? Do you want kappa written out at every timestep, when it normally doesn't? I don't know how the mixture models work. You could use your first implementation, except change the constructor you use. Maybe give it a dimensioned scalar instead of the whole field. Code:
... |
Thank you David for the reply!
Quote:
Quote:
Quote:
Code:
tmp<volScalarField> compressibleTwoPhaseMixture::kappa() const Ilya |
Quote:
I'm sorry I didn't notice this: your kappa() function returns tmp<>. It is a temporary object. There is no permanent storage for kappa, therefore you aren't being wasteful by keeping a copy at the solver level. But you need to keep it up to date at every timestep before runTime.write() by setting it equal to the result of the function call as I suggested above. |
Thanks once again David.
Quote:
Quote:
|
All times are GMT -4. The time now is 15:27. |