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 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>& cellCoords,
36  const Field<Type>& pointCoords
37 ) const
38 {
39  auto tfld = tmp<Field<Type>>::New(pointToVerts_.size());
40  auto& fld = tfld.ref();
41 
42  forAll(pointToVerts_, i)
43  {
44  scalar s0;
45  Type p0;
46  {
47  label idx = pointToVerts_[i].first();
48  if (idx < mesh_.nPoints())
49  {
50  // Point index
51  s0 = pVals_[idx];
52  p0 = pointCoords[idx];
53  }
54  else
55  {
56  // Cell index
57  idx -= mesh_.nPoints();
58  s0 = cVals_[idx];
59  p0 = cellCoords[idx];
60  }
61  }
62 
63  scalar s1;
64  Type p1;
65  {
66  label idx = pointToVerts_[i].second();
67  if (idx < mesh_.nPoints())
68  {
69  // Point index
70  s1 = pVals_[idx];
71  p1 = pointCoords[idx];
72  }
73  else
74  {
75  // Cell index
76  idx -= mesh_.nPoints();
77  s1 = cVals_[idx];
78  p1 = cellCoords[idx];
79  }
80  }
81 
82  const scalar d = s1-s0;
83  if (mag(d) > VSMALL)
84  {
85  const scalar s = (iso_-s0)/d;
86  fld[i] = s*p1+(1.0-s)*p0;
87  }
88  else
89  {
90  fld[i] = 0.5*(p0+p1);
91  }
92  }
93 
94  return tfld;
95 }
96 
97 
98 // ************************************************************************* //
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::isoSurfaceTopo::interpolateTemplate
tmp< Field< Type > > interpolateTemplate(const Field< Type > &cCoords, const Field< Type > &pCoords) const
Interpolates cCoords,pCoords.
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
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)
p0
const volScalarField & p0
Definition: EEqn.H:36