|
[Sponsors] |
November 17, 2010, 16:57 |
volScalarField
|
#1 |
Member
Diego Villa
Join Date: Mar 2010
Location: Genova Italy
Posts: 37
Rep Power: 16 |
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:rintStack(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? |
|
November 18, 2010, 04:49 |
|
#2 |
Senior Member
Nima Samkhaniani
Join Date: Sep 2009
Location: Tehran, Iran
Posts: 1,267
Blog Entries: 1
Rep Power: 25 |
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? |
|
November 18, 2010, 12:30 |
|
#3 |
Member
Diego Villa
Join Date: Mar 2010
Location: Genova Italy
Posts: 37
Rep Power: 16 |
Thank you very much nima,
Now it's work well. |
|
January 30, 2012, 10:06 |
|
#4 |
Senior Member
Illya Shevchuk
Join Date: Aug 2009
Location: Darmstadt, Germany
Posts: 176
Rep Power: 17 |
Hi all,
I have another question to this topic. In createField.H I create a volScalarField Code:
volScalarField kappa ( IOobject ( "kappa", runTime.timeName(), mesh, IOobject::NO_READ, IOobject::AUTO_WRITE ), twoPhaseProperties.kappa() ); Code:
tmp<volScalarField> compressibleTwoPhaseMixture::kappa() const { return tmp<volScalarField> ( new volScalarField ( "kappa", limitedAlpha1*kappaModel1_->kappa() + (scalar(1) - limitedAlpha1)*kappaModel2_->kappa() ) ); } Code:
tmp<volScalarField> compressibleTwoPhaseMixture::kappa() const { return tmp<volScalarField> ( limitedAlpha1*kappaModel1_->kappa() + (scalar(1) - limitedAlpha1)*kappaModel2_->kappa() ); } 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 |
|
January 30, 2012, 12:58 |
|
#5 |
Senior Member
David Gaden
Join Date: Apr 2009
Location: Winnipeg, Canada
Posts: 437
Rep Power: 22 |
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:
... IOobject ( ... ), mesh, dimensionedScalar ( "kappa", twoPhaseProperties.kappa().dimensions(), 0.0 ) );
__________________
~~~ Follow me on twitter @DavidGaden |
|
February 1, 2012, 14:42 |
|
#6 | ||
Senior Member
Illya Shevchuk
Join Date: Aug 2009
Location: Darmstadt, Germany
Posts: 176
Rep Power: 17 |
Thank you David for the reply!
Quote:
Quote:
Well, kappa is different in each cell (e.g. it could be pressure or temperature dependent), thus volScalarField is ok. My goal is to make my two phase properties library, which is generally usable. One could either use the properties directly (e.g. fvm::laplacian(twoPhaseProperties.kappaf(),T) ) or to update an already existing field (e.g. kappa = twoPhaseProperties.kappa()). In the last case I want to prevent the double usage of memory. But I'm not sure if my second variant is right: Code:
tmp<volScalarField> compressibleTwoPhaseMixture::kappa() const { return tmp<volScalarField> ( new volScalarField ( "kappa", limitedAlpha1*kappaModel1_->kappa() + (scalar(1) - limitedAlpha1)*kappaModel2_->kappa() ) ); } Ilya |
|||
February 1, 2012, 14:49 |
|
#7 | |
Senior Member
David Gaden
Join Date: Apr 2009
Location: Winnipeg, Canada
Posts: 437
Rep Power: 22 |
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.
__________________
~~~ Follow me on twitter @DavidGaden |
||
February 2, 2012, 04:04 |
|
#8 | |
Senior Member
Illya Shevchuk
Join Date: Aug 2009
Location: Darmstadt, Germany
Posts: 176
Rep Power: 17 |
Thanks once again David.
Quote:
That's clear. |
||
|
|
Similar Threads | ||||
Thread | Thread Starter | Forum | Replies | Last Post |
How to create initiate a volScalarField p without reading from disk NO_READ does not seem to work | dbxmcf | OpenFOAM Running, Solving & CFD | 14 | March 25, 2022 07:08 |
if-loop, volScalarField comparison | volker | OpenFOAM | 7 | March 6, 2020 21:03 |
Problems with creating a volScalarField | georlade | OpenFOAM Programming & Development | 4 | December 4, 2016 13:31 |
Fill a volScalarField | DiegoNaval | OpenFOAM Programming & Development | 6 | November 19, 2010 10:26 |
dimensioned volScalarField | lions85 | OpenFOAM | 1 | November 12, 2009 03:41 |