diff --git a/src/finiteVolume/Make/files b/src/finiteVolume/Make/files index 1b9c242765..a8eaa08639 100644 --- a/src/finiteVolume/Make/files +++ b/src/finiteVolume/Make/files @@ -200,6 +200,7 @@ $(derivedFvPatchFields)/waveSurfacePressure/waveSurfacePressureFvPatchScalarFiel $(derivedFvPatchFields)/interstitialInletVelocity/interstitialInletVelocityFvPatchVectorField.C $(derivedFvPatchFields)/prghPressure/prghPressureFvPatchScalarField.C $(derivedFvPatchFields)/prghTotalPressure/prghTotalPressureFvPatchScalarField.C +$(derivedFvPatchFields)/fixedProfile/fixedProfileFvPatchFields.C fvsPatchFields = fields/fvsPatchFields $(fvsPatchFields)/fvsPatchField/fvsPatchFields.C diff --git a/src/finiteVolume/fields/fvPatchFields/derived/fixedProfile/fixedProfileFvPatchField.C b/src/finiteVolume/fields/fvPatchFields/derived/fixedProfile/fixedProfileFvPatchField.C new file mode 100644 index 0000000000..a9db1a7036 --- /dev/null +++ b/src/finiteVolume/fields/fvPatchFields/derived/fixedProfile/fixedProfileFvPatchField.C @@ -0,0 +1,167 @@ +/*---------------------------------------------------------------------------*\ + ========= | + \\ / F ield | OpenFOAM: The Open Source CFD Toolbox + \\ / O peration | + \\ / A nd | Copyright (C) 2015 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 . + +\*---------------------------------------------------------------------------*/ + +#include "fixedProfileFvPatchField.H" + +// * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * // + +template +Foam::fixedProfileFvPatchField::fixedProfileFvPatchField +( + const fvPatch& p, + const DimensionedField& iF +) +: + fixedValueFvPatchField(p, iF), + profile_(), + dir_(pTraits::zero), + origin_(0) +{} + + +template +Foam::fixedProfileFvPatchField::fixedProfileFvPatchField +( + const fvPatch& p, + const DimensionedField& iF, + const Field& fld +) +: + fixedValueFvPatchField(p, iF, fld), + profile_(), + dir_(pTraits::zero), + origin_(0) +{} + + +template +Foam::fixedProfileFvPatchField::fixedProfileFvPatchField +( + const fvPatch& p, + const DimensionedField& iF, + const dictionary& dict +) +: + fixedValueFvPatchField(p, iF), + profile_(DataEntry::New("profile", dict)), + dir_(dict.lookup("direction")), + origin_(readScalar(dict.lookup("origin"))) +{ + if (mag(dir_) < SMALL) + { + FatalErrorInFunction + << "magnitude Direction must be greater than zero" + << abort(FatalError); + } + + // Ensure direction vector is normalized + dir_ /= mag(dir_); + + // Evaluate profile + this->evaluate(); +} + + +template +Foam::fixedProfileFvPatchField::fixedProfileFvPatchField +( + const fixedProfileFvPatchField& ptf, + const fvPatch& p, + const DimensionedField& iF, + const fvPatchFieldMapper& mapper +) +: + fixedValueFvPatchField(p, iF), // Don't map + profile_(ptf.profile_, false), + dir_(ptf.dir_), + origin_(ptf.origin_) +{ + // Evaluate profile since value not mapped + this->evaluate(); +} + + +template +Foam::fixedProfileFvPatchField::fixedProfileFvPatchField +( + const fixedProfileFvPatchField& ptf +) +: + fixedValueFvPatchField(ptf), + profile_(ptf.profile_, false), + dir_(ptf.dir_), + origin_(ptf.origin_) +{} + + +template +Foam::fixedProfileFvPatchField::fixedProfileFvPatchField +( + const fixedProfileFvPatchField& ptf, + const DimensionedField& iF +) +: + fixedValueFvPatchField(ptf, iF), + profile_(ptf.profile_, false), + dir_(ptf.dir_), + origin_(ptf.origin_) +{ + // Evaluate the profile if defined + if (ptf.profile_.valid()) + { + this->evaluate(); + } +} + + +// * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * // + +template +void Foam::fixedProfileFvPatchField::updateCoeffs() +{ + if (this->updated()) + { + return; + } + + const scalarField dirCmpt((dir_ & this->patch().Cf()) - origin_); + fvPatchField::operator==(profile_->value(dirCmpt)); + + fixedValueFvPatchField::updateCoeffs(); +} + + +template +void Foam::fixedProfileFvPatchField::write(Ostream& os) const +{ + fvPatchField::write(os); + profile_->writeData(os); + os.writeKeyword("direction") << dir_ << token::END_STATEMENT << nl; + os.writeKeyword("origin") << origin_ << token::END_STATEMENT << nl; + this->writeEntry("value", os); +} + + +// ************************************************************************* // diff --git a/src/finiteVolume/fields/fvPatchFields/derived/fixedProfile/fixedProfileFvPatchField.H b/src/finiteVolume/fields/fvPatchFields/derived/fixedProfile/fixedProfileFvPatchField.H new file mode 100644 index 0000000000..d644a8e73c --- /dev/null +++ b/src/finiteVolume/fields/fvPatchFields/derived/fixedProfile/fixedProfileFvPatchField.H @@ -0,0 +1,230 @@ +/*---------------------------------------------------------------------------*\ + ========= | + \\ / F ield | OpenFOAM: The Open Source CFD Toolbox + \\ / O peration | + \\ / A nd | Copyright (C) 2015 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 . + +Class + Foam::fixedProfileFvPatchField + +Group + grpGenericBoundaryConditions + +Description + This boundary condition provides a fixed value profile condition. + + \heading Patch usage + + \table + Property | Description | Required | Default value + profile | Profile DataEntry | yes | + direction | Profile direction | yes | + origin | Profile origin | yes | + \endtable + + Example of the boundary condition specification: + \verbatim + myPatch + { + type fixedProfile; + profile csvFile; + + profileCoeffs + { + nHeaderLine 0; // Number of header lines + refColumn 0; // Reference column index + componentColumns (1 2 3); // Component column indices + separator ","; // Optional (defaults to ",") + mergeSeparators no; // Merge multiple separators + fileName "Uprofile.csv"; // name of csv data file + outOfBounds clamp; // Optional out-of-bounds handling + interpolationScheme linear; // Optional interpolation scheme + } + direction (0 1 0); + origin 0; + } + \endverbatim + + Example setting a parabolic inlet profile for the PitzDaily case: + \verbatim + inlet + { + type fixedProfile; + + profile polynomial + ( + ((1 0 0) (0 0 0)) + ((-6200 0 0) (2 0 0)) + ); + direction (0 1 0); + origin 0.0127; + } + \endverbatim + +Note + The profile entry is a DataEntry type. The example above gives the + usage for supplying csv file. + +SeeAlso + Foam::fixedValueFvPatchField + Foam::DataEntry + Foam::timeVaryingMappedFixedValueFvPatchField + +SourceFiles + fixedProfileFvPatchField.C + +\*---------------------------------------------------------------------------*/ + +#ifndef fixedProfileFvPatchField_H +#define fixedProfileFvPatchField_H + +#include "fixedValueFvPatchFields.H" +#include "DataEntry.H" + +// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // + +namespace Foam +{ + +/*---------------------------------------------------------------------------*\ + Class fixedProfileFvPatchField Declaration +\*---------------------------------------------------------------------------*/ + +template +class fixedProfileFvPatchField +: + public fixedValueFvPatchField +{ + // Private data + + //- Profile data + autoPtr > profile_; + + //- Profile direction + vector dir_; + + //- Profile origin + scalar origin_; + + +public: + + //- Runtime type information + TypeName("fixedProfile"); + + + // Constructors + + //- Construct from patch and internal field + fixedProfileFvPatchField + ( + const fvPatch&, + const DimensionedField& + ); + + //- Construct from patch and internal field and patch field + fixedProfileFvPatchField + ( + const fvPatch&, + const DimensionedField&, + const Field& fld + ); + + //- Construct from patch, internal field and dictionary + fixedProfileFvPatchField + ( + const fvPatch&, + const DimensionedField&, + const dictionary& + ); + + //- Construct by mapping given fixedProfileFvPatchField + // onto a new patch + fixedProfileFvPatchField + ( + const fixedProfileFvPatchField&, + const fvPatch&, + const DimensionedField&, + const fvPatchFieldMapper& + ); + + //- Construct as copy + fixedProfileFvPatchField + ( + const fixedProfileFvPatchField& + ); + + //- Construct and return a clone + virtual tmp > clone() const + { + return tmp > + ( + new fixedProfileFvPatchField(*this) + ); + } + + //- Construct as copy setting internal field reference + fixedProfileFvPatchField + ( + const fixedProfileFvPatchField&, + const DimensionedField& + ); + + //- Construct and return a clone setting internal field reference + virtual tmp > clone + ( + const DimensionedField& iF + ) const + { + return tmp > + ( + new fixedProfileFvPatchField(*this, iF) + ); + } + + + // Member functions + + // Evaluation functions + + //- Update the coefficients associated with the patch field + virtual void updateCoeffs(); + + + //- Write + virtual void write(Ostream&) const; +}; + + +// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // + +} // End namespace Foam + +// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // + +#ifdef NoRepository +# include "fixedProfileFvPatchField.C" +#endif + +// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // + +#endif + +// ************************************************************************* // diff --git a/src/finiteVolume/fields/fvPatchFields/derived/fixedProfile/fixedProfileFvPatchFields.C b/src/finiteVolume/fields/fvPatchFields/derived/fixedProfile/fixedProfileFvPatchFields.C new file mode 100644 index 0000000000..155f369672 --- /dev/null +++ b/src/finiteVolume/fields/fvPatchFields/derived/fixedProfile/fixedProfileFvPatchFields.C @@ -0,0 +1,43 @@ +/*---------------------------------------------------------------------------*\ + ========= | + \\ / F ield | OpenFOAM: The Open Source CFD Toolbox + \\ / O peration | + \\ / A nd | Copyright (C) 2015 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 . + +\*---------------------------------------------------------------------------*/ + +#include "fixedProfileFvPatchFields.H" +#include "addToRunTimeSelectionTable.H" +#include "volFields.H" + +// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // + +namespace Foam +{ + +// * * * * * * * * * * * * * * Static Data Members * * * * * * * * * * * * * // + +makePatchFields(fixedProfile); + +// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // + +} // End namespace Foam + +// ************************************************************************* // diff --git a/src/finiteVolume/fields/fvPatchFields/derived/fixedProfile/fixedProfileFvPatchFields.H b/src/finiteVolume/fields/fvPatchFields/derived/fixedProfile/fixedProfileFvPatchFields.H new file mode 100644 index 0000000000..0896b8c760 --- /dev/null +++ b/src/finiteVolume/fields/fvPatchFields/derived/fixedProfile/fixedProfileFvPatchFields.H @@ -0,0 +1,49 @@ +/*---------------------------------------------------------------------------*\ + ========= | + \\ / F ield | OpenFOAM: The Open Source CFD Toolbox + \\ / O peration | + \\ / A nd | Copyright (C) 2015 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 . + +\*---------------------------------------------------------------------------*/ + +#ifndef fixedProfileFvPatchFields_H +#define fixedProfileFvPatchFields_H + +#include "fixedProfileFvPatchField.H" +#include "fieldTypes.H" + +// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // + +namespace Foam +{ + +// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // + +makePatchTypeFieldTypedefs(fixedProfile); + +// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // + +} // End namespace Foam + +// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // + +#endif + +// ************************************************************************* // diff --git a/src/finiteVolume/fields/fvPatchFields/derived/fixedProfile/fixedProfileFvPatchFieldsFwd.H b/src/finiteVolume/fields/fvPatchFields/derived/fixedProfile/fixedProfileFvPatchFieldsFwd.H new file mode 100644 index 0000000000..e324c24dc9 --- /dev/null +++ b/src/finiteVolume/fields/fvPatchFields/derived/fixedProfile/fixedProfileFvPatchFieldsFwd.H @@ -0,0 +1,50 @@ +/*---------------------------------------------------------------------------*\ + ========= | + \\ / F ield | OpenFOAM: The Open Source CFD Toolbox + \\ / O peration | + \\ / A nd | Copyright (C) 2015 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 . + +\*---------------------------------------------------------------------------*/ + +#ifndef fixedProfileFvPatchFieldsFwd_H +#define fixedProfileFvPatchFieldsFwd_H + +#include "fieldTypes.H" + +// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // + +namespace Foam +{ + +// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // + +template class fixedProfileFvPatchField; + +makePatchTypeFieldTypedefs(fixedValue); + +// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // + +} // End namespace Foam + +// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // + +#endif + +// ************************************************************************* //