Creating labelList from cells with certain attribute
Hello Foamers,
I am stuck in the moment with following problem: I want to use the setValues command to manipulate my Matrix just before solving. I not only want to set the values of a boundary, I want to set the values of internal cells. To be more precise, I want to set the values of internal cells which have a certain attribute. The attribute is a blending function value of each cell. My basic idea of solving this problem is to create a volScalarField with all the cells forfilling the attribute. The size of this field needs to be exactly the amount of the chosen cells, so I do not override too many values in the matrix. I would then create a labelList from that field and use these two as arguments for the setValue funtion. I do not know how to create the field with exactly the amount of cells which have the attribute. I thought of using a forAll loop, but for this I have to initiate a field which has already a given size. I am very helpful for any help! Thanks, Julian |
Maybe it's just me, but I don't really get what you ask for. You want to set values in a volScalarField as well as on the boundary? Could you explain this in brief?
|
Hello Jens,
Sorry, I thought it would maybe be too confusing :-). I want to implement a two-layer turbulence model, so I need to use the transport equation for k and epsilon in the outer boundary layer, but closer to the wall I need to use algebraic equations to solve the turbulence parameters. The problem is, that I need to include the algebraic into the matrix before solving it. So I need to set up the matrix with the standard transport equations and then replace some parts of the matrix with the algebraic equations. I do not need to set the values at the wall, as they are already set by the boundary conditions, but the values of the cells which forfill the attribute to use the algebraic equations. For this, I want to use the "setValue" command. To use the setValues I need to give the function a labellist and a volScalarField with the values to set for the cells. What I am now struggeling with is to built a labellist and a volScalarField with the cells forfilling an attribute (saying some scalar of the cell is smaller than some number), for which the setValues command should be used to replace the transport equations with the algebraic equations befor solving the matrix. I hope this was somehow more understandable :-). |
Maybe someone can help me to get there step by step. In the moment I am using following piece to start with to build my labelList:
Code:
label CellCount = 0; Tanks for any kind of help, Julian |
Hello Foamers,
I will try again to get this going by posting my process. I now managed to create a labellist with the cell IDs I am needing as argument for my setValue() function. As far as I understood, the setValue() function needs also a volScalarField with the same size as the labelList to work correctly (is that right)? I created the labelList as follows: Code:
Does anybody know how to create a volScalarField only including the cells of a given labelList? I would be so thankful for any kind of help or support! Julian |
In case this issue is still pending, I am positing my solution here. There are some redundant variables. So please ignore them.
codeSetValue #{ Pout<< "**codeSetValue**" << endl; int my_cs_sz =0; List<label> my_labs; const volScalarField& alpha_m2 = mesh().lookupObject<volScalarField>("alpha.air"); forAll(alpha_m2, celli) { if(alpha_m2[celli]>0){ my_labs.append(celli); } } cellSet my_set(mesh(),"arc"); const labelUList& my_cel =my_set.toc(); forAll(my_cel,id) { my_cs_sz+=1; } //List<scalar> my_list(my_cs_sz); List<scalar> my_list(my_labs.size()); scalar my_temp = 782 + mesh().time().value()*30000; my_list =(my_temp); eqn.setValues(my_cel,my_list); Pout<< my_cs_sz << endl; //eqn.setValues() = 8000; #}; } I was trying to set temperature values to locations based on alpha. |
Hello api:
I want to set different value for different elememt in my_lisy. But it seems that in your code the operator= is only reloaded to set the same value for all elements in my_list. Could you please give me some advices. Thanks samuel |
you can set the list to any value. I am not sure if i understand your question well. I think the snippet below is what you are looking for.
Code:
codeSetValue |
Thanks a lot!!!!!That's really what I need!
samuel |
All times are GMT -4. The time now is 01:50. |