diff --git a/src/immersedBoundary/immersedBoundary/immersedBoundaryFvPatchFields/basic/zeroGradientIbFvPatchField/zeroGradientIbFvPatchField.C b/src/immersedBoundary/immersedBoundary/immersedBoundaryFvPatchFields/basic/zeroGradientIbFvPatchField/zeroGradientIbFvPatchField.C new file mode 100644 index 000000000..10a57cf0f --- /dev/null +++ b/src/immersedBoundary/immersedBoundary/immersedBoundaryFvPatchFields/basic/zeroGradientIbFvPatchField/zeroGradientIbFvPatchField.C @@ -0,0 +1,262 @@ +/*---------------------------------------------------------------------------*\ + ========= | + \\ / F ield | foam-extend: Open Source CFD + \\ / O peration | Version: 4.1 + \\ / A nd | Web: http://www.foam-extend.org + \\/ M anipulation | For copyright notice see file Copyright +------------------------------------------------------------------------------- +License + This file is part of foam-extend. + + foam-extend 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. + + foam-extend 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 foam-extend. If not, see . + +\*---------------------------------------------------------------------------*/ + +#include "zeroGradientIbFvPatchField.H" +#include "surfaceWriter.H" + +// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // + +namespace Foam +{ + +// * * * * * * * * * * * * * Private Member Functions * * * * * * * * * * * // + +template +void zeroGradientIbFvPatchField::updateIbValues() +{ + // // Interpolate the values from tri surface using nearest triangle + // const labelList& nt = this->ibPatch().ibPolyPatch().nearestTri(); + + Field::operator=(this->patchInternalField()); +} + + +// * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * // + +template +zeroGradientIbFvPatchField::zeroGradientIbFvPatchField +( + const fvPatch& p, + const DimensionedField& iF +) +: + zeroGradientFvPatchField(p, iF), + immersedBoundaryFieldBase(p, false, pTraits::zero) +{} + + +template +zeroGradientIbFvPatchField::zeroGradientIbFvPatchField +( + const fvPatch& p, + const DimensionedField& iF, + const dictionary& dict +) +: + zeroGradientFvPatchField(p, iF), + immersedBoundaryFieldBase + ( + p, + Switch(dict.lookup("setDeadValue")), + pTraits(dict.lookup("deadValue")) + ) +{ + // Since patch does not read a dictionary, the patch type needs to be read + // manually. HJ, 6/Sep/2018 + this->readPatchType(dict); + + if (!isType(p)) + { + FatalIOErrorInFunction(dict) + << "\n patch type '" << p.type() + << "' not constraint type '" << typeName << "'" + << "\n for patch " << p.name() + << " of field " << this->dimensionedInternalField().name() + << " in file " << this->dimensionedInternalField().objectPath() + << exit(FatalIOError); + } + + zeroGradientFvPatchField::evaluate(); +} + + +template +zeroGradientIbFvPatchField::zeroGradientIbFvPatchField +( + const zeroGradientIbFvPatchField& ptf, + const fvPatch& p, + const DimensionedField& iF, + const fvPatchFieldMapper& mapper +) +: + zeroGradientFvPatchField(p, iF), + immersedBoundaryFieldBase + ( + p, + ptf.setDeadValue(), + ptf.deadValue() + ) +{ + // Note: NO MAPPING. Fields are created on the immersed boundary + // HJ, 12/Apr/2012 + if (!isType(p)) + { + FatalErrorInFunction + << "\n patch type '" << p.type() + << "' not constraint type '" << typeName << "'" + << "\n for patch " << p.name() + << " of field " << this->dimensionedInternalField().name() + << " in file " << this->dimensionedInternalField().objectPath() + << exit(FatalIOError); + } + + this->setPatchType(ptf); + + // On creation of the mapped field, the internal field is dummy and + // cannot be used. Initialise the value to avoid errors + // HJ, 1/Dec/2017 + Field::operator=(pTraits::zero); +} + + +template +zeroGradientIbFvPatchField::zeroGradientIbFvPatchField +( + const zeroGradientIbFvPatchField& ptf +) +: + zeroGradientFvPatchField(ptf), + immersedBoundaryFieldBase + ( + ptf.ibPatch(), + ptf.setDeadValue(), + ptf.deadValue() + ) +{ + this->setPatchType(ptf); +} + + +template +zeroGradientIbFvPatchField::zeroGradientIbFvPatchField +( + const zeroGradientIbFvPatchField& ptf, + const DimensionedField& iF +) +: + zeroGradientFvPatchField(ptf, iF), + immersedBoundaryFieldBase + ( + ptf.ibPatch(), + ptf.setDeadValue(), + ptf.deadValue() + ) +{ + this->setPatchType(ptf); +} + + +// * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * // + +// template +// void zeroGradientIbFvPatchField::autoMap +// ( +// const fvPatchFieldMapper& m +// ) +// { +// // Base fields do not map: re-interpolate them from tri data +// this->updateIbValues(); +// } + + +// template +// void zeroGradientIbFvPatchField::rmap +// ( +// const fvPatchField& ptf, +// const labelList& +// ) +// { +// // Base fields do not rmap: re-interpolate them from tri data + +// const zeroGradientIbFvPatchField& mptf = +// refCast >(ptf); + +// // Set rmap tri data +// triValue_ = mptf.triValue_; + +// this->updateIbValues(); +// } + + +template +void zeroGradientIbFvPatchField::updateOnMotion() +{ + if (this->size() != this->ibPatch().size()) + { + this->updateIbValues(); + } +} + + +template +void zeroGradientIbFvPatchField::evaluate +( + const Pstream::commsTypes +) +{ + this->updateIbValues(); + + // Get non-constant reference to internal field + Field& intField = const_cast&>(this->internalField()); + + // Set dead value + this->setDeadValues(intField); + + // Evaluate fixed value condition + zeroGradientFvPatchField::evaluate(); +} + + +template +void Foam::zeroGradientIbFvPatchField::manipulateMatrix +( + fvMatrix& matrix +) +{ + this->setDeadValues(matrix); +} + + +template +void zeroGradientIbFvPatchField::write(Ostream& os) const +{ + // Resolve post-processing issues. HJ, 1/Dec/2017 + zeroGradientFvPatchField::write(os); + // triValue_.writeEntry("triValue", os); + immersedBoundaryFieldBase::writeDeadData(os); + + // The value entry needs to be written with zero size + Field::null().writeEntry("value", os); + // this->writeEntry("value", os); + + this->writeField(*this); +} + + +// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // + +} // End namespace Foam + +// ************************************************************************* // diff --git a/src/immersedBoundary/immersedBoundary/immersedBoundaryFvPatchFields/basic/zeroGradientIbFvPatchField/zeroGradientIbFvPatchField.H b/src/immersedBoundary/immersedBoundary/immersedBoundaryFvPatchFields/basic/zeroGradientIbFvPatchField/zeroGradientIbFvPatchField.H new file mode 100644 index 000000000..72975a1a6 --- /dev/null +++ b/src/immersedBoundary/immersedBoundary/immersedBoundaryFvPatchFields/basic/zeroGradientIbFvPatchField/zeroGradientIbFvPatchField.H @@ -0,0 +1,192 @@ +/*---------------------------------------------------------------------------*\ + ========= | + \\ / F ield | foam-extend: Open Source CFD + \\ / O peration | Version: 4.1 + \\ / A nd | Web: http://www.foam-extend.org + \\/ M anipulation | For copyright notice see file Copyright +------------------------------------------------------------------------------- +License + This file is part of foam-extend. + + foam-extend 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. + + foam-extend 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 foam-extend. If not, see . + +Class + Foam::zeroGradientIbFvPatchField + +Description + Foam::zeroGradientIbFvPatchField + +Author + Hrvoje Jasak + +SourceFiles + zeroGradientIbFvPatchField.C + +\*---------------------------------------------------------------------------*/ + +#ifndef zeroGradientIbFvPatchField_H +#define zeroGradientIbFvPatchField_H + +#include "zeroGradientFvPatchFields.H" +#include "immersedBoundaryFieldBase.H" + +// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // + +namespace Foam +{ + +/*---------------------------------------------------------------------------*\ + Class zeroGradientIbFvPatchField Declaration +\*---------------------------------------------------------------------------*/ + +template +class zeroGradientIbFvPatchField +: + public zeroGradientFvPatchField, + public immersedBoundaryFieldBase +{ + // Private Member Functions + + //- Update IB value and gradient + void updateIbValues(); + + +public: + + //- Runtime type information + TypeName("zeroGradientIb"); + + + // Constructors + + //- Construct from patch and internal field + zeroGradientIbFvPatchField + ( + const fvPatch&, + const DimensionedField& + ); + + //- Construct from patch, internal field and dictionary + zeroGradientIbFvPatchField + ( + const fvPatch&, + const DimensionedField&, + const dictionary& + ); + + //- Construct by mapping given zeroGradientIbFvPatchField + // onto a new patch + zeroGradientIbFvPatchField + ( + const zeroGradientIbFvPatchField&, + const fvPatch&, + const DimensionedField&, + const fvPatchFieldMapper& + ); + + //- Construct as copy + zeroGradientIbFvPatchField + ( + const zeroGradientIbFvPatchField& + ); + + //- Construct and return a clone + virtual tmp > clone() const + { + return tmp > + ( + new zeroGradientIbFvPatchField(*this) + ); + } + + //- Construct as copy setting internal field reference + zeroGradientIbFvPatchField + ( + const zeroGradientIbFvPatchField&, + const DimensionedField& + ); + + //- Construct and return a clone setting internal field reference + virtual tmp > clone + ( + const DimensionedField& iF + ) const + { + return tmp > + ( + new zeroGradientIbFvPatchField(*this, iF) + ); + } + + + //- Destructor + virtual ~zeroGradientIbFvPatchField() + {} + + + // Member functions + + // Mapping functions + + // //- Map (and resize as needed) from self given a mapping object + // virtual void autoMap + // ( + // const fvPatchFieldMapper& + // ); + + // //- Reverse map the given fvPatchField onto this fvPatchField + // virtual void rmap + // ( + // const fvPatchField&, + // const labelList& + // ); + + //- Update on mesh motion + virtual void updateOnMotion(); + + + // Evaluation functions + + //- Evaluate the patch field + virtual void evaluate + ( + const Pstream::commsTypes commsType = Pstream::blocking + ); + + //- Manipulate a matrix + virtual void manipulateMatrix(fvMatrix& matrix); + + + // I-O + + //- Write + virtual void write(Ostream&) const; +}; + + +// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // + +} // End namespace Foam + +// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // + +#ifdef NoRepository +# include "zeroGradientIbFvPatchField.C" +#endif + +// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // + +#endif + +// ************************************************************************* // diff --git a/src/immersedBoundary/immersedBoundary/immersedBoundaryFvPatchFields/basic/zeroGradientIbFvPatchField/zeroGradientIbFvPatchFields.C b/src/immersedBoundary/immersedBoundary/immersedBoundaryFvPatchFields/basic/zeroGradientIbFvPatchField/zeroGradientIbFvPatchFields.C new file mode 100644 index 000000000..d2a139029 --- /dev/null +++ b/src/immersedBoundary/immersedBoundary/immersedBoundaryFvPatchFields/basic/zeroGradientIbFvPatchField/zeroGradientIbFvPatchFields.C @@ -0,0 +1,44 @@ +/*---------------------------------------------------------------------------*\ + ========= | + \\ / F ield | foam-extend: Open Source CFD + \\ / O peration | Version: 4.1 + \\ / A nd | Web: http://www.foam-extend.org + \\/ M anipulation | For copyright notice see file Copyright +------------------------------------------------------------------------------- +License + This file is part of foam-extend. + + foam-extend 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. + + foam-extend 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 foam-extend. If not, see . + +\*---------------------------------------------------------------------------*/ + +#include "volFields.H" +#include "fvPatchFields.H" +#include "zeroGradientIbFvPatchFields.H" +#include "addToRunTimeSelectionTable.H" + +// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // + +namespace Foam +{ + +// * * * * * * * * * * * * * * Static Data Members * * * * * * * * * * * * * // + +makePatchFields(zeroGradientIb); + +// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // + +} // End namespace Foam + +// ************************************************************************* // diff --git a/src/immersedBoundary/immersedBoundary/immersedBoundaryFvPatchFields/basic/zeroGradientIbFvPatchField/zeroGradientIbFvPatchFields.H b/src/immersedBoundary/immersedBoundary/immersedBoundaryFvPatchFields/basic/zeroGradientIbFvPatchField/zeroGradientIbFvPatchFields.H new file mode 100644 index 000000000..20a169bd7 --- /dev/null +++ b/src/immersedBoundary/immersedBoundary/immersedBoundaryFvPatchFields/basic/zeroGradientIbFvPatchField/zeroGradientIbFvPatchFields.H @@ -0,0 +1,49 @@ +/*---------------------------------------------------------------------------*\ + ========= | + \\ / F ield | foam-extend: Open Source CFD + \\ / O peration | Version: 4.1 + \\ / A nd | Web: http://www.foam-extend.org + \\/ M anipulation | For copyright notice see file Copyright +------------------------------------------------------------------------------- +License + This file is part of foam-extend. + + foam-extend 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. + + foam-extend 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 foam-extend. If not, see . + +\*---------------------------------------------------------------------------*/ + +#ifndef zeroGradientIbFvPatchFields_H +#define zeroGradientIbFvPatchFields_H + +#include "zeroGradientIbFvPatchField.H" +#include "fieldTypes.H" + +// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // + +namespace Foam +{ + +// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // + +makePatchTypeFieldTypedefs(zeroGradientIb) + +// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // + +} // End namespace Foam + +// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // + +#endif + +// ************************************************************************* // diff --git a/src/immersedBoundary/immersedBoundary/immersedBoundaryFvPatchFields/basic/zeroGradientIbFvPatchField/zeroGradientIbFvPatchFieldsFwd.H b/src/immersedBoundary/immersedBoundary/immersedBoundaryFvPatchFields/basic/zeroGradientIbFvPatchField/zeroGradientIbFvPatchFieldsFwd.H new file mode 100644 index 000000000..767a6db0a --- /dev/null +++ b/src/immersedBoundary/immersedBoundary/immersedBoundaryFvPatchFields/basic/zeroGradientIbFvPatchField/zeroGradientIbFvPatchFieldsFwd.H @@ -0,0 +1,51 @@ +/*---------------------------------------------------------------------------*\ + ========= | + \\ / F ield | foam-extend: Open Source CFD + \\ / O peration | Version: 4.1 + \\ / A nd | Web: http://www.foam-extend.org + \\/ M anipulation | For copyright notice see file Copyright +------------------------------------------------------------------------------- +License + This file is part of foam-extend. + + foam-extend 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. + + foam-extend 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 foam-extend. If not, see . + +\*---------------------------------------------------------------------------*/ + +#ifndef zeroGradientIbFvPatchFieldsFwd_H +#define zeroGradientIbFvPatchFieldsFwd_H + +#include "fvPatchFieldsFwd.H" +#include "fieldTypes.H" + +// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // + +namespace Foam +{ + +// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // + +template class zeroGradientIbFvPatchField; + +makePatchTypeFieldTypedefs(zeroGradientIb) + +// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // + +} // End namespace Foam + +// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // + +#endif + +// ************************************************************************* //