mirror of
https://develop.openfoam.com/Development/openfoam.git
synced 2025-11-28 03:28:01 +00:00
CONT: Addition of compressibleIsoInterFOam and PLIC
1) Implementation of the compressibleIsoInterFOam solver 2) Implementation of a new PLIC interpolation scheme. 3) New tutorials associated with the solvers This implementation was carried out by Henning Scheufler (DLR) and Johan Roenby (DHI), following : \verbatim Henning Scheufler, Johan Roenby, Accurate and efficient surface reconstruction from volume fraction data on general meshes, Journal of Computational Physics, 2019, doi 10.1016/j.jcp.2019.01.009 \endverbatim The integration of the code was carried out by Andy Heather and Sergio Ferraris from OpenCFD Ltd.
This commit is contained in:
committed by
Andrew Heather
parent
237f2e1076
commit
44a84d4778
7
applications/utilities/preProcessing/setAlphaField/Allwclean
Executable file
7
applications/utilities/preProcessing/setAlphaField/Allwclean
Executable file
@ -0,0 +1,7 @@
|
||||
#!/bin/sh
|
||||
cd "${0%/*}" || exit # Run from this directory
|
||||
|
||||
wclean libso alphaFieldFunctions
|
||||
wclean
|
||||
|
||||
#------------------------------------------------------------------------------
|
||||
10
applications/utilities/preProcessing/setAlphaField/Allwmake
Executable file
10
applications/utilities/preProcessing/setAlphaField/Allwmake
Executable file
@ -0,0 +1,10 @@
|
||||
#!/bin/sh
|
||||
cd "${0%/*}" || exit # Run from this directory
|
||||
. ${WM_PROJECT_DIR:?}/wmake/scripts/AllwmakeParseArguments
|
||||
|
||||
#------------------------------------------------------------------------------
|
||||
|
||||
wmake $targetType alphaFieldFunctions
|
||||
wmake $targetType
|
||||
|
||||
#------------------------------------------------------------------------------
|
||||
@ -1,9 +1,17 @@
|
||||
EXE_INC = \
|
||||
-IalphaFieldFunctions/lnInclude \
|
||||
-I$(LIB_SRC)/finiteVolume/lnInclude \
|
||||
-I$(LIB_SRC)/surfMesh/lnInclude \
|
||||
-I$(LIB_SRC)/meshTools/lnInclude \
|
||||
-I$(LIB_SRC)/sampling/lnInclude
|
||||
-I$(LIB_SRC)/fileFormats/lnInclude \
|
||||
-I$(LIB_SRC)/sampling/lnInclude \
|
||||
-I$(LIB_SRC)/transportModels/geometricVoF/lnInclude
|
||||
|
||||
EXE_LIBS = \
|
||||
-lfiniteVolume \
|
||||
-lfileFormats \
|
||||
-lsurfMesh \
|
||||
-lmeshTools \
|
||||
-lsampling
|
||||
-lsampling \
|
||||
-lgeometricVoF \
|
||||
-lalphaFieldFunctions
|
||||
|
||||
@ -0,0 +1,11 @@
|
||||
/* Run-time selectable implicitFunctions */
|
||||
implicitFunctions/implicitFunction.C
|
||||
implicitFunctions/sphere/sphereImplicitFunction.C
|
||||
implicitFunctions/sin/sinImplicitFunction.C
|
||||
implicitFunctions/ellipsoid/ellipsoidImplicitFunction.C
|
||||
implicitFunctions/paraboloid/paraboloidImplicitFunction.C
|
||||
implicitFunctions/plane/planeImplicitFunction.C
|
||||
implicitFunctions/cylinder/cylinderImplicitFunction.C
|
||||
implicitFunctions/composedFunction/composedFunctionImplicitFunction.C
|
||||
|
||||
LIB = $(FOAM_LIBBIN)/libalphaFieldFunctions
|
||||
@ -0,0 +1,2 @@
|
||||
/* EXE_INC = */
|
||||
/* LIB_LIBS = */
|
||||
@ -0,0 +1,207 @@
|
||||
/*---------------------------------------------------------------------------*\
|
||||
========= |
|
||||
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
|
||||
\\ / O peration |
|
||||
\\ / A nd | www.openfoam.com
|
||||
\\/ M anipulation |
|
||||
-------------------------------------------------------------------------------
|
||||
Copyright (C) 2019 OpenCFD Ltd.
|
||||
Copyright (C) 2019-2020 DLR
|
||||
-------------------------------------------------------------------------------
|
||||
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 "composedFunctionImplicitFunction.H"
|
||||
#include "scalarField.H"
|
||||
#include "addToRunTimeSelectionTable.H"
|
||||
|
||||
// * * * * * * * * * * * * * * Static Data Members * * * * * * * * * * * * * //
|
||||
|
||||
namespace Foam
|
||||
{
|
||||
namespace implicitFunctions
|
||||
{
|
||||
defineTypeNameAndDebug(composedFunctionImplicitFunction, 0);
|
||||
addToRunTimeSelectionTable
|
||||
(
|
||||
implicitFunction,
|
||||
composedFunctionImplicitFunction,
|
||||
dict
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
// * * * * * * * * * * * * * Private Member Functions * * * * * * * * * * * //
|
||||
|
||||
const Foam::Enum
|
||||
<
|
||||
Foam::implicitFunctions::composedFunctionImplicitFunction::modeType
|
||||
>
|
||||
Foam::implicitFunctions::composedFunctionImplicitFunction::modeTypeNames
|
||||
({
|
||||
{ modeType::ADD, "add" },
|
||||
{ modeType::SUBTRACT, "subtract" },
|
||||
{ modeType::MINDIST, "minDist" },
|
||||
{ modeType::INTERSECT, "intersect" },
|
||||
});
|
||||
|
||||
|
||||
Foam::label
|
||||
Foam::implicitFunctions::composedFunctionImplicitFunction::selectFunction
|
||||
(
|
||||
const scalarField& values
|
||||
) const
|
||||
{
|
||||
switch (mode_)
|
||||
{
|
||||
case modeType::MINDIST:
|
||||
{
|
||||
scalarField absVal(mag(values));
|
||||
return findMin(absVal);
|
||||
}
|
||||
case modeType::ADD:
|
||||
{
|
||||
return findMax(values);
|
||||
}
|
||||
case modeType::SUBTRACT:
|
||||
{
|
||||
// Note: start at the second entry
|
||||
const label idx = findMin(values, 1);
|
||||
|
||||
if (values[idx] < values[0] && pos(values[0]))
|
||||
{
|
||||
return idx;
|
||||
}
|
||||
else
|
||||
{
|
||||
return 0;
|
||||
}
|
||||
}
|
||||
case modeType::INTERSECT:
|
||||
{
|
||||
return findMin(values);
|
||||
}
|
||||
default:
|
||||
{
|
||||
FatalErrorInFunction
|
||||
<< "This mode is not supported only " << nl
|
||||
<< "Supported modes are: " << nl
|
||||
<< modeTypeNames
|
||||
<< abort(FatalError);
|
||||
}
|
||||
}
|
||||
|
||||
return -1;
|
||||
}
|
||||
|
||||
|
||||
// * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * //
|
||||
|
||||
Foam::implicitFunctions::composedFunctionImplicitFunction::
|
||||
composedFunctionImplicitFunction
|
||||
(
|
||||
const dictionary& dict
|
||||
)
|
||||
:
|
||||
functions_(),
|
||||
mode_(modeTypeNames.get("mode", dict)),
|
||||
values_()
|
||||
{
|
||||
const dictionary& funcDict = dict.subDict("composedFunction");
|
||||
|
||||
functions_.resize(funcDict.size());
|
||||
values_.resize(funcDict.size(), Zero);
|
||||
|
||||
label funci = 0;
|
||||
|
||||
for (const entry& dEntry : funcDict)
|
||||
{
|
||||
const word& key = dEntry.keyword();
|
||||
|
||||
if (!dEntry.isDict())
|
||||
{
|
||||
FatalIOErrorInFunction(funcDict)
|
||||
<< "Entry " << key << " is not a dictionary" << endl
|
||||
<< exit(FatalError);
|
||||
}
|
||||
|
||||
const dictionary& subdict = dEntry.dict();
|
||||
|
||||
functions_.set
|
||||
(
|
||||
funci,
|
||||
implicitFunction::New(subdict.get<word>("type"), subdict)
|
||||
);
|
||||
|
||||
++funci;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
// * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * //
|
||||
|
||||
Foam::scalar Foam::implicitFunctions::composedFunctionImplicitFunction::value
|
||||
(
|
||||
const vector& p
|
||||
) const
|
||||
{
|
||||
forAll(values_,i)
|
||||
{
|
||||
values_[i] = functions_[i].value(p);
|
||||
}
|
||||
|
||||
const label idx = selectFunction(values_);
|
||||
|
||||
return values_[idx];
|
||||
}
|
||||
|
||||
|
||||
Foam::vector Foam::implicitFunctions::composedFunctionImplicitFunction::grad
|
||||
(
|
||||
const vector& p
|
||||
) const
|
||||
{
|
||||
forAll(values_,i)
|
||||
{
|
||||
values_[i] = mag(functions_[i].value(p));
|
||||
}
|
||||
|
||||
const label minIdx = findMin(values_);
|
||||
|
||||
return functions_[minIdx].grad(p);
|
||||
}
|
||||
|
||||
|
||||
Foam::scalar
|
||||
Foam::implicitFunctions::composedFunctionImplicitFunction::distanceToSurfaces
|
||||
(
|
||||
const vector& p
|
||||
) const
|
||||
{
|
||||
forAll(values_,i)
|
||||
{
|
||||
values_[i] = mag(functions_[i].value(p));
|
||||
}
|
||||
|
||||
const label minIdx = findMin(values_);
|
||||
|
||||
return functions_[minIdx].distanceToSurfaces(p);
|
||||
}
|
||||
|
||||
|
||||
// ************************************************************************* //
|
||||
@ -0,0 +1,169 @@
|
||||
/*---------------------------------------------------------------------------*\
|
||||
========= |
|
||||
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
|
||||
\\ / O peration |
|
||||
\\ / A nd | www.openfoam.com
|
||||
\\/ M anipulation |
|
||||
-------------------------------------------------------------------------------
|
||||
Copyright (C) 2019 OpenCFD Ltd.
|
||||
Copyright (C) 2019-2020 DLR
|
||||
-------------------------------------------------------------------------------
|
||||
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::implicitFunctions::composedFunctionImplicitFunction
|
||||
|
||||
Description
|
||||
Handles multiple implicit functions and offers multiple ways to combine
|
||||
them
|
||||
|
||||
Usage
|
||||
Example of function object partial specification:
|
||||
\verbatim
|
||||
function composedFunctionImplicitFunction;
|
||||
mode minDist;
|
||||
// following mode are available:
|
||||
// "add" "subtract" "minDist" "intersect"
|
||||
composedFunctionImplicitFunctions
|
||||
{
|
||||
plane
|
||||
{
|
||||
function plane;
|
||||
origin (0 1. 0);
|
||||
normal (0 1 0);
|
||||
}
|
||||
|
||||
sphere
|
||||
{
|
||||
function sphere;
|
||||
radius 0.4;
|
||||
origin (0.5 1.5 0.5);
|
||||
scale 1;
|
||||
}
|
||||
|
||||
sphere2
|
||||
{
|
||||
function sphere;
|
||||
radius 0.4;
|
||||
origin (0.5 0.5 0.5);
|
||||
scale -1;
|
||||
}
|
||||
}
|
||||
\endverbatim
|
||||
|
||||
Original code supplied by Henning Scheufler, DLR (2019)
|
||||
|
||||
SourceFiles
|
||||
composedFunctionImplicitFunction.C
|
||||
|
||||
\*---------------------------------------------------------------------------*/
|
||||
|
||||
#ifndef implicitFunctions_composedFunctionImplicitFunction_H
|
||||
#define implicitFunctions_composedFunctionImplicitFunction_H
|
||||
|
||||
#include "implicitFunction.H"
|
||||
#include "scalarField.H"
|
||||
|
||||
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
|
||||
|
||||
namespace Foam
|
||||
{
|
||||
namespace implicitFunctions
|
||||
{
|
||||
|
||||
/*---------------------------------------------------------------------------*\
|
||||
Class composedFunctionImplicitFunction Declaration
|
||||
\*---------------------------------------------------------------------------*/
|
||||
|
||||
class composedFunctionImplicitFunction
|
||||
:
|
||||
public implicitFunction
|
||||
{
|
||||
// Private Member Data
|
||||
|
||||
//- Enumeration defining the valid actions
|
||||
enum class modeType
|
||||
{
|
||||
ADD,
|
||||
SUBTRACT,
|
||||
MINDIST,
|
||||
INTERSECT
|
||||
};
|
||||
|
||||
//- The setActions text representations
|
||||
static const Enum<modeType> modeTypeNames;
|
||||
|
||||
//- Stores the functions
|
||||
PtrList<implicitFunction> functions_;
|
||||
|
||||
//- Mode
|
||||
modeType mode_;
|
||||
|
||||
//- Needed for finding the closest function.
|
||||
// Note: avoid creation every call
|
||||
mutable scalarField values_;
|
||||
|
||||
|
||||
// Private Member Functions
|
||||
|
||||
label selectFunction(const scalarField& values) const;
|
||||
|
||||
//- No copy construct
|
||||
composedFunctionImplicitFunction
|
||||
(
|
||||
const composedFunctionImplicitFunction&
|
||||
) = delete;
|
||||
|
||||
//- No copy assignment
|
||||
void operator=(const composedFunctionImplicitFunction&) = delete;
|
||||
|
||||
|
||||
public:
|
||||
|
||||
//- Runtime type information
|
||||
TypeName("composedFunction");
|
||||
|
||||
|
||||
// Constructors
|
||||
|
||||
//- Construct from dictionary
|
||||
explicit composedFunctionImplicitFunction(const dictionary& dict);
|
||||
|
||||
|
||||
//- Destructor
|
||||
virtual ~composedFunctionImplicitFunction() = default;
|
||||
|
||||
|
||||
// Member Functions
|
||||
|
||||
virtual scalar value(const vector& p) const;
|
||||
|
||||
virtual vector grad(const vector& p) const;
|
||||
|
||||
virtual scalar distanceToSurfaces(const vector& p) const;
|
||||
};
|
||||
|
||||
|
||||
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
|
||||
} // End namespace implicitFunctions
|
||||
} // End namespace Foam
|
||||
|
||||
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
|
||||
|
||||
#endif
|
||||
|
||||
// ************************************************************************* //
|
||||
@ -0,0 +1,82 @@
|
||||
/*---------------------------------------------------------------------------*\
|
||||
========= |
|
||||
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
|
||||
\\ / O peration |
|
||||
\\ / A nd | www.openfoam.com
|
||||
\\/ M anipulation |
|
||||
-------------------------------------------------------------------------------
|
||||
Copyright (C) 2019 OpenCFD Ltd.
|
||||
Copyright (C) 2019-2020 DLR
|
||||
-------------------------------------------------------------------------------
|
||||
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 "cylinderImplicitFunction.H"
|
||||
#include "addToRunTimeSelectionTable.H"
|
||||
|
||||
// * * * * * * * * * * * * * * Static Data Members * * * * * * * * * * * * * //
|
||||
|
||||
namespace Foam
|
||||
{
|
||||
namespace implicitFunctions
|
||||
{
|
||||
defineTypeNameAndDebug(cylinderImplicitFunction, 0);
|
||||
addToRunTimeSelectionTable
|
||||
(
|
||||
implicitFunction,
|
||||
cylinderImplicitFunction,
|
||||
dict
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
// * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * //
|
||||
|
||||
Foam::implicitFunctions::cylinderImplicitFunction::cylinderImplicitFunction
|
||||
(
|
||||
const point& origin,
|
||||
const scalar radius,
|
||||
const scalar scale,
|
||||
const vector& direction
|
||||
)
|
||||
:
|
||||
origin_(origin),
|
||||
radius_(radius),
|
||||
scale_(scale),
|
||||
direction_(normalised(direction)),
|
||||
project_(tensor::I - direction_*direction_) // outer product
|
||||
{}
|
||||
|
||||
|
||||
Foam::implicitFunctions::cylinderImplicitFunction::cylinderImplicitFunction
|
||||
(
|
||||
const dictionary& dict
|
||||
)
|
||||
:
|
||||
cylinderImplicitFunction
|
||||
(
|
||||
dict.get<point>("origin"),
|
||||
dict.get<scalar>("radius"),
|
||||
dict.getOrDefault<scalar>("scale", 1),
|
||||
dict.get<vector>("direction")
|
||||
)
|
||||
{}
|
||||
|
||||
|
||||
// ************************************************************************* //
|
||||
@ -0,0 +1,132 @@
|
||||
/*---------------------------------------------------------------------------*\
|
||||
========= |
|
||||
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
|
||||
\\ / O peration |
|
||||
\\ / A nd | www.openfoam.com
|
||||
\\/ M anipulation |
|
||||
-------------------------------------------------------------------------------
|
||||
Copyright (C) 2019 OpenCFD Ltd.
|
||||
Copyright (C) 2019-2020 DLR
|
||||
-------------------------------------------------------------------------------
|
||||
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::implicitFunctions::cylinderImplicitFunction
|
||||
|
||||
Description
|
||||
creates a infintite long cylinderImplicitFunction
|
||||
|
||||
Original code supplied by Henning Scheufler, DLR (2019)
|
||||
|
||||
SourceFiles
|
||||
cylinderImplicitFunction.C
|
||||
|
||||
\*---------------------------------------------------------------------------*/
|
||||
|
||||
#ifndef implicitFunction_cylinderImplicitFunction_H
|
||||
#define implicitFunction_cylinderImplicitFunction_H
|
||||
|
||||
#include "implicitFunction.H"
|
||||
#include "point.H"
|
||||
#include "tensor.H"
|
||||
|
||||
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
|
||||
|
||||
namespace Foam
|
||||
{
|
||||
namespace implicitFunctions
|
||||
{
|
||||
|
||||
/*---------------------------------------------------------------------------*\
|
||||
Class cylinderImplicitFunction Declaration
|
||||
\*---------------------------------------------------------------------------*/
|
||||
|
||||
class cylinderImplicitFunction
|
||||
:
|
||||
public implicitFunction
|
||||
{
|
||||
private:
|
||||
|
||||
// Private Data
|
||||
|
||||
//- Origin point
|
||||
const point origin_;
|
||||
|
||||
//- Radius
|
||||
const scalar radius_;
|
||||
|
||||
const scalar scale_;
|
||||
|
||||
const vector direction_;
|
||||
|
||||
const tensor project_;
|
||||
|
||||
|
||||
public:
|
||||
|
||||
//- Runtime type information
|
||||
TypeName("cylinder");
|
||||
|
||||
|
||||
// Constructors
|
||||
|
||||
//- Construct from components
|
||||
cylinderImplicitFunction
|
||||
(
|
||||
const point& origin,
|
||||
const scalar radius,
|
||||
const scalar scale,
|
||||
const vector& direction
|
||||
);
|
||||
|
||||
//- Construct from dictionary
|
||||
explicit cylinderImplicitFunction(const dictionary& dict);
|
||||
|
||||
|
||||
//- Destructor
|
||||
virtual ~cylinderImplicitFunction() = default;
|
||||
|
||||
|
||||
// Member Functions
|
||||
|
||||
virtual scalar value(const vector& p) const
|
||||
{
|
||||
return (-mag(project_ & (p - origin_)) + radius_)*scale_;
|
||||
}
|
||||
|
||||
virtual vector grad(const vector& p) const
|
||||
{
|
||||
return -(project_ & (p - origin_))*scale_;
|
||||
}
|
||||
|
||||
virtual scalar distanceToSurfaces(const vector& p) const
|
||||
{
|
||||
return mag(mag(project_ & (p - origin_)) - radius_)*scale_;
|
||||
}
|
||||
};
|
||||
|
||||
|
||||
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
|
||||
|
||||
} // End namespace implicitFunctions
|
||||
} // End namespace Foam
|
||||
|
||||
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
|
||||
|
||||
#endif
|
||||
|
||||
// ************************************************************************* //
|
||||
@ -0,0 +1,73 @@
|
||||
/*---------------------------------------------------------------------------*\
|
||||
========= |
|
||||
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
|
||||
\\ / O peration |
|
||||
\\ / A nd | www.openfoam.com
|
||||
\\/ M anipulation |
|
||||
-------------------------------------------------------------------------------
|
||||
Copyright (C) 2019 OpenCFD Ltd.
|
||||
Copyright (C) 2019-2020 DLR
|
||||
-------------------------------------------------------------------------------
|
||||
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 "ellipsoidImplicitFunction.H"
|
||||
#include "addToRunTimeSelectionTable.H"
|
||||
|
||||
// * * * * * * * * * * * * * * Static Data Members * * * * * * * * * * * * * //
|
||||
|
||||
namespace Foam
|
||||
{
|
||||
namespace implicitFunctions
|
||||
{
|
||||
defineTypeNameAndDebug(ellipsoidImplicitFunction, 0);
|
||||
addToRunTimeSelectionTable
|
||||
(
|
||||
implicitFunction,
|
||||
ellipsoidImplicitFunction,
|
||||
dict
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
// * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * //
|
||||
|
||||
Foam::implicitFunctions::ellipsoidImplicitFunction::ellipsoidImplicitFunction
|
||||
(
|
||||
const vector& semiAxis
|
||||
)
|
||||
:
|
||||
semiAxis_(semiAxis),
|
||||
origin_(Zero)
|
||||
{}
|
||||
|
||||
|
||||
Foam::implicitFunctions::ellipsoidImplicitFunction::ellipsoidImplicitFunction
|
||||
(
|
||||
const dictionary& dict
|
||||
)
|
||||
:
|
||||
ellipsoidImplicitFunction
|
||||
(
|
||||
dict.get<vector>("semiAxis")
|
||||
)
|
||||
{}
|
||||
|
||||
|
||||
// ************************************************************************* //
|
||||
@ -0,0 +1,131 @@
|
||||
/*---------------------------------------------------------------------------*\
|
||||
========= |
|
||||
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
|
||||
\\ / O peration |
|
||||
\\ / A nd | www.openfoam.com
|
||||
\\/ M anipulation |
|
||||
-------------------------------------------------------------------------------
|
||||
Copyright (C) 2019 OpenCFD Ltd.
|
||||
Copyright (C) 2019-2020 DLR
|
||||
-------------------------------------------------------------------------------
|
||||
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::implicitFunctions::ellipsoidImplicitFunction
|
||||
|
||||
Description
|
||||
creates an ellipsoidImplicitFunction
|
||||
|
||||
Original code supplied by Henning Scheufler, DLR (2019)
|
||||
|
||||
SourceFiles
|
||||
ellipsoidImplicitFunction.C
|
||||
|
||||
\*---------------------------------------------------------------------------*/
|
||||
|
||||
#ifndef implicitFunction_ellipsoidImplicitFunction_H
|
||||
#define implicitFunction_ellipsoidImplicitFunction_H
|
||||
|
||||
#include "implicitFunction.H"
|
||||
#include "mathematicalConstants.H"
|
||||
|
||||
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
|
||||
|
||||
namespace Foam
|
||||
{
|
||||
namespace implicitFunctions
|
||||
{
|
||||
|
||||
/*---------------------------------------------------------------------------*\
|
||||
Class ellipsoidImplicitFunction Declaration
|
||||
\*---------------------------------------------------------------------------*/
|
||||
|
||||
class ellipsoidImplicitFunction
|
||||
:
|
||||
public implicitFunction
|
||||
{
|
||||
// Private Member Data
|
||||
|
||||
//- Axis
|
||||
const vector semiAxis_;
|
||||
|
||||
//- Origin point
|
||||
const vector origin_;
|
||||
|
||||
|
||||
public:
|
||||
|
||||
//- Runtime type information
|
||||
TypeName("ellipsoidImplicitFunction");
|
||||
|
||||
|
||||
// Constructors
|
||||
|
||||
//- Construct from components
|
||||
explicit ellipsoidImplicitFunction(const vector& semiAxis);
|
||||
|
||||
//- Construct from dictionary
|
||||
explicit ellipsoidImplicitFunction(const dictionary& dict);
|
||||
|
||||
|
||||
//- Destructor
|
||||
virtual ~ellipsoidImplicitFunction() = default;
|
||||
|
||||
|
||||
// Member Functions
|
||||
|
||||
virtual scalar value(const vector& p) const
|
||||
{
|
||||
return
|
||||
-sqrt
|
||||
(
|
||||
sqr((p.x() - origin_.x())/semiAxis_.x())
|
||||
+ sqr((p.y() - origin_.y())/semiAxis_.y())
|
||||
+ sqr((p.z() - origin_.z())/semiAxis_.z())
|
||||
) + 1;
|
||||
}
|
||||
|
||||
|
||||
virtual vector grad(const vector& p) const
|
||||
{
|
||||
// normal_ has the length of one
|
||||
return vector
|
||||
(
|
||||
2*(p.x() - origin_.x())/sqr(semiAxis_.x()),
|
||||
2*(p.y() - origin_.y())/sqr(semiAxis_.y()),
|
||||
2*(p.z() - origin_.z())/sqr(semiAxis_.z())
|
||||
);
|
||||
}
|
||||
|
||||
virtual scalar distanceToSurfaces(const vector& p) const
|
||||
{
|
||||
NotImplemented;
|
||||
return GREAT;
|
||||
}
|
||||
};
|
||||
|
||||
|
||||
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
|
||||
|
||||
} // End namespace implicitFunctions
|
||||
} // End namespace Foam
|
||||
|
||||
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
|
||||
|
||||
#endif
|
||||
|
||||
// ************************************************************************* //
|
||||
@ -0,0 +1,66 @@
|
||||
/*---------------------------------------------------------------------------*\
|
||||
========= |
|
||||
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
|
||||
\\ / O peration |
|
||||
\\ / A nd | www.openfoam.com
|
||||
\\/ M anipulation |
|
||||
-------------------------------------------------------------------------------
|
||||
Copyright (C) 2019 OpenCFD Ltd.
|
||||
Copyright (C) 2019-2020 DLR
|
||||
-------------------------------------------------------------------------------
|
||||
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 "implicitFunction.H"
|
||||
#include "error.H"
|
||||
|
||||
// * * * * * * * * * * * * * * Static Data Members * * * * * * * * * * * * * //
|
||||
|
||||
namespace Foam
|
||||
{
|
||||
defineTypeNameAndDebug(implicitFunction, 0);
|
||||
defineRunTimeSelectionTable(implicitFunction, dict);
|
||||
}
|
||||
|
||||
|
||||
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
|
||||
|
||||
Foam::autoPtr<Foam::implicitFunction> Foam::implicitFunction::New
|
||||
(
|
||||
const word& implicitFunctionType,
|
||||
const dictionary& dict
|
||||
)
|
||||
{
|
||||
auto cstrIter = dictConstructorTablePtr_->cfind(implicitFunctionType);
|
||||
|
||||
if (!cstrIter.found())
|
||||
{
|
||||
FatalIOErrorInLookup
|
||||
(
|
||||
dict,
|
||||
"implicitFunction",
|
||||
implicitFunctionType,
|
||||
*dictConstructorTablePtr_
|
||||
) << exit(FatalIOError);
|
||||
}
|
||||
|
||||
return autoPtr<implicitFunction>(cstrIter()(dict));
|
||||
}
|
||||
|
||||
|
||||
// ************************************************************************* //
|
||||
@ -0,0 +1,122 @@
|
||||
/*---------------------------------------------------------------------------*\
|
||||
========= |
|
||||
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
|
||||
\\ / O peration |
|
||||
\\ / A nd | www.openfoam.com
|
||||
\\/ M anipulation |
|
||||
-------------------------------------------------------------------------------
|
||||
Copyright (C) 2019 OpenCFD Ltd.
|
||||
Copyright (C) 2019-2020 DLR
|
||||
-------------------------------------------------------------------------------
|
||||
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::implicitFunction
|
||||
|
||||
Description
|
||||
Base class for implicit functions
|
||||
|
||||
Original code supplied by Henning Scheufler, DLR (2019)
|
||||
|
||||
SourceFiles
|
||||
implicitFunction.C
|
||||
|
||||
\*---------------------------------------------------------------------------*/
|
||||
|
||||
#ifndef implicitFunction_H
|
||||
#define implicitFunction_H
|
||||
|
||||
#include "autoPtr.H"
|
||||
#include "dictionary.H"
|
||||
#include "vector.H"
|
||||
#include "runTimeSelectionTables.H"
|
||||
|
||||
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
|
||||
|
||||
namespace Foam
|
||||
{
|
||||
|
||||
/*---------------------------------------------------------------------------*\
|
||||
Class implicitFunction Declaration
|
||||
\*---------------------------------------------------------------------------*/
|
||||
|
||||
class implicitFunction
|
||||
{
|
||||
public:
|
||||
|
||||
//- Runtime type information
|
||||
TypeName("implicitFunction");
|
||||
|
||||
//- Declare run-time constructor selection table
|
||||
declareRunTimeSelectionTable
|
||||
(
|
||||
autoPtr,
|
||||
implicitFunction,
|
||||
dict,
|
||||
(
|
||||
const dictionary& dict
|
||||
),
|
||||
(dict)
|
||||
);
|
||||
|
||||
|
||||
// Constructors
|
||||
|
||||
//- Default construct
|
||||
implicitFunction() = default;
|
||||
|
||||
|
||||
//- Return a reference to the selected implicitFunction
|
||||
static autoPtr<implicitFunction> New
|
||||
(
|
||||
const word& implicitFunctionType,
|
||||
const dictionary& dict
|
||||
);
|
||||
|
||||
|
||||
//- Destructor
|
||||
virtual ~implicitFunction() = default;
|
||||
|
||||
|
||||
// Member Functions
|
||||
|
||||
virtual scalar value(const vector& p) const
|
||||
{
|
||||
return GREAT;
|
||||
}
|
||||
|
||||
virtual vector grad(const vector& p) const
|
||||
{
|
||||
return vector::max;
|
||||
}
|
||||
|
||||
virtual scalar distanceToSurfaces(const vector& p) const
|
||||
{
|
||||
return GREAT;
|
||||
}
|
||||
};
|
||||
|
||||
|
||||
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
|
||||
|
||||
} // End namespace Foam
|
||||
|
||||
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
|
||||
|
||||
#endif
|
||||
|
||||
// ************************************************************************* //
|
||||
@ -0,0 +1,73 @@
|
||||
/*---------------------------------------------------------------------------*\
|
||||
========= |
|
||||
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
|
||||
\\ / O peration |
|
||||
\\ / A nd | www.openfoam.com
|
||||
\\/ M anipulation |
|
||||
-------------------------------------------------------------------------------
|
||||
Copyright (C) 2019 OpenCFD Ltd.
|
||||
Copyright (C) 2019 DLR
|
||||
-------------------------------------------------------------------------------
|
||||
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 "paraboloidImplicitFunction.H"
|
||||
#include "addToRunTimeSelectionTable.H"
|
||||
|
||||
// * * * * * * * * * * * * * * Static Data Members * * * * * * * * * * * * * //
|
||||
|
||||
namespace Foam
|
||||
{
|
||||
namespace implicitFunctions
|
||||
{
|
||||
defineTypeNameAndDebug(paraboloidImplicitFunction, 0);
|
||||
addToRunTimeSelectionTable
|
||||
(
|
||||
implicitFunction,
|
||||
paraboloidImplicitFunction,
|
||||
dict
|
||||
);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
|
||||
// * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * //
|
||||
|
||||
Foam::implicitFunctions::paraboloidImplicitFunction::paraboloidImplicitFunction
|
||||
(
|
||||
const vector& coeffs
|
||||
)
|
||||
:
|
||||
coeffs_(coeffs)
|
||||
{}
|
||||
|
||||
|
||||
Foam::implicitFunctions::paraboloidImplicitFunction::paraboloidImplicitFunction
|
||||
(
|
||||
const dictionary& dict
|
||||
)
|
||||
:
|
||||
paraboloidImplicitFunction
|
||||
(
|
||||
dict.get<vector>("coeffs")
|
||||
)
|
||||
{}
|
||||
|
||||
|
||||
// ************************************************************************* //
|
||||
@ -0,0 +1,120 @@
|
||||
/*---------------------------------------------------------------------------*\
|
||||
========= |
|
||||
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
|
||||
\\ / O peration |
|
||||
\\ / A nd | www.openfoam.com
|
||||
\\/ M anipulation |
|
||||
-------------------------------------------------------------------------------
|
||||
Copyright (C) 2019 OpenCFD Ltd.
|
||||
Copyright (C) 2019-2020 DLR
|
||||
-------------------------------------------------------------------------------
|
||||
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::implicitFunctions::paraboloidImplicitFunction
|
||||
|
||||
Description
|
||||
creates a paraboloid
|
||||
|
||||
Original code supplied by Henning Scheufler, DLR (2019)
|
||||
|
||||
SourceFiles
|
||||
paraboloidImplicitFunction.C
|
||||
|
||||
\*---------------------------------------------------------------------------*/
|
||||
|
||||
#ifndef implicitFunction_paraboloidImplicitFunction_H
|
||||
#define implicitFunction_paraboloidImplicitFunction_H
|
||||
|
||||
#include "implicitFunction.H"
|
||||
#include "mathematicalConstants.H"
|
||||
|
||||
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
|
||||
|
||||
namespace Foam
|
||||
{
|
||||
namespace implicitFunctions
|
||||
{
|
||||
|
||||
/*---------------------------------------------------------------------------*\
|
||||
Class paraboloidImplicitFunction Declaration
|
||||
\*---------------------------------------------------------------------------*/
|
||||
|
||||
class paraboloidImplicitFunction
|
||||
:
|
||||
public implicitFunction
|
||||
{
|
||||
// Private Data
|
||||
|
||||
//- Coefficients of ax^2 + bx*y + cy^2
|
||||
const vector coeffs_;
|
||||
|
||||
|
||||
public:
|
||||
|
||||
//- Runtime type information
|
||||
TypeName("paraboloid");
|
||||
|
||||
|
||||
// Constructors
|
||||
|
||||
//- Construct from components
|
||||
explicit paraboloidImplicitFunction(const vector& coeffs);
|
||||
|
||||
//- Construct from dictionary
|
||||
explicit paraboloidImplicitFunction(const dictionary& dict);
|
||||
|
||||
|
||||
//- Destructor
|
||||
virtual ~paraboloidImplicitFunction() = default;
|
||||
|
||||
|
||||
// Member Functions
|
||||
|
||||
virtual scalar value(const vector& p) const
|
||||
{
|
||||
return
|
||||
coeffs_.x()*sqr(p.x())
|
||||
+ coeffs_.y()*p.x()*p.y()
|
||||
+ coeffs_.z()*sqr(p.y())
|
||||
- p.z();
|
||||
}
|
||||
|
||||
virtual vector grad(const vector& p) const
|
||||
{
|
||||
NotImplemented;
|
||||
return Zero;
|
||||
}
|
||||
|
||||
virtual scalar distanceToSurfaces(const vector& p) const
|
||||
{
|
||||
NotImplemented;
|
||||
return 0;
|
||||
}
|
||||
};
|
||||
|
||||
|
||||
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
|
||||
|
||||
} // End namespace implicitFunctions
|
||||
} // End namespace Foam
|
||||
|
||||
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
|
||||
|
||||
#endif
|
||||
|
||||
// ************************************************************************* //
|
||||
@ -0,0 +1,75 @@
|
||||
/*---------------------------------------------------------------------------*\
|
||||
========= |
|
||||
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
|
||||
\\ / O peration |
|
||||
\\ / A nd | www.openfoam.com
|
||||
\\/ M anipulation |
|
||||
-------------------------------------------------------------------------------
|
||||
Copyright (C) 2019 OpenCFD Ltd.
|
||||
Copyright (C) 2019-2020 DLR
|
||||
-------------------------------------------------------------------------------
|
||||
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 "planeImplicitFunction.H"
|
||||
#include "addToRunTimeSelectionTable.H"
|
||||
|
||||
// * * * * * * * * * * * * * * Static Data Members * * * * * * * * * * * * * //
|
||||
|
||||
namespace Foam
|
||||
{
|
||||
namespace implicitFunctions
|
||||
{
|
||||
defineTypeNameAndDebug(planeImplicitFunction, 0);
|
||||
addToRunTimeSelectionTable
|
||||
(
|
||||
implicitFunction,
|
||||
planeImplicitFunction,
|
||||
dict
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
// * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * //
|
||||
|
||||
Foam::implicitFunctions::planeImplicitFunction::planeImplicitFunction
|
||||
(
|
||||
const vector& origin,
|
||||
const vector& normal
|
||||
)
|
||||
:
|
||||
origin_(origin),
|
||||
normal_(normalised(normal))
|
||||
{}
|
||||
|
||||
|
||||
Foam::implicitFunctions::planeImplicitFunction::planeImplicitFunction
|
||||
(
|
||||
const dictionary& dict
|
||||
)
|
||||
:
|
||||
planeImplicitFunction
|
||||
(
|
||||
dict.get<vector>("origin"),
|
||||
dict.get<vector>("normal")
|
||||
)
|
||||
{}
|
||||
|
||||
|
||||
// ************************************************************************* //
|
||||
@ -0,0 +1,120 @@
|
||||
/*---------------------------------------------------------------------------*\
|
||||
========= |
|
||||
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
|
||||
\\ / O peration |
|
||||
\\ / A nd | www.openfoam.com
|
||||
\\/ M anipulation |
|
||||
-------------------------------------------------------------------------------
|
||||
Copyright (C) 2019 OpenCFD Ltd.
|
||||
Copyright (C) 2019-2020 DLR
|
||||
-------------------------------------------------------------------------------
|
||||
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::implicitFunctions::planeImplicitFunction
|
||||
|
||||
Description
|
||||
creates a plane
|
||||
|
||||
Original code supplied by Henning Scheufler, DLR (2019)
|
||||
|
||||
SourceFiles
|
||||
planeImplicitFunction.C
|
||||
|
||||
\*---------------------------------------------------------------------------*/
|
||||
|
||||
#ifndef implicitFunction_planeImplicitFunction_H
|
||||
#define implicitFunction_planeImplicitFunction_H
|
||||
|
||||
#include "implicitFunction.H"
|
||||
#include "mathematicalConstants.H"
|
||||
|
||||
|
||||
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
|
||||
|
||||
namespace Foam
|
||||
{
|
||||
namespace implicitFunctions
|
||||
{
|
||||
|
||||
/*---------------------------------------------------------------------------*\
|
||||
Class planeImplicitFunction Declaration
|
||||
\*---------------------------------------------------------------------------*/
|
||||
|
||||
class planeImplicitFunction
|
||||
:
|
||||
public implicitFunction
|
||||
{
|
||||
// Private Data
|
||||
|
||||
//- Reference point
|
||||
const vector origin_;
|
||||
|
||||
//- Unit-normal vector
|
||||
const vector normal_;
|
||||
|
||||
|
||||
public:
|
||||
|
||||
//- Runtime type information
|
||||
TypeName("plane");
|
||||
|
||||
|
||||
// Constructors
|
||||
|
||||
//- Construct from components
|
||||
planeImplicitFunction(const vector& origin, const vector& normal);
|
||||
|
||||
//- Construct from dictionary (used by implicitFunctions)
|
||||
explicit planeImplicitFunction(const dictionary& dict);
|
||||
|
||||
|
||||
//- Destructor
|
||||
virtual ~planeImplicitFunction() = default;
|
||||
|
||||
|
||||
// Member Functions
|
||||
|
||||
virtual scalar value(const vector& p) const
|
||||
{
|
||||
return -normal_ & (origin_ - p);
|
||||
}
|
||||
|
||||
virtual vector grad(const vector& p) const
|
||||
{
|
||||
// normal_ has the length of one
|
||||
return normal_;
|
||||
}
|
||||
|
||||
virtual scalar distanceToSurfaces(const vector& p) const
|
||||
{
|
||||
// normal_ has the length of one
|
||||
return mag((p - origin_) & -normal_);
|
||||
}
|
||||
};
|
||||
|
||||
|
||||
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
|
||||
|
||||
} // End namespace implicitFunctions
|
||||
} // End namespace Foam
|
||||
|
||||
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
|
||||
|
||||
#endif
|
||||
|
||||
// ************************************************************************* //
|
||||
@ -0,0 +1,87 @@
|
||||
/*---------------------------------------------------------------------------*\
|
||||
========= |
|
||||
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
|
||||
\\ / O peration |
|
||||
\\ / A nd | www.openfoam.com
|
||||
\\/ M anipulation |
|
||||
-------------------------------------------------------------------------------
|
||||
Copyright (C) 2019 OpenCFD Ltd.
|
||||
Copyright (C) 2019-2020 DLR
|
||||
-------------------------------------------------------------------------------
|
||||
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 "sinImplicitFunction.H"
|
||||
#include "addToRunTimeSelectionTable.H"
|
||||
|
||||
// * * * * * * * * * * * * * * Static Data Members * * * * * * * * * * * * * //
|
||||
|
||||
namespace Foam
|
||||
{
|
||||
namespace implicitFunctions
|
||||
{
|
||||
defineTypeNameAndDebug(sinImplicitFunction, 0);
|
||||
addToRunTimeSelectionTable
|
||||
(
|
||||
implicitFunction,
|
||||
sinImplicitFunction,
|
||||
dict
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
// * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * //
|
||||
|
||||
Foam::implicitFunctions::sinImplicitFunction::sinImplicitFunction
|
||||
(
|
||||
const scalar period,
|
||||
const scalar phase,
|
||||
const scalar amplitude,
|
||||
const vector& direction,
|
||||
const vector& up,
|
||||
const vector& origin
|
||||
)
|
||||
:
|
||||
period_(period),
|
||||
phase_(phase),
|
||||
amplitude_(amplitude),
|
||||
up_(normalised(up)),
|
||||
direction_(normalised(direction)),
|
||||
origin_(origin)
|
||||
{}
|
||||
|
||||
|
||||
Foam::implicitFunctions::sinImplicitFunction::sinImplicitFunction
|
||||
(
|
||||
const dictionary& dict
|
||||
)
|
||||
:
|
||||
sinImplicitFunction
|
||||
(
|
||||
dict.get<scalar>("period"),
|
||||
dict.getOrDefault<scalar>("phase", 0),
|
||||
dict.get<scalar>("amplitude"),
|
||||
dict.get<vector>("direction"),
|
||||
dict.get<vector>("up"),
|
||||
dict.get<vector>("origin")
|
||||
)
|
||||
{}
|
||||
|
||||
|
||||
// ************************************************************************* //
|
||||
@ -0,0 +1,142 @@
|
||||
/*---------------------------------------------------------------------------*\
|
||||
========= |
|
||||
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
|
||||
\\ / O peration |
|
||||
\\ / A nd | www.openfoam.com
|
||||
\\/ M anipulation |
|
||||
-------------------------------------------------------------------------------
|
||||
Copyright (C) 2019 OpenCFD Ltd.
|
||||
Copyright (C) 2019-2020 DLR
|
||||
-------------------------------------------------------------------------------
|
||||
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::implicitFunctions::sinImplicitFunction
|
||||
|
||||
Description
|
||||
|
||||
Original code supplied by Henning Scheufler, DLR (2019)
|
||||
|
||||
SourceFiles
|
||||
sinImplicitFunction.C
|
||||
|
||||
\*---------------------------------------------------------------------------*/
|
||||
|
||||
#ifndef implicitFunction_sinImplicitFunction_H
|
||||
#define implicitFunction_sinImplicitFunction_H
|
||||
|
||||
#include "implicitFunction.H"
|
||||
#include "mathematicalConstants.H"
|
||||
|
||||
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
|
||||
|
||||
namespace Foam
|
||||
{
|
||||
namespace implicitFunctions
|
||||
{
|
||||
|
||||
/*---------------------------------------------------------------------------*\
|
||||
Class sinImplicitFunction Declaration
|
||||
\*---------------------------------------------------------------------------*/
|
||||
|
||||
class sinImplicitFunction
|
||||
:
|
||||
public implicitFunction
|
||||
{
|
||||
private:
|
||||
|
||||
// Private Data
|
||||
|
||||
//- Origin point
|
||||
const scalar period_;
|
||||
|
||||
//- Radius
|
||||
const scalar phase_;
|
||||
|
||||
const scalar amplitude_;
|
||||
|
||||
const vector up_;
|
||||
|
||||
const vector direction_;
|
||||
|
||||
const vector origin_;
|
||||
|
||||
|
||||
public:
|
||||
|
||||
//- Runtime type information
|
||||
TypeName("sin");
|
||||
|
||||
|
||||
// Constructors
|
||||
|
||||
//- Construct from components
|
||||
sinImplicitFunction
|
||||
(
|
||||
const scalar period,
|
||||
const scalar phase,
|
||||
const scalar amplitude,
|
||||
const vector& direction,
|
||||
const vector& up,
|
||||
const vector& origin
|
||||
);
|
||||
|
||||
//- Construct from dictionary (used by implicitFunctions)
|
||||
explicit sinImplicitFunction(const dictionary& dict);
|
||||
|
||||
|
||||
//- Destructor
|
||||
virtual ~sinImplicitFunction() = default;
|
||||
|
||||
|
||||
// Member Functions
|
||||
|
||||
virtual scalar value(const vector& p) const
|
||||
{
|
||||
const scalar x = (p - origin_) & direction_;
|
||||
const scalar z = (p - origin_) & -up_;
|
||||
|
||||
return
|
||||
z
|
||||
- amplitude_
|
||||
*Foam::sin(2*constant::mathematical::pi*x/period_ + phase_);
|
||||
}
|
||||
|
||||
virtual vector grad(const vector& p) const
|
||||
{
|
||||
NotImplemented;
|
||||
return Zero;
|
||||
}
|
||||
|
||||
virtual scalar distanceToSurfaces(const vector& p) const
|
||||
{
|
||||
NotImplemented;
|
||||
return 0;
|
||||
}
|
||||
};
|
||||
|
||||
|
||||
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
|
||||
|
||||
} // End namespace implicitFunctions
|
||||
} // End namespace Foam
|
||||
|
||||
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
|
||||
|
||||
#endif
|
||||
|
||||
// ************************************************************************* //
|
||||
@ -0,0 +1,78 @@
|
||||
/*---------------------------------------------------------------------------*\
|
||||
========= |
|
||||
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
|
||||
\\ / O peration |
|
||||
\\ / A nd | www.openfoam.com
|
||||
\\/ M anipulation |
|
||||
-------------------------------------------------------------------------------
|
||||
Copyright (C) 2019 OpenCFD Ltd.
|
||||
Copyright (C) 2019-2020 DLR
|
||||
-------------------------------------------------------------------------------
|
||||
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 "sphereImplicitFunction.H"
|
||||
#include "addToRunTimeSelectionTable.H"
|
||||
|
||||
// * * * * * * * * * * * * * * Static Data Members * * * * * * * * * * * * * //
|
||||
|
||||
namespace Foam
|
||||
{
|
||||
namespace implicitFunctions
|
||||
{
|
||||
defineTypeNameAndDebug(sphereImplicitFunction, 0);
|
||||
addToRunTimeSelectionTable
|
||||
(
|
||||
implicitFunction,
|
||||
sphereImplicitFunction,
|
||||
dict
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
// * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * //
|
||||
|
||||
Foam::implicitFunctions::sphereImplicitFunction::sphereImplicitFunction
|
||||
(
|
||||
const point& origin,
|
||||
const scalar radius,
|
||||
const scalar scale
|
||||
)
|
||||
:
|
||||
origin_(origin),
|
||||
radius_(radius),
|
||||
scale_(scale)
|
||||
{}
|
||||
|
||||
|
||||
Foam::implicitFunctions::sphereImplicitFunction::sphereImplicitFunction
|
||||
(
|
||||
const dictionary& dict
|
||||
)
|
||||
:
|
||||
sphereImplicitFunction
|
||||
(
|
||||
dict.get<point>("origin"),
|
||||
dict.get<scalar>("radius"),
|
||||
dict.getOrDefault<scalar>("scale", 1)
|
||||
)
|
||||
{}
|
||||
|
||||
|
||||
// ************************************************************************* //
|
||||
@ -0,0 +1,124 @@
|
||||
/*---------------------------------------------------------------------------*\
|
||||
========= |
|
||||
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
|
||||
\\ / O peration |
|
||||
\\ / A nd | www.openfoam.com
|
||||
\\/ M anipulation |
|
||||
-------------------------------------------------------------------------------
|
||||
Copyright (C) 2019 OpenCFD Ltd.
|
||||
Copyright (C) 2019-2020 DLR
|
||||
-------------------------------------------------------------------------------
|
||||
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::implicitFunctions::sphereImplicitFunction
|
||||
|
||||
Description
|
||||
Creates a sphere
|
||||
|
||||
Original code supplied by Henning Scheufler, DLR (2019)
|
||||
|
||||
SourceFiles
|
||||
sphereImplicitFunction.C
|
||||
|
||||
\*---------------------------------------------------------------------------*/
|
||||
|
||||
#ifndef implicitFunction_sphereImplicitFunction_H
|
||||
#define implicitFunction_sphereImplicitFunction_H
|
||||
|
||||
#include "implicitFunction.H"
|
||||
#include "point.H"
|
||||
|
||||
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
|
||||
|
||||
namespace Foam
|
||||
{
|
||||
namespace implicitFunctions
|
||||
{
|
||||
|
||||
/*---------------------------------------------------------------------------*\
|
||||
Class sphereImplicitFunction Declaration
|
||||
\*---------------------------------------------------------------------------*/
|
||||
|
||||
class sphereImplicitFunction
|
||||
:
|
||||
public implicitFunction
|
||||
{
|
||||
// Private Data
|
||||
|
||||
//- Origin point
|
||||
const point origin_;
|
||||
|
||||
//- Radius
|
||||
const scalar radius_;
|
||||
|
||||
const scalar scale_;
|
||||
|
||||
|
||||
public:
|
||||
|
||||
//- Runtime type information
|
||||
TypeName("sphere");
|
||||
|
||||
|
||||
// Constructors
|
||||
|
||||
//- Construct from components
|
||||
sphereImplicitFunction
|
||||
(
|
||||
const point&,
|
||||
const scalar radius,
|
||||
const scalar scale
|
||||
);
|
||||
|
||||
//- Construct from dictionary
|
||||
explicit sphereImplicitFunction(const dictionary& dict);
|
||||
|
||||
|
||||
//- Destructor
|
||||
virtual ~sphereImplicitFunction() = default;
|
||||
|
||||
|
||||
// Member Functions
|
||||
|
||||
virtual scalar value(const vector& p) const
|
||||
{
|
||||
return (-mag(p - origin_) + radius_)*scale_;
|
||||
}
|
||||
|
||||
virtual vector grad(const vector& p) const
|
||||
{
|
||||
return (origin_ - p)*scale_;
|
||||
}
|
||||
|
||||
virtual scalar distanceToSurfaces(const vector& p) const
|
||||
{
|
||||
return mag(mag(p - origin_) - radius_)*scale_;
|
||||
}
|
||||
};
|
||||
|
||||
|
||||
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
|
||||
|
||||
} // End namespace implicitFunctions
|
||||
} // End namespace Foam
|
||||
|
||||
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
|
||||
|
||||
#endif
|
||||
|
||||
// ************************************************************************* //
|
||||
@ -7,6 +7,7 @@
|
||||
-------------------------------------------------------------------------------
|
||||
Copyright (C) 2016-2017 DHI
|
||||
Copyright (C) 2017-2020 OpenCFD Ltd.
|
||||
Copyright (c) 2017-2020, German Aerospace Center (DLR)
|
||||
-------------------------------------------------------------------------------
|
||||
License
|
||||
This file is part of OpenFOAM.
|
||||
@ -28,86 +29,94 @@ Application
|
||||
setAlphaField
|
||||
|
||||
Description
|
||||
Uses isoCutCell to create a volume fraction field from either a cylinder,
|
||||
Uses cutCellIso to create a volume fraction field from either a cylinder,
|
||||
a sphere or a plane.
|
||||
|
||||
Original code supplied by Johan Roenby, DHI (2016)
|
||||
Modification Henning Scheufler, DLR (2019)
|
||||
|
||||
\*---------------------------------------------------------------------------*/
|
||||
|
||||
#include "fvCFD.H"
|
||||
#include "isoCutFace.H"
|
||||
#include "isoCutCell.H"
|
||||
#include "Enum.H"
|
||||
#include "mathematicalConstants.H"
|
||||
|
||||
using namespace Foam::constant;
|
||||
#include "triSurface.H"
|
||||
#include "triSurfaceTools.H"
|
||||
|
||||
#include "implicitFunction.H"
|
||||
|
||||
#include "cutCellIso.H"
|
||||
#include "OBJstream.H"
|
||||
|
||||
|
||||
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
|
||||
|
||||
class shapeSelector
|
||||
void isoFacesToFile
|
||||
(
|
||||
const DynamicList<List<point>>& faces,
|
||||
const word& fileName
|
||||
)
|
||||
{
|
||||
public:
|
||||
// Writing isofaces to OBJ file for inspection in paraview
|
||||
OBJstream os(fileName + ".obj");
|
||||
|
||||
enum class shapeType
|
||||
if (Pstream::parRun())
|
||||
{
|
||||
// Collect points from all the processors
|
||||
List<DynamicList<List<point>>> allProcFaces(Pstream::nProcs());
|
||||
allProcFaces[Pstream::myProcNo()] = faces;
|
||||
Pstream::gatherList(allProcFaces);
|
||||
|
||||
if (Pstream::master())
|
||||
{
|
||||
PLANE,
|
||||
SPHERE,
|
||||
CYLINDER,
|
||||
SIN
|
||||
};
|
||||
Info<< "Writing file: " << fileName << endl;
|
||||
|
||||
static const Foam::Enum<shapeType> shapeTypeNames;
|
||||
};
|
||||
for (const DynamicList<List<point>>& procFaces : allProcFaces)
|
||||
{
|
||||
for (const List<point>& facePts : procFaces)
|
||||
{
|
||||
os.write(face(identity(facePts.size())), facePts);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
Info<< "Writing file: " << fileName << endl;
|
||||
|
||||
|
||||
const Foam::Enum
|
||||
<
|
||||
shapeSelector::shapeType
|
||||
>
|
||||
shapeSelector::shapeTypeNames
|
||||
({
|
||||
{ shapeSelector::shapeType::PLANE, "plane" },
|
||||
{ shapeSelector::shapeType::SPHERE, "sphere" },
|
||||
{ shapeSelector::shapeType::CYLINDER, "cylinder" },
|
||||
{ shapeSelector::shapeType::SIN, "sin" },
|
||||
});
|
||||
for (const List<point>& facePts : faces)
|
||||
{
|
||||
os.write(face(identity(facePts.size())), facePts);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
int main(int argc, char *argv[])
|
||||
{
|
||||
argList::addNote
|
||||
(
|
||||
"Uses isoCutCell to create a volume fraction field from a"
|
||||
" cylinder, sphere or a plane."
|
||||
"Uses cutCellIso to create a volume fraction field from an "
|
||||
"implicit function."
|
||||
);
|
||||
|
||||
#include "addDictOption.H"
|
||||
#include "addRegionOption.H"
|
||||
#include "setRootCase.H"
|
||||
#include "createTime.H"
|
||||
#include "createNamedMesh.H"
|
||||
|
||||
Info<< "Reading setAlphaFieldDict\n" << endl;
|
||||
const word dictName("setAlphaFieldDict");
|
||||
#include "setSystemMeshDictionaryIO.H"
|
||||
|
||||
IOdictionary dict
|
||||
(
|
||||
IOobject
|
||||
(
|
||||
"setAlphaFieldDict",
|
||||
runTime.system(),
|
||||
mesh,
|
||||
IOobject::MUST_READ,
|
||||
IOobject::NO_WRITE
|
||||
)
|
||||
);
|
||||
IOdictionary setAlphaFieldDict(dictIO);
|
||||
|
||||
const shapeSelector::shapeType surfType
|
||||
(
|
||||
shapeSelector::shapeTypeNames.get("type", dict)
|
||||
);
|
||||
const vector origin(dict.getCompat<vector>("origin", {{"centre", 1806}}));
|
||||
const word fieldName(dict.get<word>("field"));
|
||||
Info<< "Reading " << setAlphaFieldDict.name() << endl;
|
||||
|
||||
Info<< "Reading field " << fieldName << "\n" << endl;
|
||||
const word fieldName = setAlphaFieldDict.get<word>("field");
|
||||
const bool invert = setAlphaFieldDict.getOrDefault("invert", false);
|
||||
const bool writeOBJ = setAlphaFieldDict.getOrDefault("writeOBJ", false);
|
||||
|
||||
Info<< "Reading field " << fieldName << nl << endl;
|
||||
volScalarField alpha1
|
||||
(
|
||||
IOobject
|
||||
@ -121,85 +130,76 @@ int main(int argc, char *argv[])
|
||||
mesh
|
||||
);
|
||||
|
||||
scalar f0 = 0;
|
||||
scalarField f(mesh.points().size());
|
||||
autoPtr<implicitFunction> func = implicitFunction::New
|
||||
(
|
||||
setAlphaFieldDict.get<word>("type"),
|
||||
setAlphaFieldDict
|
||||
);
|
||||
|
||||
Info<< "Processing type '" << shapeSelector::shapeTypeNames[surfType]
|
||||
<< "'" << endl;
|
||||
scalarField f(mesh.nPoints(), Zero);
|
||||
|
||||
switch (surfType)
|
||||
forAll(f, pi)
|
||||
{
|
||||
case shapeSelector::shapeType::PLANE:
|
||||
{
|
||||
const vector direction(dict.get<vector>("direction"));
|
||||
f[pi] = func->value(mesh.points()[pi]);
|
||||
};
|
||||
|
||||
f = -(mesh.points() - origin) & (direction/mag(direction));
|
||||
f0 = 0;
|
||||
break;
|
||||
cutCellIso cutCell(mesh, f);
|
||||
|
||||
DynamicList<List<point>> facePts;
|
||||
|
||||
DynamicList<triSurface> surface;
|
||||
|
||||
surfaceScalarField cellToCellDist(mag(mesh.delta()));
|
||||
|
||||
forAll(alpha1, cellI)
|
||||
{
|
||||
label cellStatus = cutCell.calcSubCell(cellI, 0.0);
|
||||
|
||||
if (cellStatus == -1)
|
||||
{
|
||||
alpha1[cellI] = 1;
|
||||
}
|
||||
case shapeSelector::shapeType::SPHERE:
|
||||
else if (cellStatus == 1)
|
||||
{
|
||||
const scalar radius(dict.get<scalar>("radius"));
|
||||
|
||||
f = -mag(mesh.points() - origin);
|
||||
f0 = -radius;
|
||||
break;
|
||||
alpha1[cellI] = 0;
|
||||
}
|
||||
case shapeSelector::shapeType::CYLINDER:
|
||||
else if (cellStatus == 0)
|
||||
{
|
||||
const scalar radius(dict.get<scalar>("radius"));
|
||||
const vector direction(dict.get<vector>("direction"));
|
||||
|
||||
f = -sqrt
|
||||
(
|
||||
sqr(mag(mesh.points() - origin))
|
||||
- sqr(mag((mesh.points() - origin) & direction))
|
||||
);
|
||||
f0 = -radius;
|
||||
break;
|
||||
}
|
||||
case shapeSelector::shapeType::SIN:
|
||||
{
|
||||
const scalar period(dict.get<scalar>("period"));
|
||||
const scalar amplitude(dict.get<scalar>("amplitude"));
|
||||
const vector up(dict.get<vector>("up"));
|
||||
const vector direction(dict.get<vector>("direction"));
|
||||
|
||||
const scalarField xx
|
||||
(
|
||||
(mesh.points() - origin) & direction/mag(direction)
|
||||
);
|
||||
const scalarField zz((mesh.points() - origin) & up/mag(up));
|
||||
|
||||
f = amplitude*Foam::sin(2*mathematical::pi*xx/period) - zz;
|
||||
f0 = 0;
|
||||
break;
|
||||
if (mag(cutCell.faceArea()) != 0)
|
||||
{
|
||||
alpha1[cellI] = max(min(cutCell.VolumeOfFluid(), 1), 0);
|
||||
if (writeOBJ && (mag(cutCell.faceArea()) >= 1e-14))
|
||||
{
|
||||
facePts.append(cutCell.facePoints());
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
// Define function on mesh points and isovalue
|
||||
|
||||
// Calculating alpha1 volScalarField from f = f0 isosurface
|
||||
isoCutCell icc(mesh, f);
|
||||
icc.volumeOfFluid(alpha1, f0);
|
||||
|
||||
if (dict.getOrDefault("invertAlpha", false))
|
||||
if (writeOBJ)
|
||||
{
|
||||
alpha1 = 1 - alpha1;
|
||||
isoFacesToFile(facePts, fieldName + "0");
|
||||
}
|
||||
|
||||
// Writing volScalarField alpha1
|
||||
ISstream::defaultPrecision(18);
|
||||
|
||||
if (invert)
|
||||
{
|
||||
alpha1 = scalar(1) - alpha1;
|
||||
}
|
||||
|
||||
alpha1.correctBoundaryConditions();
|
||||
|
||||
Info<< "Writing new alpha field " << alpha1.name() << endl;
|
||||
alpha1.write();
|
||||
|
||||
Info<< nl << "Phase-1 volume fraction = "
|
||||
<< alpha1.weightedAverage(mesh.Vsc()).value()
|
||||
<< " Min(" << alpha1.name() << ") = " << min(alpha1).value()
|
||||
<< " Max(" << alpha1.name() << ") - 1 = " << max(alpha1).value() - 1
|
||||
<< nl << endl;
|
||||
const scalarField& alpha = alpha1.internalField();
|
||||
|
||||
Info<< "End\n" << endl;
|
||||
Info<< "sum(alpha*V):" << gSum(mesh.V()*alpha)
|
||||
<< ", 1-max(alpha1): " << 1 - gMax(alpha)
|
||||
<< " min(alpha1): " << gMin(alpha) << endl;
|
||||
|
||||
Info<< "\nEnd\n" << endl;
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
@ -0,0 +1,48 @@
|
||||
/*--------------------------------*- C++ -*----------------------------------*\
|
||||
| ========= | |
|
||||
| \\ / F ield | OpenFOAM: The Open Source CFD Toolbox |
|
||||
| \\ / O peration | Version: v1912 |
|
||||
| \\ / A nd | Website: www.openfoam.com |
|
||||
| \\/ M anipulation | |
|
||||
\*---------------------------------------------------------------------------*/
|
||||
FoamFile
|
||||
{
|
||||
version 2.0;
|
||||
format ascii;
|
||||
class dictionary;
|
||||
location "system";
|
||||
object fvSolution;
|
||||
}
|
||||
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
|
||||
|
||||
field "alpha.water";
|
||||
|
||||
type composedFunction;
|
||||
mode add;
|
||||
composedFunctions
|
||||
{
|
||||
plane
|
||||
{
|
||||
type plane;
|
||||
centre (0 1. 0);
|
||||
normal (0 1 0);
|
||||
}
|
||||
|
||||
sphere
|
||||
{
|
||||
type sphere;
|
||||
radius 0.4;
|
||||
centre (0.5 0.8 0.5);
|
||||
scale 1;
|
||||
}
|
||||
|
||||
sphere2
|
||||
{
|
||||
type sphere;
|
||||
radius 0.4;
|
||||
centre (0.5 0.5 0.5);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
// ************************************************************************* //
|
||||
Reference in New Issue
Block a user