CFD Online Logo CFD Online URL
www.cfd-online.com
[Sponsors]
Home > Forums > Software User Forums > OpenFOAM > OpenFOAM Running, Solving & CFD

TimeVaryingMappedFixedValue field creation

Register Blogs Community New Posts Updated Threads Search

Reply
 
LinkBack Thread Tools Search this Thread Display Modes
Old   January 9, 2008, 15:21
Default Hi, I would like to output
  #1
Senior Member
 
John Deas
Join Date: Mar 2009
Posts: 160
Rep Power: 17
johndeas is on a distinguished road
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.
johndeas is offline   Reply With Quote

Old   January 10, 2008, 04:53
Default Get patchfield of e.g. p goes
  #2
Senior Member
 
Mattijs Janssens
Join Date: Mar 2009
Posts: 1,419
Rep Power: 26
mattijs is on a distinguished road
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.
mattijs is offline   Reply With Quote

Old   January 10, 2008, 05:28
Default It is not the order during rea
  #3
Senior Member
 
John Deas
Join Date: Mar 2009
Posts: 160
Rep Power: 17
johndeas is on a distinguished road
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.
johndeas is offline   Reply With Quote

Old   January 10, 2008, 16:39
Default Yes. The interpolation factors
  #4
Senior Member
 
Mattijs Janssens
Join Date: Mar 2009
Posts: 1,419
Rep Power: 26
mattijs is on a distinguished road
Yes. The interpolation factors (nearestVertex_, nearestVertexWeight_) are calculated once and then the interpolation always proceeds in the same order.

timeVaryingMappedFixedValueFvPatchField.C line 630.
mattijs is offline   Reply With Quote

Old   January 14, 2008, 05:44
Default Hi, I tried to use an IOobj
  #5
Senior Member
 
John Deas
Join Date: Mar 2009
Posts: 160
Rep Power: 17
johndeas is on a distinguished road
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 is offline   Reply With Quote

Old   January 14, 2008, 05:51
Default "I hint that a local value as
  #6
Senior Member
 
John Deas
Join Date: Mar 2009
Posts: 160
Rep Power: 17
johndeas is on a distinguished road
"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 is offline   Reply With Quote

Old   January 15, 2008, 08:05
Default I looked into timeVaryingMappe
  #7
Senior Member
 
John Deas
Join Date: Mar 2009
Posts: 160
Rep Power: 17
johndeas is on a distinguished road
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.
johndeas is offline   Reply With Quote

Old   January 15, 2008, 12:57
Default The objectRegistry (this->db()
  #8
Senior Member
 
Mattijs Janssens
Join Date: Mar 2009
Posts: 1,419
Rep Power: 26
mattijs is on a distinguished road
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.
mattijs is offline   Reply With Quote

Old   January 16, 2008, 08:24
Default I rewrote your example as :
  #9
Senior Member
 
John Deas
Join Date: Mar 2009
Posts: 160
Rep Power: 17
johndeas is on a distinguished road
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
johndeas is offline   Reply With Quote

Old   January 17, 2008, 15:45
Default My example was incorrect - jus
  #10
Senior Member
 
Mattijs Janssens
Join Date: Mar 2009
Posts: 1,419
Rep Power: 26
mattijs is on a distinguished road
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);
mattijs is offline   Reply With Quote

Old   January 18, 2008, 04:48
Default Hi all, I wrote a simple sc
  #11
New Member
 
Lourens Aanen
Join Date: Mar 2009
Posts: 16
Rep Power: 17
lourens is on a distinguished road
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.

ProbesToTimes

Regards,

Lourens
lourens is offline   Reply With Quote

Old   May 22, 2008, 11:02
Default Hi, if I create an AverageIOFi
  #12
Senior Member
 
John Deas
Join Date: Mar 2009
Posts: 160
Rep Power: 17
johndeas is on a distinguished road
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 is offline   Reply With Quote

Old   May 28, 2008, 09:34
Default And, if I use AverageIOFiel
  #13
Senior Member
 
John Deas
Join Date: Mar 2009
Posts: 160
Rep Power: 17
johndeas is on a distinguished road
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'
johndeas is offline   Reply With Quote

Old   May 28, 2008, 09:50
Default AverageIOField ...
  #14
Super Moderator
 
niklas's Avatar
 
Niklas Nordin
Join Date: Mar 2009
Location: Stockholm, Sweden
Posts: 693
Rep Power: 29
niklas will become famous soon enoughniklas will become famous soon enough
AverageIOField<vector>

...
niklas is offline   Reply With Quote

Old   May 28, 2008, 09:52
Default ... Which gives me the error m
  #15
Senior Member
 
John Deas
Join Date: Mar 2009
Posts: 160
Rep Power: 17
johndeas is on a distinguished road
... Which gives me the error mentioned one post above
johndeas is offline   Reply With Quote

Old   May 28, 2008, 10:39
Default looking the the pTraits.H file
  #16
Super Moderator
 
niklas's Avatar
 
Niklas Nordin
Join Date: Mar 2009
Location: Stockholm, Sweden
Posts: 693
Rep Power: 29
niklas will become famous soon enoughniklas will become famous soon enough
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
)
);
niklas is offline   Reply With Quote

Old   May 29, 2008, 04:42
Default You could add a constructor fr
  #17
Senior Member
 
Mattijs Janssens
Join Date: Mar 2009
Posts: 1,419
Rep Power: 26
mattijs is on a distinguished road
You could add a constructor from primitive to pTraits.H

pTraits.H
mattijs is offline   Reply With Quote

Old   May 29, 2008, 06:45
Default I modified it, and tried to wm
  #18
Senior Member
 
John Deas
Join Date: Mar 2009
Posts: 160
Rep Power: 17
johndeas is on a distinguished road
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
johndeas is offline   Reply With Quote

Old   May 29, 2008, 07:03
Default wmake is for compiling applica
  #19
Super Moderator
 
niklas's Avatar
 
Niklas Nordin
Join Date: Mar 2009
Location: Stockholm, Sweden
Posts: 693
Rep Power: 29
niklas will become famous soon enoughniklas will become famous soon enough
wmake is for compiling applications.
use wmake libso
niklas is offline   Reply With Quote

Old   May 29, 2008, 07:11
Default thank you
  #20
Senior Member
 
John Deas
Join Date: Mar 2009
Posts: 160
Rep Power: 17
johndeas is on a distinguished road
thank you
johndeas is offline   Reply With Quote

Reply


Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are Off
Pingbacks are On
Refbacks are On


Similar Threads
Thread Thread Starter Forum Replies Last Post
TimeVaryingMappedFixedValue irishdave OpenFOAM Running, Solving & CFD 32 June 16, 2021 06:55
TimeVaryingMappedFixedValue best practice to extract subset points and fields podallaire OpenFOAM Running, Solving & CFD 6 May 21, 2014 10:25
TimeVaryingMappedFixedValue sunnysun OpenFOAM Running, Solving & CFD 12 October 30, 2013 15:22
Possible bug with timeVaryingMappedFixedValue jerome OpenFOAM Bugs 2 October 9, 2007 09:38
Putting submesh field values into field on parent mesh helmut OpenFOAM Running, Solving & CFD 2 June 20, 2006 07:31


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