/*---------------------------------------------------------------------------*\ ========= | \\ / F ield | OpenFOAM: The Open Source CFD Toolbox \\ / O peration | \\ / A nd | www.openfoam.com \\/ M anipulation | ------------------------------------------------------------------------------- Copyright (C) 2022-2025 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 "transformField.H" // * * * * * * * * * * * * Protected Member Functions * * * * * * * * * * * // template Foam::tmp> Foam::coordSetWriter::adjustFieldTemplate ( const word& fieldName, const tmp>& tfield ) const { if (verbose_) { Info<< "Writing field " << fieldName; } tmp> tadjusted; // Output scaling for the variable, but not for integer types // which are typically ids etc. if constexpr (std::is_integral_v) { return tfield; } else { scalar value; // Remove *uniform* reference level if ( fieldLevel_.readIfPresent(fieldName, value, keyType::REGEX) && !equal(value, 0) ) { // Could also detect brackets (...) and read accordingly // or automatically scale by 1/sqrt(nComponents) instead ... Type refLevel; if constexpr (is_vectorspace_v) { refLevel.fill(value); } else { refLevel = value; } if (verbose_) { Info<< " [level " << refLevel << ']'; } if (!tadjusted) { // Steal or clone tadjusted.reset(tfield.ptr()); } // Remove offset level tadjusted.ref() -= refLevel; } // Apply scaling if ( fieldScale_.readIfPresent(fieldName, value, keyType::REGEX) && !equal(value, 1) ) { if (verbose_) { Info<< " [scaling " << value << ']'; } if (!tadjusted) { // Steal or clone tadjusted.reset(tfield.ptr()); } // Apply scaling tadjusted.ref() *= value; } } // Rotate fields (vector and non-spherical tensors) if constexpr (is_rotational_vectorspace_v) { if (geometryTransform_.good() && !geometryTransform_.R().is_identity()) { if (!tadjusted) { // Steal or clone tadjusted.reset(tfield.ptr()); } Foam::transform ( tadjusted.ref(), geometryTransform_.R(), tadjusted() ); } } return (tadjusted ? tadjusted : tfield); } template Foam::UPtrList> Foam::coordSetWriter::repackageFields(const Field& field) { UPtrList> fieldPtrs(1); fieldPtrs.set(0, &field); return fieldPtrs; } template Foam::UPtrList> Foam::coordSetWriter::repackageFields(const UList>& fieldValues) { UPtrList> fieldPtrs(fieldValues.size()); forAll(fieldValues, i) { fieldPtrs.set(i, &(fieldValues[i])); } return fieldPtrs; } template void Foam::coordSetWriter::writeTable ( Ostream& os, const coordSet& coords, const UList& values, const char* sep ) { forAll(coords, pointi) { // Output coordinate (point or scalar) with separator if (coords.hasVectorAxis()) { const vector& p = coords.vectorCoord(pointi); os << p.x() << sep << p.y() << sep << p.z(); } else { os << coords.scalarCoord(pointi); } // Output component values with separator const auto& val = values[pointi]; for (direction d=0; d < pTraits::nComponents; ++d) { os << sep << component(val, d); } os << nl; } } // ************************************************************************* //