|
[Sponsors] |
January 24, 2014, 15:37 |
Constructing vector from three scalars
|
#1 |
Member
India
Join Date: Oct 2012
Posts: 84
Rep Power: 13 |
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 |
|
January 24, 2014, 15:59 |
|
#2 |
Senior Member
Lieven
Join Date: Dec 2011
Location: Leuven, Belgium
Posts: 299
Rep Power: 22 |
Hi Mayank,
Simply try Code:
vector f(e,c,0); L |
|
January 27, 2014, 17:00 |
|
#3 |
Member
India
Join Date: Oct 2012
Posts: 84
Rep Power: 13 |
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? |
|
January 27, 2014, 21:45 |
|
#4 | |
New Member
Join Date: Nov 2012
Posts: 13
Rep Power: 13 |
Quote:
|
||
January 28, 2014, 00:08 |
|
#5 |
Member
India
Join Date: Oct 2012
Posts: 84
Rep Power: 13 |
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. |
|
January 28, 2014, 01:21 |
|
#6 |
Senior Member
Lieven
Join Date: Dec 2011
Location: Leuven, Belgium
Posts: 299
Rep Power: 22 |
Hi Mayank,
To construct a dimensionedScalar and dimensionedVector: Code:
dimensionedScalar scalarTest("s",dimLength,1.0); dimensionedVector vectorTest("v",dimLength,vector(1,1,1)); Code:
dimensionedVector f("f",dimLength,vector(r.x(),r.y(),0)); Code:
dimensionedVector f = p.position(); f.component(Vector::Z) = 0; Lieven |
|
January 28, 2014, 01:49 |
|
#7 |
Member
India
Join Date: Oct 2012
Posts: 84
Rep Power: 13 |
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"? |
|
January 28, 2014, 02:36 |
|
#8 | |
New Member
Join Date: Nov 2012
Posts: 13
Rep Power: 13 |
Quote:
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; |
||
January 28, 2014, 16:07 |
|
#9 |
Member
India
Join Date: Oct 2012
Posts: 84
Rep Power: 13 |
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; } 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$ |
|
Thread Tools | Search this Thread |
Display Modes | |
|
|
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 |