initial commit for version 1.5.x patch release
[OpenFOAM-1.5.x.git] / src / finiteVolume / fvMesh / fvMeshCutSurface / meshCut / meshCutSurfaceInterpolate.C
blob37327e04670b737aebea0bfc8db1677a3e6afc88
1 /*---------------------------------------------------------------------------*\
2   =========                 |
3   \\      /  F ield         | OpenFOAM: The Open Source CFD Toolbox
4    \\    /   O peration     |
5     \\  /    A nd           | Copyright (C) 1991-2008 OpenCFD Ltd.
6      \\/     M anipulation  |
7 -------------------------------------------------------------------------------
8 License
9     This file is part of OpenFOAM.
11     OpenFOAM is free software; you can redistribute it and/or modify it
12     under the terms of the GNU General Public License as published by the
13     Free Software Foundation; either version 2 of the License, or (at your
14     option) any later version.
16     OpenFOAM is distributed in the hope that it will be useful, but WITHOUT
17     ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
18     FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
19     for more details.
21     You should have received a copy of the GNU General Public License
22     along with OpenFOAM; if not, write to the Free Software Foundation,
23     Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
25 \*---------------------------------------------------------------------------*/
27 #include "meshCutSurface.H"
28 #include "pyramidEdge.H"
29 #include "faceEdge.H"
30 #include "centreEdge.H"
31 #include "diagonalEdge.H"
32 #include "faceDecompCuts.H"
33 #include "cellDecompCuts.H"
35 // * * * * * * * * * * * * * Private Member Functions  * * * * * * * * * * * //
37 template <class T>
38 Foam::tmp<Foam::Field<T> > Foam::meshCutSurface::interpolate
40     const faceDecompCuts& cuts,
41     const Field<T>& vField,
42     const Field<T>& fField,
43     const Field<T>& pField
46     const primitiveMesh& mesh = cuts.mesh();
48     tmp<Field<T> > tvals(new Field<T>(cuts.size()));
49     Field<T>& vals = tvals();
51     label pointI = 0;
53     forAll(cuts.meshVerts(), cutVertI)
54     {
55         vals[pointI++] = pField[cuts.meshVerts()[cutVertI]];
56     }
58     forAll(cuts.meshFaceCentres(), cutFaceCentreI)
59     {
60         label faceI = cuts.meshFaceCentres()[cutFaceCentreI];
62         vals[pointI++] = fField[faceI];
63     }
65     forAll(cuts.meshCellCentres(), cutCellCentreI)
66     {
67         label cellI = cuts.meshCellCentres()[cutCellCentreI];
69         vals[pointI++] = vField[cellI];
70     }
72     forAll(cuts.meshEdges(), meshCutSurfaceEdgeI)
73     {
74         label edgeI = cuts.meshEdges()[meshCutSurfaceEdgeI];
76         const edge& e = mesh.edges()[edgeI];
78         scalar weight = cuts.meshEdgeWeights()[meshCutSurfaceEdgeI];
80         vals[pointI++] = weight*pField[e.start()] + (1-weight)*pField[e.end()];
81     }
83     forAll(cuts.pyrEdges(), edgeI)
84     {
85         const pyramidEdge& e = cuts.pyrEdges()[edgeI];
87         scalar weight = cuts.pyrEdgeWeights()[edgeI];
89         vals[pointI++] = e.interpolate(vField, pField, weight);
90     }
92     forAll(cuts.centreEdges(), edgeI)
93     {
94         const centreEdge& e = cuts.centreEdges()[edgeI];
96         scalar weight = cuts.centreEdgeWeights()[edgeI];
98         vals[pointI++] = e.interpolate(mesh, vField, fField, weight);
99     }
101     forAll(cuts.faceEdges(), edgeI)
102     {
103         const faceEdge& e = cuts.faceEdges()[edgeI];
105         scalar weight = cuts.faceEdgeWeights()[edgeI];
107         vals[pointI++] = e.interpolate(mesh, fField, pField, weight);
108     }
110     return tvals;
114 template <class T>
115 Foam::tmp<Foam::Field<T> > Foam::meshCutSurface::interpolate
117     const cellDecompCuts& cuts,
118     const Field<T>& vField,
119     const Field<T>& pField
122     const primitiveMesh& mesh = cuts.mesh();
124     tmp<Field<T> > tvals(new Field<T>(cuts.size()));
125     Field<T>& vals = tvals();
127     label pointI = 0;
129     forAll(cuts.meshVerts(), cutVertI)
130     {
131         vals[pointI++] = pField[cuts.meshVerts()[cutVertI]];
132     }
134     forAll(cuts.meshCellCentres(), cutCellCentreI)
135     {
136         label cellI = cuts.meshCellCentres()[cutCellCentreI];
138         vals[pointI++] = vField[cellI];
139     }
141     forAll(cuts.meshEdges(), meshCutSurfaceEdgeI)
142     {
143         label edgeI = cuts.meshEdges()[meshCutSurfaceEdgeI];
145         const edge& e = mesh.edges()[edgeI];
147         scalar weight = cuts.meshEdgeWeights()[meshCutSurfaceEdgeI];
149         vals[pointI++] = weight*pField[e.start()] + (1-weight)*pField[e.end()];
150     }
152     forAll(cuts.pyrEdges(), edgeI)
153     {
154         const pyramidEdge& e = cuts.pyrEdges()[edgeI];
156         scalar weight = cuts.pyrEdgeWeights()[edgeI];
158         vals[pointI++] = e.interpolate(vField, pField, weight);
159     }
161     forAll(cuts.diagEdges(), edgeI)
162     {
163         const diagonalEdge& e = cuts.diagEdges()[edgeI];
165         scalar weight = cuts.diagEdgeWeights()[edgeI];
167         vals[pointI++] = e.interpolate(mesh, pField, weight);
168     }
170     return tvals;
174 // ************************************************************************* //