30 void Foam::potential::setSiteIdList(
const dictionary& moleculePropertiesDict)
33 DynamicList<word> pairPotentialSiteIdList;
37 const word& id(idList_[i]);
39 if (!moleculePropertiesDict.found(
id))
42 <<
id <<
" molecule subDict not found" 46 const dictionary& molDict(moleculePropertiesDict.subDict(
id));
48 List<word> siteIdNames = molDict.lookup(
"siteIds");
52 const word& siteId = siteIdNames[sI];
56 siteIdList.append(siteId);
60 List<word> pairPotSiteIds = molDict.lookup(
"pairPotentialSiteIds");
64 const word& siteId = pairPotSiteIds[sI];
69 << siteId <<
" in pairPotentialSiteIds is not in siteIds: " 73 if (
findIndex(pairPotentialSiteIdList, siteId) == -1)
75 pairPotentialSiteIdList.append(siteId);
80 nPairPotIds_ = pairPotentialSiteIdList.size();
84 const word& siteId = siteIdList[aSIN];
86 if (
findIndex(pairPotentialSiteIdList, siteId) == -1)
88 pairPotentialSiteIdList.append(siteId);
92 siteIdList_.
transfer(pairPotentialSiteIdList.shrink());
96 void Foam::potential::potential::readPotentialDict()
98 Info<<
nl <<
"Reading potential dictionary:" <<
endl;
100 IOdictionary idListDict
112 idList_ = List<word>(idListDict.
lookup(
"idList"));
120 "moleculeProperties",
130 List<word> pairPotentialSiteIdList
132 SubList<word>(siteIdList_, nPairPotIds_)
135 Info<<
nl <<
"Unique site ids found: " << siteIdList_
136 <<
nl <<
"Site Ids requiring a pair potential: " 137 << pairPotentialSiteIdList
140 List<word> tetherSiteIdList(0);
142 if (idListDict.
found(
"tetherSiteIdList"))
144 tetherSiteIdList = List<word>(idListDict.
lookup(
"tetherSiteIdList"));
147 IOdictionary potentialDict
161 potentialDict.lookup(
"potentialEnergyLimit")
164 if (potentialDict.found(
"removalOrder"))
166 List<word> remOrd = potentialDict.lookup(
"removalOrder");
168 removalOrder_.
setSize(remOrd.size());
172 removalOrder_[rO] =
findIndex(idList_, remOrd[rO]);
174 if (removalOrder_[rO] == -1)
177 <<
"removalOrder entry: " << remOrd[rO]
178 <<
" not found in idList." 187 if (!potentialDict.found(
"pair"))
190 <<
"pair potential specification subDict not found" 194 const dictionary& pairDict = potentialDict.subDict(
"pair");
198 pairPotentialSiteIdList,
206 if (tetherSiteIdList.size())
208 if (!potentialDict.found(
"tether"))
211 <<
"tether potential specification subDict not found" 215 const dictionary& tetherDict = potentialDict.subDict(
"tether");
230 if (potentialDict.found(
"external"))
232 Info<<
nl <<
"Reading external forces:" <<
endl;
234 const dictionary& externalDict = potentialDict.subDict(
"external");
237 externalDict.readIfPresent(
"gravity", gravity_);
244 void Foam::potential::potential::readMdInitialiseDict
246 const IOdictionary& mdInitialiseDict,
247 IOdictionary& idListDict
250 IOdictionary moleculePropertiesDict
254 "moleculeProperties",
265 DynamicList<word> tetherSiteIdList;
267 forAll(mdInitialiseDict.toc(), zone)
269 const dictionary& zoneDict = mdInitialiseDict.subDict
271 mdInitialiseDict.toc()[zone]
274 List<word> latticeIds
276 zoneDict.lookup(
"latticeIds")
281 const word&
id = latticeIds[i];
283 if (!moleculePropertiesDict.found(
id))
286 <<
"Molecule type " <<
id 287 <<
" not found in moleculeProperties dictionary." <<
nl 297 List<word> tetherSiteIds
299 zoneDict.lookup(
"tetherSiteIds")
304 const word& tetherSiteId = tetherSiteIds[t];
306 bool idFound =
false;
315 const word&
id = latticeIds[i];
319 moleculePropertiesDict.subDict(
id).lookup(
"siteIds")
322 if (
findIndex(siteIds, tetherSiteId) != -1)
330 tetherSiteIdList.append(tetherSiteId);
335 <<
" not found as a site of any molecule in zone." <<
nl 343 tetherSiteIdList.shrink();
345 idListDict.add(
"idList", idList_);
347 idListDict.add(
"tetherSiteIdList", tetherSiteIdList);
349 setSiteIdList(moleculePropertiesDict);
362 Foam::potential::potential
371 readMdInitialiseDict(mdInitialiseDict, idListDict);
const Time & time() const
Return time.
#define forAll(list, i)
Loop across all elements in list.
#define FatalErrorInFunction
Report an error message using Foam::FatalError.
const List< word > & siteIdList() const
Ostream & endl(Ostream &os)
Add newline and flush stream.
IOdictionary is derived from dictionary and IOobject to give the dictionary automatic IO functionalit...
const word & constant() const
Return constant name.
bool found(const word &, bool recursive=false, bool patternMatch=true) const
Search dictionary for given keyword.
bool readScalar(const char *buf, doubleScalar &s)
Read whole of buf as a scalar. Return true if succesful.
errorManip< error > abort(error &err)
label findIndex(const ListType &, typename ListType::const_reference, const label start=0)
Find first occurence of given element and return index,.
void buildPotentials(const List< word > &siteIdList, const dictionary &tetherPotentialDict, const List< word > &tetherSiteIdList)
void setSize(const label)
Reset size of List.
void buildPotentials(const List< word > &idList, const dictionary &pairPotentialDict, const polyMesh &mesh)
Mesh consisting of general polyhedral cells.
const List< word > & idList() const
const word & system() const
Return system name.
void transfer(List< T > &)
Transfer the contents of the argument List into this list.
ITstream & lookup(const word &, bool recursive=false, bool patternMatch=true) const
Find and return an entry data stream.