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

Setup of file U

Register Blogs Community New Posts Updated Threads Search

Reply
 
LinkBack Thread Tools Search this Thread Display Modes
Old   December 9, 2009, 02:48
Default Setup of file U
  #1
OFU
New Member
 
Jennifer
Join Date: Aug 2009
Location: Germany
Posts: 28
Rep Power: 16
OFU is on a distinguished road
Hello,

for my computations I need to precribe the velocity U by using simple functions for each of the three components (Ux, Uy, Uz). The functions should be applied to all six patches that are used and they look like following:
Ux = 2 + x^2
Uy = 2(z-x)y
Uz = 2 - z^2
To set these values to U I tried to write an application named setU, where the different functions are set to the three components of U. It did compile without giving an error message, but when I ran the applications the values were not set in U, so the file and the values did not change.
But for example when I describe U by the expression U=omega ^ mesh.C() with
dimensionedVector omega
(
"omega",
dimensionSet(0, 0, -1, 0, 0),
vector(0, 0, 1000)
);
and uncomment the three other lines, it works and the results of U = omega ^ mesh.C() are written to the six patches in the file U.
But I need to calculate the components of U by the given three functions, so can anyone tell me how it is possible to evaluate the function in each cell and then write the results to the file U?

----------------------------------- setU ------------------------------------------------------------------
#include "fvCFD.H"
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
int main(int argc, char *argv[])
{
# include "addTimeOptions.H"
# include "setRootCase.H"
# include "createTime.H"
// Get times list
instantList Times = runTime.times();
// set startTime and endTime depending on -time and -latestTime options
# include "checkTimeOptions.H"
runTime.setTime(Times[startTime], startTime);
# include "createMesh.H"
for (label i=startTime; i<endTime; i++)
{
runTime.setTime(Times[i], i);
Info<< "Time = " << runTime.timeName() << endl;
mesh.readUpdate();
# include "createFields.H"

//U = omega ^ mesh.C();
U.component(0) = 2 * factor + sqr(mesh.C().component(0));
U.component(1) = 2 * (mesh.C().component(2)-mesh.C().component(0)) * mesh.C().component(1);
U.component(2) = 2 * factor - sqr(mesh.C().component(2));
U.write();
}
Info<< "End\n" << endl;
return(0);
}

------------------------------------------------- U ------------------------------------------------------
FoamFile
{
version 2.0;
format ascii;
class volVectorField;
location "0";
object U;
}
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
dimensions [0 1 -1 0 0 0 0];
internalField uniform (0 0 0);
boundaryField
{
inside
{
type patch;
value uniform (0 0 0);
}
outside
{
type patch;
value uniform (0 0 0);
}
bottom
{
type patch;
value uniform (0 0 0);
}
top
{
type patch;
value uniform (0 0 0);
}
theta
{
type patch;
value uniform (0 0 0);
}
theta1
{
type patch;
value uniform (0 0 0);
}
}
OFU is offline   Reply With Quote

Old   December 10, 2009, 08:03
Default
  #2
Senior Member
 
Laurence R. McGlashan
Join Date: Mar 2009
Posts: 370
Rep Power: 23
l_r_mcglashan will become famous soon enough
Looking at Doxygen;

http://foam.sourceforge.net/doc/Doxy...tricField.html

it looks like component just returns a value and can't be overwritten. Use replace instead.
__________________
Laurence R. McGlashan :: Website
l_r_mcglashan is offline   Reply With Quote

Old   December 11, 2009, 04:37
Default
  #3
OFU
New Member
 
Jennifer
Join Date: Aug 2009
Location: Germany
Posts: 28
Rep Power: 16
OFU is on a distinguished road
Thanks for your reply. Now it works...
OFU is offline   Reply With Quote

Old   March 27, 2010, 10:59
Default
  #4
Member
 
Robertas N.
Join Date: Mar 2009
Location: Kaunas, Lithuania
Posts: 53
Rep Power: 17
r08n is on a distinguished road
How to use 'replace' for scalar fields? E.g.,

volScalarField Q
(
IOobject
(
"Q",
runTime.timeName(),
mesh,
IOobject::MUST_READ,
IOobject::AUTO_WRITE
),
mesh
);

// ...

Q.internalField()[mesh.findCell(point(0.01, 0.01, 0))].replace (0, 20.0);

produces this error:

icoTempFoam_src.C:80: error: request for member 'replace' in '((Foam::Field<double>*)Q.Foam::GeometricField<Typ e, PatchField, GeoMesh>::internalField [with Type = double, PatchField = Foam::fvPatchField, GeoMesh = Foam::volMesh]())->Foam::Field<double>::<anonymous>.Foam::List<doubl e>::<anonymous>.Foam::UList<T>:perator[] [with T = double](mesh.Foam::fvMesh::<anonymous>.Foam:olyMesh::<a nonymous>.Foam:rimitiveMesh::findCell(((const Foam:oint&)((const Foam:oint*)(& Foam::Vector<double>(((const double&)((const double*)(&1.00000000000000002081668171172168513294 309377670288085938e-2))), ((const double&)((const double*)(&1.00000000000000002081668171172168513294 309377670288085938e-2))), ((const double&)((const double*)(&0.0)))))))))', which is of non-class type 'double'
r08n 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
OF 1.6 | Ubuntu 9.10 (64bit) | GLIBCXX_3.4.11 not found piprus OpenFOAM Installation 22 February 25, 2010 13:43
Version 15 on Mac OS X gschaider OpenFOAM Installation 113 December 2, 2009 10:23
Changing the grid on the same set-up Katya FLUENT 7 October 8, 2009 16:31
FoamToVTK and MayaVi alexandrepereira OpenFOAM Post-Processing 57 August 11, 2008 04:15
Importing I-DEAS unv file hbetb FLUENT 1 August 10, 2001 13:22


All times are GMT -4. The time now is 01:47.