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 -------------------------------------------------------------------------------
10 License
11  This file is part of OpenFOAM.
12 
13  OpenFOAM is free software: you can redistribute it and/or modify it
14  under the terms of the GNU General Public License as published by
15  the Free Software Foundation, either version 3 of the License, or
16  (at your option) any later version.
17 
18  OpenFOAM is distributed in the hope that it will be useful, but WITHOUT
19  ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
20  FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
21  for more details.
22 
23  You should have received a copy of the GNU General Public License
24  along with OpenFOAM. If not, see <http://www.gnu.org/licenses/>.
25 
26 \*---------------------------------------------------------------------------*/
27 
28 // * * * * * * * * * * * * * Private Member Functions * * * * * * * * * * * //
29 
30 template<class Type>
33 (
34  const Field<Type>& cellCoords,
35  const Field<Type>& pointCoords
36 ) const
37 {
38  tmp<Field<Type>> tfld(new Field<Type>(pointToVerts_.size()));
39  Field<Type>& fld = tfld.ref();
40 
41  forAll(pointToVerts_, i)
42  {
43  scalar s0;
44  Type p0;
45  {
46  label v0 = pointToVerts_[i][0];
47  if (v0 < mesh_.nPoints())
48  {
49  s0 = pVals_[v0];
50  p0 = pointCoords[v0];
51  }
52  else
53  {
54  label celli = v0-mesh_.nPoints();
55  s0 = cVals_[celli];
56  p0 = cellCoords[celli];
57  }
58  }
59 
60  scalar s1;
61  Type p1;
62  {
63  label v1 = pointToVerts_[i][1];
64  if (v1 < mesh_.nPoints())
65  {
66  s1 = pVals_[v1];
67  p1 = pointCoords[v1];
68  }
69  else
70  {
71  label celli = v1-mesh_.nPoints();
72  s1 = cVals_[celli];
73  p1 = cellCoords[celli];
74  }
75  }
76 
77  scalar d = s1-s0;
78  if (mag(d) > VSMALL)
79  {
80  scalar s = (iso_-s0)/d;
81  fld[i] = s*p1+(1.0-s)*p0;
82  }
83  else
84  {
85  fld[i] = 0.5*(p0+p1);
86  }
87  }
88 
89  return tfld;
90 }
91 
92 
93 // ************************************************************************* //
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:59
Foam::isoSurfaceTopo::interpolate
tmp< Field< Type > > interpolate(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:290
Foam::tmp::ref
T & ref() const
Definition: tmpI.H:258
Foam::label
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:62
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::mag
dimensioned< typename typeOfMag< Type >::type > mag(const dimensioned< Type > &dt)
p0
const volScalarField & p0
Definition: EEqn.H:36