diff --git a/src/VectorN/OpenFOAM/primitives/vector3/diagTensor3.H b/src/VectorN/OpenFOAM/primitives/vector3/diagTensor3.H new file mode 100644 index 000000000..a94bfc9e9 --- /dev/null +++ b/src/VectorN/OpenFOAM/primitives/vector3/diagTensor3.H @@ -0,0 +1,63 @@ +/*---------------------------------------------------------------------------*\ + ========= | + \\ / F ield | OpenFOAM: The Open Source CFD Toolbox + \\ / O peration | + \\ / A nd | Copyright held by original author + \\/ 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 2 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, write to the Free Software Foundation, + Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA + +Type + diagTensor3 + +Description + DiagTensorN of 3 scalars. + +\*---------------------------------------------------------------------------*/ + +#ifndef diagTensor3_H +#define diagTensor3_H + +#include "DiagTensorN.H" +#include "vector3.H" +#include "sphericalTensor3.H" +#include "contiguous.H" + +// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // + +namespace Foam +{ + +// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // + +typedef DiagTensorN diagTensor3; + +//- Specify data associated with diagTensor3 type is contiguous +template<> +inline bool contiguous() {return true;} + + +// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // + +} // End namespace Foam + +// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // + +#endif + +// ************************************************************************* // diff --git a/src/VectorN/OpenFOAM/primitives/vector3/sphericalTensor3.H b/src/VectorN/OpenFOAM/primitives/vector3/sphericalTensor3.H new file mode 100644 index 000000000..9a549305b --- /dev/null +++ b/src/VectorN/OpenFOAM/primitives/vector3/sphericalTensor3.H @@ -0,0 +1,62 @@ +/*---------------------------------------------------------------------------*\ + ========= | + \\ / F ield | OpenFOAM: The Open Source CFD Toolbox + \\ / O peration | + \\ / A nd | Copyright held by original author + \\/ 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 2 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, write to the Free Software Foundation, + Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA + +Type + sphericalTensor3 + +Description + SphericalTensorN of 3 scalars. + +\*---------------------------------------------------------------------------*/ + +#ifndef sphericalTensor3_H +#define sphericalTensor3_H + +#include "SphericalTensorN.H" +#include "vector3.H" +#include "contiguous.H" + +// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // + +namespace Foam +{ + +// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // + +typedef SphericalTensorN sphericalTensor3; + +//- Specify data associated with sphericalTensor3 type is contiguous +template<> +inline bool contiguous() {return true;} + + +// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // + +} // End namespace Foam + +// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // + +#endif + +// ************************************************************************* // diff --git a/src/VectorN/OpenFOAM/primitives/vector3/tensor3.H b/src/VectorN/OpenFOAM/primitives/vector3/tensor3.H new file mode 100644 index 000000000..6c46e6d61 --- /dev/null +++ b/src/VectorN/OpenFOAM/primitives/vector3/tensor3.H @@ -0,0 +1,67 @@ +/*---------------------------------------------------------------------------*\ + ========= | + \\ / F ield | OpenFOAM: The Open Source CFD Toolbox + \\ / O peration | + \\ / A nd | Copyright held by original author + \\/ 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 2 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, write to the Free Software Foundation, + Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA + +Type + tensor3 + +Description + TensorN of 3 scalars. + +\*---------------------------------------------------------------------------*/ + +#ifndef tensor3_H +#define tensor3_H + +#include "TensorN.H" +#include "vector3.H" +#include "sphericalTensor3.H" +#include "diagTensor3.H" +#include "contiguous.H" + +// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // + +namespace Foam +{ + +// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // + +typedef TensorN tensor3; + +//- Specify data associated with tensor3 type is contiguous +template<> +inline bool contiguous() {return true;} + + +// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // + +} // End namespace Foam + +// Include inline implementations +#include "tensor3I.H" + +// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // + +#endif + +// ************************************************************************* // diff --git a/src/VectorN/OpenFOAM/primitives/vector3/tensor3I.H b/src/VectorN/OpenFOAM/primitives/vector3/tensor3I.H new file mode 100644 index 000000000..6134d308b --- /dev/null +++ b/src/VectorN/OpenFOAM/primitives/vector3/tensor3I.H @@ -0,0 +1,75 @@ +/*---------------------------------------------------------------------------*\ + ========= | + \\ / F ield | OpenFOAM: The Open Source CFD Toolbox + \\ / O peration | + \\ / A nd | Copyright held by original author + \\/ 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 2 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, write to the Free Software Foundation, + Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA + +Type + tensor3 + +Description + TensorN of 3 scalars. + +\*---------------------------------------------------------------------------*/ + +// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // + +namespace Foam +{ + +// * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * // + + +//- Return the determinant of a tensor +inline scalar det(const tensor3& t) +{ + return + ( + t[0]*t[4]*t[8] + t[1]*t[5]*t[6] + + t[2]*t[3]*t[7] - t[0]*t[5]*t[7] + - t[1]*t[3]*t[8] - t[2]*t[4]*t[6] + ); +} + + +//- Return the inverse of a tensor given the determinant +inline tensor3 inv(const tensor3& t) +{ + tensor3 cofactor; + + cofactor[0] = t[4]*t[8] - t[7]*t[5]; + cofactor[1] = t[6]*t[5] - t[3]*t[8]; + cofactor[2] = t[3]*t[7] - t[4]*t[6]; + cofactor[3] = t[2]*t[7] - t[1]*t[8]; + cofactor[4] = t[0]*t[8] - t[2]*t[6]; + cofactor[5] = t[1]*t[6] - t[0]*t[7]; + cofactor[6] = t[1]*t[5] - t[2]*t[4]; + cofactor[7] = t[3]*t[2] - t[0]*t[5]; + cofactor[8] = t[0]*t[4] - t[3]*t[1]; + + return cofactor/det(t); +} + +// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // + +} // End namespace Foam + +// ************************************************************************* // diff --git a/src/VectorN/OpenFOAM/primitives/vector3/vector3.H b/src/VectorN/OpenFOAM/primitives/vector3/vector3.H new file mode 100644 index 000000000..9065eb10d --- /dev/null +++ b/src/VectorN/OpenFOAM/primitives/vector3/vector3.H @@ -0,0 +1,66 @@ +/*---------------------------------------------------------------------------*\ + ========= | + \\ / F ield | OpenFOAM: The Open Source CFD Toolbox + \\ / O peration | + \\ / A nd | Copyright held by original author + \\/ 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 2 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, write to the Free Software Foundation, + Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA + +Type + Vector3 + +Description + Vector3 obtained from generic VectorN + +SourceFiles + Vector3.C + +\*---------------------------------------------------------------------------*/ + +#ifndef Vector3_H +#define Vector3_H + +#include "scalar.H" +#include "VectorN.H" +#include "contiguous.H" + +// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // + +namespace Foam +{ + +// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // + +typedef VectorN vector3; + + +//- Specify data associated with vector3 type is contiguous +template<> +inline bool contiguous() {return true;} + + +// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // + +} // End namespace Foam + +// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // + +#endif + +// ************************************************************************* //