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

addPatchCellLayer

Register Blogs Community New Posts Updated Threads Search

Reply
 
LinkBack Thread Tools Search this Thread Display Modes
Old   May 3, 2010, 13:13
Default addPatchCellLayer
  #1
Member
 
Niklas Winkler
Join Date: Mar 2009
Location: Stockholm, Stockholm, Sweden
Posts: 73
Rep Power: 17
nikwin is on a distinguished road
Hi,

I would like to add a cell layer on a wall patch of a pipe to be able to calculate the gradient over the original patch faces.

To add a cell layer it seems that the addPatchCellLayer class should be able to do it for me, but I don't understand how to obtain the arguments for the setRefinement function?

Thanks
/NW
nikwin is offline   Reply With Quote

Old   May 14, 2010, 07:37
Default
  #2
Member
 
Niklas Winkler
Join Date: Mar 2009
Location: Stockholm, Stockholm, Sweden
Posts: 73
Rep Power: 17
nikwin is on a distinguished road
Copy and paste from autoLayerDriver.C did it.
/NW
nikwin is offline   Reply With Quote

Old   December 14, 2010, 16:49
Default
  #3
Senior Member
 
Sandeep Menon
Join Date: Mar 2009
Location: Amherst, MA
Posts: 403
Rep Power: 25
deepsterblue will become famous soon enough
Niklas,
Did you add a cell-layer towards the interior of the domain (fluid)? Or was it an addition outside the mesh? Could you post your code, if that's possible... It would be really helpful.

Thanks
__________________
Sandeep Menon
University of Massachusetts Amherst
https://github.com/smenon
deepsterblue is offline   Reply With Quote

Old   December 15, 2010, 13:12
Default
  #4
Member
 
Niklas Winkler
Join Date: Mar 2009
Location: Stockholm, Stockholm, Sweden
Posts: 73
Rep Power: 17
nikwin is on a distinguished road
Hi,

I just added a cell layer as an addition to the mesh to be able to compute derivatives of a field on the "old" boundaries. Adding the code below but as I wrote it's just a copy and paste from the doxygen manual.

All the Best
/NW

int main(int argc, char *argv[])
{

# include "setRootCase.H"
# include "createTime.H"
# include "createMesh.H"

//////////////////////////////////////////////
// AddCellLayer
//////////////////////////////////////////////

addPatchCellLayer addLayer(mesh);
label nLayers=1;
polyTopoChange meshMod(mesh);

const polyBoundaryMesh& patches = mesh.boundaryMesh();

// Count faces.
label nFaces = 0;

nFaces = patches[0].size();
// Collect faces.
labelList addressing(nFaces);
nFaces = 0;

const polyPatch& pp = patches[0];

label meshFaceI = pp.start();

forAll(pp, i)
{
addressing[nFaces++] = meshFaceI++;
}
indirectPrimitivePatch ipp(IndirectList<face>(mesh.faces(), addressing),mesh.points());

// scalar thickness = 1e-4;
scalar thickness = 3e-4;

vectorField faceNormals = pp.faceNormals();
pointField patchDispl(pp.nPoints(), vector::zero);

pointField pointNormals(pp.pointNormals()); // Determine pointNormal

// Start off from same thickness everywhere (except where no extrusion)
patchDispl = thickness*pointNormals;

// Add topo regardless of whether extrudeStatus is extruderemove.
// Not add layer if patchDisp is zero.

addLayer.setRefinement(nLayers,ipp,patchDispl,mesh Mod);

// With the stored topo changes we create a new mesh so we can
// undo if neccesary.

autoPtr<fvMesh> meshPtr;
autoPtr<mapPolyMesh> map = meshMod.makeMesh
(
meshPtr,
IOobject
(
mesh.name(),
static_cast<polyMesh&>(mesh).instance(),
mesh.thisDb(),
static_cast<polyMesh&>(mesh).readOpt(),
static_cast<polyMesh&>(mesh).writeOpt()
), // io params from original mesh but new name
mesh, // original mesh
true // parallel sync
);

// Update numbering on addLayer:
// - cell/point labels to be newMesh.
// - patchFaces to remain in oldMesh order.
addLayer.updateMesh
(
map,
identity(pp.size()),
identity(pp.nPoints())
);

mesh.write();

runTime.write();

Info<< "END" << endl;
return(0);
}
nikwin is offline   Reply With Quote

Old   December 15, 2010, 14:00
Default
  #5
Senior Member
 
Sandeep Menon
Join Date: Mar 2009
Location: Amherst, MA
Posts: 403
Rep Power: 25
deepsterblue will become famous soon enough
Thanks a ton for the code, Niklas.

Just in case someone's looking for a simple solution, here's the alternative:

0. Backup the original mesh.

1. Call extrudeMesh using the following settings for extrudeProperties:

Code:
FoamFile
{
    version     2.0;
    format      ascii;
    class       dictionary;
    object      extrudeProperties;
}
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //

    // Where to get surface from: either from surface ('surface') or
    // from (flipped) patch of existing case ('patch')
    constructFrom patch;

    // If construct from (flipped) patch
    sourceCase "$FOAM_RUN/myCase";
    sourcePatch myPatchName;

    // Flip surface normals before usage.
    flipNormals false;

    // Do front and back need to be merged? Usually only makes sense for 360
    // degree wedges.
    mergeFaces false;

    //- Linear extrusion in point-normal direction
    extrudeModel        linearNormal;

    nLayers 1;

    linearNormalCoeffs
    {
        thickness       0.05;
    }
2. Copy the extrudeMesh result to a new case.

3. Use mergeMeshes with the original and new cases.

4. Use stitchMesh with the -perfect flag.
__________________
Sandeep Menon
University of Massachusetts Amherst
https://github.com/smenon
deepsterblue 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



All times are GMT -4. The time now is 01:33.