CFD Online Logo CFD Online URL
www.cfd-online.com
[Sponsors]
Home > Forums > Software User Forums > OpenFOAM > OpenFOAM Pre-Processing

Using topoSet/swakExpression to select faces 2cm above ground

Register Blogs Community New Posts Updated Threads Search

Reply
 
LinkBack Thread Tools Search this Thread Display Modes
Old   April 15, 2016, 11:05
Default Using topoSet/swakExpression to select faces 2cm above ground
  #1
Member
 
Timm Severin
Join Date: Mar 2014
Location: Munich
Posts: 63
Rep Power: 12
Astrodan is on a distinguished road
Hello there,

I have a (sloped) channel, for which I have an inlet patch defined. Now I don't want the whole inlet to act as such, but only a small, 1cm high part of it (see attached image).
My approach was to select all faces of the original inlet patch, remove the 1cm part (which starts 2cm above the bottom) and then declare the selected faces as wall patch.

This process generally works, but I can't select the correct cells dynamically. My topoSetDict looks as follows:
Code:
actions
(
    {
        name        inletWallSet;
        type        faceSet;
        action      new;
        source      patchToFace;
        sourceInfo
        {
            name    inlet;
        }
    }
    
    {
        name        inletWallSet;
        type        faceSet;
        action      delete;
        source      expressionToFace;

        sourceInfo
        {
            variables
            (
                "inletStart=0.02;"
                "inletHeight=0.01;"
                "zMin=min(pos().z);"
                "start=zMin+inletStart;"
                "end=zMin+inletStart+inletHeight;"
            );
            debugCommonDriver 1;
            expression  "fpos().z>=interpolate(start)&&fpos().z<=interpolate(end)";
        }
    }
);
The idea was that I get the minimum z value on the patch in zMin, and use this to set the start of my actual inlet. However, min(pos().z) returns the minimum z-position over the complete domain, and since my channel is sloped this returns the wrong result.

I have tried working with onPatch(inlet), (e.g. zMin="(onPatch(inlet) ? fpos().z : surf(999);"), but this either fails or always pretends that the minimum value is 0 (which is right, incidently, but when i translate the mesh in z direction it still returns 0, even if this is outside of the bounding box).

Is there anything I'm missing? Does anyone have an alternative idea?

Thanks for any replies,
Timm
Attached Images
File Type: png prob.png (7.6 KB, 28 views)
Astrodan is offline   Reply With Quote

Old   May 30, 2016, 13:20
Default
  #2
Member
 
Timm Severin
Join Date: Mar 2014
Location: Munich
Posts: 63
Rep Power: 12
Astrodan is on a distinguished road
Ok, due to the mass of replies I choose another way and used some basic algebra which I had completely forgotten since leaving school.

However, it now seems to be running, so I present the new topoSet source "patchPartToFace". An entry for this looks lie this:

Code:
    {   
        name        selectFaceSet;
        type        faceSet;
        action      new;
        source      patchPartToFace;
        sourceInfo
        {
            name        inlet;
            radius      0.03;
            direction   (1 0 0); 
            inside      true;
        }
    }
How does it work?
Based on the name, it selects a patch and tries to figure out what is the least distance of the vector given by dir and the coordinates of all patch faces is. This basically moves the given direction vector onto the plane that is the patch.
When this is done, all cells that are within radius around this vector will be selected (inside = true) or not selected (inside = false).

To use it, extract the attached .zip file, and run "wmake lib" in the main directory "topoSet". The library will be install in $FOAM_USER_LIBBIN as libtopoSet. If you want to use it, you will also need to add it in the controlDict under libs();

Example: To achieve the goal I posted in the image of the first post, I used the following commands:
Code:
    {   
        name        inletWallSet;
        type        faceSet;
        action      delete;
        source      patchPartToFace;
        sourceInfo
        {
            name        inlet;
            radius      0.03;
            direction   (1 0 0); 
            inside      true;
        }
    }   

    {   
        name        inletWallSet;
        type        faceSet;
        action      add;
        source      patchPartToFace;
        sourceInfo
        {
            name        inlet;
            radius      0.02;
            direction   (1 0 0);
            inside      true;
        }
    }
Note: Sadly, the calculations seems to be highly inaccurate when using a direction that is not aligned to the coordinate system close to (0 0 0), where "close" is approximately 0.1 m. I suppose it's some numerical reason that could be fixed, but right now I just don't care enough. A workaround would be to first use transformPoints -translate '(1 1 1)', then use topoSet and finally transform the points back.
Attached Files
File Type: zip topoSet.zip (31.4 KB, 10 views)
Astrodan 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
decomposePar no field transfert Jeanp OpenFOAM Pre-Processing 3 June 18, 2022 12:01
decomposePar problem: Cell 0contains face labels out of range vaina74 OpenFOAM Pre-Processing 37 July 20, 2020 05:38
Cluster ID's not contiguous in compute-nodes domain. ??? Shogan FLUENT 1 May 28, 2014 15:03
decomposePar pointfield flying OpenFOAM Running, Solving & CFD 28 December 30, 2013 15:05
[Commercial meshers] fluentMeshToFoam multidomain mesh conversion problem Attesz OpenFOAM Meshing & Mesh Conversion 12 May 2, 2013 10:52


All times are GMT -4. The time now is 06:38.