Add the OpenFOAM source tree

This commit is contained in:
Henry
2014-12-10 22:40:10 +00:00
parent ee487c860d
commit 446e5777f0
13379 changed files with 3983377 additions and 0 deletions

View File

@ -0,0 +1,111 @@
/*---------------------------------------------------------------------------*\
========= |
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
\\ / O peration |
\\ / A nd | Copyright (C) 2012 OpenFOAM Foundation
\\/ 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 3 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, see <http://www.gnu.org/licenses/>.
\*---------------------------------------------------------------------------*/
#include "faceSelection.H"
#include "fvMesh.H"
// * * * * * * * * * * * * * * Static Data Members * * * * * * * * * * * * * //
namespace Foam
{
defineTypeNameAndDebug(faceSelection, 0);
defineRunTimeSelectionTable(faceSelection, dictionary);
}
// * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * //
Foam::faceSelection::faceSelection
(
const word& name,
const fvMesh& mesh,
const dictionary& dict
)
:
name_(name),
mesh_(mesh),
dict_(dict),
flip_(dict.lookupOrDefault("flip", false))
{}
// * * * * * * * * * * * * * * * * Destructor * * * * * * * * * * * * * * * //
Foam::faceSelection::~faceSelection()
{}
// * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * //
Foam::autoPtr<Foam::faceSelection> Foam::faceSelection::New
(
const word& name,
const fvMesh& mesh,
const dictionary& dict
)
{
const word sampleType(dict.lookup("type"));
dictionaryConstructorTable::iterator cstrIter =
dictionaryConstructorTablePtr_->find(sampleType);
if (cstrIter == dictionaryConstructorTablePtr_->end())
{
FatalErrorIn
(
"faceSelection::New"
"(const word&, const fvMesh&, const dictionary&)"
) << "Unknown faceSelection type "
<< sampleType << nl << nl
<< "Valid faceSelection types : " << endl
<< dictionaryConstructorTablePtr_->sortedToc()
<< exit(FatalError);
}
return autoPtr<faceSelection>(cstrIter()(name, mesh, dict));
}
void Foam::faceSelection::select
(
const label zoneID,
labelList& faceToZoneID,
boolList& faceToFlip
) const
{
if (flip_)
{
forAll(faceToZoneID, faceI)
{
if (faceToZoneID[faceI] == zoneID)
{
faceToFlip[faceI] = !faceToFlip[faceI];
}
}
}
}
// ************************************************************************* //

View File

@ -0,0 +1,156 @@
/*---------------------------------------------------------------------------*\
========= |
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
\\ / O peration |
\\ / A nd | Copyright (C) 2012 OpenFOAM Foundation
\\/ 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 3 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, see <http://www.gnu.org/licenses/>.
Class
Foam::faceSelection
Description
Face selection method for createBaffles
SourceFiles
faceSelection.C
\*---------------------------------------------------------------------------*/
#ifndef faceSelection_H
#define faceSelection_H
#include "dictionary.H"
#include "typeInfo.H"
#include "runTimeSelectionTables.H"
#include "autoPtr.H"
#include "boolList.H"
#include "labelList.H"
#include "Switch.H"
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
namespace Foam
{
// Forward declaration of classes
class fvMesh;
/*---------------------------------------------------------------------------*\
Class faceSelection Declaration
\*---------------------------------------------------------------------------*/
class faceSelection
{
protected:
// Protected data
//- Name
const word name_;
//- Reference to mesh
const fvMesh& mesh_;
//- Input dictionary
const dictionary dict_;
//- Switch direction?
const Switch flip_;
public:
//- Runtime type information
TypeName("faceSelection");
// Declare run-time constructor selection table
declareRunTimeSelectionTable
(
autoPtr,
faceSelection,
dictionary,
(
const word& name,
const fvMesh& mesh,
const dictionary& dict
),
(name, mesh, dict)
);
// Constructors
//- Construct from dictionary
faceSelection
(
const word& name,
const fvMesh& mesh,
const dictionary& dict
);
//- Clone
autoPtr<faceSelection> clone() const
{
notImplemented("autoPtr<faceSelection> clone() const");
return autoPtr<faceSelection>(NULL);
}
// Selectors
//- Return a reference to the selected faceSelection
static autoPtr<faceSelection> New
(
const word& name,
const fvMesh& mesh,
const dictionary& dict
);
//- Destructor
virtual ~faceSelection();
// Member Functions
const word& name() const
{
return name_;
}
const dictionary& dict() const
{
return dict_;
}
virtual void select(const label, labelList&, boolList&) const = 0;
};
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
} // End namespace Foam
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
#endif
// ************************************************************************* //

View File

@ -0,0 +1,108 @@
/*---------------------------------------------------------------------------*\
========= |
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
\\ / O peration |
\\ / A nd | Copyright (C) 2012 OpenFOAM Foundation
\\/ 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 3 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, see <http://www.gnu.org/licenses/>.
\*---------------------------------------------------------------------------*/
#include "faceZoneSelection.H"
#include "addToRunTimeSelectionTable.H"
#include "fvMesh.H"
// * * * * * * * * * * * * * * Static Data Members * * * * * * * * * * * * * //
namespace Foam
{
namespace faceSelections
{
defineTypeNameAndDebug(faceZoneSelection, 0);
addToRunTimeSelectionTable(faceSelection, faceZoneSelection, dictionary);
}
}
// * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * //
Foam::faceSelections::faceZoneSelection::faceZoneSelection
(
const word& name,
const fvMesh& mesh,
const dictionary& dict
)
:
faceSelection(name, mesh, dict),
zoneName_(dict_.lookup("zoneName"))
{}
// * * * * * * * * * * * * * * * * Destructor * * * * * * * * * * * * * * * //
Foam::faceSelections::faceZoneSelection::~faceZoneSelection()
{}
// * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * //
void Foam::faceSelections::faceZoneSelection::select
(
const label zoneID,
labelList& faceToZoneID,
boolList& faceToFlip
) const
{
label readID = mesh_.faceZones().findZoneID(zoneName_);
if (readID == -1)
{
FatalErrorIn
(
"faceSelections::faceZoneSelection::select(labelList&) const"
) << "Cannot find faceZone " << zoneName_ << nl << "Valid zones are "
<< mesh_.faceZones().names()
<< exit(FatalError);
}
const faceZone& fZone = mesh_.faceZones()[readID];
forAll(fZone, i)
{
label faceI = fZone[i];
if (faceToZoneID[faceI] == -1)
{
faceToZoneID[faceI] = zoneID;
faceToFlip[faceI] = fZone.flipMap()[i];
}
else if (faceToZoneID[faceI] != zoneID)
{
FatalErrorIn
(
"faceSelections::faceZoneSelection::select(labelList&) const"
) << "Face " << faceI << " already in faceZone "
<< faceToZoneID[faceI]
<< exit(FatalError);
}
}
faceSelection::select(zoneID, faceToZoneID, faceToFlip);
}
// ************************************************************************* //

View File

@ -0,0 +1,114 @@
/*---------------------------------------------------------------------------*\
========= |
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
\\ / O peration |
\\ / A nd | Copyright (C) 2012-2014 OpenFOAM Foundation
\\/ 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 3 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, see <http://www.gnu.org/licenses/>.
Class
Foam::faceSelections::faceZoneSelection
Description
Select faces from faceZone
SourceFiles
faceZoneSelection.C
\*---------------------------------------------------------------------------*/
#ifndef faceZoneSelection_H
#define faceZoneSelection_H
#include "faceSelection.H"
#include "pointField.H"
#include "boolList.H"
#include "volFields.H"
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
namespace Foam
{
class regionSplit;
namespace faceSelections
{
/*---------------------------------------------------------------------------*\
Class faceZoneSelection Declaration
\*---------------------------------------------------------------------------*/
class faceZoneSelection
:
public faceSelection
{
// Private data
//- Name of faceZone
const word zoneName_;
// Private Member Functions
public:
//- Runtime type information
TypeName("faceZone");
// Constructors
//- Construct from dictionary
faceZoneSelection
(
const word& name,
const fvMesh& mesh,
const dictionary& dict
);
//- Clone
autoPtr<faceSelection> clone() const
{
notImplemented("autoPtr<faceSelection> clone() const");
return autoPtr<faceSelection>(NULL);
}
//- Destructor
virtual ~faceZoneSelection();
// Member Functions
//- Apply this selector
virtual void select(const label zoneID, labelList&, boolList&) const;
};
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
} // End namespace faceSelections
} // End namespace Foam
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
#endif
// ************************************************************************* //

View File

@ -0,0 +1,181 @@
/*---------------------------------------------------------------------------*\
========= |
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
\\ / O peration |
\\ / A nd | Copyright (C) 2012-2013 OpenFOAM Foundation
\\/ 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 3 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, see <http://www.gnu.org/licenses/>.
\*---------------------------------------------------------------------------*/
#include "searchableSurfaceSelection.H"
#include "addToRunTimeSelectionTable.H"
#include "syncTools.H"
#include "searchableSurface.H"
#include "fvMesh.H"
#include "Time.H"
// * * * * * * * * * * * * * * Static Data Members * * * * * * * * * * * * * //
namespace Foam
{
namespace faceSelections
{
defineTypeNameAndDebug(searchableSurfaceSelection, 0);
addToRunTimeSelectionTable
(
faceSelection,
searchableSurfaceSelection,
dictionary
);
}
}
// * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * //
Foam::faceSelections::searchableSurfaceSelection::searchableSurfaceSelection
(
const word& name,
const fvMesh& mesh,
const dictionary& dict
)
:
faceSelection(name, mesh, dict),
surfacePtr_
(
searchableSurface::New
(
word(dict.lookup("surface")),
IOobject
(
dict.lookupOrDefault("name", mesh.objectRegistry::db().name()),
mesh.time().constant(),
"triSurface",
mesh.objectRegistry::db(),
IOobject::MUST_READ,
IOobject::NO_WRITE
),
dict
)
)
{}
// * * * * * * * * * * * * * * * * Destructor * * * * * * * * * * * * * * * //
Foam::faceSelections::searchableSurfaceSelection::~searchableSurfaceSelection()
{}
// * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * //
void Foam::faceSelections::searchableSurfaceSelection::select
(
const label zoneID,
labelList& faceToZoneID,
boolList& faceToFlip
) const
{
// Get cell-cell centre vectors
pointField start(mesh_.nFaces());
pointField end(mesh_.nFaces());
// Internal faces
for (label faceI = 0; faceI < mesh_.nInternalFaces(); faceI++)
{
start[faceI] = mesh_.cellCentres()[mesh_.faceOwner()[faceI]];
end[faceI] = mesh_.cellCentres()[mesh_.faceNeighbour()[faceI]];
}
// Boundary faces
vectorField neighbourCellCentres;
syncTools::swapBoundaryCellPositions
(
mesh_,
mesh_.cellCentres(),
neighbourCellCentres
);
const polyBoundaryMesh& pbm = mesh_.boundaryMesh();
forAll(pbm, patchI)
{
const polyPatch& pp = pbm[patchI];
if (pp.coupled())
{
forAll(pp, i)
{
label faceI = pp.start()+i;
start[faceI] = mesh_.cellCentres()[mesh_.faceOwner()[faceI]];
end[faceI] = neighbourCellCentres[faceI-mesh_.nInternalFaces()];
}
}
else
{
forAll(pp, i)
{
label faceI = pp.start()+i;
start[faceI] = mesh_.cellCentres()[mesh_.faceOwner()[faceI]];
end[faceI] = mesh_.faceCentres()[faceI];
}
}
}
List<pointIndexHit> hits;
surfacePtr_().findLine(start, end, hits);
pointField normals;
surfacePtr_().getNormal(hits, normals);
//- Note: do not select boundary faces.
for (label faceI = 0; faceI < mesh_.nInternalFaces(); faceI++)
{
if (hits[faceI].hit())
{
faceToZoneID[faceI] = zoneID;
vector d = end[faceI]-start[faceI];
faceToFlip[faceI] = ((normals[faceI] & d) < 0);
}
}
forAll(pbm, patchI)
{
const polyPatch& pp = pbm[patchI];
if (pp.coupled())
{
forAll(pp, i)
{
label faceI = pp.start()+i;
if (hits[faceI].hit())
{
faceToZoneID[faceI] = zoneID;
vector d = end[faceI]-start[faceI];
faceToFlip[faceI] = ((normals[faceI] & d) < 0);
}
}
}
}
faceSelection::select(zoneID, faceToZoneID, faceToFlip);
}
// ************************************************************************* //

View File

@ -0,0 +1,106 @@
/*---------------------------------------------------------------------------*\
========= |
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
\\ / O peration |
\\ / A nd | Copyright (C) 2012 OpenFOAM Foundation
\\/ 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 3 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, see <http://www.gnu.org/licenses/>.
Class
Foam::faceSelections::searchableSurfaceSelection
Description
Selects all (internal or coupled) faces intersecting the searchableSurface.
SourceFiles
searchableSurfaceSelection.C
\*---------------------------------------------------------------------------*/
#ifndef searchableSurfaceSelection_H
#define searchableSurfaceSelection_H
#include "faceSelection.H"
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
namespace Foam
{
class searchableSurface;
namespace faceSelections
{
/*---------------------------------------------------------------------------*\
Class searchableSurfaceSelection Declaration
\*---------------------------------------------------------------------------*/
class searchableSurfaceSelection
:
public faceSelection
{
// Private data
autoPtr<searchableSurface> surfacePtr_;
public:
//- Runtime type information
TypeName("searchableSurface");
// Constructors
//- Construct from dictionary
searchableSurfaceSelection
(
const word& name,
const fvMesh& mesh,
const dictionary& dict
);
//- Clone
autoPtr<faceSelection> clone() const
{
notImplemented("autoPtr<faceSelection> clone() const");
return autoPtr<faceSelection>(NULL);
}
//- Destructor
virtual ~searchableSurfaceSelection();
// Member Functions
virtual void select(const label zoneID, labelList&, boolList&) const;
};
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
} // End namespace faceSelections
} // End namespace Foam
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
#endif
// ************************************************************************* //