CFD Online Logo CFD Online URL
www.cfd-online.com
[Sponsors]
Home > Forums > Software User Forums > OpenFOAM > OpenFOAM Running, Solving & CFD

Understanding dimensionedScalar

Register Blogs Community New Posts Updated Threads Search

Like Tree2Likes
  • 1 Post By lr103476
  • 1 Post By chiven

Reply
 
LinkBack Thread Tools Search this Thread Display Modes
Old   July 19, 2007, 12:31
Default Hi OpenFOAM users I have tr
  #1
Senior Member
 
Join Date: Mar 2009
Posts: 248
Rep Power: 18
jaswi is on a distinguished road
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
jaswi is offline   Reply With Quote

Old   July 19, 2007, 13:40
Default Hi Jaswinder, I think that
  #2
Senior Member
 
Frank Bos
Join Date: Mar 2009
Location: The Netherlands
Posts: 340
Rep Power: 18
lr103476 is on a distinguished road
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
lr103476 is offline   Reply With Quote

Old   July 19, 2007, 13:52
Default Hi Frank Is there any other
  #3
Senior Member
 
Join Date: Mar 2009
Posts: 248
Rep Power: 18
jaswi is on a distinguished road
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
jaswi is offline   Reply With Quote

Old   July 19, 2007, 14:08
Default Hi Frank I just wanted to
  #4
Senior Member
 
Join Date: Mar 2009
Posts: 248
Rep Power: 18
jaswi is on a distinguished road
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
jaswi is offline   Reply With Quote

Old   July 19, 2007, 16:04
Default Hi Jaswinder, What exactly
  #5
Senior Member
 
Frank Bos
Join Date: Mar 2009
Location: The Netherlands
Posts: 340
Rep Power: 18
lr103476 is on a distinguished road
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
Luttappy likes this.
__________________
Frank Bos
lr103476 is offline   Reply With Quote

Old   July 19, 2007, 22:46
Default Thanks Frank It worked :-)
  #6
Senior Member
 
Join Date: Mar 2009
Posts: 248
Rep Power: 18
jaswi is on a distinguished road
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
jaswi is offline   Reply With Quote

Old   October 20, 2009, 21:03
Default
  #7
Senior Member
 
J. Cai
Join Date: Apr 2009
Posts: 180
Rep Power: 17
chiven is on a distinguished road
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

// ************************************************** *********************** //
mm.abdollahzadeh likes this.
chiven is offline   Reply With Quote

Old   December 4, 2014, 12:55
Default
  #8
New Member
 
Ral Bielawski
Join Date: Oct 2014
Posts: 3
Rep Power: 11
BielawskiR is on a distinguished road
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.
BielawskiR is offline   Reply With Quote

Reply


Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are Off
Pingbacks are On
Refbacks are On


Similar Threads
Thread Thread Starter Forum Replies Last Post
Understanding interFoam sega OpenFOAM Running, Solving & CFD 26 February 10, 2022 03:21
Understanding k from kepsilon markh83 OpenFOAM Post-Processing 3 December 5, 2008 03:42
Suggestion Molecular weight as a dimensionedScalar marĂ­a OpenFOAM Bugs 0 April 17, 2008 11:23
Understanding ODE transFuncj0 david_flo1 OpenFOAM Running, Solving & CFD 1 March 8, 2008 12:30
LUSGS understanding Gustavo Main CFD Forum 0 February 14, 2007 10:12


All times are GMT -4. The time now is 23:15.