mirror of
https://develop.openfoam.com/Development/openfoam.git
synced 2025-11-28 03:28:01 +00:00
ENH: setExplicitValue source
This commit is contained in:
@ -388,6 +388,7 @@ $(basicSource)/basicSource/IObasicSourceList.C
|
|||||||
$(basicSource)/actuationDiskSource/actuationDiskSource.C
|
$(basicSource)/actuationDiskSource/actuationDiskSource.C
|
||||||
$(basicSource)/radialActuationDiskSource/radialActuationDiskSource.C
|
$(basicSource)/radialActuationDiskSource/radialActuationDiskSource.C
|
||||||
$(basicSource)/explicitSource/explicitSource.C
|
$(basicSource)/explicitSource/explicitSource.C
|
||||||
|
$(basicSource)/explicitSetValue/explicitSetValue.C
|
||||||
|
|
||||||
|
|
||||||
LIB = $(FOAM_LIBBIN)/libfiniteVolume
|
LIB = $(FOAM_LIBBIN)/libfiniteVolume
|
||||||
|
|||||||
@ -48,14 +48,14 @@ void Foam::actuationDiskSource::addActuationDiskAxialInertialResistance
|
|||||||
E.xx() = uniDiskDir.x();
|
E.xx() = uniDiskDir.x();
|
||||||
E.yy() = uniDiskDir.y();
|
E.yy() = uniDiskDir.y();
|
||||||
E.zz() = uniDiskDir.z();
|
E.zz() = uniDiskDir.z();
|
||||||
const vectorField U1((1.0 - a)*U);
|
|
||||||
forAll(cells, i)
|
forAll(cells, i)
|
||||||
{
|
{
|
||||||
T[i] = 2.0*rho[cells[i]]*diskArea_*mag(U1[cells[i]])*a/(1.0 - a);
|
T[i] = 2.0*rho[cells[i]]*diskArea_*mag(U[cells[i]])*a/(1.0 - a);
|
||||||
}
|
}
|
||||||
forAll(cells, i)
|
forAll(cells, i)
|
||||||
{
|
{
|
||||||
Usource[cells[i]] += ((Vcells[cells[i]]/V())*T[i]*E) & U1[cells[i]];
|
Usource[cells[i]] += ((Vcells[cells[i]]/V())*T[i]*E) & U[cells[i]];
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@ -116,10 +116,15 @@ void Foam::basicSource::setCellSet()
|
|||||||
label globalCellI = returnReduce(cellI, maxOp<label>());
|
label globalCellI = returnReduce(cellI, maxOp<label>());
|
||||||
if (globalCellI < 0)
|
if (globalCellI < 0)
|
||||||
{
|
{
|
||||||
WarningIn("TimeActivatedExplicitSource<Type>::setCellIds()")
|
WarningIn
|
||||||
<< "Unable to find owner cell for point " << points_[i]
|
(
|
||||||
<< endl;
|
"TimeActivatedExplicitSource<Type>::setCellIds()"
|
||||||
|
)
|
||||||
|
<< "Unable to find owner cell for point " << points_[i]
|
||||||
|
<< endl;
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
cells_ = selectedCells.toc();
|
cells_ = selectedCells.toc();
|
||||||
@ -270,4 +275,30 @@ bool Foam::basicSource::isActive()
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
void Foam::basicSource::addSu(Foam::fvMatrix<vector>& Eqn)
|
||||||
|
{
|
||||||
|
notImplemented
|
||||||
|
(
|
||||||
|
"Foam::basicSource addSu(Foam::fvMatrix<vector>& Eqn)"
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
void Foam::basicSource::addSu(Foam::fvMatrix<scalar>& Eqn)
|
||||||
|
{
|
||||||
|
notImplemented
|
||||||
|
(
|
||||||
|
"Foam::basicSource addSu(Foam::fvMatrix<scalar>& Eqn)"
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
void Foam::basicSource::setValue(Foam::fvMatrix<scalar>& Eqn)
|
||||||
|
{
|
||||||
|
notImplemented
|
||||||
|
(
|
||||||
|
"Foam::basicSource setValue(Foam::fvMatrix<scalar>& Eqn)"
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
// ************************************************************************* //
|
// ************************************************************************* //
|
||||||
|
|||||||
@ -56,13 +56,13 @@ Description
|
|||||||
selectionMode points;
|
selectionMode points;
|
||||||
cellSet c0;
|
cellSet c0;
|
||||||
|
|
||||||
|
points // list of points when selectionMode = points
|
||||||
|
(
|
||||||
|
(-0.088 0.007 -0.02)
|
||||||
|
(-0.028 0.007 -0.02)
|
||||||
|
);
|
||||||
explicitSourceCoeffs
|
explicitSourceCoeffs
|
||||||
{
|
{
|
||||||
points // list of points when selectionMode = points
|
|
||||||
(
|
|
||||||
(-0.088 0.007 -0.02)
|
|
||||||
(-0.028 0.007 -0.02)
|
|
||||||
);
|
|
||||||
volumeMode specific; //absolute
|
volumeMode specific; //absolute
|
||||||
fieldData //field data
|
fieldData //field data
|
||||||
{
|
{
|
||||||
@ -323,10 +323,14 @@ public:
|
|||||||
// Evaluation
|
// Evaluation
|
||||||
|
|
||||||
//- Add source term to vector fvMatrix
|
//- Add source term to vector fvMatrix
|
||||||
virtual void addSu(fvMatrix<vector>& Eqn) = 0;
|
virtual void addSu(fvMatrix<vector>& Eqn);
|
||||||
|
|
||||||
//- Add source term to scalar fvMatrix
|
//- Add source term to scalar fvMatrix
|
||||||
virtual void addSu(fvMatrix<scalar>& Eqn) = 0;
|
virtual void addSu(fvMatrix<scalar>& Eqn);
|
||||||
|
|
||||||
|
//- Set constant value on field
|
||||||
|
virtual void setValue(fvMatrix<scalar>& Eq);
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
// I-O
|
// I-O
|
||||||
|
|||||||
@ -90,6 +90,19 @@ void Foam::basicSourceList::addSu(fvMatrix<vector>& Eqn)
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
void Foam::basicSourceList::setValue(fvMatrix<scalar>& Eqn)
|
||||||
|
{
|
||||||
|
|
||||||
|
forAll(*this, i)
|
||||||
|
{
|
||||||
|
if (this->operator[](i).isActive())
|
||||||
|
{
|
||||||
|
this->operator[](i).setValue(Eqn);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
bool Foam::basicSourceList::read(const dictionary& dict)
|
bool Foam::basicSourceList::read(const dictionary& dict)
|
||||||
{
|
{
|
||||||
bool allOk = true;
|
bool allOk = true;
|
||||||
|
|||||||
@ -92,6 +92,9 @@ public:
|
|||||||
//- Add source terms to vector fvMatrix
|
//- Add source terms to vector fvMatrix
|
||||||
void addSu(fvMatrix<vector>& Eq);
|
void addSu(fvMatrix<vector>& Eq);
|
||||||
|
|
||||||
|
//- Set constant value on field
|
||||||
|
void setValue(fvMatrix<scalar>& Eq);
|
||||||
|
|
||||||
|
|
||||||
// I-O
|
// I-O
|
||||||
|
|
||||||
|
|||||||
@ -0,0 +1,117 @@
|
|||||||
|
/*---------------------------------------------------------------------------*\
|
||||||
|
========= |
|
||||||
|
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
|
||||||
|
\\ / O peration |
|
||||||
|
\\ / A nd | Copyright (C) 2011 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 "explicitSetValue.H"
|
||||||
|
#include "fvMesh.H"
|
||||||
|
#include "volFields.H"
|
||||||
|
#include "addToRunTimeSelectionTable.H"
|
||||||
|
#include "HashSet.H"
|
||||||
|
|
||||||
|
// * * * * * * * * * * * * Static Member Functions * * * * * * * * * * * * * //
|
||||||
|
|
||||||
|
namespace Foam
|
||||||
|
{
|
||||||
|
defineTypeNameAndDebug(explicitSetValue, 0);
|
||||||
|
addToRunTimeSelectionTable
|
||||||
|
(
|
||||||
|
basicSource,
|
||||||
|
explicitSetValue,
|
||||||
|
dictionary
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
// * * * * * * * * * * * * Protected Member Functions * * * * * * * * * * * //
|
||||||
|
|
||||||
|
void Foam::explicitSetValue::setFieldData(const dictionary& dict)
|
||||||
|
{
|
||||||
|
scalarFields_.clear();
|
||||||
|
vectorFields_.clear();
|
||||||
|
|
||||||
|
wordList fieldTypes(dict.toc().size());
|
||||||
|
wordList fieldNames(dict.toc().size());
|
||||||
|
|
||||||
|
forAll(dict.toc(), i)
|
||||||
|
{
|
||||||
|
const word& fieldName = dict.toc()[i];
|
||||||
|
IOobject io
|
||||||
|
(
|
||||||
|
fieldName,
|
||||||
|
this->mesh().time().timeName(),
|
||||||
|
this->mesh(),
|
||||||
|
IOobject::NO_READ,
|
||||||
|
IOobject::NO_WRITE,
|
||||||
|
false
|
||||||
|
);
|
||||||
|
if (io.headerOk())
|
||||||
|
{
|
||||||
|
fieldTypes[i] = io.headerClassName();
|
||||||
|
fieldNames[i] = dict.toc()[i];
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
FatalErrorIn
|
||||||
|
(
|
||||||
|
"explicitSetValue::setFieldData"
|
||||||
|
) << "header not OK " << io.name()
|
||||||
|
<< exit(FatalError);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
addField(scalarFields_, fieldTypes, fieldNames, dict);
|
||||||
|
addField(vectorFields_, fieldTypes, fieldNames, dict);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
// * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * //
|
||||||
|
|
||||||
|
Foam::explicitSetValue::explicitSetValue
|
||||||
|
(
|
||||||
|
const word& name,
|
||||||
|
const word& modelType,
|
||||||
|
const dictionary& dict,
|
||||||
|
const fvMesh& mesh
|
||||||
|
)
|
||||||
|
:
|
||||||
|
basicSource(name, modelType, dict, mesh),
|
||||||
|
dict_(dict.subDict(modelType + "Coeffs"))
|
||||||
|
{
|
||||||
|
setFieldData(dict_.subDict("fieldData"));
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
void Foam::explicitSetValue::setValue(fvMatrix<scalar>& Eqn)
|
||||||
|
{
|
||||||
|
setFieldValue(Eqn, scalarFields_[Eqn.psi().name()]);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
void Foam::explicitSetValue::setValue(fvMatrix<vector>& Eqn)
|
||||||
|
{
|
||||||
|
setFieldValue(Eqn, vectorFields_[Eqn.psi().name()]);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
// ************************************************************************* //
|
||||||
@ -0,0 +1,184 @@
|
|||||||
|
/*---------------------------------------------------------------------------*\
|
||||||
|
========= |
|
||||||
|
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
|
||||||
|
\\ / O peration |
|
||||||
|
\\ / A nd | Copyright (C) 2011 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::explicitSetValue
|
||||||
|
|
||||||
|
Description
|
||||||
|
Explicit set values on fields.
|
||||||
|
|
||||||
|
Sources described by:
|
||||||
|
|
||||||
|
explicitSetValueCoeffs
|
||||||
|
{
|
||||||
|
fieldData // field data - usage for multiple fields
|
||||||
|
{
|
||||||
|
k 30.7;
|
||||||
|
epsilon 1.5;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
SourceFiles
|
||||||
|
explicitSetValue.C
|
||||||
|
|
||||||
|
\*---------------------------------------------------------------------------*/
|
||||||
|
|
||||||
|
#ifndef explicitSetValue_H
|
||||||
|
#define explicitSetValue_H
|
||||||
|
|
||||||
|
#include "cellSet.H"
|
||||||
|
#include "volFieldsFwd.H"
|
||||||
|
#include "DimensionedField.H"
|
||||||
|
#include "basicSource.H"
|
||||||
|
|
||||||
|
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
|
||||||
|
|
||||||
|
namespace Foam
|
||||||
|
{
|
||||||
|
|
||||||
|
/*---------------------------------------------------------------------------*\
|
||||||
|
Class explicitSetValue Declaration
|
||||||
|
\*---------------------------------------------------------------------------*/
|
||||||
|
|
||||||
|
class explicitSetValue
|
||||||
|
:
|
||||||
|
public basicSource
|
||||||
|
{
|
||||||
|
// Private data
|
||||||
|
|
||||||
|
//- List of field types
|
||||||
|
HashTable<scalar> scalarFields_;
|
||||||
|
HashTable<vector> vectorFields_;
|
||||||
|
|
||||||
|
//- Set value to field
|
||||||
|
template<class Type>
|
||||||
|
void setFieldValue(fvMatrix<Type>&, const Type&) const;
|
||||||
|
|
||||||
|
//- Add field names and values to field table for types.
|
||||||
|
template<class Type>
|
||||||
|
void addField
|
||||||
|
(
|
||||||
|
HashTable<Type>& fields,
|
||||||
|
const wordList& fieldTypes,
|
||||||
|
const wordList& fieldNames,
|
||||||
|
const dictionary& dict
|
||||||
|
);
|
||||||
|
|
||||||
|
|
||||||
|
protected:
|
||||||
|
|
||||||
|
// Protected data
|
||||||
|
|
||||||
|
//- Sub dictionary for time activated explicit sources
|
||||||
|
const dictionary& dict_;
|
||||||
|
|
||||||
|
|
||||||
|
// Protected functions
|
||||||
|
|
||||||
|
//- Set the local field data
|
||||||
|
void setFieldData(const dictionary& dict);
|
||||||
|
|
||||||
|
|
||||||
|
public:
|
||||||
|
|
||||||
|
//- Runtime type information
|
||||||
|
TypeName("explicitSetValue");
|
||||||
|
|
||||||
|
|
||||||
|
// Constructors
|
||||||
|
|
||||||
|
//- Construct from components
|
||||||
|
explicitSetValue
|
||||||
|
(
|
||||||
|
const word& name,
|
||||||
|
const word& modelType,
|
||||||
|
const dictionary& dict,
|
||||||
|
const fvMesh& mesh
|
||||||
|
);
|
||||||
|
|
||||||
|
//- Return clone
|
||||||
|
autoPtr<explicitSetValue> clone() const
|
||||||
|
{
|
||||||
|
notImplemented
|
||||||
|
(
|
||||||
|
"autoPtr<explicitSetValue> clone() const"
|
||||||
|
);
|
||||||
|
return autoPtr<explicitSetValue>(NULL);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
// Member Functions
|
||||||
|
|
||||||
|
|
||||||
|
// Edit
|
||||||
|
|
||||||
|
//- Return points
|
||||||
|
inline const List<point>& points() const;
|
||||||
|
|
||||||
|
|
||||||
|
// Evaluation
|
||||||
|
|
||||||
|
//- Set value on vector field
|
||||||
|
virtual void setValue(fvMatrix<vector>& UEqn);
|
||||||
|
|
||||||
|
//- Set value on scalar field
|
||||||
|
virtual void setValue(fvMatrix<scalar>& UEqn);
|
||||||
|
|
||||||
|
|
||||||
|
// I-O
|
||||||
|
|
||||||
|
//- Write the source properties
|
||||||
|
virtual void writeData(Ostream&) const;
|
||||||
|
|
||||||
|
//- Read fieldData in sub-dictionary
|
||||||
|
virtual bool read(const dictionary& dict);
|
||||||
|
|
||||||
|
//- Ostream operator
|
||||||
|
friend Ostream& operator<<
|
||||||
|
(
|
||||||
|
Ostream& os,
|
||||||
|
const explicitSetValue& source
|
||||||
|
);
|
||||||
|
};
|
||||||
|
|
||||||
|
|
||||||
|
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
|
||||||
|
|
||||||
|
} // End namespace Foam
|
||||||
|
|
||||||
|
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
|
||||||
|
|
||||||
|
#include "explicitSetValueIO.C"
|
||||||
|
#include "explicitSetValueI.H"
|
||||||
|
|
||||||
|
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
|
||||||
|
|
||||||
|
#ifdef NoRepository
|
||||||
|
# include "explicitSetValueTemplates.C"
|
||||||
|
#endif
|
||||||
|
|
||||||
|
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
|
||||||
|
|
||||||
|
#endif
|
||||||
|
|
||||||
|
// ************************************************************************* //
|
||||||
@ -0,0 +1,37 @@
|
|||||||
|
/*---------------------------------------------------------------------------*\
|
||||||
|
========= |
|
||||||
|
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
|
||||||
|
\\ / O peration |
|
||||||
|
\\ / A nd | Copyright (C) 2011 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 "explicitSetValue.H"
|
||||||
|
|
||||||
|
// * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * //
|
||||||
|
|
||||||
|
inline const Foam::List<Foam::point>&
|
||||||
|
Foam::explicitSetValue::points() const
|
||||||
|
{
|
||||||
|
return points_;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
// ************************************************************************* //
|
||||||
@ -0,0 +1,79 @@
|
|||||||
|
/*---------------------------------------------------------------------------*\
|
||||||
|
========= |
|
||||||
|
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
|
||||||
|
\\ / O peration |
|
||||||
|
\\ / A nd | Copyright (C) 2011 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 "explicitSetValue.H"
|
||||||
|
|
||||||
|
// * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * //
|
||||||
|
|
||||||
|
void Foam::explicitSetValue::writeData(Ostream& os) const
|
||||||
|
{
|
||||||
|
os << indent << name_ << nl
|
||||||
|
<< indent << token::BEGIN_BLOCK << incrIndent << nl;
|
||||||
|
|
||||||
|
if (scalarFields_.size() > 0)
|
||||||
|
{
|
||||||
|
os.writeKeyword("scalarFields") << scalarFields_
|
||||||
|
<< token::END_STATEMENT << nl;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (vectorFields_.size() > 0)
|
||||||
|
{
|
||||||
|
os.writeKeyword("vectorFields") << vectorFields_
|
||||||
|
<< token::END_STATEMENT << nl;
|
||||||
|
}
|
||||||
|
|
||||||
|
os << decrIndent << indent << token::END_BLOCK << endl;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
bool Foam::explicitSetValue::read(const dictionary& dict)
|
||||||
|
{
|
||||||
|
if (basicSource::read(dict))
|
||||||
|
{
|
||||||
|
const dictionary& sourceDict = dict.subDict(name());
|
||||||
|
const dictionary& subDictCoeffs = sourceDict.subDict
|
||||||
|
(
|
||||||
|
typeName + "Coeffs"
|
||||||
|
);
|
||||||
|
setFieldData(subDictCoeffs.subDict("fieldData"));
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
// * * * * * * * * * * * * * * * IOstream Operators * * * * * * * * * * * * //
|
||||||
|
|
||||||
|
Foam::Ostream& Foam::operator<<(Ostream& os, const explicitSetValue& source)
|
||||||
|
{
|
||||||
|
source.writeData(os);
|
||||||
|
return os;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
// ************************************************************************* //
|
||||||
@ -0,0 +1,105 @@
|
|||||||
|
/*---------------------------------------------------------------------------*\
|
||||||
|
========= |
|
||||||
|
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
|
||||||
|
\\ / O peration |
|
||||||
|
\\ / A nd | Copyright (C) 2011 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/>.
|
||||||
|
|
||||||
|
\*---------------------------------------------------------------------------*/
|
||||||
|
|
||||||
|
template <class Type>
|
||||||
|
void Foam::explicitSetValue::setFieldValue
|
||||||
|
(
|
||||||
|
fvMatrix<Type>& Eqn,
|
||||||
|
const Type& value
|
||||||
|
) const
|
||||||
|
{
|
||||||
|
Type data = value;
|
||||||
|
|
||||||
|
DimensionedField<Type, volMesh> rhs
|
||||||
|
(
|
||||||
|
IOobject
|
||||||
|
(
|
||||||
|
"rhs",
|
||||||
|
Eqn.psi().mesh().time().timeName(),
|
||||||
|
Eqn.psi().mesh(),
|
||||||
|
IOobject::NO_READ,
|
||||||
|
IOobject::NO_WRITE,
|
||||||
|
false
|
||||||
|
),
|
||||||
|
Eqn.psi().mesh(),
|
||||||
|
dimensioned<Type>
|
||||||
|
(
|
||||||
|
"zero",
|
||||||
|
dimless,
|
||||||
|
pTraits<Type>::zero
|
||||||
|
)
|
||||||
|
);
|
||||||
|
|
||||||
|
List<Type> values(this->cells().size());
|
||||||
|
|
||||||
|
forAll (values, i)
|
||||||
|
{
|
||||||
|
values[i] = data;
|
||||||
|
}
|
||||||
|
|
||||||
|
Eqn.setValues(this->cells(), values);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
template <class Type>
|
||||||
|
void Foam::explicitSetValue::addField
|
||||||
|
(
|
||||||
|
HashTable<Type>& fields,
|
||||||
|
const wordList& fieldTypes,
|
||||||
|
const wordList& fieldNames,
|
||||||
|
const dictionary& fieldDataDict
|
||||||
|
)
|
||||||
|
{
|
||||||
|
typedef GeometricField<Type, fvPatchField, volMesh> geometricField;
|
||||||
|
|
||||||
|
forAll (fieldTypes, fieldI)
|
||||||
|
{
|
||||||
|
word fieldName = fieldNames[fieldI];
|
||||||
|
word fieldType = fieldTypes[fieldI];
|
||||||
|
|
||||||
|
if
|
||||||
|
(
|
||||||
|
(
|
||||||
|
fieldType
|
||||||
|
== GeometricField<Type, fvPatchField, volMesh>::typeName
|
||||||
|
) &&
|
||||||
|
(
|
||||||
|
this->mesh().foundObject<geometricField>(fieldName)
|
||||||
|
)
|
||||||
|
)
|
||||||
|
{
|
||||||
|
Type fieldValue = fieldDataDict.lookupOrDefault<Type>
|
||||||
|
(
|
||||||
|
fieldName,
|
||||||
|
pTraits<Type>::zero
|
||||||
|
);
|
||||||
|
|
||||||
|
fields.insert(fieldName, fieldValue);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
// ************************************************************************* //
|
||||||
@ -75,7 +75,7 @@ void Foam::explicitSource::setFieldData(const dictionary& dict)
|
|||||||
IOobject io
|
IOobject io
|
||||||
(
|
(
|
||||||
fieldName,
|
fieldName,
|
||||||
this->mesh().time().timeName(0),
|
this->mesh().time().timeName(),
|
||||||
this->mesh(),
|
this->mesh(),
|
||||||
IOobject::NO_READ,
|
IOobject::NO_READ,
|
||||||
IOobject::NO_WRITE,
|
IOobject::NO_WRITE,
|
||||||
|
|||||||
@ -53,7 +53,6 @@ addRadialActuationDiskAxialInertialResistance
|
|||||||
E.xx() = uniDiskDir.x();
|
E.xx() = uniDiskDir.x();
|
||||||
E.yy() = uniDiskDir.y();
|
E.yy() = uniDiskDir.y();
|
||||||
E.zz() = uniDiskDir.z();
|
E.zz() = uniDiskDir.z();
|
||||||
const vectorField U1((1.0 - a)*U);
|
|
||||||
|
|
||||||
const Field<vector> zoneCellCentres(mesh().cellCentres(), cells);
|
const Field<vector> zoneCellCentres(mesh().cellCentres(), cells);
|
||||||
const Field<scalar> zoneCellVolumes(mesh().cellVolumes(), cells);
|
const Field<scalar> zoneCellVolumes(mesh().cellVolumes(), cells);
|
||||||
@ -68,7 +67,7 @@ addRadialActuationDiskAxialInertialResistance
|
|||||||
|
|
||||||
forAll(cells, i)
|
forAll(cells, i)
|
||||||
{
|
{
|
||||||
T[i] = 2.0*rho[cells[i]]*diskArea_*mag(U1[cells[i]])*a/(1.0 - a);
|
T[i] = 2.0*rho[cells[i]]*diskArea_*mag(U[cells[i]])*a/(1.0 - a);
|
||||||
|
|
||||||
scalar r = mag(mesh().cellCentres()[cells[i]] - avgCentre);
|
scalar r = mag(mesh().cellCentres()[cells[i]] - avgCentre);
|
||||||
|
|
||||||
@ -79,7 +78,7 @@ addRadialActuationDiskAxialInertialResistance
|
|||||||
|
|
||||||
forAll(cells, i)
|
forAll(cells, i)
|
||||||
{
|
{
|
||||||
Usource[cells[i]] += ((Vcells[cells[i]]/V())*Tr[i]*E) & U1[cells[i]];
|
Usource[cells[i]] += ((Vcells[cells[i]]/V())*Tr[i]*E) & U[cells[i]];
|
||||||
}
|
}
|
||||||
|
|
||||||
if (debug)
|
if (debug)
|
||||||
|
|||||||
Reference in New Issue
Block a user