Constructing vector from three scalars
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 |
Hi Mayank,
Simply try Code:
vector f(e,c,0); L |
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? |
Quote:
|
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. |
Hi Mayank,
To construct a dimensionedScalar and dimensionedVector: Code:
dimensionedScalar scalarTest("s",dimLength,1.0); Code:
dimensionedVector f("f",dimLength,vector(r.x(),r.y(),0)); Code:
dimensionedVector f = p.position(); Lieven |
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"? |
Quote:
Code:
extern const dimensionSet dimless; |
Thank you guys for your help. I tested what u guys suggested.
I tried something like this: Code:
// * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * // 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::parcelType&, Foam::scalar, Foam::scalar, Foam::scalar, Foam::scalar) const [with CloudType = Foam::KinematicCloud<Foam::Cloud<Foam::KinematicPa rcel<Foam::particle> > >, typename CloudType::parcelType = Foam::KinematicParcel<Foam::particle>, 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>::operator=(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$ |
All times are GMT -4. The time now is 08:48. |