CFD Online Logo CFD Online URL
www.cfd-online.com
[Sponsors]
Home > Forums

access to data

Register Blogs Community New Posts Updated Threads Search

Rate this Entry

access to data

Posted February 28, 2017 at 06:17 by kindle
Updated February 28, 2017 at 13:41 by kindle

// access to field<Type>

Ex: in /finiteVolume/fields/fvPatchField/derived/turbulentInlet.C.
This class is templated, here we take a example for vector field:

Code:
Field<vector> randomField(this->size());
to have access to x-component for example
Code:
Info << "randomField = " << randomField.component(vector::X) <<
    endl;
// vector::X=0 this enum equals to 0 as enum's defaut value: Y=1, Z=2
where ".component" is a member function to return component field of a field : meaning the return type is still a field.
It seems that vectorField is a List of vectors and that when returning calling .component it returns a scalarField (maybe, at least I expected), therefore cmptType in the following (field.H) is scalar not a vector :

Code:
  
333         //- Return a component field of the field
334         tmp<Field<cmptType>> component(const direction) const;
But randomField is of field<vector> type and Type must be replaced by vector. The return type of the above function is then tmp<Field<pTraits<vector>> not really a scalar field as we expected !!

Code:
   
86     //- Component type
87     typedef typename pTraits<Type>::cmptType cmptType;
// access to dimensioned<Type>
// src/OpenFOAM/dimensionedTypes/dimensionedType/dimensionedType.H
need to perform accessor .value()
Posted in programming
Views 1082 Comments 0 Edit Tags Email Blog Entry
« Prev     Main     Next »
Total Comments 0

Comments

 

All times are GMT -4. The time now is 09:53.