CFD Online Discussion Forums

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

johndeas January 9, 2008 16:21

Hi, I would like to output
 
Hi,

I would like to output fields that will serve as inputs for a timeVaryingMappedFixedValue patch. I will have to write all the files in the constant/boundaryData/inlet folder (points and speed) using the field of cyclic patch. I would have liked to know if someone already did this (and can give some direction on how to retrieve fields at boundaries), and if the numbering will be consistent between all files (i.e. are the faces automatically crawled with the same order across the patch for all field and the position).

Thanks,

J.D.

mattijs January 10, 2008 05:53

Get patchfield of e.g. p goes
 
Get patchfield of e.g. p goes something like

label patchI = mesh.boundaryMesh().findPatchID("myCyclicPatch");

Info<< "patchField is " << p.boundaryField()[patchI] << endl;

The timeVaryingMappedFixedValue does a triangulation of the points and interpolation so ordering does not matter.

Search for boundaryField on this forum or the Wiki and you'll find more info.

johndeas January 10, 2008 06:28

It is not the order during rea
 
It is not the order during reading that worried me, but the order when writing the boundaryData files. I wanted to know if 14th value of U would always be assigned to the 14th point in "points" for example.

mattijs January 10, 2008 17:39

Yes. The interpolation factors
 
Yes. The interpolation factors (nearestVertex_, nearestVertexWeight_) are calculated once and then the interpolation always proceeds in the same order.

timeVaryingMappedFixedValueFvPatchField.C line 630.

johndeas January 14, 2008 06:44

Hi, I tried to use an IOobj
 
Hi,

I tried to use an IOobject to store the velocity field contained in one of my periodic boundary condition to create the field at each timestep, as future input fields for another calculation, which will use a timeVaryingMappedFixedValue patch as the rest of this thread suggests.

Based on the way the lambda2 field is written at each timestep in lambda2.c, I added the following code to my solver (a modification of icoFoam) :

word inletPatchName = "cyclic";

vectorField UBoundField
(
IOobject
(
"UBoundField",
runTime.timeName(),
mesh,
IOobject::NO_READ,
IOobject::NO_WRITE
),
U.boundaryField()[patchID]
);

The compilation gave me the following error :

sandFoam.C:159: error: no matching function for call to 'Foam::Field<foam::vector<double> >::Field(Foam::IOobject, Foam::fvPatchField<foam::vector<double> >&)'
/home/vinz/OpenFOAM/OpenFOAM-1.4.1/src/OpenFOAM/lnInclude/Field.C:197: note: candidates are: Foam::Field<type>::Field(const Foam::word&, const Foam::dictionary&, Foam::label) [with Type = Foam::Vector<double>]
...
and a list of other constructors

I understand that I am not calling the vectorField constructor using the good types. U being of type volVectorField, U.boundaryField is of type "reference to GeometricBoundaryField". In the original IOobject in lambda2.c, one can read :

volScalarField Lambda2
(
IOobject
(
"Lambda2",
runTime.timeName(),
mesh,
IOobject::NO_READ,
IOobject::NO_WRITE
),
-eigenValues(SSplusWW)().component(vector::Y)
);

A look at the Doxygen documentation teaches that: eigenValues() is of type dimensionedVector and as such -eigenValues(SSplusWW)().component(vector::Y) is of type dimensionedScalar.

My question is, how can I write the my IOobject for the velocity at the boundary to fill the IOobject with a dimensionedVector instead of U.boundaryField()[patchID] ? I hint that a local value as to be given (a vector or a scalar) which will be crawled on the domain specified to create a field (in the lambda2 example the domain would be 'mesh', which is of type FOAM::fvMesh). If this is the case, how can I create a domain (in the form of a mesh) that just contains my boundary condition, so as to call something which would look like

word inletPatchName = "cyclic";

vectorField UBoundField
(
IOobject
(
"UBoundField",
runTime.timeName(),
!!! boundarycondition domain !!!,
IOobject::NO_READ,
IOobject::NO_WRITE
),
!!! local value of U !!!
);

Thank you for you help,

J.D.

johndeas January 14, 2008 06:51

"I hint that a local value as
 
"I hint that a local value as to be given (a vector or a scalar) which will be crawled on the domain specified to create a field (in the lambda2 example the domain would be 'mesh', which is of type FOAM::fvMesh)."

This makes no sense... It is a field which is provided.

johndeas January 15, 2008 09:05

I looked into timeVaryingMappe
 
I looked into timeVaryingMappedFixedValueFvPatchField.C to understand how the patch reads its input fields to mimic its behaviour and be able to write those fields.

For the points, a pointIOField is created:

pointIOField samplePoints
(
IOobject
(
"points",
this->db().time().constant(),
"boundaryData"/this->patch().name(),
this->db(),
IOobject::MUST_READ,
IOobject::AUTO_WRITE,
false
)
);

There, this->db() refers to the objectRegistry of the timeVaryingMappedFixedValueFvPatchField that is instanciated, right ?

Given the name of a patch with inletPatchName = "cyclic" , how can I get its objectRegistry, to create an IOobject and output the values at boundary ?

Any help appreciated, even if just to point on how objectRegistry works... I am getting stuck on this problem...

Thanks,

J.D.

mattijs January 15, 2008 13:57

The objectRegistry (this->db()
 
The objectRegistry (this->db()) is the polyMesh i.e. 'mesh' in your top-level application.

db.time() is the Time object, i.e. 'runTime' in your top-level application.

Create a pointIOField (in two steps for clarity reasons), fill it and write it.

IOobject io
(
"points",
runTime.constant(),
"boundaryData"/"cyclic",
mesh,
IOobject::NO_READ,
IOobject::NO_WRITE,
false
);

pointIOField samplePoints(io, 100);
samplePoints[0] = 0.0;
..
samplePoints[99] = 0.0;

samplePoints.write();


This is the simplistic use of ioobject. With different settings it allow you to
- register the object on the polyMesh
- so as to have automatic writing
Have a look at how e.g. volXXXfields are created.

johndeas January 16, 2008 09:24

I rewrote your example as :
 
I rewrote your example as :

IOobject io
(
"points",
runTime.constant()/"boundaryData"/"cyclic",
mesh,
IOobject::NO_READ,
IOobject::NO_WRITE,
false
);

pointIOField samplePoints(io, 2);
samplePoints[0] = 0.0;
samplePoints[1] = 0.0;

samplePoints.write();

and get the following error:

sandFoam.C:174: error: no match for 'operator=' in 'samplePoints.Foam::IOField<foam::vector<double> >::<anonymous>.Foam::Field<foam::vector<double> >::<anonymous>.Foam::List<foam::vector<double> >::<anonymous>.Foam::UList<t>::operator[] [with T = Foam::Vector<double>](0) = 0.0'
/home/vinz/OpenFOAM/OpenFOAM-1.4.1/src/OpenFOAM/lnInclude/Vector.H:62: note: candidates are: Foam::Vector<double>& Foam::Vector<double>::operator=(const Foam::Vector<double>&)

I also do not understand how to create fields that exist on a subpart of the mesh and with wich I would like to use IOobject (my boundaries).

My problem is very similar to this one: http://www.cfd-online.com/OpenFOAM_D...tml?1113927929 in the sense that I would not like to code loops and generate boundaryData files myself, but use the OF librairies.

I do not know if I am really clear in what I want to do

mattijs January 17, 2008 16:45

My example was incorrect - jus
 
My example was incorrect - just typed it in. samplePoints is an array of points so you can't assign e.g 0.0 to it. Instead

samplePoints[0] = point(0,0,0);

lourens January 18, 2008 05:48

Hi all, I wrote a simple sc
 
Hi all,

I wrote a simple script (using awk) to convert time series resulting from probes as defined in controlDict to the input for the TimeVaryingMappedFixedValue function. For the moment I hardcoded the variables to convert in the script. It creates a directory BoundaryData, in which the directories for the different times are located. It reads the data from the directory "starttime" in "probes" where starttime has to be specified inthe commandline (probesToTimes root case starttime).
I hope it is usefull for somebody.

http://www.cfd-online.com/OpenFOAM_D...hment_icon.gif ProbesToTimes

Regards,

Lourens

johndeas May 22, 2008 11:02

Hi, if I create an AverageIOFi
 
Hi, if I create an AverageIOField this way:

AverageIOField<vector> writeU
(
IOobject
(
"values",
runTime.timeName(),
mesh,
IOobject::NO_READ,
IOobject::NO_WRITE
),
vector(0.1,0,0), // dummy vector for average value
U.boundaryField()[outletName]
);

I get the following compilation error:

/home/flurec/commun/OpenFOAM/1.4.1-dev/OpenFOAM-1.4.1-dev/src/finiteVolume/lnInc lude/AverageIOField.C: In constructor 'Foam::AverageIOField<type>::AverageIOField(const Foam::IOobject&, const Type&, const Foam::Field<type>&) [with Type = Foam::Vector<double>]':
dpIcoFoamAdimWrite.C:84: instantiated from here
/home/flurec/commun/OpenFOAM/1.4.1-dev/OpenFOAM-1.4.1-dev/src/finiteVolume/lnInc lude/AverageIOField.C:73: error: no matching function for call to 'Foam::pTraits<foam::vector<double> >::pTraits(const Foam::Vector<double>&)'
/home/flurec/commun/OpenFOAM/1.4.1-dev/OpenFOAM-1.4.1-dev/src/OpenFOAM/lnInclude /pTraits.H:56: note: candidates are: Foam::pTraits<primitive>::pTraits(Foam::Istream&) [with primitive = Foam::Vector<double>]
/home/flurec/commun/OpenFOAM/1.4.1-dev/OpenFOAM-1.4.1-dev/src/OpenFOAM/lnInclude /pTraits.H:52: note: Foam::pTraits<foam::vector<double> >::pTraits(const Foam::pTraits<foam::vector<double> >&)
make: *** [Make/linuxGccDPOpt/dpIcoFoamAdimWrite.o] Erreur 1

I am not quit sure how to modify this to get it to work with vectors.

johndeas May 28, 2008 09:34

And, if I use AverageIOFiel
 
And, if I use

AverageIOField writeFlds
(
IOobject
(
"cutPlaneU",
runTime.timeName(),
mesh,
IOobject::NO_READ,
IOobject::NO_WRITE
),
vector(0.66666666,0,0),
vectorFlds[i].internalField()
);

I get this error : icoFoamWrite.C:149: error: missing template arguments before 'writeFlds'

niklas May 28, 2008 09:50

AverageIOField ...
 
AverageIOField<vector>

...

johndeas May 28, 2008 09:52

... Which gives me the error m
 
... Which gives me the error mentioned one post above

niklas May 28, 2008 10:39

looking the the pTraits.H file
 
looking the the pTraits.H file I only
see an Istream constructor

pTraits(Istream& is)
:
primitive(is)
{}

so I think that's why it wont work with vector(0.6.....)

I dont know how to solve this, but looking at the various constructors this worked (although I dont know if thats an acceptable solution)


AverageIOField<vector> writeU
(
IOobject
(
"values",
runTime.timeName(),
mesh,
IOobject::NO_READ,
IOobject::NO_WRITE
)
);

mattijs May 29, 2008 04:42

You could add a constructor fr
 
You could add a constructor from primitive to pTraits.H

http://www.cfd-online.com/OpenFOAM_D...hment_icon.gif pTraits.H

johndeas May 29, 2008 06:45

I modified it, and tried to wm
 
I modified it, and tried to wmake src/OpenFOAM. There are no problem related to pTraits. All the intermediary .o are correctly built. However, when it comes to linking everything, I get:

g++ -m32 -Dlinux -DDP -Wall -Wno-strict-aliasing -Wextra -Wno-unused-parameter -Wold-style-cast -O3 -DNoRepository -ftemplate-depth-40 -DWM_PROJECT_VERSION='"'1.4.1'"' -I/home/vinz/OpenFOAM/OpenFOAM-1.4.1/src/zlib-1.2.1 -IlnInclude -I. -I/home/vinz/OpenFOAM/OpenFOAM-1.4.1/src/OpenFOAM/lnInclude -fPIC -pthread Make/linuxGccDPOpt/sigFpe.o Make/linuxGccDPOpt/sigSegv.o Make/linuxGccDPOpt/sigInt.o
[...]
Make/linuxGccDPOpt/MeshWaveName.o Make/linuxGccDPOpt/FaceCellWaveName.o Make/linuxGccDPOpt/curve.o Make/linuxGccDPOpt/graph.o Make/linuxGccDPOpt/rawGraph.o Make/linuxGccDPOpt/gnuplotGraph.o Make/linuxGccDPOpt/xmgrGraph.o Make/linuxGccDPOpt/jplotGraph.o -L/home/vinz/OpenFOAM/OpenFOAM-1.4.1/lib/linuxGccDPOpt \
-lOpenFOAM -ldl -lm -o OpenFOAM.out
/usr/lib/crt1.o: In function `_start':
(.text+0x18): undefined reference to `main'
collect2: ld returned 1 exit status
make: *** [OpenFOAM.out] Error 1

Sorry if I abuse readers time, but I am completely lost at this point...

JD

niklas May 29, 2008 07:03

wmake is for compiling applica
 
wmake is for compiling applications.
use wmake libso

johndeas May 29, 2008 07:11

thank you
 
thank you


All times are GMT -4. The time now is 12:42.