Commit 9211bebd authored by franjo_j@hotmail.com's avatar franjo_j@hotmail.com
Browse files

refineBoundaryLayers bug fixes. Not finished yet.


git-svn-id: https://pl5.projectlocker.com/igui/meshGeneration/svn@34 fdcce57e-7e00-11e2-b579-49867b4cea03
parent 991810d5
......@@ -44,7 +44,27 @@ void refineBoundaryLayers::generateNewCellsPrism
DynList<DynList<DynList<label, 8>, 10> >& cellsFromCell
)
{
const cell& c = mesh_.cells()[cellI];
cellsFromCell.setSize(1);
DynList<DynList<label, 8>, 10>& cellFaces = cellsFromCell[0];
forAll(c, fI)
{
forAllRow(facesFromFace_, c[fI], cfI)
{
const label nfI = facesFromFace_(c[fI], cfI);
DynList<label, 8> cf;
cf.setSize(newFaces_.sizeOfRow(nfI));
forAllRow(newFaces_, nfI, pI)
cf[pI] = newFaces_(nfI, pI);
cellFaces.append(cf);
}
}
}
//- generate new cells from a hex at a feature edge
......@@ -54,7 +74,27 @@ void refineBoundaryLayers::generateNewCellsEdgeHex
DynList<DynList<DynList<label, 4>, 6>, 64>& cellsFromCell
)
{
const cell& c = mesh_.cells()[cellI];
cellsFromCell.setSize(1);
DynList<DynList<label, 4>, 6>& cellFaces = cellsFromCell[0];
forAll(c, fI)
{
forAllRow(facesFromFace_, c[fI], cfI)
{
const label nfI = facesFromFace_(c[fI], cfI);
DynList<label, 4> cf;
cf.setSize(newFaces_.sizeOfRow(nfI));
forAllRow(newFaces_, nfI, pI)
cf[pI] = newFaces_(nfI, pI);
cellFaces.append(cf);
}
}
}
//- generate new cells from a hex at a corner
......@@ -64,7 +104,27 @@ void refineBoundaryLayers::generateNewCellsCornerHex
DynList<DynList<DynList<label, 4>, 6>, 256>& cellsFromCell
)
{
const cell& c = mesh_.cells()[cellI];
cellsFromCell.setSize(1);
DynList<DynList<label, 4>, 6>& cellFaces = cellsFromCell[0];
forAll(c, fI)
{
forAllRow(facesFromFace_, c[fI], cfI)
{
const label nfI = facesFromFace_(c[fI], cfI);
DynList<label, 4> cf;
cf.setSize(newFaces_.sizeOfRow(nfI));
forAllRow(newFaces_, nfI, pI)
cf[pI] = newFaces_(nfI, pI);
cellFaces.append(cf);
}
}
}
void refineBoundaryLayers::generateNewCells()
......@@ -88,7 +148,7 @@ void refineBoundaryLayers::generateNewCells()
label nNewCells(0);
forAll(nCellsFromCell, cellI)
nNewCells += (nCellsFromCell[cellI] - 1);
/*
forAll(nCellsFromCell, cellI)
{
Info << "\nCell " << cellI << endl;
......@@ -96,15 +156,21 @@ void refineBoundaryLayers::generateNewCells()
Info << "Ref type " << refType[cellI] << endl;
}
Info << "Number of newly generated cells " << nNewCells << endl;
//- generate new cells
*/
//- create mesh modifier
polyMeshGenModifier meshModifier(mesh_);
faceListPMG& faces = meshModifier.facesAccess();
const label numFacesBefore = newFaces_.size();
//- set the number of cells to the new value
cellListPMG& cells = meshModifier.cellsAccess();
label nCells = cells.size();
cells.setSize(nCells+nNewCells);
//- start creating new cells
//- store the information which new cells were generated from
//- an existing cell
VRWGraph newCellsFromCell(refType.size());
VRWGraph pointNewFaces;
......@@ -115,6 +181,15 @@ void refineBoundaryLayers::generateNewCells()
if( refType[cellI] == 0 )
{
newCellsFromCell.append(cellI, cellI);
cell& c = cells[cellI];
forAll(c, fI)
{
if( facesFromFace_.sizeOfRow(c[fI]) != 1 )
FatalError << "Crap!" << abort(FatalError);
c[fI] = facesFromFace_(c[fI], 0);
}
}
else if( refType[cellI] == 1 )
{
......@@ -149,6 +224,7 @@ void refineBoundaryLayers::generateNewCells()
if( faceLabel < 0 )
{
FatalError << "1.Sranje" << abort(FatalError);
forAll(nf, pI)
pointNewFaces.append(nf[pI], newFaces_.size());
c[fI] = newFaces_.size();
......@@ -191,6 +267,7 @@ void refineBoundaryLayers::generateNewCells()
if( faceLabel < 0 )
{
FatalError << "2.Sranje" << abort(FatalError);
forAll(nf, pI)
pointNewFaces.append(nf[pI], newFaces_.size());
c[fI] = newFaces_.size();
......@@ -238,6 +315,7 @@ void refineBoundaryLayers::generateNewCells()
if( faceLabel < 0 )
{
FatalError << "3.Sranje" << abort(FatalError);
forAll(nf, pI)
pointNewFaces.append(nf[pI], newFaces_.size());
c[fI] = newFaces_.size();
......@@ -255,6 +333,168 @@ void refineBoundaryLayers::generateNewCells()
<< cellI << abort(FatalError);
}
}
//- update cell sets
mesh_.updateCellSubsets(newCellsFromCell);
newCellsFromCell.setSize(0);
//- point-faces addressing is not needed any more
pointNewFaces.setSize(0);
//- copy the newFaces to the mesh
const label nOrigInternalFaces = mesh_.nInternalFaces();
const label nNewInternalFaces =
facesFromFace_(mesh_.boundaries()[0].patchStart(), 0);
//- store internal faces originating from existing faces
Info << "Copying internal faces " << endl;
Info << "Original number of internal faces " << nOrigInternalFaces << endl;
labelListPMG newFaceLabel(newFaces_.size());
faces.setSize(newFaces_.size());
label currFace = 0;
for(label faceI=0;faceI<nOrigInternalFaces;++faceI)
{
forAllRow(facesFromFace_, faceI, ffI)
{
face& f = faces[currFace];
newFaceLabel[currFace] = currFace;
++currFace;
const label newFaceI = facesFromFace_(faceI, ffI);
f.setSize(newFaces_.sizeOfRow(newFaceI));
forAll(f, pI)
f[pI] = newFaces_(newFaceI, pI);
}
}
//- store newly-generated internal faces
Info << "Copying newly generated internal faces" << endl;
Info << "nNewInternalFaces " << currFace << endl;
Info << "numFacesBefore " << numFacesBefore << endl;
Info << "Total number of faces " << newFaces_.size() << endl;
for(label faceI=numFacesBefore;faceI<newFaces_.size();++faceI)
{
newFaceLabel[faceI] = currFace;
face& f = faces[currFace];
++currFace;
f.setSize(newFaces_.sizeOfRow(faceI));
forAll(f, pI)
f[pI] = newFaces_(faceI, pI);
}
//- store new boundary faces
Info << "Copying boundary faces " << endl;
Info << "currFace " << currFace << endl;
Info << "Faces size " << faces.size() << endl;
Info << "Initial number of faces " << facesFromFace_.size() << endl;
PtrList<writePatch>& boundaries = meshModifier.boundariesAccess();
forAll(boundaries, patchI)
{
const label start = boundaries[patchI].patchStart();
const label size = boundaries[patchI].patchSize();
const label newStart = currFace;
label nNewFacesInPatch(0);
for(label fI=0;fI<size;++fI)
{
const label faceI = start + fI;
forAllRow(facesFromFace_, faceI, nfI)
{
face& f = faces[currFace];
//- update the new label
const label origFaceI = facesFromFace_(faceI, nfI);
newFaceLabel[origFaceI] = currFace;
facesFromFace_(faceI, nfI) = currFace;
++currFace;
//- copy the face into the mesh
f.setSize(newFaces_.sizeOfRow(origFaceI));
forAll(f, pI)
f[pI] = newFaces_(origFaceI, pI);
++nNewFacesInPatch;
}
}
//- update patch
boundaries[patchI].patchStart() = newStart;
boundaries[patchI].patchSize() = nNewFacesInPatch;
}
if( Pstream::parRun() )
{
Info << "Copying processor faces" << endl;
//- copy faces at inter-processor boundaries
PtrList<writeProcessorPatch>& procBoundaries =
meshModifier.procBoundariesAccess();
forAll(procBoundaries, patchI)
{
const label start = procBoundaries[patchI].patchStart();
const label size = procBoundaries[patchI].patchSize();
const label newStart = currFace;
label nNewFacesInPatch(0);
for(label fI=0;fI<size;++fI)
{
const label faceI = start + fI;
forAllRow(facesFromFace_, faceI, nfI)
{
face& f = faces[currFace];
newFaceLabel[faceI] = currFace;
//- update the new label
const label origFaceI = facesFromFace_(faceI, nfI);
facesFromFace_(faceI, nfI) = currFace;
++currFace;
//- copy the face into the mesh
f.setSize(newFaces_.sizeOfRow(origFaceI));
forAll(f, pI)
f[pI] = newFaces_(origFaceI, pI);
++nNewFacesInPatch;
}
}
//- update patch
procBoundaries[patchI].patchStart() = newStart;
procBoundaries[patchI].patchSize() = nNewFacesInPatch;
}
}
Info << "Faces after refinement " << faces << endl;
Info << "newFaceLabel " << newFaceLabel << endl;
//- update face subsets
Info << "Updating subsets" << endl;
mesh_.updateFaceSubsets(facesFromFace_);
facesFromFace_.setSize(0);
newFaces_.setSize(0);
//- update cells to match the faces
Info << "Updating cells to match new faces" << endl;
forAll(cells, cellI)
{
cell& c = cells[cellI];
forAll(c, fI)
c[fI] = newFaceLabel[c[fI]];
}
Info << "Cleaning mesh " << endl;
meshModifier.clearAll();
Info << "Finished generating new cells " << endl;
//::exit(1);
}
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
......
......@@ -234,11 +234,13 @@ void refineBoundaryLayers::refineFace
(1.0 - u) * points[facePoints[0][j]] +
u * points[facePoints[nLayersDir0][j]] -
(1.0 - u) * (1.0 - v) * points[facePoints[0][0]] -
u * v * points[facePoints[nLayersDir0][nLayersDir1]] -
u * (1.0 - v) * points[facePoints[nLayersDir0][0]] -
u * v * points[facePoints[nLayersDir0][0]] -
u * (1.0 - v) * points[facePoints[nLayersDir0][nLayersDir1]] -
(1.0 - u) * v * points[facePoints[0][nLayersDir1]]
);
Info << "Point coordinate " << newP << endl;
//- add the vertex to the mesh
facePoints[i][j] = points.size();
mesh_.appendVertex(newP);
......@@ -310,6 +312,7 @@ void refineBoundaryLayers::refineFace
newFaces.append(newF);
//Info << "Input face " << f << endl;
//Info << "Decomposed faces are " << newFaces << endl;
//if( (nLayersInDirection[0] > 1) && (nLayersInDirection[1] > 1) )
//::exit(1);
......@@ -336,7 +339,6 @@ void refineBoundaryLayers::generateNewFaces()
newFaces_.clear();
//- split internal faces
Info << "Splitting internal faces " << endl;
for(label faceI=0;faceI<nInternalFaces;++faceI)
{
const face& f = faces[faceI];
......@@ -400,7 +402,6 @@ void refineBoundaryLayers::generateNewFaces()
//- refine boundary faces where needed
//- it is required in locations where two or three layers intersect
const label startingBoundaryFace = mesh_.boundaries()[0].patchStart();
Info << "Splitting boundary faces" << endl;
forAll(bFaces, bfI)
{
const face& bf = bFaces[bfI];
......@@ -456,7 +457,6 @@ void refineBoundaryLayers::generateNewFaces()
if( Pstream::parRun() )
{
Info << "Refine faces at inter-processor boundaries" << endl;
//- refine faces at interprocessor boundaries
const PtrList<writeProcessorPatch>& procBoundaries =
mesh_.procBoundaries();
......@@ -610,10 +610,6 @@ void refineBoundaryLayers::generateNewFaces()
{
const DynList<label, 4>& df = facesFromFace[i];
DynList<label, 4> rFace = help::reverseFace(df);
// rFace.setSize(df.size());
// rFace[0] = df[0];
// for(label pI=1;df.size();++pI)
// rFace[df.size()-pI] = df[pI];
facesFromFace_.append(faceI, newFaces_.size());
newFaces_.appendList(rFace);
......@@ -622,6 +618,9 @@ void refineBoundaryLayers::generateNewFaces()
}
}
}
Info << "facesFromFace_ " << facesFromFace_ << endl;
Info << "newFaces_ " << newFaces_ << endl;
}
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
......
......@@ -375,9 +375,6 @@ void refineBoundaryLayers::analyseLayers()
if( !found )
maxNumLayers = globalNumLayers_;
Info << "Checking patch " << patchI << endl;
Info << "Max num layers " << maxNumLayers << endl;
//- set the number of layer to all patches which are not protected
forAll(patchesInLayer_[layerI], lpI)
{
......@@ -388,9 +385,12 @@ void refineBoundaryLayers::analyseLayers()
}
}
Info << "nLayersAtPatch " << nLayersAtPatch << endl;
//- set the number of boundary layers which shall be generated above
//- each boundary face
nLayersAtBndFace_.setSize(facePatch.size());
nLayersAtBndFace_ = 0;
# ifdef USE_OMP
# pragma omp parallel for schedule(dynamic, 50)
......@@ -412,8 +412,7 @@ void refineBoundaryLayers::analyseLayers()
}
}
Info << "nLayersAtPatch " << nLayersAtPatch << endl;
Info << "nLayersAtBndFace " << nLayersAtBndFace_ << endl;
Info << "nLayersAtBndFace_ " << nLayersAtBndFace_ << endl;
}
void refineBoundaryLayers::calculateAddressing
......
......@@ -26,7 +26,7 @@ Application
Test for boundary layers
Description
-
-
\*---------------------------------------------------------------------------*/
......@@ -36,6 +36,7 @@ Description
#include "polyMeshGen.H"
#include "boundaryLayers.H"
#include "refineBoundaryLayers.H"
#include "polyMeshGenChecks.H"
using namespace Foam;
......@@ -47,10 +48,10 @@ int main(int argc, char *argv[])
{
# include "setRootCase.H"
# include "createTime.H"
polyMeshGen pmg(runTime);
pmg.read();
//boundaryLayers bndLayers(pmg);
//bndLayers.addLayerForPatch("inlet");
//bndLayers.addLayerForPatch("symmetryplane");
......@@ -63,14 +64,16 @@ int main(int argc, char *argv[])
refLayers.setGlobalThicknessRatio(1.5);
refLayers.refineLayers();
//pmg.write();
//polyMeshGenChecks::checkMesh(pmg, true);
pmg.write();
//meshOctree* octreePtr = NULL;
//meshOptimizer(*octreePtr, pmg).preOptimize();
//writeMeshEnsight(pmg, "meshWithBndLayers");
//pmg.addressingData().checkMesh(true);
Info << "End\n" << endl;
return 0;
}
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment