diff --git a/src/lagrangian/basic/InteractionLists/globalIndexAndTransform/vectorTensorTransform/vectorTensorTransform.C b/src/lagrangian/basic/InteractionLists/globalIndexAndTransform/vectorTensorTransform/vectorTensorTransform.C new file mode 100644 index 0000000000..1b0a830c62 --- /dev/null +++ b/src/lagrangian/basic/InteractionLists/globalIndexAndTransform/vectorTensorTransform/vectorTensorTransform.C @@ -0,0 +1,98 @@ +/*---------------------------------------------------------------------------*\ + ========= | + \\ / F ield | OpenFOAM: The Open Source CFD Toolbox + \\ / O peration | + \\ / A nd | Copyright (C) 1991-2009 OpenCFD Ltd. + \\/ 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 "vectorTensorTransform.H" +#include "IOstreams.H" +#include "OStringStream.H" + +// * * * * * * * * * * * * * * Static Data Members * * * * * * * * * * * * * // + +const char* const Foam::vectorTensorTransform::typeName = +"vectorTensorTransform"; + +const Foam::vectorTensorTransform Foam::vectorTensorTransform::zero +( + vector::zero, + tensor::zero +); + + +const Foam::vectorTensorTransform Foam::vectorTensorTransform::I +( + vector::zero, + sphericalTensor::I +); + + +// * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * // + +Foam::vectorTensorTransform::vectorTensorTransform(Istream& is) +{ + is >> *this; +} + + +// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // + +Foam::word Foam::name(const vectorTensorTransform& s) +{ + OStringStream buf; + + buf << '(' << s.t() << ',' << s.R() << ')'; + + return buf.str(); +} + + +// * * * * * * * * * * * * * * * IOstream Operators * * * * * * * * * * * * // + +Foam::Istream& Foam::operator>>(Istream& is, vectorTensorTransform& tr) +{ + // Read beginning of vectorTensorTransform + is.readBegin("vectorTensorTransform"); + + is >> tr.t() >> tr.R(); + + // Read end of vectorTensorTransform + is.readEnd("vectorTensorTransform"); + + // Check state of Istream + is.check("operator>>(Istream&, vectorTensorTransform&)"); + + return is; +} + + +Foam::Ostream& Foam::operator<<(Ostream& os, const vectorTensorTransform& tr) +{ + os << token::BEGIN_LIST + << tr.t() << token::SPACE << tr.R() + << token::END_LIST; + + return os; +} + + +// ************************************************************************* // diff --git a/src/lagrangian/basic/InteractionLists/globalIndexAndTransform/vectorTensorTransform/vectorTensorTransform.H b/src/lagrangian/basic/InteractionLists/globalIndexAndTransform/vectorTensorTransform/vectorTensorTransform.H new file mode 100644 index 0000000000..bcd0e766b7 --- /dev/null +++ b/src/lagrangian/basic/InteractionLists/globalIndexAndTransform/vectorTensorTransform/vectorTensorTransform.H @@ -0,0 +1,217 @@ +/*---------------------------------------------------------------------------*\ + ========= | + \\ / F ield | OpenFOAM: The Open Source CFD Toolbox + \\ / O peration | + \\ / A nd | Copyright (C) 1991-2009 OpenCFD Ltd. + \\/ 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::vectorTensorTransform + +Description + Vector-tensor class used to perform translations and rotations in + 3D space. + +SourceFiles + vectorTensorTransformI.H + vectorTensorTransform.C + +\*---------------------------------------------------------------------------*/ + +#ifndef vectorTensorTransform_H +#define vectorTensorTransform_H + +#include "vector.H" +#include "tensor.H" +#include "word.H" +#include "contiguous.H" + +// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // + +namespace Foam +{ + +// Forward declaration of friend functions and operators + +class vectorTensorTransform; +Istream& operator>>(Istream& is, vectorTensorTransform&); +Ostream& operator<<(Ostream& os, const vectorTensorTransform& C); + + +/*---------------------------------------------------------------------------*\ + Class vectorTensorTransform Declaration +\*---------------------------------------------------------------------------*/ + +class vectorTensorTransform +{ + // private data + + //- Translation vector + vector t_; + + //- Rotation tensor + tensor R_; + + +public: + + // Static data members + + static const char* const typeName; + + static const vectorTensorTransform zero; + + static const vectorTensorTransform I; + + + // Constructors + + //- Construct null + inline vectorTensorTransform(); + + //- Construct given a translation vector and rotation tensor + inline vectorTensorTransform(const vector& t, const tensor& R); + + //- Construct a pure translation vectorTensorTransform given a + // translation vector + inline explicit vectorTensorTransform(const vector& t); + + //- Construct a pure rotation vectorTensorTransform given a + // rotation tensor + inline explicit vectorTensorTransform(const tensor& R); + + //- Construct from Istream + vectorTensorTransform(Istream&); + + + // Member functions + + // Access + + inline const vector& t() const; + + inline const tensor& R() const; + + + // Edit + + inline vector& t(); + + inline tensor& R(); + + + // Transform + + //- Transform the given vector + inline vector transform(const vector& v) const; + + //- Inverse Transform the given vector + inline vector invTransform(const vector& v) const; + + + // Member operators + + inline void operator=(const vectorTensorTransform&); + inline void operator&=(const vectorTensorTransform&); + + inline void operator=(const vector&); + inline void operator+=(const vector&); + inline void operator-=(const vector&); + + inline void operator=(const tensor&); + inline void operator&=(const tensor&); + + + // IOstream operators + + friend Istream& operator>>(Istream& is, vectorTensorTransform&); + + friend Ostream& operator<<(Ostream& os, const vectorTensorTransform&); +}; + + +// * * * * * * * * * * * * * * * Global Functions * * * * * * * * * * * * * // + +//- Return a string representation of a vectorTensorTransform +word name(const vectorTensorTransform&); + + +//- Data associated with vectorTensorTransform type are contiguous +template<> +inline bool contiguous() {return true;} + + +// * * * * * * * * * * * * * * * Global Operators * * * * * * * * * * * * * // + +inline bool operator== +( + const vectorTensorTransform& tr1, + const vectorTensorTransform& tr2 +); + + +inline bool operator!= +( + const vectorTensorTransform& tr1, + const vectorTensorTransform& tr2 + +); + + +inline vectorTensorTransform operator+ +( + const vectorTensorTransform& tr, + const vector& t +); + + +inline vectorTensorTransform operator+ +( + const vector& t, + const vectorTensorTransform& tr +); + + +inline vectorTensorTransform operator- +( + const vectorTensorTransform& tr, + const vector& t +); + + +inline vectorTensorTransform operator& +( + const vectorTensorTransform& tr1, + const vectorTensorTransform& tr2 +); + + +// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // + +} // End namespace Foam + +// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // + +#include "vectorTensorTransformI.H" + +// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // + +#endif + +// ************************************************************************* // diff --git a/src/lagrangian/basic/InteractionLists/globalIndexAndTransform/vectorTensorTransform/vectorTensorTransformI.H b/src/lagrangian/basic/InteractionLists/globalIndexAndTransform/vectorTensorTransform/vectorTensorTransformI.H new file mode 100644 index 0000000000..8681d5b04e --- /dev/null +++ b/src/lagrangian/basic/InteractionLists/globalIndexAndTransform/vectorTensorTransform/vectorTensorTransformI.H @@ -0,0 +1,219 @@ +/*---------------------------------------------------------------------------*\ + ========= | + \\ / F ield | OpenFOAM: The Open Source CFD Toolbox + \\ / O peration | + \\ / A nd | Copyright (C) 1991-2009 OpenCFD Ltd. + \\/ 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 . + +\*---------------------------------------------------------------------------*/ + +// * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * // + +inline Foam::vectorTensorTransform::vectorTensorTransform() +: + t_(vector::zero), + R_(sphericalTensor::I) +{} + +inline Foam::vectorTensorTransform::vectorTensorTransform +( + const vector& t, + const tensor& R +) +: + t_(t), + R_(R) +{} + +inline Foam::vectorTensorTransform::vectorTensorTransform(const vector& t) +: + t_(t), + R_(sphericalTensor::I) +{} + +inline Foam::vectorTensorTransform::vectorTensorTransform(const tensor& R) +: + t_(vector::zero), + R_(R) +{} + + +// * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * // + +inline const Foam::vector& Foam::vectorTensorTransform::t() const +{ + return t_; +} + + +inline const Foam::tensor& Foam::vectorTensorTransform::R() const +{ + return R_; +} + + +inline Foam::vector& Foam::vectorTensorTransform::t() +{ + return t_; +} + + +inline Foam::tensor& Foam::vectorTensorTransform::R() +{ + return R_; +} + + +inline Foam::vector Foam::vectorTensorTransform::transform +( + const vector& v +) const +{ + return t() + (R() & v); +} + + +inline Foam::vector Foam::vectorTensorTransform::invTransform +( + const vector& v +) const +{ + return (R().T() & (v - t())); +} + + +// * * * * * * * * * * * * * * * Member Operators * * * * * * * * * * * * * // + +inline void Foam::vectorTensorTransform::operator= +( + const vectorTensorTransform& tr +) +{ + t_ = tr.t_; + R_ = tr.R_; +} + + +inline void Foam::vectorTensorTransform::operator&= +( + const vectorTensorTransform& tr +) +{ + t_ += tr.t_; + R_ = tr.R_ & R_; +} + + +inline void Foam::vectorTensorTransform::operator=(const vector& t) +{ + t_ = t; +} + + +inline void Foam::vectorTensorTransform::operator+=(const vector& t) +{ + t_ += t; +} + + +inline void Foam::vectorTensorTransform::operator-=(const vector& t) +{ + t_ -= t; +} + + +inline void Foam::vectorTensorTransform::operator=(const tensor& R) +{ + R_ = R; +} + + +inline void Foam::vectorTensorTransform::operator&=(const tensor& R) +{ + R_ = R & R_; +} + + +// * * * * * * * * * * * * * * * Global Operators * * * * * * * * * * * * * // + +inline bool Foam::operator== +( + const vectorTensorTransform& tr1, + const vectorTensorTransform& tr2 +) +{ + return (tr1.t() == tr2.t() && tr1.R() == tr2.R()); +} + + +inline bool Foam::operator!= +( + const vectorTensorTransform& tr1, + const vectorTensorTransform& tr2 +) +{ + return !operator==(tr1, tr2); +} + + +inline Foam::vectorTensorTransform Foam::operator+ +( + const vectorTensorTransform& tr, + const vector& t +) +{ + return vectorTensorTransform(tr.t() + t, tr.R()); +} + + +inline Foam::vectorTensorTransform Foam::operator+ +( + const vector& t, + const vectorTensorTransform& tr +) +{ + return vectorTensorTransform(t + tr.t(), tr.R()); +} + + +inline Foam::vectorTensorTransform Foam::operator- +( + const vectorTensorTransform& tr, + const vector& t +) +{ + return vectorTensorTransform(tr.t() - t, tr.R()); +} + + +inline Foam::vectorTensorTransform Foam::operator& +( + const vectorTensorTransform& tr1, + const vectorTensorTransform& tr2 +) +{ + return vectorTensorTransform + ( + tr1.t() + tr2.t(), + tr1.R() & tr2.R() + ); +} + + +// ************************************************************************* // diff --git a/src/lagrangian/basic/Make/files b/src/lagrangian/basic/Make/files index 574adb603c..c226859e6e 100644 --- a/src/lagrangian/basic/Make/files +++ b/src/lagrangian/basic/Make/files @@ -5,6 +5,7 @@ $(passiveParticle)/passiveParticleCloud.C $(indexedParticle)/indexedParticleCloud.C InteractionLists/globalIndexAndTransform/globalIndexAndTransform.C +InteractionLists/globalIndexAndTransform/vectorTensorTransform/vectorTensorTransform.C InteractionLists/referredWallFace/referredWallFace.C LIB = $(FOAM_LIBBIN)/liblagrangian