CFD Online Discussion Forums

CFD Online Discussion Forums (
-   OpenFOAM Programming & Development (
-   -   Dimension checking for internalField() / Field() (

timbojones August 29, 2011 23:28

Dimension checking for internalField() / Field()

I'm still pretty new to OpenFOAM, but have been developing a couple of solvers of late. In my most recent work, I have an internal mass source that's introduced into an arbitrary number of cells based on a flag. As part of this operation, I need to calculate the total volume over which the mass source is added and then weight the mass source in each cell by the cell volume divided by the total volume over which the mass source acts.

In implementing this scheme, I've used the .internalField() along with mesh.V() to build up the weighted mass source. It all seems to be going OK. However, I do have a couple of questions based on what I have right now.

1) Are individual elements of a volScalarField accessed within a forAll loop treated as dimensionless? For example, I need to define totalVol as a scalar to make the assignment totalVol += mesh.V()]celli] within a forAll loop (with celli as the iterator).

2. Perhaps along a similar line, are the dimensions of assignments made using .internalField() or .Field() checked? It seems that the dimensions of the result are whatever dimensions have been assigned to the LHS field.

Hopefully this is understandable to readers out there and someone can help me to understand things a bit better.

Thanks and Regards,

l_r_mcglashan August 30, 2011 11:59


1) Using [ ] will not have dimensions attached. You can use sum or gSum(if you'll be running in parallel) instead of explicitly looping.

2) Take a look at:

You'll see you need dimensionedInternalField() if you want the dimensions.

All times are GMT -4. The time now is 08:27.