|
[Sponsors] |
July 19, 2007, 13:31 |
Hi OpenFOAM users
I have tr
|
#1 |
Senior Member
Join Date: Mar 2009
Posts: 248
Rep Power: 18 |
Hi OpenFOAM users
I have tried the following and do not understand why it doesn't works. I have declared a dimensioned scalar, followed by a volVectorField. I need to change "X" component of the mesh.C() field by a constant value , i.e. ecentricity. after doing this operation when i print out the newCellCenter, I found that it hasn't changed. dimensionedScalar excenter ( "excenter", dimensionSet(0,1,0,0,0,0,0), scalar(3.0) ); volVectorField newCellCentres = mesh.C(); newCellCentres.component(0) = (mesh.C().component(0) - excenter); newCellCentres.component(1) = mesh.C().component(1); newCellCentres.component(2) = mesh.C().component(2); When I tried this in the creatField.H volScalarField WALLPOS ( IOobject ( "WALLPOS", runTime.timeName(), mesh, IOobject::NO_READ, IOobject::AUTO_WRITE ),mesh.C().component(0) - excenter ); It does writes the expected values. What am I doing wrong !!!! Please comment With best Regards Jaswinder |
|
July 19, 2007, 14:40 |
Hi Jaswinder,
I think that
|
#2 |
Senior Member
Frank Bos
Join Date: Mar 2009
Location: The Netherlands
Posts: 340
Rep Power: 18 |
Hi Jaswinder,
I think that you are not allowed to change the value of mesh.C(). That member function (found in fvMesh class) returns a const. Frank
__________________
Frank Bos |
|
July 19, 2007, 14:52 |
Hi Frank
Is there any other
|
#3 |
Senior Member
Join Date: Mar 2009
Posts: 248
Rep Power: 18 |
Hi Frank
Is there any other way I could save a volVectorField comprising of mesh.C() and then change one of its components and use it for further computations. Thanks in advance Regards Jaswinder |
|
July 19, 2007, 15:08 |
Hi Frank
I just wanted to
|
#4 |
Senior Member
Join Date: Mar 2009
Posts: 248
Rep Power: 18 |
Hi Frank
I just wanted to inform that when i do the following Info << "New X component "<< newCellCentres.component(0) -excenter <<endl; where excenter = 3.0 then i do get as an output what i am expecting. Now i am wondering why is it not possible to do it as i have tried in my original post Regards Jaswinder |
|
July 19, 2007, 17:04 |
Hi Jaswinder,
What exactly
|
#5 |
Senior Member
Frank Bos
Join Date: Mar 2009
Location: The Netherlands
Posts: 340
Rep Power: 18 |
Hi Jaswinder,
What exactly do you want? You can't change the value of mesh.C() directly, instead you should create a volScalarField containing the x component and modify that field accordingly. If your intention is to move the cell centres, you should create a pointField newPoints = mesh.points(), move those points using your excenter, update the mesh and your mesh.C() will be changed accordingly. Regards, Frank
__________________
Frank Bos |
|
July 19, 2007, 23:46 |
Thanks Frank
It worked :-)
|
#6 |
Senior Member
Join Date: Mar 2009
Posts: 248
Rep Power: 18 |
Thanks Frank
It worked :-) By the way i do not need to move the mesh but your clue did solve my problem Thanks once again Regards Jaswinder |
|
October 20, 2009, 22:03 |
|
#7 |
Senior Member
J. Cai
Join Date: Apr 2009
Posts: 180
Rep Power: 17 |
Hi, Foamers, I want to modify "dimensoionedScalar rho1_" to "const volScalarField& rho1_", how can I do it? Thank you very much. Chiven
\*---------------------------------------------------------------------------*/ #include "twoPhaseMixture.H" #include "addToRunTimeSelectionTable.H" #include "surfaceFields.H" #include "fvc.H" // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // namespace Foam { // * * * * * * * * * * * * Private Member Functions * * * * * * * * * * * * // //- Calculate and return the laminar viscosity void twoPhaseMixture::calcNu() { nuModel1_->correct(); nuModel2_->correct(); volScalarField limitedAlpha1 ( "limitedAlpha1", min(max(alpha1_, scalar(0)), scalar(1)) ); // Average kinematic viscosity calculated from dynamic viscosity nu_ = mu()/(limitedAlpha1*rho1_ + (scalar(1) - limitedAlpha1)*rho2_); } // * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * // twoPhaseMixture::twoPhaseMixture ( const volVectorField& U, const surfaceScalarField& phi, const word& alpha1Name ) : transportModel(U, phi), phase1Name_("phase1"), phase2Name_("phase2"), nuModel1_ ( viscosityModel::New ( "nu1", subDict(phase1Name_), U, phi ) ), nuModel2_ ( viscosityModel::New ( "nu2", subDict(phase2Name_), U, phi ) ), rho1_(nuModel1_->viscosityProperties().lookup("rho")), rho2_(nuModel2_->viscosityProperties().lookup("rho")), U_(U), phi_(phi), alpha1_(U_.db().lookupObject<const volScalarField> (alpha1Name)), nu_ ( IOobject ( "nu", U_.time().timeName(), U_.db() ), U_.mesh(), dimensionedScalar("nu", dimensionSet(0, 2, -1, 0, 0), 0), calculatedFvPatchScalarField::typeName ) { calcNu(); } // * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * * // tmp<volScalarField> twoPhaseMixture::mu() const { volScalarField limitedAlpha1 = min(max(alpha1_, scalar(0)), scalar(1)); return tmp<volScalarField> ( new volScalarField ( "mu", limitedAlpha1*rho1_*nuModel1_->nu() + (scalar(1) - limitedAlpha1)*rho2_*nuModel2_->nu() ) ); } tmp<surfaceScalarField> twoPhaseMixture::muf() const { surfaceScalarField alpha1f = min(max(fvc::interpolate(alpha1_), scalar(0)), scalar(1)); return tmp<surfaceScalarField> ( new surfaceScalarField ( "muf", alpha1f*rho1_*fvc::interpolate(nuModel1_->nu()) + (scalar(1) - alpha1f)*rho2_*fvc::interpolate(nuModel2_->nu()) ) ); } tmp<surfaceScalarField> twoPhaseMixture::nuf() const { surfaceScalarField alpha1f = min(max(fvc::interpolate(alpha1_), scalar(0)), scalar(1)); return tmp<surfaceScalarField> ( new surfaceScalarField ( "nuf", ( alpha1f*rho1_*fvc::interpolate(nuModel1_->nu()) + (scalar(1) - alpha1f)*rho2_*fvc::interpolate(nuModel2_->nu()) )/(alpha1f*rho1_ + (scalar(1) - alpha1f)*rho2_) ) ); } bool twoPhaseMixture::read() { if (transportModel::read()) { if ( nuModel1_().read(subDict(phase1Name_)) && nuModel2_().read(subDict(phase2Name_)) ) { nuModel1_->viscosityProperties().lookup("rho") >> rho1_; nuModel2_->viscosityProperties().lookup("rho") >> rho2_; return true; } else { return false; } } else { return false; } } // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // } // End namespace Foam // ************************************************** *********************** // |
|
December 4, 2014, 13:55 |
|
#8 |
New Member
Ral Bielawski
Join Date: Oct 2014
Posts: 3
Rep Power: 12 |
I believe that the root of why you couldn't change the component is because mesh.c is a actually two arrays added together, one that contains all the points (number of cells by 3) and then one array that is the dimensions (1 by 7). So if you looped through mesh.c so you where editing each cell one at a time it would work.
|
|
|
|
Similar Threads | ||||
Thread | Thread Starter | Forum | Replies | Last Post |
Understanding interFoam | sega | OpenFOAM Running, Solving & CFD | 26 | February 10, 2022 04:21 |
Understanding k from kepsilon | markh83 | OpenFOAM Post-Processing | 3 | December 5, 2008 04:42 |
Suggestion Molecular weight as a dimensionedScalar | marĂa | OpenFOAM Bugs | 0 | April 17, 2008 12:23 |
Understanding ODE transFuncj0 | david_flo1 | OpenFOAM Running, Solving & CFD | 1 | March 8, 2008 13:30 |
LUSGS understanding | Gustavo | Main CFD Forum | 0 | February 14, 2007 11:12 |