OFtutorial08_customBC

OFtutorial08_customBC

用户自定义边界条件

注:

本文是对Github上openfoam开发教程的中文解析。

总的来说这个系列的教程,边界条件这块做的不是很易懂,我回头会结合其他资料自己写一个易懂的

类:Foam::prescribedPipeInletFvPatchVectorField

组:grpInletBoundaryConditions grpWallBoundaryConditions

描述:对圆形管道的入口设置边界条件。流动方向通过面的法方向自动获得,只需要指定速度的大小。

Property Description Required Default value
R pipe radius yes
flowSpeed magnitude of flow velocity yes
deltaByR wall function thickness as a fraction of pipe radius yes
approximationType name of approximation profile no exponential
centrePoint point on the centreline of the pipe no (0 0 0)
lambda pressure gradient coefficient no 0

指定边界条件的例子:

inlet
{
	// prescribes a parabolic inlet profile
    type        prescribedPipeInlet;
    // (optional, default exponential) type of profile used for approximation
    approximationType exponential;
    // pipe radius
    R	$Rpipe;
    // magnitude of flow velocity into the pipe
    flowSpeed	$flowVelocity;
    // (optional, defaults at origin) centrepoint of the pipe used to determine the radius of each face
    centrepoint	(0 0 0);
    // inlet as a function of radius
    deltaByR $deltaByR;
    // (optional, default 0) pressure gradient coefficient (see Polhausen profile literature for explanation)
    lambda 0.;
    // dummy value overwritten by the BC, used for initialisation only
    value		$internalField;
}

参考Foam::fixedValueFvPatchField

代码:

#ifndef prescribedPipeInletFvPatchVectorField_H
#define prescribedPipeInletFvPatchVectorField_H
//your code

#endif

作用:

养成良好的代码习惯,在所有的头文件中加上这种结构防止头文件被重复包含。

代码:

class prescribedPipeInletFvPatchVectorField
:
    public fixedValueFvPatchVectorField
{
private:
        
public:
        
}

作用:

以公有继承的方式继承现有的fixedValueFvPatchVectorField类。fixedValueFvPatchVectorField类在边界上指定固定的值,但是在新建的prescribedPipeInletFvPatchVectorField实现了在边界上指定不均匀的值。

代码:

private:
    // Private data
        // NOTE: these class fields are used to determine the inlet profile

    	// denotes the type of the profile used to perform the approximation
        // (optional, defaults to exponential)
    	word approximationType_;

    	// flow velocity magnitude
    	scalar flowSpeed_;

    	// bl thickness
    	scalar deltaByR_;

    	// centre of the pipe (optional, defaults to the origin)
    	vector centrepoint_;

    	// radius of the pipe
    	scalar R_;

    	// pressure gradient coefficient (optional, default to 0, not used by all approximations)
    	scalar lambda_;

作用:

私有变量

这些量决定了入口处的信息。

word approximationType_:近似的方式,可选,默认是指数型

scalar flowSpeed_:入口处的速度的大小

scalar deltaByR_:bl thickness(我也不知道啥意思)

vector centrepoint_:管道中心的位置(可选,默认值为原点)

scalar R_:管道的半径

scalar lambda_:压力梯度系数(可选,默认值为0,并不是在所有的近似中都使用)

代码:

以下均为public

TypeName("prescribedPipeInlet");

作用:

Runtime类型信息

定义边界条件的名称。通过RuntimeSelector使用。openfoam通过这个名称知道用户使用的边界类型。

代码:

// Constructors

    //- Construct from patch and internal field
    prescribedPipeInletFvPatchVectorField
    (
        const fvPatch&,
        const DimensionedField<vector, volMesh>&
    );

    //- Construct as copy setting internal field reference
    prescribedPipeInletFvPatchVectorField
    (
        const prescribedPipeInletFvPatchVectorField&,
        const DimensionedField<vector, volMesh>&
    );

作用:

类的构造器。此处为函数重载,两个同名函数有不同的输入。编译器会根据输入的类型决定调用哪一个函数。

  • 根据patch和internal field构造
  • 从internal field中拷贝构造

代码:

//- Construct and return a clone setting internal field reference
virtual tmp<fvPatchVectorField> clone
(
    const DimensionedField<vector, volMesh>& iF
) const
{
    return tmp<fvPatchVectorField>
    (
        new prescribedPipeInletFvPatchVectorField(*this, iF)
    );
}

作用:

构造并返回内部流场引用的克隆

代码:

//- Construct from patch, internal field and dictionary
 prescribedPipeInletFvPatchVectorField
(
    const fvPatch&,
    const DimensionedField<vector, volMesh>&,
    const dictionary&,
    const bool valueRequired=true
);

作用:

另一个构造器,从patch,内部场以及dictionary中构造

代码:

//- Construct by mapping given prescribedPipeInletFvPatchVectorField
//  onto a new patch
prescribedPipeInletFvPatchVectorField
(
    const prescribedPipeInletFvPatchVectorField&,
    const fvPatch&,
    const DimensionedField<vector, volMesh>&,
    const fvPatchFieldMapper&,
    const bool mappingRequired=true
);

作用:

通过映射prescribedPipeInletFvPatchVectorField到一个新的patch构造

代码:

//- Disallow copy without setting internal field reference
prescribedPipeInletFvPatchVectorField(const prescribedPipeInletFvPatchVectorField&) = delete;

作用:

在未设置内部场的时候不允许复制。

代码:

成员函数

// Evaluation functions

//- Update the coefficients associated with the patch field
virtual void updateCoeffs();

作用:

更新与patch相关的系数

代码:

//- Write
virtual void write(Ostream&) const;

作用:

IO,写数据

代码:

Foam::prescribedPipeInletFvPatchVectorField::prescribedPipeInletFvPatchVectorField
(
    const fvPatch& p,
    const DimensionedField<vector, volMesh>& iF
)
:
    // NOTE: call the default constructor to make sure everything gets initialised properly
    fixedValueFvPatchVectorField(p, iF),
    // NOTE: assign default values to the members using an initialiser list
    approximationType_("exponential"),
    flowSpeed_(0.),
	deltaByR_(0.),
	centrepoint_(vector::zero),
	R_(0.),
	lambda_(0.)
{}

作用:

调用默认的构造器以确保类中的数据会被初始化。把默认值赋给成员变量。

代码:

Foam::prescribedPipeInletFvPatchVectorField::prescribedPipeInletFvPatchVectorField
(
    const fvPatch& p,
    const DimensionedField<vector, volMesh>& iF,
    const dictionary& dict,
    const bool valueRequired
)
:
    // NOTE: this constructor reads all of the control parameters from the boundary
    // condition definition specified in the time folder U file, imported here
    // as a dictionary reference.
    fixedValueFvPatchVectorField(p, iF),
    approximationType_("exponential"),
    flowSpeed_(0.),
	deltaByR_(0.),
	centrepoint_(vector::zero),
	R_(0.),
	lambda_(0.)
{
    // NOTE: calls the = operator to assign the value to the faces held by this BC
    fvPatchVectorField::operator=(vectorField("value", dict, p.size()));

    // NOTE: looks up the necessary paramters
    approximationType_ = dict.lookupOrDefault<word>("approximationType","exponential");
    dict.lookup("flowSpeed") >> flowSpeed_;
	dict.lookup("deltaByR") >> deltaByR_;
	centrepoint_ = dict.lookupOrDefault<vector>("centrepoint",vector::zero);
	dict.lookup("R") >> R_;
	lambda_ = dict.lookupOrDefault<scalar>("lambda",0.);

    // NOTE: calls the .updateCoeffs() method to calculate the inlet profile in
    // accordance with the controls which have just been read.
	updateCoeffs();
}

作用:

这个构造函数在指定的文件夹下的U文件中读取边界条件的控制参数,然后输出到这里作为边界条件的参考值。

fvPatchVectorField::operator=(vectorField("value", dict, p.size())):调用=操作符给

lookup读取必要的数据

调用updateCoeffs()方法根据刚刚读到的参数计算入口的profile

代码:

Foam::prescribedPipeInletFvPatchVectorField::prescribedPipeInletFvPatchVectorField
(
    const prescribedPipeInletFvPatchVectorField& ptf,
    const fvPatch& p,
    const DimensionedField<vector, volMesh>& iF,
    const fvPatchFieldMapper& mapper,
    const bool mappingRequired
)
:
    // NOTE: this constructor, and the two subsequent ones, transfer data to the
    // instance being created from another one.
    fixedValueFvPatchVectorField(ptf, p, iF, mapper),
    approximationType_(ptf.approximationType_),
    flowSpeed_(ptf.flowSpeed_),
	deltaByR_(ptf.deltaByR_),
	centrepoint_(ptf.centrepoint_),
	R_(ptf.R_),
	lambda_(ptf.lambda_)
{}
Foam::prescribedPipeInletFvPatchVectorField::prescribedPipeInletFvPatchVectorField
(
    const prescribedPipeInletFvPatchVectorField& rifvpvf,
    const DimensionedField<vector, volMesh>& iF
)
:
    fixedValueFvPatchVectorField(rifvpvf, iF),
    approximationType_(rifvpvf.approximationType_),
    flowSpeed_(rifvpvf.flowSpeed_),
    deltaByR_(rifvpvf.deltaByR_),
    centrepoint_(rifvpvf.centrepoint_),
    R_(rifvpvf.R_),
    lambda_(rifvpvf.lambda_)
{}

作用:

这;两个构造器,把数据传输给另一个构造器创建的实例中。

代码:

以下为成员函数

void Foam::prescribedPipeInletFvPatchVectorField::updateCoeffs()
{
    if (updated())
    {
        return;
    }

	// assign inlet velocity normal to the patch
	// by convention, patch faces point outside of the domain
	vectorField Uin = (-1.)*(patch().Sf()/patch().magSf()) * flowSpeed_;

    // go over each face and add the BL profile for faces close to the wall
	forAll(patch().Cf(), faceI)
	{
        // non-dimensional distance away from the wall
		scalar yOverDelta ( (1.-mag(centrepoint_ - patch().Cf()[faceI])/R_)/deltaByR_ );

		if (approximationType_.compare("parabolic") == 0)
		{
			if (yOverDelta < 1.0)
				Uin[faceI] *= (2*yOverDelta-pow(yOverDelta,2.0));
		}
		else if (approximationType_.compare("Polhausen") == 0)
		{
			if (yOverDelta < 1.0)
				Uin[faceI] *= 1.-(1.+yOverDelta)*pow(1.-yOverDelta,3.) + lambda_/6.*yOverDelta*pow(1.-yOverDelta,3.);
		}
		else if (approximationType_.compare("exponential") == 0)
		{
			if (yOverDelta < 1.0)
				Uin[faceI] *= pow(yOverDelta,1./7.);
		}
		else
		{
			FatalErrorIn
		    (
		        "prescribedPipeInletFvPatchVectorField::updateCoeffs()"
		    )   << "Unknown boundary layer profile approximation type " << approximationType_ << nl << nl
		        << "Valid types are :" << nl
		        << tab << "parabolic" << nl
		        << tab << "Polhausen" << nl
		        << tab << "exponential" << nl
		        << exit(FatalError);
		}
	}



	// set the value_ of this patch to the newly computed flow speed
    this->operator==(Uin);

    // call the base class method to make sure all the other bits and pieces get updated
    fixedValueFvPatchVectorField::updateCoeffs();
}

作用:

这个是这个类中的主要的方法,在这个方法里面计算入口条件。

vectorField Uin = (-1.)*(patch().Sf()/patch().magSf()) * flowSpeed_:把总的流速分解为x,y,z三个方向的值,得到的向量与面垂直。patch().Sf()这个函数得到面的法向量。patch().magSf()得到面的法向量的模。两个相除,得到单位法向量。边界上的面的法向量指向外侧,所以需要乘以-1

代码:

void Foam::prescribedPipeInletFvPatchVectorField::write(Ostream& os) const
{
    fvPatchVectorField::write(os);
    os.writeKeyword("approximationType") << approximationType_ << token::END_STATEMENT << nl;
    os.writeKeyword("flowSpeed") << flowSpeed_ << token::END_STATEMENT << nl;
    os.writeKeyword("deltaByR") << deltaByR_ << token::END_STATEMENT << nl;
    os.writeKeyword("centrepoint") << centrepoint_ << token::END_STATEMENT << nl;
    os.writeKeyword("R") << R_ << token::END_STATEMENT << nl;
    os.writeKeyword("lambda") << lambda_ << token::END_STATEMENT << nl;
    writeEntry(os, "value", *this);
}

作用:

写文件

编译:

options文件:

EXE_INC = \
    -I$(LIB_SRC)/finiteVolume/lnInclude
    
LIB_LIBS = \
    -lfiniteVolume

files文件:

prescribedPipeInletFvPatchVectorField.C

LIB = $(FOAM_USER_LIBBIN)/libprescribedPipeInlet

说明:

边界条件属于生成一个C++的库,makes文件和files文件的书写与教程7中的类似。

使用:

在controlDict文件的末尾要按照以下方式包含进去这个库,不然运行的时候会找不到

// include the custom inlet library
libs ("libprescribedPipeInlet.so");

总体代码:

prescribedPipeInletFvPatchVectorField.H:

/*---------------------------------------------------------------------------*\
  =========                 |
  \\      /  F ield         | OpenFOAM: The Open Source CFD Toolbox
   \\    /   O peration     |
    \\  /    A nd           | Copyright (C) 2011-2013 OpenFOAM Foundation
     \\/     M anipulation  |
-------------------------------------------------------------------------------
License
    This file is part of OpenFOAM.

    OpenFOAM is free software: you can redistribute it and/or modify it
    under the terms of the GNU General Public License as published by
    the Free Software Foundation, either version 3 of the License, or
    (at your option) any later version.

    OpenFOAM is distributed in the hope that it will be useful, but WITHOUT
    ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
    FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
    for more details.

    You should have received a copy of the GNU General Public License
    along with OpenFOAM.  If not, see <http://www.gnu.org/licenses/>.

Class
    Foam::prescribedPipeInletFvPatchVectorField

Group
    grpInletBoundaryConditions grpWallBoundaryConditions

Description
    Prescribes an inlet profile for a circular pipe inlet patch. Flow direction is determined
    automatically from face normals, only velocity magnitude needs to be provided.

    \heading Patch usage

    \table
        Property    		| Description             								| Required  | Default value
        R           		| pipe radius 											| yes     	|
        flowSpeed   		| magnitude of flow velocity      						| yes       |
        deltaByR			| wall function thickness as a fraction of pipe radius  | yes 		|
        approximationType	| name of approximation profile							| no		| exponential
        centrePoint			| point on the centreline of the pipe					| no 		| (0 0 0)
        lambda				| pressure gradient coefficient 						| no 		| 0
    \endtable

    Example of the boundary condition specification:
    \verbatim
    inlet
	{
		// prescribes a parabolic inlet profile
	    type        prescribedPipeInlet;
	    // (optional, default exponential) type of profile used for approximation
	    approximationType exponential;
	    // pipe radius
	    R	$Rpipe;
	    // magnitude of flow velocity into the pipe
	    flowSpeed	$flowVelocity;
	    // (optional, defaults at origin) centrepoint of the pipe used to determine the radius of each face
	    centrepoint	(0 0 0);
	    // inlet BL thickness as a function of radius
	    deltaByR $deltaByR;
	    // (optional, default 0) pressure gradient coefficient (see Polhausen profile literature for explanation)
	    lambda 0.;
	    // dummy value overwritten by the BC, used for initialisation only
	    value		$internalField;
	}
	\endverbatim

SeeAlso
    Foam::fixedValueFvPatchField

SourceFiles
    prescribedPipeInletFvPatchVectorField.C

\*---------------------------------------------------------------------------*/

#ifndef prescribedPipeInletFvPatchVectorField_H
#define prescribedPipeInletFvPatchVectorField_H

#include "fvPatchFields.H"
#include "fixedValueFvPatchFields.H"
#include "Switch.H"
#include "addToRunTimeSelectionTable.H"
#include "volFields.H"

// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //

namespace Foam
{

/*---------------------------------------------------------------------------*\
               Class prescribedPipeInletFvPatchVectorField Declaration
\*---------------------------------------------------------------------------*/

// NOTE: the patch is derived from a fixedValue BC since it does prescribe
// a fixed value, although non-uniform across all of the faces, unlike the base
// class does.
class prescribedPipeInletFvPatchVectorField
:
    public fixedValueFvPatchVectorField
{
private:
    // Private data
        // NOTE: these class fields are used to determine the inlet profile

    	// denotes the type of the profile used to perform the approximation
        // (optional, defaults to exponential)
    	word approximationType_;

    	// flow velocity magnitude
    	scalar flowSpeed_;

    	// bl thickness
    	scalar deltaByR_;

    	// centre of the pipe (optional, defaults to the origin)
    	vector centrepoint_;

    	// radius of the pipe
    	scalar R_;

    	// pressure gradient coefficient (optional, default to 0, not used by all approximations)
    	scalar lambda_;

public:

    //- Runtime type information
    // NOTE: this gets used by the runtimeSelector. In other words, this is the
    // name under which OpenFOAM knows this BC.
    TypeName("prescribedPipeInlet");

    // Constructors

        //- Construct from patch and internal field
        prescribedPipeInletFvPatchVectorField
        (
            const fvPatch&,
            const DimensionedField<vector, volMesh>&
        );

        //- Construct as copy setting internal field reference
        prescribedPipeInletFvPatchVectorField
        (
            const prescribedPipeInletFvPatchVectorField&,
            const DimensionedField<vector, volMesh>&
        );

        //- Construct and return a clone setting internal field reference
        virtual tmp<fvPatchVectorField> clone
        (
            const DimensionedField<vector, volMesh>& iF
        ) const
        {
            return tmp<fvPatchVectorField>
            (
                new prescribedPipeInletFvPatchVectorField(*this, iF)
            );
        }

        //- Construct from patch, internal field and dictionary
        prescribedPipeInletFvPatchVectorField
        (
            const fvPatch&,
            const DimensionedField<vector, volMesh>&,
            const dictionary&,
            const bool valueRequired=true
        );

        //- Construct by mapping given prescribedPipeInletFvPatchVectorField
        //  onto a new patch
        prescribedPipeInletFvPatchVectorField
        (
            const prescribedPipeInletFvPatchVectorField&,
            const fvPatch&,
            const DimensionedField<vector, volMesh>&,
            const fvPatchFieldMapper&,
            const bool mappingRequired=true
        );

        //- Disallow copy without setting internal field reference
        prescribedPipeInletFvPatchVectorField(const prescribedPipeInletFvPatchVectorField&) = delete;

    // Member functions

        // Evaluation functions

            //- Update the coefficients associated with the patch field
            virtual void updateCoeffs();

        // I-O

            //- Write
            virtual void write(Ostream&) const;
};


// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //

} // End namespace Foam

// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //

#endif

// ************************************************************************* //

prescribedPipeInletFvPatchVectorField.H:

/*---------------------------------------------------------------------------* \
  =========                 |
  \\      /  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 "prescribedPipeInletFvPatchVectorField.H"

// * * * * * * * * * * * * * * * * Constructors  * * * * * * * * * * * * * * //

Foam::prescribedPipeInletFvPatchVectorField::prescribedPipeInletFvPatchVectorField
(
    const fvPatch& p,
    const DimensionedField<vector, volMesh>& iF
)
:
    // NOTE: call the default constructor to make sure everything gets initialised properly
    fixedValueFvPatchVectorField(p, iF),
    // NOTE: assign default values to the members using an initialiser list
    approximationType_("exponential"),
    flowSpeed_(0.),
	deltaByR_(0.),
	centrepoint_(vector::zero),
	R_(0.),
	lambda_(0.)
{}

Foam::prescribedPipeInletFvPatchVectorField::prescribedPipeInletFvPatchVectorField
(
    const fvPatch& p,
    const DimensionedField<vector, volMesh>& iF,
    const dictionary& dict,
    const bool valueRequired
)
:
    // NOTE: this constructor reads all of the control parameters from the boundary
    // condition definition specified in the time folder U file, imported here
    // as a dictionary reference.
    fixedValueFvPatchVectorField(p, iF),
    approximationType_("exponential"),
    flowSpeed_(0.),
	deltaByR_(0.),
	centrepoint_(vector::zero),
	R_(0.),
	lambda_(0.)
{
    // NOTE: calls the = operator to assign the value to the faces held by this BC
    fvPatchVectorField::operator=(vectorField("value", dict, p.size()));

    // NOTE: looks up the necessary paramters
    approximationType_ = dict.lookupOrDefault<word>("approximationType","exponential");
    dict.lookup("flowSpeed") >> flowSpeed_;
	dict.lookup("deltaByR") >> deltaByR_;
	centrepoint_ = dict.lookupOrDefault<vector>("centrepoint",vector::zero);
	dict.lookup("R") >> R_;
	lambda_ = dict.lookupOrDefault<scalar>("lambda",0.);

    // NOTE: calls the .updateCoeffs() method to calculate the inlet profile in
    // accordance with the controls which have just been read.
	updateCoeffs();
}

Foam::prescribedPipeInletFvPatchVectorField::prescribedPipeInletFvPatchVectorField
(
    const prescribedPipeInletFvPatchVectorField& ptf,
    const fvPatch& p,
    const DimensionedField<vector, volMesh>& iF,
    const fvPatchFieldMapper& mapper,
    const bool mappingRequired
)
:
    // NOTE: this constructor, and the two subsequent ones, transfer data to the
    // instance being created from another one.
    fixedValueFvPatchVectorField(ptf, p, iF, mapper),
    approximationType_(ptf.approximationType_),
    flowSpeed_(ptf.flowSpeed_),
	deltaByR_(ptf.deltaByR_),
	centrepoint_(ptf.centrepoint_),
	R_(ptf.R_),
	lambda_(ptf.lambda_)
{}

Foam::prescribedPipeInletFvPatchVectorField::prescribedPipeInletFvPatchVectorField
(
    const prescribedPipeInletFvPatchVectorField& rifvpvf,
    const DimensionedField<vector, volMesh>& iF
)
:
    fixedValueFvPatchVectorField(rifvpvf, iF),
    approximationType_(rifvpvf.approximationType_),
    flowSpeed_(rifvpvf.flowSpeed_),
    deltaByR_(rifvpvf.deltaByR_),
    centrepoint_(rifvpvf.centrepoint_),
    R_(rifvpvf.R_),
    lambda_(rifvpvf.lambda_)
{}

// * * * * * * * * * * * * * * * Member Functions  * * * * * * * * * * * * * //

// NOTE: this is the key method which implements the actual maths for calculating
// the inlet profiles.
void Foam::prescribedPipeInletFvPatchVectorField::updateCoeffs()
{
    if (updated())
    {
        return;
    }

	// assign inlet velocity normal to the patch
	// by convention, patch faces point outside of the domain
	vectorField Uin = (-1.)*(patch().Sf()/patch().magSf()) * flowSpeed_;

    // go over each face and add the BL profile for faces close to the wall
	forAll(patch().Cf(), faceI)
	{
        // non-dimensional distance away from the wall
		scalar yOverDelta ( (1.-mag(centrepoint_ - patch().Cf()[faceI])/R_)/deltaByR_ );

		if (approximationType_.compare("parabolic") == 0)
		{
			if (yOverDelta < 1.0)
				Uin[faceI] *= (2*yOverDelta-pow(yOverDelta,2.0));
		}
		else if (approximationType_.compare("Polhausen") == 0)
		{
			if (yOverDelta < 1.0)
				Uin[faceI] *= 1.-(1.+yOverDelta)*pow(1.-yOverDelta,3.) + lambda_/6.*yOverDelta*pow(1.-yOverDelta,3.);
		}
		else if (approximationType_.compare("exponential") == 0)
		{
			if (yOverDelta < 1.0)
				Uin[faceI] *= pow(yOverDelta,1./7.);
		}
		else
		{
			FatalErrorIn
		    (
		        "prescribedPipeInletFvPatchVectorField::updateCoeffs()"
		    )   << "Unknown boundary layer profile approximation type " << approximationType_ << nl << nl
		        << "Valid types are :" << nl
		        << tab << "parabolic" << nl
		        << tab << "Polhausen" << nl
		        << tab << "exponential" << nl
		        << exit(FatalError);
		}
	}



	// set the value_ of this patch to the newly computed flow speed
    this->operator==(Uin);

    // call the base class method to make sure all the other bits and pieces get updated
    fixedValueFvPatchVectorField::updateCoeffs();
}


void Foam::prescribedPipeInletFvPatchVectorField::write(Ostream& os) const
{
    fvPatchVectorField::write(os);
    os.writeKeyword("approximationType") << approximationType_ << token::END_STATEMENT << nl;
    os.writeKeyword("flowSpeed") << flowSpeed_ << token::END_STATEMENT << nl;
    os.writeKeyword("deltaByR") << deltaByR_ << token::END_STATEMENT << nl;
    os.writeKeyword("centrepoint") << centrepoint_ << token::END_STATEMENT << nl;
    os.writeKeyword("R") << R_ << token::END_STATEMENT << nl;
    os.writeKeyword("lambda") << lambda_ << token::END_STATEMENT << nl;
    writeEntry(os, "value", *this);
}


// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //

namespace Foam
{
    makePatchTypeField
    (
        fvPatchVectorField,
        prescribedPipeInletFvPatchVectorField
    );
}

// ************************************************************************* //

posted @ 2021-11-05 10:36  xubonan  阅读(223)  评论(0)    收藏  举报