diff --git a/src/adjoint/DAFvSource/DAFvSourceHeatSource.C b/src/adjoint/DAFvSource/DAFvSourceHeatSource.C index 13ec0fa8..3fff3688 100755 --- a/src/adjoint/DAFvSource/DAFvSourceHeatSource.C +++ b/src/adjoint/DAFvSource/DAFvSourceHeatSource.C @@ -24,7 +24,85 @@ DAFvSourceHeatSource::DAFvSourceHeatSource( const DAIndex& daIndex) : DAFvSource(modelType, mesh, daOption, daModel, daIndex) { - this->calcFvSourceCellIndices(fvSourceCellIndices_); + const dictionary& allOptions = daOption_.getAllOptions(); + + dictionary fvSourceSubDict = allOptions.subDict("fvSource"); + + forAll(fvSourceSubDict.toc(), idxI) + { + word sourceName = fvSourceSubDict.toc()[idxI]; + dictionary sourceSubDict = fvSourceSubDict.subDict(sourceName); + word sourceType = sourceSubDict.getWord("source"); + + scalarList p1List; + sourceSubDict.readEntry("p1", p1List); + cylinderP1_.set(sourceName, p1List); + scalarList p2List; + sourceSubDict.readEntry("p2", p2List); + cylinderP2_.set(sourceName, p2List); + cylinderRadius_.set(sourceName, sourceSubDict.getScalar("radius")); + power_.set(sourceName, sourceSubDict.getScalar("power")); + + if (sourceType == "cylinderToCell") + { + fvSourceCellIndices_.set(sourceName, {}); + // all available source type are in src/meshTools/sets/cellSources + // Example of IO parameters os in applications/utilities/mesh/manipulation/topoSet + + // create a topoSet + autoPtr currentSet( + topoSet::New( + "cellSet", + mesh_, + "set0", + IOobject::NO_READ)); + // we need to change the min and max because they need to + // be of type point; however, we can't parse point type + // in pyDict, we need to change them here. + + point p1; + point p2; + p1[0] = cylinderP1_[sourceName][0]; + p1[1] = cylinderP1_[sourceName][1]; + p1[2] = cylinderP1_[sourceName][2]; + p2[0] = cylinderP2_[sourceName][0]; + p2[1] = cylinderP2_[sourceName][1]; + p2[2] = cylinderP2_[sourceName][2]; + + dictionary tmpDict; + tmpDict.set("p1", p1); + tmpDict.set("p2", p2); + tmpDict.set("radius", cylinderRadius_[sourceName]); + + // create the source + autoPtr sourceSet( + topoSetSource::New("cylinderToCell", mesh_, tmpDict)); + + // add the sourceSet to topoSet + sourceSet().applyToSet(topoSetSource::NEW, currentSet()); + // get the face index from currentSet, we need to use + // this special for loop + for (const label i : currentSet()) + { + fvSourceCellIndices_[sourceName].append(i); + } + + if (daOption_.getOption