CFD Online Discussion Forums

CFD Online Discussion Forums (https://www.cfd-online.com/Forums/)
-   OpenFOAM (https://www.cfd-online.com/Forums/openfoam/)
-   -   uniform Scalar,setFields (https://www.cfd-online.com/Forums/openfoam/100296-uniform-scalar-setfields.html)

zxj160 April 23, 2012 12:01

uniform Scalar,setFields
 
Dear foamers,

I want to define a uniform scalar (e.g alpha) with 0 in some region and 1 otherwise (may use setfields utility). Also, I just want to make these values unchanged when running the code. How to deal with that in the solver?

mturcios777 April 23, 2012 13:29

Are you trying to use this field as a source term? If you are running OF 2.1 you might be able to use the source term functionality:

http://www.openfoam.org/version2.1.0/numerics.php

zxj160 April 23, 2012 13:54

YES. My current code is :

fvVectorMatrix UEqn
(
fvm::ddt(U)
+ fvm::div(phi, U)
+ turbulence->divDevReff(U)
==
alpha*gradP
);

I defined gradP as a vector and alpha as a scalar. I want to keep alpha uniform when running as follows:

defaultFieldValues
(
volScalarFieldValue alpha 0
);

regions
(
boxToCell
{
box (0 0 10) (30 10 50);
fieldValues
(
volScalarFieldValue alpha 1
);
}
);

mturcios777 April 23, 2012 14:12

Looks like what you have is right, so long as no transport equation is solved for alpha you're in business. Are you having trouble with the current approach as is?

zxj160 April 23, 2012 14:16

The initial alpha is right. It seems that the next time step the value of alpha is 0. I just want to keep it as the initial value all the running time.

ybapat April 25, 2012 00:23

Hello,

You might try this function in fvMatrix.H which sets values in given cells.

//- Set solution in given cells to the specified values
template<template<class> class ListType>
void setValuesFromList
(
const labelUList& cells,
const ListType<Type>& values
);

zxj160 April 25, 2012 11:52

Quote:

Originally Posted by ybapat (Post 356787)
Hello,

You might try this function in fvMatrix.H which sets values in given cells.

//- Set solution in given cells to the specified values
template<template<class> class ListType>
void setValuesFromList
(
const labelUList& cells,
const ListType<Type>& values
);

Hi,

Many thanks. Could you tell me more about how to use the function in the fvMatrix.H?

ybapat April 25, 2012 23:56

Hi,

I think it takes list of cells in which you want to set values and list of values in those cells.
So you have to create list of cells in which you want to set value of alpha.
You have to call this function before solve function for matrix is called.

Regards,
-Yogesh

zxj160 April 26, 2012 13:10

Hi Yogesh,

Thanks. I have solved the problem by changing the definition of alpha in the creatalpha.H file similar to 'p'.

Cheers,
Jian


All times are GMT -4. The time now is 07:05.