/*---------------------------------------------------------------------------*\ ========= | \\ / F ield | OpenFOAM: The Open Source CFD Toolbox \\ / O peration | \\ / A nd | www.openfoam.com \\/ M anipulation | ------------------------------------------------------------------------------- Copyright (C) 2016-2017 Wikki Ltd Copyright (C) 2019 OpenCFD Ltd. ------------------------------------------------------------------------------- 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 "processorFaPatchField.H" #include "processorFaPatch.H" #include "transformField.H" // * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * // template Foam::processorFaPatchField::processorFaPatchField ( const faPatch& p, const DimensionedField& iF ) : coupledFaPatchField(p, iF), procPatch_(refCast(p)) {} template Foam::processorFaPatchField::processorFaPatchField ( const faPatch& p, const DimensionedField& iF, const Field& f ) : coupledFaPatchField(p, iF, f), procPatch_(refCast(p)) {} template Foam::processorFaPatchField::processorFaPatchField ( const processorFaPatchField& ptf, const faPatch& p, const DimensionedField& iF, const faPatchFieldMapper& mapper ) : coupledFaPatchField(ptf, p, iF, mapper), procPatch_(refCast(p)) { if (!isType(this->patch())) { FatalErrorInFunction << "\n patch type '" << p.type() << "' not constraint type '" << typeName << "'" << "\n for patch " << p.name() << " of field " << this->internalField().name() << " in file " << this->internalField().objectPath() << exit(FatalError); } } template Foam::processorFaPatchField::processorFaPatchField ( const faPatch& p, const DimensionedField& iF, const dictionary& dict ) : coupledFaPatchField(p, iF, dict), procPatch_(refCast(p, dict)) { if (!isType(p)) { FatalIOErrorInFunction(dict) << "\n patch type '" << p.type() << "' not constraint type '" << typeName << "'" << "\n for patch " << p.name() << " of field " << this->internalField().name() << " in file " << this->internalField().objectPath() << exit(FatalIOError); } } template Foam::processorFaPatchField::processorFaPatchField ( const processorFaPatchField& ptf ) : processorLduInterfaceField(), coupledFaPatchField(ptf), procPatch_(refCast(ptf.patch())) {} template Foam::processorFaPatchField::processorFaPatchField ( const processorFaPatchField& ptf, const DimensionedField& iF ) : coupledFaPatchField(ptf, iF), procPatch_(refCast(ptf.patch())) {} // * * * * * * * * * * * * * * * * * Destructor * * * * * * * * * * * * * * // template Foam::processorFaPatchField::~processorFaPatchField() {} // * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * // template Foam::tmp> Foam::processorFaPatchField::patchNeighbourField() const { return *this; } template void Foam::processorFaPatchField::initEvaluate ( const Pstream::commsTypes commsType ) { if (Pstream::parRun()) { procPatch_.send(commsType, this->patchInternalField()()); } } template void Foam::processorFaPatchField::evaluate ( const Pstream::commsTypes commsType ) { if (Pstream::parRun()) { procPatch_.receive(commsType, *this); if (doTransform()) { transform(*this, procPatch_.forwardT(), *this); } } } template Foam::tmp> Foam::processorFaPatchField::snGrad() const { return this->patch().deltaCoeffs()*(*this - this->patchInternalField()); } template void Foam::processorFaPatchField::initInterfaceMatrixUpdate ( solveScalarField& result, const bool add, const lduAddressing& lduAddr, const label patchId, const solveScalarField& psiInternal, const scalarField& coeffs, const direction, const Pstream::commsTypes commsType ) const { procPatch_.send ( commsType, this->patch().patchInternalField(psiInternal)() ); } template void Foam::processorFaPatchField::updateInterfaceMatrix ( solveScalarField& result, const bool add, const lduAddressing& lduAddr, const label patchId, const solveScalarField&, const scalarField& coeffs, const direction cmpt, const Pstream::commsTypes commsType ) const { solveScalarField pnf ( procPatch_.receive(commsType, this->size())() ); // Transform according to the transformation tensor transformCoupleField(pnf, cmpt); // Multiply the field by coefficients and add into the result const labelUList& edgeFaces = this->patch().edgeFaces(); if (add) { forAll(edgeFaces, elemI) { result[edgeFaces[elemI]] += coeffs[elemI]*pnf[elemI]; } } else { forAll(edgeFaces, elemI) { result[edgeFaces[elemI]] -= coeffs[elemI]*pnf[elemI]; } } } template void Foam::processorFaPatchField::initInterfaceMatrixUpdate ( Field& result, const bool add, const lduAddressing& lduAddr, const label patchId, const Field& psiInternal, const scalarField& coeffs, const Pstream::commsTypes commsType ) const { procPatch_.send ( commsType, this->patch().patchInternalField(psiInternal)() ); } template void Foam::processorFaPatchField::updateInterfaceMatrix ( Field& result, const bool add, const lduAddressing& lduAddr, const label patchId, const Field&, const scalarField& coeffs, const Pstream::commsTypes commsType ) const { Field pnf ( procPatch_.receive(commsType, this->size())() ); // Multiply the field by coefficients and add into the result const labelUList& edgeFaces = this->patch().edgeFaces(); if (add) { forAll(edgeFaces, elemI) { result[edgeFaces[elemI]] += coeffs[elemI]*pnf[elemI]; } } else { forAll(edgeFaces, elemI) { result[edgeFaces[elemI]] -= coeffs[elemI]*pnf[elemI]; } } } // ************************************************************************* //