|
[Sponsors] |
March 4, 2009, 01:22 |
Hello,
I have a couple of q
|
#1 |
New Member
Peter Johnston
Join Date: Mar 2009
Location: Brisbane, Queensland, Australia
Posts: 25
Rep Power: 17 |
Hello,
I have a couple of questions regarding the use of interpolationTable. I have studied the routine timeVaryingUniformFixedValueFvPatchField.C quite closely. In this routine interpolationTable is instantiated with the name timeSeries_. The interpolation is performed via the line timeSeries_(this->db().time().timeOutputValue()) This line performs an interpolation from a data table given in a file and returns a value. In the above mentioned routine this value is used to set the inlet velocity in flow simulation. My questions are: 1) What is the form (type?) of the value returned after the call to timeSeries_? 2) How can I see (print out) this value? 3) How can I use the value is some other fashion? 4) Can I use the value simply as a scalar (which is what it should be)? Any insights would be much appreciated. Thank you, Peter. |
|
March 4, 2009, 05:49 |
Did you look at the doxygen do
|
#2 |
Senior Member
Mark Olesen
Join Date: Mar 2009
Location: https://olesenm.github.io/
Posts: 1,715
Rep Power: 40 |
Did you look at the doxygen docs for the interpolationTable class?
1) The interpolationTable is templated on Type. It is a list of Tuple2 values, with a scalar as the first element (eg, the time-value) and Type as the entry. 2) Doesn't Info<< myList; work? 3) From the docs, operator[] to lookup via an integer index, operator() to lookup and interpolate via a scalar value. 4) I don't understand what you mean. It is a table of values, how is it supposed to be a scalar? |
|
March 5, 2009, 01:04 |
Dear Mark,
Thank you for yo
|
#3 |
New Member
Peter Johnston
Join Date: Mar 2009
Location: Brisbane, Queensland, Australia
Posts: 25
Rep Power: 17 |
Dear Mark,
Thank you for your ideas. I have had a look at the doxygen pages, but am still coming to terms with what they mean, being new to C++. Perhaps I should explain my example a bit more thoroughly: I have a velocity forcing function in a file which looks like n ( (t0 (u0 v0 w0)) (t1 (u1 v1 w1)) . . . ) When I use the line Info << timeSeries_(tt); I get the values (ut vt wt) appearing on the screen. The output is then a vector? What I would like to do is assign the output from the command timeSeries_(tt) to some variable something like velocity = timeSeries_(tt); Of the many things I have tried, nothing compiles, complaining of type mismatches and coercion errors. I wish to be able to access the variable wt (from above) as a scalar constant and multiply it by a vector field I have created. Thanks again, Peter. |
|
March 5, 2009, 03:20 |
I'm not sure about your notati
|
#4 |
Senior Member
Mark Olesen
Join Date: Mar 2009
Location: https://olesenm.github.io/
Posts: 1,715
Rep Power: 40 |
I'm not sure about your notation, but I'll assume 'tt' means some time value and similarly '(ut vt wt)' means the corresponding vector at some time.
Since your interpolationTable clearly has vectors as the second type of the Tuple2, the return values are obviously vectors as well. eg, scalar timeX = ...; vector velAtTimeX = timeSeries_(timeX); Info<< "z velocity component:" << velAtTimeX.z() <<endl; Or all at once in a multiplication: someThing *= timeSeries_(timeX).z(); Note that the interpolation values are plain types (without any dimensions). You need to consider this when assigning/comparing to dimensioned types. |
|
March 5, 2009, 18:52 |
Dear Mark,
Thanks for your
|
#5 |
New Member
Peter Johnston
Join Date: Mar 2009
Location: Brisbane, Queensland, Australia
Posts: 25
Rep Power: 17 |
Dear Mark,
Thanks for your further input. You interpreted my notation correctly. As a result of your comments I added the following three lines of code to my programme timeVaryingParaboloidalFvPatchField.C: 149) scalar timeX = this->db().time().timeOutputValue(); 150) Info << "timeX = " << timeX << endl; 151) vector velAtTimeX = timeSeries_(timeX); where the numbers represent the line numbers in the code. When I compile this code with "wmake libso" I get the following errors: SOURCE=timeVaryingParaboloidalFvPatchFields.C ; g++ -m32 -Dlinux -DDP -Wall -Wno-strict-aliasing -Wextra -Wno-unused-parameter -Wold-style-cast -O3 -DNoRepository -ftemplate-depth-40 -I/home/peter/OpenFOAM/OpenFOAM-1.5/src/finiteVolume/lnInclude -I/home/peter/OpenFOAM/OpenFOAM-1.5/src/triSurface/lnInclude -I/home/peter/OpenFOAM/OpenFOAM-1.5/src/meshTools/lnInclude -IlnInclude -I. -I/home/peter/OpenFOAM/OpenFOAM-1.5/src/OpenFOAM/lnInclude -I/home/peter/OpenFOAM/OpenFOAM-1.5/src/OSspecific/Unix/lnInclude -fPIC -pthread -c $SOURCE -o Make/linuxGccDPOpt/timeVaryingParaboloidalFvPatchFields.o timeVaryingParaboloidalFvPatchField.C: In member function 'void Foam::timeVaryingParaboloidalFvPatchField<type>::u pdateCoeffs() [with Type = double]': timeVaryingParaboloidalFvPatchField.C:63: instantiated from 'Foam::timeVaryingParaboloidalFvPatchField<type>:: timeVaryingParaboloidalFvPat chField(const Foam::fvPatch&, const Foam::DimensionedField<type,>&, const Foam::dictionary&) [with Type = double]' /home/peter/OpenFOAM/OpenFOAM-1.5/src/finiteVolume/lnInclude/fvPatchField.H:140: instantiated from 'static Foam::tmp<foam::fvpatchfield<type> > Foam::fvPatchField<type>::adddictionaryConstructor ToTable<fvpatchfieldtype>::New (const Foam::fvPatch&, const Foam::DimensionedField<type,>&, const Foam::dictionary&) [with fvPatchFieldType = Foam::timeVaryingParaboloidalFvPatchField<double>, Type = double]' /home/peter/OpenFOAM/OpenFOAM-1.5/src/finiteVolume/lnInclude/fvPatchField.H:151: instantiated from 'Foam::fvPatchField<type>::adddictionaryConstructo rToTable<fvpatchfieldtype>:: adddictionaryConstructorToTable(const Foam::word&) [with fvPatchFieldType = Foam::timeVaryingParaboloidalFvPatchField<double>, Type = double]' timeVaryingParaboloidalFvPatchFields.C:38: instantiated from here timeVaryingParaboloidalFvPatchField.C:151: error: conversion from 'double' to non-scalar type 'Foam::vector' requested timeVaryingParaboloidalFvPatchField.C: In member function 'void Foam::timeVaryingParaboloidalFvPatchField<type>::u pdateCoeffs() [with Type = Foam::SphericalTensor<double>]': timeVaryingParaboloidalFvPatchField.C:63: instantiated from 'Foam::timeVaryingParaboloidalFvPatchField<type>:: timeVaryingParaboloidalFvPat chField(const Foam::fvPatch&, const Foam::DimensionedField<type,>&, const Foam::dictionary&) [with Type = Foam::SphericalTensor<double>]' /home/peter/OpenFOAM/OpenFOAM-1.5/src/finiteVolume/lnInclude/fvPatchField.H:140: instantiated from 'static Foam::tmp<foam::fvpatchfield<type> > Foam::fvPatchField<type>::adddictionaryConstructor ToTable<fvpatchfieldtype>::New (const Foam::fvPatch&, const Foam::DimensionedField<type,>&, const Foam::dictionary&) [with fvPatchFieldType = Foam::timeVaryingParaboloidalFvPatchField<foam::sp hericaltensor<double> >, Type = Foam::SphericalTensor<double>]' /home/peter/OpenFOAM/OpenFOAM-1.5/src/finiteVolume/lnInclude/fvPatchField.H:151: instantiated from 'Foam::fvPatchField<type>::adddictionaryConstructo rToTable<fvpatchfieldtype>:: adddictionaryConstructorToTable(const Foam::word&) [with fvPatchFieldType = Foam::timeVaryingParaboloidalFvPatchField<foam::sp hericaltensor<double> >, Type = Foam::SphericalTensor<double>]' timeVaryingParaboloidalFvPatchFields.C:38: instantiated from here timeVaryingParaboloidalFvPatchField.C:151: error: conversion from 'Foam::SphericalTensor<double>' to non-scalar type 'Foam::vector' requested timeVaryingParaboloidalFvPatchField.C: In member function 'void Foam::timeVaryingParaboloidalFvPatchField<type>::u pdateCoeffs() [with Type = Foam::SymmTensor<double>]': timeVaryingParaboloidalFvPatchField.C:63: instantiated from 'Foam::timeVaryingParaboloidalFvPatchField<type>:: timeVaryingParaboloidalFvPat chField(const Foam::fvPatch&, const Foam::DimensionedField<type,>&, const Foam::dictionary&) [with Type = Foam::SymmTensor<double>]' /home/peter/OpenFOAM/OpenFOAM-1.5/src/finiteVolume/lnInclude/fvPatchField.H:140: instantiated from 'static Foam::tmp<foam::fvpatchfield<type> > Foam::fvPatchField<type>::adddictionaryConstructor ToTable<fvpatchfieldtype>::New (const Foam::fvPatch&, const Foam::DimensionedField<type,>&, const Foam::dictionary&) [with fvPatchFieldType = Foam::timeVaryingParaboloidalFvPatchField<foam::sy mmtensor<double> >, Type = Foam::SymmTensor<double>]' /home/peter/OpenFOAM/OpenFOAM-1.5/src/finiteVolume/lnInclude/fvPatchField.H:151: instantiated from 'Foam::fvPatchField<type>::adddictionaryConstructo rToTable<fvpatchfieldtype>:: adddictionaryConstructorToTable(const Foam::word&) [with fvPatchFieldType = Foam::timeVaryingParaboloidalFvPatchField<foam::sy mmtensor<double> >, Type = Foam::SymmTensor<double>]' timeVaryingParaboloidalFvPatchFields.C:38: instantiated from here timeVaryingParaboloidalFvPatchField.C:151: error: conversion from 'Foam::SymmTensor<double>' to non-scalar type 'Foam::vector' requested timeVaryingParaboloidalFvPatchField.C: In member function 'void Foam::timeVaryingParaboloidalFvPatchField<type>::u pdateCoeffs() [with Type = Foam::Tensor<double>]': timeVaryingParaboloidalFvPatchField.C:63: instantiated from 'Foam::timeVaryingParaboloidalFvPatchField<type>:: timeVaryingParaboloidalFvPat chField(const Foam::fvPatch&, const Foam::DimensionedField<type,>&, const Foam::dictionary&) [with Type = Foam::Tensor<double>]' /home/peter/OpenFOAM/OpenFOAM-1.5/src/finiteVolume/lnInclude/fvPatchField.H:140: instantiated from 'static Foam::tmp<foam::fvpatchfield<type> > Foam::fvPatchField<type>::adddictionaryConstructor ToTable<fvpatchfieldtype>::New (const Foam::fvPatch&, const Foam::DimensionedField<type,>&, const Foam::dictionary&) [with fvPatchFieldType = Foam::timeVaryingParaboloidalFvPatchField<foam::te nsor<double> >, Type = Foam::Tensor<double>]' /home/peter/OpenFOAM/OpenFOAM-1.5/src/finiteVolume/lnInclude/fvPatchField.H:151: instantiated from 'Foam::fvPatchField<type>::adddictionaryConstructo rToTable<fvpatchfieldtype>:: adddictionaryConstructorToTable(const Foam::word&) [with fvPatchFieldType = Foam::timeVaryingParaboloidalFvPatchField<foam::te nsor<double> >, Type = Foam::Tensor<double>]' timeVaryingParaboloidalFvPatchFields.C:38: instantiated from here timeVaryingParaboloidalFvPatchField.C:151: error: conversion from 'Foam::Tensor<double>' to non-scalar type 'Foam::vector' requested make: *** [Make/linuxGccDPOpt/timeVaryingParaboloidalFvPatchFields.o] Error 1 These are the types of errors I have been getting every time I tried something. I realise that you probably need more information than what I have given to you. Is there some way to facilitate this? You can recreate these errors by adding the three lines above to the file timeVaryingUniformFixedValueFvPatchField.C after line 117. Thanks again for your continued support. Peter. |
|
March 6, 2009, 03:55 |
It is indeed difficult to wade
|
#6 | ||
Senior Member
Mark Olesen
Join Date: Mar 2009
Location: https://olesenm.github.io/
Posts: 1,715
Rep Power: 40 |
It is indeed difficult to wade through all the errors and find the cause, but the problem is here:
Quote:
Quote:
interpolationTable<type> timeSeries_; Thus the interpolated return type from timeSeries_ is 'Type' (eg, scalar, vector, tensor, symmtensor, etc) and not just a 'vector' like you said you wanted. Are you trying to write a generic bc, or one that just works with vectors, or what exactly? If you are writing a generic bc, then use 'Type' as the return type. If your bc only makes sense for a single type (eg, scalar), then don't template it. See timeVaryingFlowRateInletVelocityFvPatchVectorField and timeVaryingUniformTotalPressureFvPatchScalarField provide good examples of this. |
|||
|
|