View Issue Details

IDProjectCategoryView StatusLast Update
0002004OpenFOAM[All Projects] Bugpublic2016-02-22 17:09
ReporterwyldckatAssigned Tohenry 
PrioritylowSeverityfeatureReproducibilitysometimes
Status resolvedResolutionfixed 
Product Versiondev 
Fixed in Version 
Summary0002004: Unleash dynamicMesh's multiDirRefinement class with customizable direction fields
DescriptionThis is partially a tie-in with the bug report http://www.openfoam.org/mantisbt/view.php?id=1960 - along with a feature-proof that we had made back in June last year and I finally managed to refine it up to the contribution standards/requirements.

The concept for this contributed feature is simple:

 1 - The class "src/dynamicMesh/meshModifiers/multiDirRefinement" has a built-in support for providing custom direction fields, coming from calculations made outside of the application. This allows us to circumvent some of the limitations that were pointed out in the other bug report.

 2 - The refineMesh utility is not (yet) prepared to handle providing these custom direction fields.

 3 - While developing this contribution, the conclusion was that given that the "directions" block is the natural contender for where the user should define the custom directions, I ended up concluding that it was best to overload the class "src/dynamicMesh/meshCut/directions" with the necessary feature for handling the custom field directions. The other hypothesis was to created a new dictionary entry and options dedicated to the custom field directions, which felt it would clutter the "refineMeshDict" and feel redundant in having two groups of keywords for directions.


An example of why we (at blueCAPE Lda) needed this feature to be unleashed back in June, is demonstrated in the following attached images:

  - refineFieldDirs.0000.png - This was made with a simple "blockMeshDict". And I couldn't be bothered with having to manually design the whole mesh with blockMesh.

  - refineFieldDirs.0009.png - This demonstrates what 9 iterations with refineMesh could achieve, using topoSet and a custom utility named "calcRadiusField".

  - The images for the iterations 1 to 8 are attached inside the file "refineFieldDirs.images.zip".


Attached are the following contributions (targeted to the latest OpenFOAM-dev commits):

  - refineFieldDirs_v1.5.tar.gz - This is the case that was used for the attached images. It's designed to be easily integrated into the subdirectory "tutorials/mesh/refineMesh", since it essentially only handles the mesh part of the case, it does not do the rest of the case.
    - If necessary, a more complete running case can be provided, but the one we had has a few meshing flaws, since it was using the resulting mesh as a base for snappyHexMesh to finish things up.

  - refineMeshDict - Meant for updating the file "applications/utilities/mesh/manipulation/refineMesh/refineMeshDict".
    - It provides details on the feature introduced with the files below.
    - It essentially documents the new "coordinateSystem" named "fieldBased", which relies on the field file names given in the "directions" block.

  - directions.[CH] - These two files are meant for updating the ones in the folder "src/dynamicMesh/meshCut/directions".
    - In the declarations (.H) file is the description for the additional "coordinateSystem" named "fieldBased".
    - In the definitions (.C) file, the constructor now also handles the new "coordinateSystem" named "fieldBased", by loading the "vectorField" field files. Need to change a bit the order of initializations, because of the double use of the "directions" block in the dictionary, which with this patch, it is either using the hashed standard names or the generic field names.

  - cellCuts.C - This is meant for updating the file "src/dynamicMesh/meshCut/cellCuts/cellCuts.C", because I missed a line break in the patch provided for the #1960 bug report.


More details are provided in the sections below.
Steps To ReproduceFor using the attached package "refineFieldDirs_v1.5.tar.gz", it's as simple as follows:

  tar -xf refineFieldDirs_v1.5.tar.gz
  cd refineFieldDirs
  ./Allrun

The case is essentially a 1/16th slice of a cylinder. It's designed for a symmetric profile at the minY-maxY patches, not cyclic.

It will:

  1 - Build the custom utility "calcRadiusField", which is explained further in the next section.

  2 - Run blockMesh. It uses a non-uniform grading along the radial direction. This was calculated based on the target cell sizes (manually calculated and planned).

  3 - Do 6 iterations of mesh refinement, where each iteration does the following steps:

    1 - Run calcRadiusField, for calculating the field "radiusFieldXY", which as the file name implies, it generates a "volScalarField" that contains the distance to the centre axis of the cylinder.

    2 - Run topoSet for creating a cellSet that selects the cells with the values with a set range for the field "radiusFieldXY".

    3 - Run refineMesh for refining the mesh along Z (height), on the selected cells. This will make the mesh a bit more uniform'ish along the height, as it distances itself from the centre axis (if we take into account the 6 iterations).

    4 - Removes the contents of the 0 folder, to avoid unnecessary field refinement or contamination for the next iteration.

  4 - Next is another refinement iteration, but this time it refines all orientations, but for the more coarser cells. The steps for each iteration are as follows:

    1 - Run "calcRadiusField -calcDirections", which will also calculate 3 additional vector fields: radialDirection, angularDirection, heightDirection. A particular detail here is explained in the next section.

    2 - Run topoSet for creating a cellSet that selects the cells with the values with a set range for the field "radiusFieldXY".

    3 - Run refineMesh for refining the mesh according to the provided custom direction fields. Again, with the objective of making the mesh a bit more uniform as a hole, in function of the distance from the centre axis.

Additional InformationThe custom utility "calcRadiusField" generates 4 fields:

  - "radiusFieldXY" by default, which is the field that provides the distance to the centre axis of the cylinder, which is why it is only in function of X and Y.

  - the 3 other fields are optional and created if the option "-calcDirections" is given:
    - radialDirection
    - angularDirection
    - heightDirection

    These 3 fields are of type "vectorField", not "volVectorField", because:

      1 - "refineMesh" is currently designed for operating over only the mesh itself. It does not do explicit field mapping, therefore it sticks to the minimum memory requirements for mesh manipulation.

      2 - I couldn't manage to get a workaround working, by using a hack'ish way of loading an internal field from a "volVectorField" file with a conventional "dictionary" reading class, due to the safety measures put in place to avoid just that.

The downside of this is that it doesn't allow to easily post-process these custom generated fields, but nothing that a bit of "#include" in a wrapper field file won't fix.
Tagscontribution

Activities

wyldckat

2016-02-21 17:03

updater  

refineFieldDirs.0000.png (34,235 bytes)
refineFieldDirs.0000.png (34,235 bytes)

wyldckat

2016-02-21 17:03

updater  

refineFieldDirs.0009.png (82,039 bytes)
refineFieldDirs.0009.png (82,039 bytes)

wyldckat

2016-02-21 17:03

updater  

refineFieldDirs.images.zip (335,890 bytes)

wyldckat

2016-02-21 17:03

updater  

refineFieldDirs_v1.5.tar.gz (5,038 bytes)

wyldckat

2016-02-21 17:03

updater  

refineMeshDict (2,463 bytes)
/*--------------------------------*- C++ -*----------------------------------*\
| =========                 |                                                 |
| \\      /  F ield         | OpenFOAM: The Open Source CFD Toolbox           |
|  \\    /   O peration     | Version:  dev                                   |
|   \\  /    A nd           | Web:      www.OpenFOAM.org                      |
|    \\/     M anipulation  |                                                 |
\*---------------------------------------------------------------------------*/
FoamFile
{
    version     2.0;
    format      ascii;
    class       dictionary;
    object      refineMeshDict;
}
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //

// Cells to refine; name of cell set
set c0;

// Type of coordinate system:
// - global : coordinate system same for every cell. Usually aligned with
//   x,y,z axis. Specify in globalCoeffs section below.
// - patchLocal : coordinate system different for every cell. Specify in
//   patchLocalCoeffs section below.
// - fieldBased : uses the list of field names from the directions list for
//   selecting the directions to cut. Meant to be used with geometricCut, but
//   can also be used with useHexTopology.
coordinateSystem global;
//coordinateSystem patchLocal;
//coordinateSystem fieldBased;

// .. and its coefficients. x,y in this case. (normal direction is calculated
// as tan1^tan2)
globalCoeffs
{
    tan1 (1 0 0);
    tan2 (0 1 0);
}

patchLocalCoeffs
{
    patch outside;  // Normal direction is facenormal of zero'th face of patch
    tan1 (1 0 0);
}

// List of directions to refine, if global or patchLocal
directions
(
    tan1
    tan2
    normal
);

// List of directions to refine, if "fieldBased". Keep in mind that these
// fields must be of type "vectorField", not "volVectorField".
//directions
//(
//    radialDirectionFieldName
//    angularDirectionFieldName
//    heightDirectionFieldName
//);

// Whether to use hex topology. This will
// - if patchLocal: all cells on selected patch should be hex
// - split all hexes in 2x2x2 through the middle of edges.
useHexTopology  true;

// Cut purely geometric (will cut hexes through vertices) or take topology
// into account. Incompatible with useHexTopology
geometricCut    false;

// Write meshes from intermediate steps
writeMesh       false;

// ************************************************************************* //
refineMeshDict (2,463 bytes)

wyldckat

2016-02-21 17:04

updater  

directions.C (11,772 bytes)

wyldckat

2016-02-21 17:04

updater  

directions.H (4,398 bytes)

wyldckat

2016-02-21 17:04

updater  

cellCuts.C (74,106 bytes)

henry

2016-02-22 17:09

manager   ~0005977

Thanks for the contribution Bruno,

Added to OpenFOAM-dev by commit e22f1b3514d3b9e2fbf1a6e29fca68481bfc30b4

Issue History

Date Modified Username Field Change
2016-02-21 17:02 wyldckat New Issue
2016-02-21 17:02 wyldckat Status new => assigned
2016-02-21 17:02 wyldckat Assigned To => henry
2016-02-21 17:03 wyldckat File Added: refineFieldDirs.0000.png
2016-02-21 17:03 wyldckat File Added: refineFieldDirs.0009.png
2016-02-21 17:03 wyldckat File Added: refineFieldDirs.images.zip
2016-02-21 17:03 wyldckat File Added: refineFieldDirs_v1.5.tar.gz
2016-02-21 17:03 wyldckat File Added: refineMeshDict
2016-02-21 17:04 wyldckat File Added: directions.C
2016-02-21 17:04 wyldckat File Added: directions.H
2016-02-21 17:04 wyldckat File Added: cellCuts.C
2016-02-21 17:06 wyldckat Tag Attached: contribution
2016-02-22 17:09 henry Note Added: 0005977
2016-02-22 17:09 henry Status assigned => resolved
2016-02-22 17:09 henry Resolution open => fixed