Loading...
Searching...
No Matches
MapLagrangianFields.H
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-2016 OpenFOAM Foundation
9 Copyright (C) 2019-2023 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
27InNamespace
28 Foam
29
30Description
31 Gets the indices of (source)particles that have been appended to the
32 target cloud and maps the lagrangian fields accordingly.
33
34\*---------------------------------------------------------------------------*/
35
36#ifndef Foam_MapLagrangianFields_H
37#define Foam_MapLagrangianFields_H
38
39#include "cloud.H"
40#include "GeometricField.H"
41#include "meshToMesh.H"
42#include "IOobjectList.H"
43#include "CompactIOField.H"
44
45// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
46
47namespace Foam
48{
49
50//- Gets the indices of (source)particles that have been appended to the
51// target cloud and maps the lagrangian fields accordingly.
52template<class SourceIOFieldType, class TargetIOFieldType>
54(
55 const string& cloudName,
56 const IOobjectList& objects,
57 const polyMesh& meshTarget,
58 const labelList& addParticles,
59 const char* msg
60)
61{
62 for (const IOobject& io : objects.csorted<SourceIOFieldType>())
63 {
64 Info<< " mapping lagrangian " << msg << ' ' << io.name() << endl;
65
66 // Read field (does not need mesh)
67 // Note: some fieldFields are 0 size (e.g. collision records)
68 // if not used, so catch any of those for Field as well
69
70 SourceIOFieldType fieldSource(io);
71
72 // Map
73 TargetIOFieldType fieldTarget
74 (
76 (
77 io.name(),
78 meshTarget.time().timeName(),
80 meshTarget,
84 ),
85 min(fieldSource.size(), addParticles.size()) // handle 0 size
86 );
87
88 if (!fieldSource.empty())
89 {
90 forAll(addParticles, i)
91 {
92 fieldTarget[i] = fieldSource[addParticles[i]];
93 }
94 }
95 else if (cloud::debug && !addParticles.empty())
96 {
97 Pout<< "Not mapping " << io.name()
98 << " since source size = 0 and cloud size = "
99 << addParticles.size() << endl;
100 }
101
102 fieldTarget.write();
103 }
104}
105
106
107//- Gets the indices of (source)particles that have been appended to the
108// target cloud and maps the lagrangian fields accordingly.
109template<class Type>
111(
112 const string& cloudName,
113 const IOobjectList& objects,
114 const polyMesh& meshTarget,
115 const labelList& addParticles
116)
117{
119 <
122 >
123 (
124 cloudName,
125 objects,
126 meshTarget,
127 addParticles,
128 "Field"
129 );
130
131 // Target is CompactIOField to automatically write in
132 // compact form for binary format.
134 <
137 >
138 (
139 cloudName,
140 objects,
141 meshTarget,
142 addParticles,
143 "FieldField"
144 );
145
147 <
150 >
151 (
152 cloudName,
153 objects,
154 meshTarget,
155 addParticles,
156 "FieldField"
157 );
158}
159
160
161// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
162
163} // End namespace Foam
164
165// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
166
167#endif
168
169// ************************************************************************* //
const word cloudName(propsDict.get< word >("cloud"))
A Field of objects of type <T> with automated input and output using a compact storage....
A primitive field of type <T> with automated input and output.
Definition IOField.H:53
List of IOobjects with searching and retrieving facilities. Implemented as a HashTable,...
UPtrList< const IOobject > csorted() const
The sorted list of IOobjects with headerClassName == Type::typeName.
@ NO_REGISTER
Do not request registration (bool: false).
@ NO_READ
Nothing to be read.
@ NO_WRITE
Ignore writing from objectRegistry::writeObject().
Defines the attributes of an object for which implicit objectRegistry management is supported,...
Definition IOobject.H:191
static word timeName(const scalar t, const int precision=precision_)
Return a time name for the given scalar time value formatted with the given precision.
Definition Time.C:714
bool empty() const noexcept
True if List is empty (ie, size() is zero).
Definition UList.H:701
void size(const label n)
Older name for setAddressableSize.
Definition UList.H:118
static const word prefix
The prefix to local: lagrangian.
Definition cloud.H:79
const Time & time() const noexcept
Return time registry.
Mesh consisting of general polyhedral cells.
Definition polyMesh.H:79
const auto & io
Namespace for OpenFOAM.
List< label > labelList
A List of labels.
Definition List.H:62
messageStream Info
Information stream (stdout output on master, null elsewhere).
Ostream & endl(Ostream &os)
Add newline and flush stream.
Definition Ostream.H:519
label min(const labelHashSet &set, label minValue=labelMax)
Find the min value in labelHashSet, optionally limited by second argument.
Definition hashSets.C:26
prefixOSstream Pout
OSstream wrapped stdout (std::cout) with parallel prefix.
void MapLagrangianFields(const string &cloudName, const IOobjectList &objects, const meshToMesh0 &meshToMesh0Interp, const labelList &addParticles, const char *msg)
Gets the indices of (source)particles that have been appended to the.
#define forAll(list, i)
Loop across all elements in list.
Definition stdFoam.H:299