CFD Online Discussion Forums

CFD Online Discussion Forums (https://www.cfd-online.com/Forums/)
-   OpenFOAM Running, Solving & CFD (https://www.cfd-online.com/Forums/openfoam-solving/)
-   -   TimeVaryingMappedFixedValue field creation (https://www.cfd-online.com/Forums/openfoam-solving/58251-timevaryingmappedfixedvalue-field-creation.html)

johndeas December 4, 2008 10:50

Hi, I still got problems re
 
Hi,

I still got problems related to pTraits :

I tried to modify my code in order to export other variables than U (k and p for instance).

This expression will compile:

AverageIOField<vector> writeSampleU
(
IOobject
(
"U",
mesh.time().constant(),
"boundaryData/entree"/runTime.timeName(),
mesh,
IOobject::NO_READ,
IOobject::NO_WRITE
),
U[0],
combinedVecU
);

But, as soon as I want to insert this one:

AverageIOField<scalar> writeSampleP
(
IOobject
(
"p",
mesh.time().constant(),
"boundaryData/entree"/runTime.timeName(),
mesh,
IOobject::NO_READ,
IOobject::NO_WRITE
),
p[0],
combinedScaP
);

I get a nice:

/home/flurec/OpenFOAM/OpenFOAM-1.5/src/finiteVolume/lnInclude/AverageIOField.C: In constructor 'Foam::AverageIOField<type>::AverageIOField(const Foam::IOobject&, const Type&, const Foam::Field<type>&) [with Type = double]':
writeSampleP.H:39: instantiated from here
/home/flurec/OpenFOAM/OpenFOAM-1.5/src/finiteVolume/lnInclude/AverageIOField.C:7 3: error: no matching function for call to 'Foam::pTraits<double>::pTraits(const double&)'
/home/flurec/OpenFOAM/OpenFOAM-1.5/src/OpenFOAM/lnInclude/Scalar.H:68: note: candidates are: Foam::pTraits<double>::pTraits(Foam::Istream&)
/home/flurec/OpenFOAM/OpenFOAM-1.5/src/OpenFOAM/lnInclude/Scalar.H:41: note: Foam::pTraits<double>::pTraits(const Foam::pTraits<double>&)
writeSampleP.H:39: instantiated from here
/home/flurec/OpenFOAM/OpenFOAM-1.5/src/finiteVolume/lnInclude/AverageIOField.C:7 7: error: invalid static_cast from type 'Foam::AverageIOField<double>' to type 'double&'

From my understanding of template specialization, in Scalar.H:68, when the template pTraits is specialized for scalars, its only constructor is pTraits(Istream& is)

Therefore, the general constructor from primitive:

pTraits(const primitive& p)
:
primitive(p)
{}

which has been added in this forum thread is not available. Should I modify Scalar.H and Scalar.C to get my code to compile ?

adding to Scalar.H :

pTraits(const primitive& p);

adding to Scalar.C :

pTraits<scalar>::pTraits(const primitive& p)
{
p_ = p;
}

panda60 April 2, 2010 12:07

Dear Mattijs and John Deas,
Do you have some common on how to use TimeVaryingMappedFixedValue boundary condition ?
I have two questions:
1.what's the meaning of Average in its input data ?
FoamFile
{
version 2.0;
format ascii;
class vectorAverageField;
object values;
}
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
// Average
( 0 0 0 )
//
// Data on points
70
(
//minz
(5.74803 0 0)
(5.74803 0 0)

2. Because the most useful things of this boundary condition is to read a large series of data from file as inlet condition. But its request data is a little strange, how we can generate this kind of data ?
Maybe I can get these data from functionObject surface sampling using pre-simulation. But the sampling data is a little difference from TimeVaryingMappedFixedValue data format, and the sampling result have more folders, so how can do this ?
If we have utility to convert sample data to request data format ?
Thank you very much.

panda60 April 2, 2010 12:10

This is request data format for timeVaryingMappedFixedValue :

/*--------------------------------*- C++ -*----------------------------------*\
| ========= | |
| \\ / F ield | OpenFOAM: The Open Source CFD Toolbox |
| \\ / O peration | Version: 1.6 |
| \\ / A nd | Web: http://www.OpenFOAM.org |
| \\/ M anipulation | |
\*---------------------------------------------------------------------------*/
FoamFile
{
version 2.0;
format ascii;
class vectorAverageField;
object values;
}
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
// Average
( 0 0 0 )
//
// Data on points
70
(
//minz
(5.74803 0 0)
(5.74803 0 0)
(11.3009 0 0)
(13.4518 0 0)
.,.................
)

This is sampling data format :

15408
(
(0.0239436 -6.28249e-05 0.000567144)
(0.0239436 -6.28249e-05 0.000567144)
(0.0712944 -0.00019323 -0.00045317)
(0.0712944 -0.00019323 -0.00045317)
(0.122301 -0.000335644 -0.00117908)
(0.122301 -0.000335644 -0.00117908)
(0.178985 -0.000485735 -0.000847965)
(0.178985 -0.000485735 -0.000847965)
.................................................. ....
)

syavash October 13, 2015 06:33

Quote:

Originally Posted by johndeas (Post 181899)
Hi,

I still got problems related to pTraits :

I tried to modify my code in order to export other variables than U (k and p for instance).

This expression will compile:

AverageIOField<vector> writeSampleU
(
IOobject
(
"U",
mesh.time().constant(),
"boundaryData/entree"/runTime.timeName(),
mesh,
IOobject::NO_READ,
IOobject::NO_WRITE
),
U[0],
combinedVecU
);

But, as soon as I want to insert this one:

AverageIOField<scalar> writeSampleP
(
IOobject
(
"p",
mesh.time().constant(),
"boundaryData/entree"/runTime.timeName(),
mesh,
IOobject::NO_READ,
IOobject::NO_WRITE
),
p[0],
combinedScaP
);

I get a nice:

/home/flurec/OpenFOAM/OpenFOAM-1.5/src/finiteVolume/lnInclude/AverageIOField.C: In constructor 'Foam::AverageIOField<type>::AverageIOField(const Foam::IOobject&, const Type&, const Foam::Field<type>&) [with Type = double]':
writeSampleP.H:39: instantiated from here
/home/flurec/OpenFOAM/OpenFOAM-1.5/src/finiteVolume/lnInclude/AverageIOField.C:7 3: error: no matching function for call to 'Foam::pTraits<double>::pTraits(const double&)'
/home/flurec/OpenFOAM/OpenFOAM-1.5/src/OpenFOAM/lnInclude/Scalar.H:68: note: candidates are: Foam::pTraits<double>::pTraits(Foam::Istream&)
/home/flurec/OpenFOAM/OpenFOAM-1.5/src/OpenFOAM/lnInclude/Scalar.H:41: note: Foam::pTraits<double>::pTraits(const Foam::pTraits<double>&)
writeSampleP.H:39: instantiated from here
/home/flurec/OpenFOAM/OpenFOAM-1.5/src/finiteVolume/lnInclude/AverageIOField.C:7 7: error: invalid static_cast from type 'Foam::AverageIOField<double>' to type 'double&'

From my understanding of template specialization, in Scalar.H:68, when the template pTraits is specialized for scalars, its only constructor is pTraits(Istream& is)

Therefore, the general constructor from primitive:

pTraits(const primitive& p)
:
primitive(p)
{}

which has been added in this forum thread is not available. Should I modify Scalar.H and Scalar.C to get my code to compile ?

adding to Scalar.H :

pTraits(const primitive& p);

adding to Scalar.C :

pTraits<scalar>::pTraits(const primitive& p)
{
p_ = p;
}

Hi,

I have encountered a very similar problem. I have included the following code within pimpleFoam to write U field at inlet, at each time step to be used later through TimeVaryingMappedFixedValue bc.
Code:

AverageIOField<vector> U2
(
    IOobject
    (
        "U",
        mesh.time().timeName(),
        mesh,
        IOobject::NO_READ,
        IOobject::NO_WRITE
    ),
    U.boundaryField()[ patchID ]
);

U2.write();

But when compiling, OpenFOAM gives me the following error:

Code:

MypimpleFoam.C: In function ‘int main(int, char**)’:
MypimpleFoam.C:97:4: error: ‘AverageIOField’ was not declared in this scope
    AverageIOField<vector> U2
    ^
MypimpleFoam.C:97:25: error: expected primary-expression before ‘>’ token
    AverageIOField<vector> U2
                        ^
MypimpleFoam.C:108:1: error: ‘U2’ was not declared in this scope
 );
 ^
make: *** [Make/linux64GccDPOpt/MypimpleFoam.o] Error 1

I need to implement AverageIOField because TimeVaryingMappedFixedValue accepts data with this type. How can I resolve this problem??

Thanks,
Syavash

Pilardc91 June 14, 2021 14:56

Problem with TimeVaryingMappedFixedValue
 
I am using a boundary condition for the displacement U called TimeVaryingMappedFixedValue. The definition of this BC is:

"This is a derived traction boundary which reads the time and spatial varying force data (from pressure p and/or stresses  S) and computes the traction load and compatible displacement gradient boundary. This boundary condition is derived from tractionDisplacement + timeVary-ingMappedFixedValue in OpenFOAM. (Li et al. 2020)"

When I get the results for each time, this boundary condition does not do like other boundary conditions that store the list of data in the defined patch. In fact, when I look at one of the files and search for the patch where I have imposed that B.C there is no data (it is at the top). The thing is that in Paraview if it represents them to me and it represents them just in that patch.

My doubts are:

1) why does this happen and why Paraview allows to draw it?

2) When I make the sampleDict (and execute sample) none of the interpolation options let me get the data of U, since it looks for the patch and does not find it. Any idea what I can extract those data from

Thank you very much in advance for your help.


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