CFD Online Discussion Forums

CFD Online Discussion Forums (
-   OpenFOAM Pre-Processing (
-   -   Initial conditions for simulation (

lazersos June 1, 2011 09:47

Initial conditions for simulation
I'm working on a steady-state flow problem where there is a non-uniform (but constant) vector field (magnetic field). I'd like to implement this in the code but I'm running into issue finding the relevant examples. First, is the vector field defined at the center of the cells or at the edges. Second, I can already calculate the three cartesian components of the field given the cartesian coordinates of the point at which I want to know the field. How exactly should I go about implementing this?

I was thinking some code like:

label internalPatchID = mesh.??????
fvPatchVectorField& B=B.internalField()[internalPatchID];
const fvPatchVectorField& centre = mesh.C().internalField()[internalPatchID];
scalarField x = centre.component(vector::X);
scalarField y = centre.component(vector::Y);
scalarField z = centre.component(vector::Z);

Here's a third problem. How do I loop over the individual elements of x y and z. If I had a function which provided the field like:

would that work?

Anyone have a good reference to this information?

All times are GMT -4. The time now is 03:18.