mirror of
https://develop.openfoam.com/Development/openfoam.git
synced 2025-11-28 03:28:01 +00:00
ENH: New vectorTensorTransform class for globalIndexAndTransform.
This commit is contained in:
@ -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 <http://www.gnu.org/licenses/>.
|
||||
|
||||
\*---------------------------------------------------------------------------*/
|
||||
|
||||
#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;
|
||||
}
|
||||
|
||||
|
||||
// ************************************************************************* //
|
||||
@ -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 <http://www.gnu.org/licenses/>.
|
||||
|
||||
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<vectorTensorTransform>() {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
|
||||
|
||||
// ************************************************************************* //
|
||||
@ -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 <http://www.gnu.org/licenses/>.
|
||||
|
||||
\*---------------------------------------------------------------------------*/
|
||||
|
||||
// * * * * * * * * * * * * * * * * 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()
|
||||
);
|
||||
}
|
||||
|
||||
|
||||
// ************************************************************************* //
|
||||
@ -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
|
||||
|
||||
Reference in New Issue
Block a user