58 const bool computeVectorFieldSize
65 const label patchSize =
patch.size();
66 size += label(computeVectorFieldSize ? 3*patchSize : patchSize);
75 const label
iters(
dict().getOrDefault<label>(
"iters", 500));
76 const scalar tolerance(
dict().getOrDefault<scalar>(
"tolerance", 1.
e-06));
82 Info<<
"Loaded the existing faMesh" <<
nl;
101 if (
io.typeHeaderOk<IOdictionary>(
false))
103 Info<<
"Using system/faMeshDefinition" <<
nl;
104 faMeshDefinition = IOdictionary(
io);
108 Info<<
"No " <<
io.name() <<
" in " <<
io.path() <<
nl;
113 if (faMeshDefinition.empty())
125 if (
io.typeHeaderOk<IOdictionary>(
false))
127 Info<<
"Using system/finite-area/faMeshDefinition" <<
nl;
128 faMeshDefinition = IOdictionary(
io);
132 Info<<
"No " <<
io.name() <<
" in " <<
io.path() <<
nl;
139 if (faMeshDefinition.empty())
147 faMeshDefinition.add<
wordList>(
"polyMeshPatches", polyMeshPatches);
148 (void)faMeshDefinition.subDictOrAdd(
"boundary");
154 Info<<
"Create faMeshDefinition from sensitivity patches" 157 faMeshDefinition.writeEntry(
"faMeshDefinition",
Info);
161 aMeshPtr.reset(
new faMesh(
mesh_, faMeshDefinition));
163 faMesh& aMesh = *aMeshPtr;
168 const scalar Rphysical
171 <<
"Physical radius of the sensitivity smoothing " 172 << Rphysical <<
nl <<
endl;
184 volSurfaceMapping
vsm(aMesh);
189 aMesh.newIOobject(
"sens"),
202 for (label iter = 0; iter <
iters; ++iter)
204 Info<<
"Sensitivity smoothing iteration " << iter <<
endl;
216 const scalar residual(
mag(smoothEqn.solve().initialResidual()));
219 <<
"Max smoothSens " <<
gMax(
mag(smoothedSens)()) <<
endl;
225 if (residual < tolerance)
227 Info<<
"\n***Reached smoothing equation convergence limit, " 228 "iteration " << iter <<
"***\n\n";
247 vsm.mapToVolume(smoothedSensNormal, volSmoothedSens.boundaryFieldRef());
248 volSmoothedSens.write();
254 scalar averageArea(
gAverage(aMesh.
S().field()));
259 if (geometricD[iDir] == -1)
261 averageArea /= bounds.
span()[iDir];
272 sensitivitySurface::sensitivitySurface
280 smoothSensitivities_(
dict.getOrDefault(
"smoothSensitivities", false)),
282 (
dict.getOrDefault<bool>(
"returnVectorField", true))
332 volPointInterpolationAdjoint interpolation(
mesh_);
333 interpolation.interpolateSensitivitiesField
337 label nPassedFaces(0);
341 tmp<vectorField> nf =
patch.nf();
343 SubField<vector>(faceVecSens,
patch.size(), nPassedFaces)
348 nPassedFaces +=
patch.size();
370 const label gfI = nPassedFaces + fI;
372 derivatives_[3*gfI ] = scalar(sd[0] == -1 ? 0 : fSens.x());
373 derivatives_[3*gfI + 1] = scalar(sd[1] == -1 ? 0 : fSens.y());
374 derivatives_[3*gfI + 2] = scalar(sd[2] == -1 ? 0 : fSens.z());
385 nPassedFaces +=
patch.size();
Finite area mesh (used for 2-D non-Euclidian finite area method) defined using a patch of faces on a ...
autoPtr< pointBoundaryVectorField > wallPointSensVecPtr_
Wall point sens w.r.t. (x,y.z)
const volSurfaceMapping vsm(aMesh)
dimensioned< typename typeOfMag< Type >::type > mag(const dimensioned< Type > &dt)
label nPoints() const noexcept
Number of mesh points.
A list of keyword definitions, which are a keyword followed by a number of values (eg...
labelHashSet sensitivityPatchIDs_
Patches on which to compute shape sensitivities.
dimensionedSymmTensor sqr(const dimensionedVector &dv)
const Vector< label > & solutionD() const
Return the vector of solved-for directions in mesh.
constexpr char nl
The newline '\n' character (0x0a)
dimensioned< vector > dimensionedVector
Dimensioned vector obtained from generic dimensioned type.
dimensionedScalar sqrt(const dimensionedScalar &ds)
Ostream & endl(Ostream &os)
Add newline and flush stream.
const DimensionedField< scalar, areaMesh > & S() const
Return face areas.
A finiteVolume patch using a polyPatch and a fvBoundaryMesh.
autoPtr< boundaryVectorField > wallFaceSensNormalVecPtr_
Normal sens as vectors.
Base class for adjoint solvers.
A bounding box defined in terms of min/max extrema points.
void read()
Read controls and update solver pointers if necessary.
faMatrix< vector > faVectorMatrix
Ignore writing from objectRegistry::writeObject()
const dimensionSet dimless
Dimensionless.
const Time & time() const
Return the top-level database.
autoPtr< boundaryVectorField > wallFaceSensVecPtr_
Wall face sens w.r.t. (x,y.z)
autoPtr< boundaryScalarField > wallFaceSensNormalPtr_
Wall face sens projected to normal.
label nGeometricD() const
Return the number of valid geometric dimensions in the mesh.
static const word & zeroGradientType() noexcept
The type name for zeroGradient patch fields.
Macros for easy insertion into run-time selection tables.
#define forAll(list, i)
Loop across all elements in list.
tmp< faMatrix< Type > > laplacian(const GeometricField< Type, faPatchField, areaMesh > &vf)
fileName caseSystem() const
Return the system name for the case, which is ../system() for parallel runs.
const Vector< label > & geometricD() const
Return the vector of geometric directions in mesh.
GeometricField< scalar, fvPatchField, volMesh > volScalarField
virtual void assembleSensitivities(autoPtr< designVariables > &designVars)
Assemble sensitivities.
label size() const noexcept
The number of elements in table.
zeroField Sp(const Foam::zero, const GeometricField< Type, faPatchField, areaMesh > &)
A no-op source.
const dimensionedScalar e
Elementary charge.
void setSize(const label n)
Alias for resize()
const polyBoundaryMesh & boundaryMesh() const noexcept
Return boundary mesh.
void smoothSensitivities()
Smooth sensitivity derivatives based on the computation of the 'Sobolev gradient'.
scalar computeRadius(const faMesh &aMesh)
Compute the physical smoothing radius based on the average boundary face 'length'.
Calculate the matrix for the laplacian of the field.
#define DebugInfo
Report an information message using Foam::Info.
Calculate the finiteArea matrix for implicit and explicit sources.
int debug
Static debugging option.
void normalise()
Normalise the field inplace. See notes in Field.
Type gMax(const FieldField< Field, Type > &f)
defineTypeNameAndDebug(combustionModel, 0)
bool smoothSensitivities_
Smooth sensitivity derivatives based on a surface Laplace solver.
Ostream & printExecutionTime(OSstream &os) const
Print the elapsed ExecutionTime (cpu-time), ClockTime.
word suffix_
Append this word to files related to the sensitivities.
const dictionary & dict() const
Return the construction dictionary.
dimensionedScalar pow(const dimensionedScalar &ds, const dimensionedScalar &expt)
List< word > wordList
List of word.
Internal::FieldType & primitiveFieldRef(const bool updateAccessTime=true)
Return a reference to the internal field values.
virtual void write(const word &baseName=word::null)
Write sensitivity fields.
virtual void assembleSensitivities(autoPtr< designVariables > &designVars)
Assemble sensitivities.
label computeFaceDerivativesSize(const bool computeVectorFieldSize)
Compute the size of the return field.
dimensioned< scalar > dimensionedScalar
Dimensioned scalar obtained from generic dimensioned type.
Type gAverage(const FieldField< Field, Type > &f)
scalarField derivatives_
The sensitivity derivative values.
static autoPtr< faMesh > TryNew(const word &meshName, const polyMesh &pMesh)
Read construction from polyMesh if all files are available.
Mesh data needed to do the Finite Volume discretisation.
loopControl iters(runTime, aMesh.solutionDict(), "solution")
const std::string patch
OpenFOAM patch number as a std::string.
bool returnVectorField_
Return the complete vector of sensitivities.
vector span() const
The bounding box span (from minimum to maximum)
messageStream Info
Information stream (stdout output on master, null elsewhere)
const fvBoundaryMesh & boundary() const noexcept
Return reference to boundary mesh.
A class representing the concept of 0 (zero) that can be used to avoid manipulating objects known to ...
const boundBox & bounds() const noexcept
Return mesh bounding box.
Field< vector > vectorField
Specialisation of Field<T> for vector.
Pointer management similar to std::unique_ptr, with some additional methods and type checking...
void read()
Read controls and update solver pointers if necessary.
T getOrDefault(const word &keyword, const T &deflt, enum keyType::option matchOpt=keyType::REGEX) const
Find and return a T, or return the given default value. FatalIOError if it is found and the number of...
IOobject io("surfaceFilmProperties", mesh.time().constant(), mesh, IOobject::READ_IF_PRESENT, IOobject::NO_WRITE, IOobject::NO_REGISTER)
IOobject newIOobject(const word &name, IOobjectOption ioOpt) const
Create an IOobject at the current time instance (timeName) with the specified options.
A patch is a list of labels that address the faces in the global face list.
static const word & prefix() noexcept
The prefix to the parent registry name: finite-area.
GeometricField< vector, faPatchField, areaMesh > areaVectorField
Do not request registration (bool: false)
Calculation of adjoint-based sensitivities at wall points using the E-SI formulation.
const dimensionSet dimArea(sqr(dimLength))
uindirectPrimitivePatch pp(UIndirectList< face >(mesh.faces(), faceLabels), mesh.points())
addToRunTimeSelectionTable(functionObject, pointHistory, dictionary)
A class representing the concept of 1 (one) that can be used to avoid manipulating objects known to b...
static constexpr const zero Zero
Global zero (0)