Commit c731cfdc authored by mattijs's avatar mattijs
Browse files

initial mattijsLib merge

parent 7faf6887
......@@ -54,8 +54,8 @@ Description
#include "cellInfo.H"
#include "MeshWave.H"
#include "edgeStats.H"
#include "octreeDataTriSurface.H"
#include "octree.H"
#include "treeDataTriSurface.H"
#include "indexedOctree.H"
using namespace Foam;
......@@ -185,7 +185,7 @@ void cutBySurface
<< " to the surface ..." << nl << endl;
const pointField& pts = mesh.points();
const octree<octreeDataTriSurface>& tree = querySurf.tree();
const indexedOctree<treeDataTriSurface>& tree = querySurf.tree();
label nRemoved = 0;
......@@ -193,17 +193,9 @@ void cutBySurface
{
const point& pt = pts[pointI];
// Search in tight bounding box around pt.
treeBoundBox tightest
(
pt - vector(nearDist, nearDist, nearDist),
pt + vector(nearDist, nearDist, nearDist)
);
scalar tightestDist = mag(tightest.max() - tightest.min());
label triI = tree.findNearest(pt, tightest, tightestDist);
pointIndexHit hitInfo = tree.findNearest(pt, sqr(nearDist));
if (triI != -1 && tightestDist < nearDist)
if (hitInfo.hit())
{
const labelList& pCells = mesh.pointCells()[pointI];
......
......@@ -45,6 +45,7 @@ using namespace Foam;
int main(int argc, char *argv[])
{
# include "addRegionOption.H"
# include "addTimeOptionsNoConstant.H"
......@@ -67,7 +68,7 @@ int main(int argc, char *argv[])
runTime.setTime(Times[startTime], startTime);
# include "createPolyMesh.H"
# include "createNamedPolyMesh.H"
bool firstCheck = true;
......
execFlowFunctionObjects.C
EXE = $(FOAM_USER_APPBIN)/execFlowFunctionObjects
EXE = $(FOAM_APPBIN)/execFlowFunctionObjects
calcDivPhi.C
EXE = $(FOAM_USER_APPBIN)/divPhi
EXE = $(FOAM_APPBIN)/divPhi
......@@ -51,16 +51,15 @@ void dumpBox(const treeBoundBox& bb, const fileName& fName)
pointField boxPoints(bb.points());
edgeList boxEdges(bb.edges());
forAll(boxPoints, i)
{
meshTools::writeOBJ(str, boxPoints[i]);
}
forAll(boxEdges, i)
forAll(treeBoundBox::edges, i)
{
const edge& e = boxEdges[i];
const edge& e = treeBoundBox::edges[i];
str<< "l " << e[0]+1 << ' ' << e[1]+1 << nl;
}
......
#!/bin/sh
set -x
#( cd $FOAM_SRC/other && ./Allwmake )
( cd $FOAM_SRC/other && ./Allwmake )
( cd $FOAM_SRC/OpenFOAM && wmakeLnInclude . )
......
/*---------------------------------------------------------------------------*\
========= |
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
\\ / O peration |
\\ / A nd | Copyright (C) 1991-2007 OpenCFD Ltd.
\\/ M anipulation |
-------------------------------------------------------------------------------
License
This file is part of OpenFOAM.
OpenFOAM is free software; you can redistribute it and/or modify it
under the terms of the GNU General Public License as published by the
Free Software Foundation; either version 2 of the License, or (at your
option) any later version.
OpenFOAM is distributed in the hope that it will be useful, but WITHOUT
ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
for more details.
You should have received a copy of the GNU General Public License
along with OpenFOAM; if not, write to the Free Software Foundation,
Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
Class
Foam::mapDistributeLagrangian
Description
Class containing mesh-to-mesh mapping information for particles
SourceFiles
mapDistributeLagrangian.C
\*---------------------------------------------------------------------------*/
#ifndef mapDistributeLagrangian_H
#define mapDistributeLagrangian_H
#include "mapDistributePolyMesh.H"
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
namespace Foam
{
class mapPolyMesh;
/*---------------------------------------------------------------------------*\
Class mapDistributeLagrangian Declaration
\*---------------------------------------------------------------------------*/
class mapDistributeLagrangian
{
// Private data
const label nNewParticles_;
//- Maps from subsetted mesh back to original mesh
const labelListList subParticleMap_;
//- Maps from subsetted mesh to new reconstructed mesh
const labelListList constructParticleMap_;
//- Per element in subsetted mesh the cell label
const labelListList constructCellLabels_;
public:
// Constructors
//- Construct from components
mapDistributeLagrangian
(
const label nNewParticles,
const labelListList& subParticleMap,
const labelListList& constructParticleMap,
const labelListList& constructCellLabels
)
:
nNewParticles_(nNewParticles),
subParticleMap_(subParticleMap),
constructParticleMap_(constructParticleMap),
constructCellLabels_(constructCellLabels)
{}
//- Construct from components and steal storage
mapDistributeLagrangian
(
const label nNewParticles,
labelListList& subParticleMap,
labelListList& constructParticleMap,
labelListList& constructCellLabels,
const bool reUse
)
:
nNewParticles_(nNewParticles),
subParticleMap_(subParticleMap, reUse),
constructParticleMap_(constructParticleMap, reUse),
constructCellLabels_(constructCellLabels, reUse)
{}
// Member Functions
// Access
//- From subsetted lagrangian particles back to original particles
const labelListList& subParticleMap() const
{
return subParticleMap_;
}
//- From received particles to new reconstructed particles
const labelListList& constructParticleMap() const
{
return constructParticleMap_;
}
//- Per received particle the destination cell label
const labelListList& constructCellLabels() const
{
return constructCellLabels_;
}
// Edit
//- distribute list of lagrangian data
template<class T>
void distributeLagrangianData(List<T>& lst) const
{
mapDistributePolyMesh::distribute
(
nNewParticles_,
subParticleMap(),
constructParticleMap(),
lst
);
}
//- Correct for topo change.
void updateMesh(const mapPolyMesh&)
{
notImplemented
(
"mapDistributeLagrangian::updateMesh(const mapPolyMesh&)"
);
}
};
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
} // End namespace Foam
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
#endif
// ************************************************************************* //
/*---------------------------------------------------------------------------*\
========= |
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
\\ / O peration |
\\ / A nd | Copyright (C) 1991-2007 OpenCFD Ltd.
\\/ M anipulation |
-------------------------------------------------------------------------------
License
This file is part of OpenFOAM.
OpenFOAM is free software; you can redistribute it and/or modify it
under the terms of the GNU General Public License as published by the
Free Software Foundation; either version 2 of the License, or (at your
option) any later version.
OpenFOAM is distributed in the hope that it will be useful, but WITHOUT
ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
for more details.
You should have received a copy of the GNU General Public License
along with OpenFOAM; if not, write to the Free Software Foundation,
Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
\*---------------------------------------------------------------------------*/
#include "ListOps.H"
#include "mapDistributePolyMesh.H"
// * * * * * * * * * * * * * Private Member Functions * * * * * * * * * * * //
void Foam::mapDistributePolyMesh::calcPatchSizes()
{
oldPatchSizes_.setSize(oldPatchStarts_.size());
// Calculate old patch sizes
for (label patchI = 0; patchI < oldPatchStarts_.size() - 1; patchI++)
{
oldPatchSizes_[patchI] =
oldPatchStarts_[patchI + 1] - oldPatchStarts_[patchI];
}
// Set the last one by hand
const label lastPatchID = oldPatchStarts_.size() - 1;
oldPatchSizes_[lastPatchID] = nOldFaces_ - oldPatchStarts_[lastPatchID];
if (min(oldPatchSizes_) < 0)
{
FatalErrorIn("mapDistributePolyMesh::calcPatchSizes()")
<< "Calculated negative old patch size:" << oldPatchSizes_ << nl
<< "Error in mapping data" << abort(FatalError);
}
}
// * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * //
//- Construct from components
Foam::mapDistributePolyMesh::mapDistributePolyMesh
(
const polyMesh& mesh,
// mesh before changes
const label nOldPoints,
const label nOldFaces,
const label nOldCells,
const labelList& oldPatchStarts,
const labelList& oldPatchNMeshPoints,
// how to subset pieces of mesh to send across
const labelListList& subPointMap,
const labelListList& subFaceMap,
const labelListList& subCellMap,
const labelListList& subPatchMap,
// how to reconstruct received mesh
const labelListList& constructPointMap,
const labelListList& constructFaceMap,
const labelListList& constructCellMap,
const labelListList& constructPatchMap
)
:
mesh_(mesh),
nOldPoints_(nOldPoints),
nOldFaces_(nOldFaces),
nOldCells_(nOldCells),
oldPatchSizes_(oldPatchStarts.size()),
oldPatchStarts_(oldPatchStarts),
oldPatchNMeshPoints_(oldPatchNMeshPoints),
subPointMap_(subPointMap),
subFaceMap_(subFaceMap),
subCellMap_(subCellMap),
subPatchMap_(subPatchMap),
constructPointMap_(constructPointMap),
constructFaceMap_(constructFaceMap),
constructCellMap_(constructCellMap),
constructPatchMap_(constructPatchMap)
{
calcPatchSizes();
}
//- (optionally destructively) construct from components
Foam::mapDistributePolyMesh::mapDistributePolyMesh
(
const polyMesh& mesh,
const label nOldPoints,
const label nOldFaces,
const label nOldCells,
labelList& oldPatchStarts,
labelList& oldPatchNMeshPoints,
labelListList& subPointMap,
labelListList& subFaceMap,
labelListList& subCellMap,
labelListList& subPatchMap,
labelListList& constructPointMap,
labelListList& constructFaceMap,
labelListList& constructCellMap,
labelListList& constructPatchMap,
const bool reUse // clone or reuse
)
:
mesh_(mesh),
nOldPoints_(nOldPoints),
nOldFaces_(nOldFaces),
nOldCells_(nOldCells),
oldPatchSizes_(oldPatchStarts.size()),
oldPatchStarts_(oldPatchStarts, reUse),
oldPatchNMeshPoints_(oldPatchNMeshPoints, reUse),
subPointMap_(subPointMap, reUse),
subFaceMap_(subFaceMap, reUse),
subCellMap_(subCellMap, reUse),
subPatchMap_(subPatchMap, reUse),
constructPointMap_(constructPointMap, reUse),
constructFaceMap_(constructFaceMap, reUse),
constructCellMap_(constructCellMap, reUse),
constructPatchMap_(constructPatchMap, reUse)
{
calcPatchSizes();
}
// * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * //
void Foam::mapDistributePolyMesh::distributePointIndices(labelList& lst)
const
{
// Construct boolList from selected elements
boolList isSelected
(
createWithValues<boolList>
(
nOldPoints(),
false,
lst,
true
)
);
// Distribute
distributePointData(isSelected);
// Collect selected elements
lst = findIndices(isSelected, true);
}
void Foam::mapDistributePolyMesh::distributeFaceIndices(labelList& lst)
const
{
// Construct boolList from selected elements
boolList isSelected
(
createWithValues<boolList>
(
nOldFaces(),
false,
lst,
true
)
);
// Distribute
distributeFaceData(isSelected);
// Collect selected elements
lst = findIndices(isSelected, true);
}
void Foam::mapDistributePolyMesh::distributeCellIndices(labelList& lst)
const
{
// Construct boolList from selected elements
boolList isSelected
(
createWithValues<boolList>
(
nOldCells(),
false,
lst,
true
)
);
// Distribute
distributeCellData(isSelected);
// Collect selected elements
lst = findIndices(isSelected, true);
}
void Foam::mapDistributePolyMesh::distributePatchIndices(labelList& lst)
const
{
// Construct boolList from selected elements
boolList isSelected
(
createWithValues<boolList>
(
oldPatchStarts().size(), // nOldPatches
false,
lst,
true
)
);
// Distribute
distributePatchData(isSelected);
// Collect selected elements
lst = findIndices(isSelected, true);
}
// * * * * * * * * * * * * * * * Friend Functions * * * * * * * * * * * * * //
// * * * * * * * * * * * * * * * Friend Operators * * * * * * * * * * * * * //
// ************************************************************************* //
/*---------------------------------------------------------------------------*\
========= |
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
\\ / O peration |
\\ / A nd | Copyright (C) 1991-2007 OpenCFD Ltd.
\\/ M anipulation |
-------------------------------------------------------------------------------
License
This file is part of OpenFOAM.
OpenFOAM is free software; you can redistribute it and/or modify it
under the terms of the GNU General Public License as published by the
Free Software Foundation; either version 2 of the License, or (at your
option) any later version.
OpenFOAM is distributed in the hope that it will be useful, but WITHOUT
ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
for more details.
You should have received a copy of the GNU General Public License
along with OpenFOAM; if not, write to the Free Software Foundation,
Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
Class
Foam::mapDistributePolyMesh
Description
Class containing mesh-to-mesh mapping information after a mesh distribution
where we send parts of meshes (using subsetting) to other processors
and receive and reconstruct mesh.
We store mapping from the bits-to-send to the complete starting mesh
(subXXXMap) and from the received bits to their location in the new
mesh (constructXXXMap).
SourceFiles
mapDistributePolyMesh.C
\*---------------------------------------------------------------------------*/
#ifndef mapDistributePolyMesh_H
#define mapDistributePolyMesh_H
#include "labelList.H"
#include "polyMesh.H"
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
namespace Foam
{
class mapPolyMesh;
/*---------------------------------------------------------------------------*\
Class mapDistributePolyMesh Declaration
\*---------------------------------------------------------------------------*/
class mapDistributePolyMesh
{
// Private data
const polyMesh& mesh_;
//- Number of old live points
const label nOldPoints_;
//- Number of old live faces
const label nOldFaces_;
//- Number of old live cells
const label nOldCells_;
//- List of the old patch sizes
labelList oldPatchSizes_;
//- List of the old patch start labels
const labelList oldPatchStarts_;
//- List of numbers of mesh points per old patch
const labelList oldPatchNMeshPoints_;
//- Maps from subsetted mesh back to original mesh