isoSurfaceTopoTemplates.C
Go to the documentation of this file.
1 /*---------------------------------------------------------------------------*\
2  ========= |
3  \\ / F ield | OpenFOAM: The Open Source CFD Toolbox
4  \\ / O peration |
5  \\ / A nd | www.openfoam.com
6  \\/ M anipulation |
7 -------------------------------------------------------------------------------
8  Copyright (C) 2011-2018 OpenFOAM Foundation
9  Copyright (C) 2020-2021 OpenCFD Ltd.
10 -------------------------------------------------------------------------------
11 License
12  This file is part of OpenFOAM.
13 
14  OpenFOAM is free software: you can redistribute it and/or modify it
15  under the terms of the GNU General Public License as published by
16  the Free Software Foundation, either version 3 of the License, or
17  (at your option) any later version.
18 
19  OpenFOAM is distributed in the hope that it will be useful, but WITHOUT
20  ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
21  FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
22  for more details.
23 
24  You should have received a copy of the GNU General Public License
25  along with OpenFOAM. If not, see <http://www.gnu.org/licenses/>.
26 
27 \*---------------------------------------------------------------------------*/
28 
29 // * * * * * * * * * * * * * Private Member Functions * * * * * * * * * * * //
30 
31 template<class Type>
34 (
35  const Field<Type>& cellData,
36  const Field<Type>& pointData
37 ) const
38 {
39  auto tfld = tmp<Field<Type>>::New(pointToVerts_.size());
40  auto& fld = tfld.ref();
41 
42  forAll(pointToVerts_, i)
43  {
44  const edge& verts = pointToVerts_[i];
45  Type& val = fld[i];
46 
47  scalar s0;
48  Type v0;
49  {
50  label idx = verts.first();
51  if (idx < mesh_.nPoints())
52  {
53  // Point index
54  s0 = pVals_[idx];
55  v0 = pointData[idx];
56  }
57  else
58  {
59  // Cell index
60  idx -= mesh_.nPoints();
61  s0 = cVals_[idx];
62  v0 = cellData[idx];
63  }
64  }
65 
66  scalar s1;
67  Type v1;
68  {
69  label idx = verts.second();
70  if (idx == verts.first())
71  {
72  // Duplicate index (ie, snapped)
73  val = v0;
74  continue;
75  }
76  else if (idx < mesh_.nPoints())
77  {
78  // Point index
79  s1 = pVals_[idx];
80  v1 = pointData[idx];
81  }
82  else
83  {
84  // Cell index
85  idx -= mesh_.nPoints();
86  s1 = cVals_[idx];
87  v1 = cellData[idx];
88  }
89  }
90 
91  const scalar d = s1-s0;
92  if (mag(d) > VSMALL)
93  {
94  const scalar s = (iso_-s0)/d;
95  val = s*v1+(1.0-s)*v0;
96  }
97  else
98  {
99  val = 0.5*(v0+v1);
100  }
101  }
102 
103  return tfld;
104 }
105 
106 
107 // ************************************************************************* //
Foam::Pair::second
const T & second() const noexcept
Return second element, which is also the last element.
Definition: PairI.H:122
s
gmvFile<< "tracers "<< particles.size()<< nl;for(const passiveParticle &p :particles){ gmvFile<< p.position().x()<< " ";}gmvFile<< nl;for(const passiveParticle &p :particles){ gmvFile<< p.position().y()<< " ";}gmvFile<< nl;for(const passiveParticle &p :particles){ gmvFile<< p.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))
Definition: gmvOutputSpray.H:25
Foam::tmp
A class for managing temporary objects.
Definition: PtrList.H:61
Foam::edge
An edge is a list of two point labels. The functionality it provides supports the discretisation on a...
Definition: edge.H:63
forAll
#define forAll(list, i)
Loop across all elements in list.
Definition: stdFoam.H:296
Foam::Field
Generic templated field type.
Definition: Field.H:63
Foam::isoSurfaceTopo::interpolateTemplate
tmp< Field< Type > > interpolateTemplate(const Field< Type > &cellData, const Field< Type > &pointData) const
Interpolates cellData and pointData fields.
fld
gmvFile<< "tracers "<< particles.size()<< nl;for(const passiveParticle &p :particles){ gmvFile<< p.position().x()<< ' ';}gmvFile<< nl;for(const passiveParticle &p :particles){ gmvFile<< p.position().y()<< ' ';}gmvFile<< nl;for(const passiveParticle &p :particles){ gmvFile<< p.position().z()<< ' ';}gmvFile<< nl;for(const word &name :lagrangianScalarNames){ IOField< scalar > fld(IOobject(name, runTime.timeName(), cloud::prefix, mesh, IOobject::MUST_READ, IOobject::NO_WRITE))
Definition: gmvOutputLagrangian.H:23
Foam::New
tmp< DimensionedField< TypeR, GeoMesh > > New(const tmp< DimensionedField< TypeR, GeoMesh >> &tdf1, const word &name, const dimensionSet &dimensions)
Global function forwards to reuseTmpDimensionedField::New.
Definition: DimensionedFieldReuseFunctions.H:105
Foam::mag
dimensioned< typename typeOfMag< Type >::type > mag(const dimensioned< Type > &dt)