All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Pages
isoSurfaceTemplates.C
Go to the documentation of this file.
1 /*---------------------------------------------------------------------------*\
2  ========= |
3  \\ / F ield | OpenFOAM: The Open Source CFD Toolbox
4  \\ / O peration | Website: https://openfoam.org
5  \\ / A nd | Copyright (C) 2011-2018 OpenFOAM Foundation
6  \\/ M anipulation |
7 -------------------------------------------------------------------------------
8 License
9  This file is part of OpenFOAM.
10 
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
13  the Free Software Foundation, either version 3 of the License, or
14  (at your option) any later version.
15 
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.
20 
21  You should have received a copy of the GNU General Public License
22  along with OpenFOAM. If not, see <http://www.gnu.org/licenses/>.
23 
24 \*---------------------------------------------------------------------------*/
25 
26 // * * * * * * * * * * * * * Private Member Functions * * * * * * * * * * * //
27 
28 template<class Type>
31 (
32  const Field<Type>& cellCoords,
33  const Field<Type>& pointCoords
34 ) const
35 {
36  tmp<Field<Type>> tfld(new Field<Type>(pointToVerts_.size()));
37  Field<Type>& fld = tfld.ref();
38 
39  forAll(pointToVerts_, i)
40  {
41  scalar s0;
42  Type p0;
43  {
44  label v0 = pointToVerts_[i][0];
45  if (v0 < mesh_.nPoints())
46  {
47  s0 = pVals_[v0];
48  p0 = pointCoords[v0];
49  }
50  else
51  {
52  label celli = v0-mesh_.nPoints();
53  s0 = cVals_[celli];
54  p0 = cellCoords[celli];
55  }
56  }
57 
58  scalar s1;
59  Type p1;
60  {
61  label v1 = pointToVerts_[i][1];
62  if (v1 < mesh_.nPoints())
63  {
64  s1 = pVals_[v1];
65  p1 = pointCoords[v1];
66  }
67  else
68  {
69  label celli = v1-mesh_.nPoints();
70  s1 = cVals_[celli];
71  p1 = cellCoords[celli];
72  }
73  }
74 
75  scalar d = s1-s0;
76  if (mag(d) > VSMALL)
77  {
78  scalar s = (iso_-s0)/d;
79  fld[i] = s*p1+(1.0-s)*p0;
80  }
81  else
82  {
83  fld[i] = 0.5*(p0+p1);
84  }
85  }
86 
87  return tfld;
88 }
89 
90 
91 // ************************************************************************* //
#define forAll(list, i)
Loop across all elements in list.
Definition: UList.H:434
intWM_LABEL_SIZE_t label
A label is an int32_t or int64_t as specified by the pre-processor macro WM_LABEL_SIZE.
Definition: label.H:59
T & ref() const
Return non-const reference or generate a fatal error.
Definition: tmpI.H:174
gmvFile<< "tracers "<< particles.size()<< nl;forAllConstIter(Cloud< passiveParticle >, particles, iter){ gmvFile<< iter().position().x()<< " ";}gmvFile<< nl;forAllConstIter(Cloud< passiveParticle >, particles, iter){ gmvFile<< iter().position().y()<< " ";}gmvFile<< nl;forAllConstIter(Cloud< passiveParticle >, particles, iter){ gmvFile<< iter().position().z()<< " ";}gmvFile<< nl;forAll(lagrangianScalarNames, i){ word name=lagrangianScalarNames[i];IOField< scalar > s(IOobject(name, runTime.timeName(), cloud::prefix, mesh, IOobject::MUST_READ, IOobject::NO_WRITE))
tmp< Field< Type > > interpolate(const Field< Type > &cCoords, const Field< Type > &pCoords) const
Interpolates cCoords,pCoords.
gmvFile<< "tracers "<< particles.size()<< nl;forAllConstIter(Cloud< passiveParticle >, particles, iter){ gmvFile<< iter().position().x()<< ' ';}gmvFile<< nl;forAllConstIter(Cloud< passiveParticle >, particles, iter){ gmvFile<< iter().position().y()<< ' ';}gmvFile<< nl;forAllConstIter(Cloud< passiveParticle >, particles, iter){ gmvFile<< iter().position().z()<< ' ';}gmvFile<< nl;forAll(lagrangianScalarNames, i){ const word &name=lagrangianScalarNames[i];IOField< scalar > fld(IOobject(name, runTime.timeName(), cloud::prefix, mesh, IOobject::MUST_READ, IOobject::NO_WRITE))
Pre-declare SubField and related Field type.
Definition: Field.H:56
static const scalar VSMALL
Definition: scalar.H:117
dimensioned< scalar > mag(const dimensioned< Type > &)
A class for managing temporary objects.
Definition: PtrList.H:53