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-------------------------------------------------------------------------------
11License
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
31template<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// ************************************************************************* //
Info<< nl<< "Wrote faMesh in vtk format: "<< writer.output().name()<< nl;}{ vtk::lineWriter writer(aMesh.points(), aMesh.edges(), fileName(aMesh.mesh().time().globalPath()/"finiteArea-edges"));writer.writeGeometry();writer.beginCellData(4);writer.writeProcIDs();{ Field< scalar > fld(faMeshTools::flattenEdgeField(aMesh.magLe(), true))
Generic templated field type.
Definition: Field.H:82
T & first() noexcept
The first element of the list, position [0].
Definition: FixedListI.H:207
const T & second() const noexcept
Return second element, which is also the last element.
Definition: PairI.H:120
void size(const label n)
Older name for setAddressableSize.
Definition: UList.H:114
An edge is a list of two point labels. The functionality it provides supports the discretisation on a...
Definition: edge.H:66
static autoPtr< isoSurfaceBase > New(const isoSurfaceParams &params, const volScalarField &cellValues, const scalarField &pointValues, const scalar iso, const bitSet &ignoreCells=bitSet())
Create for specified algorithm type.
const scalarField & pVals_
Point values.
const scalar iso_
Iso value.
const polyMesh & mesh_
Reference to mesh.
const scalarField & cVals_
Cell values.
tmp< Field< Type > > interpolateTemplate(const Field< Type > &cellData, const Field< Type > &pointData) const
Interpolates cellData and pointData fields.
label nPoints() const noexcept
Number of mesh points.
A class for managing temporary objects.
Definition: tmp.H:65
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))
dimensioned< typename typeOfMag< Type >::type > mag(const dimensioned< Type > &dt)
#define forAll(list, i)
Loop across all elements in list.
Definition: stdFoam.H:333