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

Constructing vector from three scalars

Register Blogs Members List Search Today's Posts Mark Forums Read

Like Tree1Likes
  • 1 Post By mayank.dce2k7

Reply
 
LinkBack Thread Tools Search this Thread Display Modes
Old   January 24, 2014, 15:37
Default Constructing vector from three scalars
  #1
Member
 
India
Join Date: Oct 2012
Posts: 84
Rep Power: 13
mayank.dce2k7 is on a distinguished road
Hi Foamers,

I have a simple question.....I have a vector defined as below:

const vector& r=p.position();

I have two components found as below:

scalar e= r.x(); scalar c=r.y();

I want to define a vector such that:

vector f= (e c 0);

where e & c are x-component and y-component respectively.......

I have tried tons of combination but I am getting error. I am not good as C++ so please help.....

Regards,
Mayank
kk415 likes this.
mayank.dce2k7 is offline   Reply With Quote

Old   January 24, 2014, 15:59
Default
  #2
Senior Member
 
Lieven
Join Date: Dec 2011
Location: Leuven, Belgium
Posts: 299
Rep Power: 22
Lieven will become famous soon enough
Hi Mayank,

Simply try
Code:
vector f(e,c,0);
Cheers,

L
Lieven is offline   Reply With Quote

Old   January 27, 2014, 17:00
Default
  #3
Member
 
India
Join Date: Oct 2012
Posts: 84
Rep Power: 13
mayank.dce2k7 is on a distinguished road
Thanks a lot Lieven.

I have an additional question:

since vector r=p.position(); its each component will have dimension 'meters'. Will my vector f(e,c,o) will also have dimensions of 'meters' and what will be the units associated with scalar e,c? ALso, if they are all unit less then how can I associate proper units with them?
mayank.dce2k7 is offline   Reply With Quote

Old   January 27, 2014, 21:45
Default
  #4
New Member
 
Join Date: Nov 2012
Posts: 13
Rep Power: 13
lixx is on a distinguished road
Quote:
Originally Posted by mayank.dce2k7 View Post
Thanks a lot Lieven.

I have an additional question:

since vector r=p.position(); its each component will have dimension 'meters'. Will my vector f(e,c,o) will also have dimensions of 'meters' and what will be the units associated with scalar e,c? ALso, if they are all unit less then how can I associate proper units with them?
What you need are dimensionedVector and dimensionedScalar.
lixx is offline   Reply With Quote

Old   January 28, 2014, 00:08
Default
  #5
Member
 
India
Join Date: Oct 2012
Posts: 84
Rep Power: 13
mayank.dce2k7 is on a distinguished road
Lixx, thanks for the reply.

Ya, you are right. I tried but couldn't get it right.Is there a simple way in which I can define vectors and scalars with their dimensions for immediate use in same file? I just want to use it in one file in lagrangian particle force library and then compile it.
mayank.dce2k7 is offline   Reply With Quote

Old   January 28, 2014, 01:21
Default
  #6
Senior Member
 
Lieven
Join Date: Dec 2011
Location: Leuven, Belgium
Posts: 299
Rep Power: 22
Lieven will become famous soon enough
Hi Mayank,

To construct a dimensionedScalar and dimensionedVector:
Code:
    dimensionedScalar scalarTest("s",dimLength,1.0);
    dimensionedVector vectorTest("v",dimLength,vector(1,1,1));
In your case, you could therefore write something like
Code:
dimensionedVector f("f",dimLength,vector(r.x(),r.y(),0));
But I'm wondering if the position() routine does not return a dimensionedVector directly. If that's the case you can write something as:
Code:
dimensionedVector f = p.position();
f.component(Vector::Z) = 0;
Cheers,

Lieven
Lieven is offline   Reply With Quote

Old   January 28, 2014, 01:49
Default
  #7
Member
 
India
Join Date: Oct 2012
Posts: 84
Rep Power: 13
mayank.dce2k7 is on a distinguished road
Thanks Lieven. I'll give it a shot and let u know.

"dimLength" is for length in case one has to define velocity then what will be the replacement of "dimLength"?
mayank.dce2k7 is offline   Reply With Quote

Old   January 28, 2014, 02:36
Default
  #8
New Member
 
Join Date: Nov 2012
Posts: 13
Rep Power: 13
lixx is on a distinguished road
Quote:
Originally Posted by mayank.dce2k7 View Post
Thanks Lieven. I'll give it a shot and let u know.

"dimLength" is for length in case one has to define velocity then what will be the replacement of "dimLength"?
You can refer to $src/OpenFOAM/dimensionSet/dimensionSets.H, where $src means the src directory in your OpenFOAM installation.

Code:
extern const dimensionSet dimless;

extern const dimensionSet dimMass;
extern const dimensionSet dimLength;
extern const dimensionSet dimTime;
extern const dimensionSet dimTemperature;

extern const dimensionSet dimArea;
extern const dimensionSet dimVolume;
extern const dimensionSet dimVol;

extern const dimensionSet dimDensity;
extern const dimensionSet dimForce;
extern const dimensionSet dimEnergy;
extern const dimensionSet dimPower;

extern const dimensionSet dimVelocity;
extern const dimensionSet dimAcceleration;
extern const dimensionSet dimPressure;
In your case you should use 'dimVelocity'.
lixx is offline   Reply With Quote

Old   January 28, 2014, 16:07
Default
  #9
Member
 
India
Join Date: Oct 2012
Posts: 84
Rep Power: 13
mayank.dce2k7 is on a distinguished road
Thank you guys for your help. I tested what u guys suggested.

I tried something like this:

Code:
// * * * * * * * * * * * * * * * Member Functions  * * * * * * * * * * * * * //

template<class CloudType>
Foam::forceSuSp Foam::newForce<CloudType>::calcNonCoupled
(
    const typename CloudType::parcelType& p,
    const scalar dt,
    const scalar mass,
    const scalar Re,
    const scalar muc
) const
{
    forceSuSp value(vector::zero, 0.0);
dimensionedVector D("D", dimForce, vector(1.0,0,0));  
  
    
  
    value.Su() = D;

    return value;
}
I made sure that I assign 'value.Su()' a vector with dimension that of force but when I compiled the library i got these error messages:

Making dependency list for source file parcels/derived/basicReactingMultiphaseParcel/makeBasicReactingMultiphaseParcelSubmodels.C
Making dependency list for source file parcels/derived/basicReactingParcel/makeBasicReactingParcelSubmodels.C
Making dependency list for source file parcels/derived/basicThermoParcel/makeBasicThermoParcelSubmodels.C
Making dependency list for source file parcels/derived/basicKinematicCollidingParcel/makeBasicKinematicCollidingParcelSubmodels.C
Making dependency list for source file parcels/derived/basicKinematicParcel/makeBasicKinematicParcelSubmodels.C
SOURCE=parcels/derived/basicKinematicParcel/makeBasicKinematicParcelSubmodels.C ; g++ -m64 -Dlinux64 -DWM_DP -Wall -Wextra -Wno-unused-parameter -Wold-style-cast -Wnon-virtual-dtor -O3 -DNoRepository -ftemplate-depth-100 -I/opt/openfoam211/src/finiteVolume/lnInclude -I/opt/openfoam211/src/meshTools/lnInclude -I/opt/openfoam211/src/lagrangian/basic/lnInclude -I/opt/openfoam211/src/lagrangian/distributionModels/lnInclude -I/opt/openfoam211/src/thermophysicalModels/specie/lnInclude -I/opt/openfoam211/src/thermophysicalModels/basic/lnInclude -I/opt/openfoam211/src/thermophysicalModels/properties/liquidProperties/lnInclude -I/opt/openfoam211/src/thermophysicalModels/properties/liquidMixtureProperties/lnInclude -I/opt/openfoam211/src/thermophysicalModels/properties/solidProperties/lnInclude -I/opt/openfoam211/src/thermophysicalModels/properties/solidMixtureProperties/lnInclude -I/opt/openfoam211/src/thermophysicalModels/reactionThermo/lnInclude -I/opt/openfoam211/src/thermophysicalModels/SLGThermo/lnInclude -I/opt/openfoam211/src/thermophysicalModels/radiationModels/lnInclude -I/opt/openfoam211/src/turbulenceModels -I/opt/openfoam211/src/transportModels/ -I/opt/openfoam211/src/transportModels/incompressible/lnInclude/ -I/opt/openfoam211/src/turbulenceModels/incompressible/turbulenceModel/lnInclude -I/opt/openfoam211/src/turbulenceModels/incompressible/RAS/lnInclude -I/opt/openfoam211/src/turbulenceModels/LES/LESdeltas/lnInclude -I/opt/openfoam211/src/turbulenceModels/incompressible/LES/lnInclude -I/opt/openfoam211/src/regionModels/regionModel/lnInclude -I/opt/openfoam211/src/regionModels/surfaceFilmModels/lnInclude -I/opt/openfoam211/src/dynamicFvMesh/lnInclude -I/opt/openfoam211/src/sampling/lnInclude -IlnInclude -I. -I/opt/openfoam211/src/OpenFOAM/lnInclude -I/opt/openfoam211/src/OSspecific/POSIX/lnInclude -fPIC -c $SOURCE -o Make/linux64GccDPOpt/makeBasicKinematicParcelSubmodels.o
In file included from lnInclude/newForce.H:125:0,
from lnInclude/makeParcelForces.H:39,
from parcels/derived/basicKinematicParcel/makeBasicKinematicParcelSubmodels.C:31:
lnInclude/newForce.C: In member function ‘Foam::forceSuSp Foam::newForce<CloudType>::calcNonCoupled(const typename CloudType:arcelType&, Foam::scalar, Foam::scalar, Foam::scalar, Foam::scalar) const [with CloudType = Foam::KinematicCloud<Foam::Cloud<Foam::KinematicPa rcel<Foam:article> > >, typename CloudType:arcelType = Foam::KinematicParcel<Foam:article>, Foam::scalar = double]’:
parcels/derived/basicKinematicParcel/makeBasicKinematicParcelSubmodels.C:49:1: instantiated from here
lnInclude/newForce.C:82:5: error: no match for ‘operator=’ in ‘value.Foam::forceSuSp::Su() = D’
lnInclude/newForce.C:82:5: note: candidate is:
/opt/openfoam211/src/OpenFOAM/lnInclude/Vector.H:58:7: note: Foam::Vector<double>& Foam::Vector<double>:perator=(const Foam::Vector<double>&)
/opt/openfoam211/src/OpenFOAM/lnInclude/Vector.H:58:7: note: no known conversion for argument 1 from ‘Foam::dimensionedVector {aka Foam::dimensioned<Foam::Vector<double> >}’ to ‘const Foam::Vector<double>&’
make: *** [Make/linux64GccDPOpt/makeBasicKinematicParcelSubmodels.o] Error 1
mayank@mayank-Precision-WorkStation-T3400:~/OpenFOAM/mayank-2.1.1/platforms/linux64GccDPOpt/src/lagrangian/incompressible/intermediate$
mayank.dce2k7 is offline   Reply With Quote

Reply

Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

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
How to apply Transport Equation on DPM Scalars? yuhai FLUENT 0 May 19, 2010 10:38
generic scalars in star manuutin STAR-CD 0 August 7, 2009 06:05
reconstructParMesh not working with an axisymetric case francesco OpenFOAM Bugs 4 May 8, 2009 05:49
about .run file and information of scalars isidro Siemens 0 March 11, 2004 11:37
The Field Scalars in Tascflow Darcy CFX 0 November 19, 2003 22:14


All times are GMT -4. The time now is 21:00.