fixedValueConstraint.C
Go to the documentation of this file.
1 /*---------------------------------------------------------------------------*\
2  ========= |
3  \\ / F ield | OpenFOAM: The Open Source CFD Toolbox
4  \\ / O peration | Website: https://openfoam.org
5  \\ / A nd | Copyright (C) 2016-2021 OpenFOAM Foundation
6  \\/ M anipulation |
7 -------------------------------------------------------------------------------
8 License
9  This file is part of OpenFOAM.
10 
11  OpenFOAM is free software: you can redistribute it and/or modify it
12  under the terms of the GNU General Public License as published by
13  the Free Software Foundation, either version 3 of the License, or
14  (at your option) any later version.
15 
16  OpenFOAM is distributed in the hope that it will be useful, but WITHOUT
17  ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
18  FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
19  for more details.
20 
21  You should have received a copy of the GNU General Public License
22  along with OpenFOAM. If not, see <http://www.gnu.org/licenses/>.
23 
24 \*---------------------------------------------------------------------------*/
25 
26 #include "fixedValueConstraint.H"
27 #include "fvMesh.H"
28 #include "fvMatrices.H"
30 
31 // * * * * * * * * * * * * * * Static Data Members * * * * * * * * * * * * * //
32 
33 namespace Foam
34 {
35 namespace fv
36 {
37  defineTypeNameAndDebug(fixedValueConstraint, 0);
38 
40  (
41  fvConstraint,
42  fixedValueConstraint,
43  dictionary
44  );
45 }
46 }
47 
48 
49 // * * * * * * * * * * * * * Private Member Functions * * * * * * * * * * * //
50 
51 void Foam::fv::fixedValueConstraint::readCoeffs()
52 {
53  fieldValues_.clear();
54  forAllConstIter(dictionary, coeffs().subDict("fieldValues"), iter)
55  {
56  fieldValues_.set
57  (
58  iter().keyword(),
59  objectFunction1::New<VolField>
60  (
61  iter().keyword(),
62  coeffs().subDict("fieldValues"),
63  iter().keyword(),
64  mesh(),
65  false
66  ).ptr()
67  );
68  }
69 }
70 
71 
72 template<class Type>
73 bool Foam::fv::fixedValueConstraint::constrainType
74 (
75  fvMatrix<Type>& eqn,
76  const word& fieldName
77 ) const
78 {
79  const scalar t = mesh().time().value();
80 
81  eqn.setValues
82  (
83  set_.cells(),
84  List<Type>(set_.cells().size(), fieldValues_[fieldName]->value<Type>(t))
85  );
86 
87  return set_.cells().size();
88 }
89 
90 
91 // * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * //
92 
94 (
95  const word& name,
96  const word& modelType,
97  const dictionary& dict,
98  const fvMesh& mesh
99 )
100 :
101  fvConstraint(name, modelType, dict, mesh),
102  set_(coeffs(), mesh)
103 {
104  readCoeffs();
105 }
106 
107 
108 // * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * //
109 
111 {
112  return fieldValues_.toc();
113 }
114 
115 
117 (
120 );
121 
122 
124 {
125  set_.updateMesh(mpm);
126 }
127 
128 
130 {
131  if (fvConstraint::read(dict))
132  {
133  set_.read(coeffs());
134  readCoeffs();
135  return true;
136  }
137  else
138  {
139  return false;
140  }
141 }
142 
143 
144 // ************************************************************************* //
FOR_ALL_FIELD_TYPES(IMPLEMENT_FV_CONSTRAINT_CONSTRAIN, fv::fixedValueConstraint)
defineTypeNameAndDebug(fixedTemperatureConstraint, 0)
A list of keyword definitions, which are a keyword followed by any number of values (e...
Definition: dictionary.H:156
Constrain the field values within a specified region.
Class containing mesh-to-mesh mapping information after a change in polyMesh topology.
Definition: mapPolyMesh.H:158
Macros for easy insertion into run-time selection tables.
virtual void updateMesh(const mapPolyMesh &)
Update for mesh changes.
virtual wordList constrainedFields() const
Return the list of fields constrained by the fvConstraint.
virtual bool read(const dictionary &dict)
Read source dictionary.
dynamicFvMesh & mesh
#define IMPLEMENT_FV_CONSTRAINT_CONSTRAIN(Type, constraintType)
Definition: fvConstraintM.H:33
A class for handling words, derived from string.
Definition: word.H:59
labelList fv(nPoints)
forAllConstIter(PtrDictionary< phaseModel >, mixture.phases(), phase)
Definition: pEqn.H:29
addToRunTimeSelectionTable(fvConstraint, fixedTemperatureConstraint, dictionary)
fixedValueConstraint(const word &name, const word &modelType, const dictionary &dict, const fvMesh &mesh)
Construct from components.
Mesh data needed to do the Finite Volume discretisation.
Definition: fvMesh.H:78
A special matrix type and solver, designed for finite volume solutions of scalar equations.
virtual bool read(const dictionary &dict)
Read source dictionary.
Definition: fvConstraint.C:143
Finite volume options abstract base class.
Definition: fvConstraint.H:54
Namespace for OpenFOAM.