Go to the documentation of this file.00001 
00002 
00003 
00004 
00005 
00006 
00007 
00008 
00009 
00010 
00011 
00012 
00013 
00014 
00015 
00016 
00017 
00018 
00019 
00020 
00021 
00022 
00023 
00024 
00025 
00026 #include <potential/tetherPotentialList.H>
00027 
00028 
00029 
00030 void Foam::tetherPotentialList::readTetherPotentialDict
00031 (
00032     const List<word>& siteIdList,
00033     const dictionary& tetherPotentialDict,
00034     const List<word>& tetherSiteIdList
00035 )
00036 {
00037 
00038     Info<< nl << "Building tether potentials." << endl;
00039 
00040     idMap_ = List<label>(siteIdList.size(), -1);
00041 
00042     label tetherMapIndex = 0;
00043 
00044     forAll(tetherSiteIdList, t)
00045     {
00046         word tetherPotentialName = tetherSiteIdList[t];
00047 
00048         label tetherId = findIndex(siteIdList, tetherPotentialName);
00049 
00050         if (tetherId == -1)
00051         {
00052             FatalErrorIn("tetherPotentialList::readTetherPotentialDict")
00053                 << nl << "No matching entry found in siteIdList for tether name "
00054                 << tetherPotentialName
00055                 << abort(FatalError);
00056         }
00057         else if (!tetherPotentialDict.found(tetherPotentialName))
00058         {
00059             FatalErrorIn("tetherPotentialList::readTetherPotentialDict")
00060                 << nl << "tether potential specification subDict "
00061                 << tetherPotentialName << " not found"
00062                 << abort(FatalError);
00063         }
00064         else
00065         {
00066             this->set
00067             (
00068                 tetherMapIndex,
00069                 tetherPotential::New
00070                 (
00071                     tetherPotentialName,
00072                     tetherPotentialDict.subDict(tetherPotentialName)
00073                 )
00074             );
00075         }
00076 
00077         idMap_[tetherId] = tetherMapIndex;
00078 
00079         tetherMapIndex++;
00080     }
00081 }
00082 
00083 
00084 
00085 
00086 Foam::tetherPotentialList::tetherPotentialList()
00087 :
00088     PtrList<tetherPotential>(),
00089     idMap_()
00090 {}
00091 
00092 
00093 Foam::tetherPotentialList::tetherPotentialList
00094 (
00095     const List<word>& siteIdList,
00096     const dictionary& tetherPotentialDict,
00097     const List<word>& tetherSiteIdList
00098 )
00099 :
00100     PtrList<tetherPotential>(),
00101     idMap_()
00102 {
00103     buildPotentials(siteIdList, tetherPotentialDict, tetherSiteIdList);
00104 }
00105 
00106 
00107 
00108 
00109 Foam::tetherPotentialList::~tetherPotentialList()
00110 {}
00111 
00112 
00113 
00114 
00115 void Foam::tetherPotentialList::buildPotentials
00116 (
00117     const List<word>& siteIdList,
00118     const dictionary& tetherPotentialDict,
00119     const List<word>& tetherSiteIdList
00120 )
00121 {
00122     setSize(tetherSiteIdList.size());
00123 
00124     readTetherPotentialDict(siteIdList, tetherPotentialDict, tetherSiteIdList);
00125 }
00126 
00127 
00128 const Foam::tetherPotential& Foam::tetherPotentialList::tetherPotentialFunction
00129 (
00130     const label a
00131 ) const
00132 {
00133     return (*this)[tetherPotentialIndex(a)];
00134 }
00135 
00136 
00137 Foam::vector Foam::tetherPotentialList::force
00138 (
00139     const label a,
00140     const vector rIT
00141 ) const
00142 {
00143     return (*this)[tetherPotentialIndex(a)].force(rIT);
00144 }
00145 
00146 
00147 Foam::scalar Foam::tetherPotentialList::energy
00148 (
00149     const label a,
00150     const vector rIT
00151 ) const
00152 {
00153     return (*this)[tetherPotentialIndex(a)].energy(rIT);
00154 }
00155 
00156 
00157