|
[Sponsors] |
October 5, 2018, 07:14 |
Subset of a volVectorField
|
#1 |
New Member
Emily
Join Date: Nov 2017
Posts: 24
Rep Power: 8 |
Hi all,
Does anyone know if it's possible to take a subset of the mesh of a volVectorField (in my case U) after the velocity has been solved? Ideally I want to create a subset of cells adjacent to a boundary patch. I want to do this because I need to solve a separate differential equation that re-calculates the velocity at a boundary cell face using the velocity values of the boundary cell centre (i.e. adjacent internal field). I know that subsetMesh can be used to split the mesh domain into two parts, but this would involve solving the UEqn on both sets, which I would like to avoid. Many thanks, Em |
|
October 5, 2018, 10:33 |
|
#2 |
Member
Martin
Join Date: Dec 2011
Posts: 40
Rep Power: 14 |
A simple way would be to create a volVectorField with reference to the current mesh and fill it with values only in the owner and neighbour cells of your patch using a forAll loop. You can loop, for example, through the owners of faces
Code:
const labelUList& owner = mesh.owner(); //Reference to owner forAll(owner, facei){ ... } Last edited by msaravia; October 8, 2018 at 10:48. |
|
October 12, 2018, 09:06 |
|
#3 |
New Member
Emily
Join Date: Nov 2017
Posts: 24
Rep Power: 8 |
Hi Martin,
Thanks for your reply. I am trying to follow your method but I do not know how to specify the size of the new volVectorField. If I specify the size using 'mesh' (like it's done for the definition of the U field, below) then my new volVectorField will be the size of the entire mesh. I can access the number of cells adjacent to the patch, but when I try to use this value (i.e. an integer number) it does not work. Do you know how I can do this? I am guessing the value of 'mesh' in the below example does not simply refer to the number of cells in the entire domain (which I initially thought it did) but something more complex - although I cannot figure out what this term represents? Thank you, Em volVectorField U ( IOobject ( "U", runTime.timeName(), mesh, IOobject::MUST_READ, IOobject::AUTO_WRITE ), mesh //this value ); |
|
October 12, 2018, 19:08 |
|
#4 |
Member
Martin
Join Date: Dec 2011
Posts: 40
Rep Power: 14 |
Yes, the volVectorField will have the size of the entire mesh, but I don't see why this would be a problem. Except it is mandatory to save memory. This is the simplest implementation that I can think of. Of course there are several alternatives, but all of them imply more code.
|
|
October 13, 2018, 05:23 |
|
#5 |
New Member
Emily
Join Date: Nov 2017
Posts: 24
Rep Power: 8 |
Okay, so the clarify - I should fill the new volVectorField with the near patch data that I want (as you described previously) and leave the rest of the volVectorField empty? I.e. don’t even initialise it?
Would this mean that the differential equation I want to solve will only be solved for the given data in the volVectorField? Not the entire domain, which would be inefficient? Thank you, Em |
|
October 15, 2018, 10:10 |
|
#6 |
Member
Martin
Join Date: Dec 2011
Posts: 40
Rep Power: 14 |
No, with this approach you will be solving the equation in the entire domain (with no interface BCs). I think the only way to solve the equation in a subdomain is to instantiate a new fvMesh object from your desired element data (see the available constructors in the fvMesh class) and then set the appropriate boundary conditions.
|
|
|
|
Similar Threads | ||||
Thread | Thread Starter | Forum | Replies | Last Post |
Multi subset mesh motion | hchen | OpenFOAM Running, Solving & CFD | 3 | March 5, 2022 23:41 |
the format of adding volVectorField term into equation | linyanx | OpenFOAM Programming & Development | 1 | March 16, 2017 09:27 |
Multiplication of two volVectorField | ChGr | OpenFOAM Programming & Development | 1 | May 30, 2016 11:08 |
Initialize a uniform 0 volVectorField | Schag | OpenFOAM | 3 | August 26, 2009 10:08 |
ICEMCFD: subset "smooth_show_map" | Andy | CFX | 2 | October 31, 2006 07:57 |