CFD Online Logo CFD Online URL
www.cfd-online.com
[Sponsors]
Home > Forums > Software User Forums > OpenFOAM > OpenFOAM Programming & Development

Subset of a volVectorField

Register Blogs Community New Posts Updated Threads Search

Like Tree1Likes
  • 1 Post By msaravia

Reply
 
LinkBack Thread Tools Search this Thread Display Modes
Old   October 5, 2018, 07:14
Default Subset of a volVectorField
  #1
New Member
 
Emily
Join Date: Nov 2017
Posts: 24
Rep Power: 8
em17 is on a distinguished road
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
em17 is offline   Reply With Quote

Old   October 5, 2018, 10:33
Default
  #2
Member
 
Martin
Join Date: Dec 2011
Posts: 40
Rep Power: 14
msaravia is on a distinguished road
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){ ... }
You could do the same only for your patch.
Tobi likes this.

Last edited by msaravia; October 8, 2018 at 10:48.
msaravia is offline   Reply With Quote

Old   October 12, 2018, 09:06
Default
  #3
New Member
 
Emily
Join Date: Nov 2017
Posts: 24
Rep Power: 8
em17 is on a distinguished road
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
);
em17 is offline   Reply With Quote

Old   October 12, 2018, 19:08
Default
  #4
Member
 
Martin
Join Date: Dec 2011
Posts: 40
Rep Power: 14
msaravia is on a distinguished road
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.
msaravia is offline   Reply With Quote

Old   October 13, 2018, 05:23
Default
  #5
New Member
 
Emily
Join Date: Nov 2017
Posts: 24
Rep Power: 8
em17 is on a distinguished road
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
em17 is offline   Reply With Quote

Old   October 15, 2018, 10:10
Default
  #6
Member
 
Martin
Join Date: Dec 2011
Posts: 40
Rep Power: 14
msaravia is on a distinguished road
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.
msaravia is offline   Reply With Quote

Reply


Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are Off
Pingbacks are On
Refbacks are On


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


All times are GMT -4. The time now is 11:35.