// Construct from dictionary Foam::thoboisValve::thoboisValve ( const word& name, const polyMesh& mesh, const dictionary& dict ) : name_(name), mesh_(mesh), engineDB_(refCast<const engineTime>(mesh_.time())), csPtr_ ( coordinateSystem::New ( "coordinateSystem", dict.subDict("coordinateSystem") ) ), bottomPatch_(dict.lookup("bottomPatch"), mesh.boundaryMesh()), poppetPatch_(dict.lookup("poppetPatch"), mesh.boundaryMesh()), sidePatch_(dict.lookup("sidePatch"), mesh.boundaryMesh()), stemPatch_(dict.lookup("stemPatch"), mesh.boundaryMesh()), detachInCylinderPatch_ ( dict.lookup("detachInCylinderPatch"), mesh.boundaryMesh() ), detachInPortPatch_ ( dict.lookup("detachInPortPatch"), mesh.boundaryMesh() ), detachFacesName_(dict.lookup("detachFaces")), liftProfile_ ( "theta", "lift", name_, IFstream ( mesh.time().path()/mesh.time().constant()/ word(dict.lookup("liftProfileFile")) )() ), liftProfileStart_(min(liftProfile_.x())), liftProfileEnd_(max(liftProfile_.x())), minLift_(readScalar(dict.lookup("minLift"))), diameter_(readScalar(dict.lookup("diameter"))), staticPointsName_(dict.lookup("staticPoints")), movingPointsName_(dict.lookup("movingPoints")), movingInternalPointsName_(dict.lookup("movingInternalPoints")), staticCellsName_(dict.lookup("staticCells")), movingCellsName_(dict.lookup("movingCells")) {}
void createDummyFvMeshFiles(const polyMesh& mesh, const word& regionName) { // Create dummy system/fv* { IOobject io ( "fvSchemes", mesh.time().system(), regionName, mesh, IOobject::NO_READ, IOobject::NO_WRITE, false ); Info<< "Testing:" << io.objectPath() << endl; if (!io.headerOk()) { Info<< "Writing dummy " << regionName/io.name() << endl; dictionary dummyDict; dictionary divDict; dummyDict.add("divSchemes", divDict); dictionary gradDict; dummyDict.add("gradSchemes", gradDict); dictionary laplDict; dummyDict.add("laplacianSchemes", laplDict); IOdictionary(io, dummyDict).regIOobject::write(); } } { IOobject io ( "fvSolution", mesh.time().system(), regionName, mesh, IOobject::NO_READ, IOobject::NO_WRITE, false ); if (!io.headerOk()) { Info<< "Writing dummy " << regionName/io.name() << endl; dictionary dummyDict; IOdictionary(io, dummyDict).regIOobject::write(); } } }
Foam::displacementFvMotionSolver::displacementFvMotionSolver ( const polyMesh& mesh, Istream& ) : fvMotionSolver(mesh), points0_ ( pointIOField ( IOobject ( "points", mesh.time().constant(), polyMesh::meshSubDir, mesh, IOobject::MUST_READ, IOobject::NO_WRITE, false ) ) ) { if (points0_.size() != mesh.nPoints()) { FatalErrorIn ( "displacementFvMotionSolver::displacementFvMotionSolver\n" "(\n" " const polyMesh&,\n" " Istream&\n" ")" ) << "Number of points in mesh " << mesh.nPoints() << " differs from number of points " << points0_.size() << " read from file " << IOobject ( "points", mesh.time().constant(), polyMesh::meshSubDir, mesh, IOobject::MUST_READ, IOobject::NO_WRITE, false ).filePath() << exit(FatalError); } }
// Check writing tolerance before doing any serious work scalar getMergeDistance(const polyMesh& mesh, const scalar mergeTol) { const boundBox& meshBb = mesh.bounds(); scalar mergeDist = mergeTol * meshBb.mag(); scalar writeTol = std::pow ( scalar(10.0), -scalar(IOstream::defaultPrecision()) ); Info<< nl << "Overall mesh bounding box : " << meshBb << nl << "Relative tolerance : " << mergeTol << nl << "Absolute matching distance : " << mergeDist << nl << endl; if (mesh.time().writeFormat() == IOstream::ASCII && mergeTol < writeTol) { FatalErrorIn("getMergeDistance(const polyMesh&, const scalar)") << "Your current settings specify ASCII writing with " << IOstream::defaultPrecision() << " digits precision." << endl << "Your merging tolerance (" << mergeTol << ") is finer than this." << endl << "Please change your writeFormat to binary" << " or increase the writePrecision" << endl << "or adjust the merge tolerance (-mergeTol)." << exit(FatalError); } return mergeDist; }
Foam::displacementSBRStressFvMotionSolver::displacementSBRStressFvMotionSolver ( const polyMesh& mesh, const IOdictionary& dict ) : displacementMotionSolver(mesh, dict, dict.lookup("solver")), fvMotionSolver(mesh), cellDisplacement_ ( IOobject ( "cellDisplacement", mesh.time().timeName(), mesh, IOobject::READ_IF_PRESENT, IOobject::AUTO_WRITE ), fvMesh_, dimensionedVector ( "cellDisplacement", pointDisplacement().dimensions(), Zero ), cellMotionBoundaryTypes<vector>(pointDisplacement().boundaryField()) ), diffusivityPtr_ ( motionDiffusivity::New(fvMesh_, coeffDict().lookup("diffusivity")) ) {}
// Write set to VTK readable files void writeVTK ( const polyMesh& mesh, const topoSet& currentSet, const fileName& vtkName ) { if (isA<faceSet>(currentSet)) { // Faces of set with OpenFOAM faceID as value faceList setFaces(currentSet.size()); labelList faceValues(currentSet.size()); label setFaceI = 0; forAllConstIter(topoSet, currentSet, iter) { setFaces[setFaceI] = mesh.faces()[iter.key()]; faceValues[setFaceI] = iter.key(); setFaceI++; } primitiveFacePatch fp(setFaces, mesh.points()); writePatch ( true, currentSet.name(), fp, "faceID", faceValues, mesh.time().path()/vtkName ); }
Foam::sampledTriSurfaceMesh::sampledTriSurfaceMesh ( const word& name, const polyMesh& mesh, const dictionary& dict ) : sampledSurface(name, mesh, dict), surface_ ( IOobject ( dict.lookup("surface"), mesh.time().constant(), // instance "triSurface", // local mesh, // registry IOobject::MUST_READ, IOobject::NO_WRITE, false ) ), needsUpdate_(true), cellLabels_(0), pointToFace_(0) {}
Foam::velocityLaplacianFvMotionSolver::velocityLaplacianFvMotionSolver ( const polyMesh& mesh, const IOdictionary& dict ) : velocityMotionSolver(mesh, dict, typeName), fvMotionSolverCore(mesh), cellMotionU_ ( IOobject ( "cellMotionU", mesh.time().timeName(), mesh, IOobject::READ_IF_PRESENT, IOobject::AUTO_WRITE ), fvMesh_, dimensionedVector ( "cellMotionU", pointMotionU_.dimensions(), Zero ), cellMotionBoundaryTypes<vector>(pointMotionU_.boundaryField()) ), diffusivityPtr_ ( motionDiffusivity::New(fvMesh_, coeffDict().lookup("diffusivity")) ) {}
Foam::displacementSBRStressFvMotionSolver::displacementSBRStressFvMotionSolver ( const polyMesh& mesh, Istream& msData ) : fvMotionSolver(mesh), points0_ ( pointIOField ( IOobject ( "points", time().constant(), polyMesh::meshSubDir, mesh, IOobject::MUST_READ, IOobject::NO_WRITE ) ) ), pointDisplacement_ ( IOobject ( "pointDisplacement", fvMesh_.time().timeName(), fvMesh_, IOobject::MUST_READ, IOobject::AUTO_WRITE ), pointMesh_ ), cellDisplacement_ ( IOobject ( "cellDisplacement", mesh.time().timeName(), mesh, IOobject::READ_IF_PRESENT, IOobject::AUTO_WRITE ), fvMesh_, dimensionedVector ( "cellDisplacement", pointDisplacement_.dimensions(), vector::zero ), cellMotionBoundaryTypes<vector>(pointDisplacement_.boundaryField()) ), diffusivityPtr_ ( motionDiffusivity::New(*this, lookup("diffusivity")) ) {}
Foam::labelList Foam::ptscotchDecomp::decompose ( const polyMesh& mesh, const pointField& points, const scalarField& pointWeights ) { if (points.size() != mesh.nCells()) { FatalErrorIn ( "ptscotchDecomp::decompose(const pointField&, const scalarField&)" ) << "Can use this decomposition method only for the whole mesh" << endl << "and supply one coordinate (cellCentre) for every cell." << endl << "The number of coordinates " << points.size() << endl << "The number of cells in the mesh " << mesh.nCells() << exit(FatalError); } // // For running sequential ... // if (Pstream::nProcs() <= 1) // { // return scotchDecomp(decompositionDict_, mesh_) // .decompose(points, pointWeights); // } // Make Metis CSR (Compressed Storage Format) storage // adjncy : contains neighbours (= edges in graph) // xadj(celli) : start of information in adjncy for celli CompactListList<label> cellCells; calcCellCells(mesh, identity(mesh.nCells()), mesh.nCells(), cellCells); // Decompose using default weights List<int> finalDecomp; decomposeZeroDomains ( mesh.time().path()/mesh.name(), cellCells.m(), cellCells.offsets(), pointWeights, finalDecomp ); // Copy back to labelList labelList decomp(finalDecomp.size()); forAll(decomp, i) { decomp[i] = finalDecomp[i]; } return decomp; }
Foam::autoPtr<Foam::motionSolver> Foam::motionSolver::New(const polyMesh& mesh) { IOdictionary solverDict ( IOobject ( "dynamicMeshDict", mesh.time().constant(), mesh, IOobject::MUST_READ, IOobject::NO_WRITE, false ) ); Istream& msData = solverDict.lookup("solver"); word solverTypeName(msData); Info << "Selecting motion solver: " << solverTypeName << endl; dlLibraryTable::open ( solverDict, "motionSolverLibs", dictionaryConstructorTablePtr_ ); if (!dictionaryConstructorTablePtr_) { FatalErrorIn ( "motionSolver::New(const polyMesh& mesh)" ) << "solver table is empty" << exit(FatalError); } dictionaryConstructorTable::iterator cstrIter = dictionaryConstructorTablePtr_->find(solverTypeName); if (cstrIter == dictionaryConstructorTablePtr_->end()) { FatalErrorIn ( "motionSolver::New(const polyMesh& mesh)" ) << "Unknown solver type " << solverTypeName << endl << endl << "Valid solver types are: " << endl << dictionaryConstructorTablePtr_->sortedToc() << exit(FatalError); } return autoPtr<motionSolver>(cstrIter()(mesh, msData)); }
Foam::labelList Foam::ptscotchDecomp::decompose ( const polyMesh& mesh, const labelList& agglom, const pointField& agglomPoints, const scalarField& pointWeights ) { if (agglom.size() != mesh.nCells()) { FatalErrorIn ( "ptscotchDecomp::decompose(const labelList&, const pointField&)" ) << "Size of cell-to-coarse map " << agglom.size() << " differs from number of cells in mesh " << mesh.nCells() << exit(FatalError); } // // For running sequential ... // if (Pstream::nProcs() <= 1) // { // return scotchDecomp(decompositionDict_, mesh) // .decompose(agglom, agglomPoints, pointWeights); // } // Make Metis CSR (Compressed Storage Format) storage // adjncy : contains neighbours (= edges in graph) // xadj(celli) : start of information in adjncy for celli CompactListList<label> cellCells; calcCellCells(mesh, agglom, agglomPoints.size(), cellCells); // Decompose using weights List<int> finalDecomp; decomposeZeroDomains ( mesh.time().path()/mesh.name(), cellCells.m(), cellCells.offsets(), pointWeights, finalDecomp ); // Rework back into decomposition for original mesh labelList fineDistribution(agglom.size()); forAll(fineDistribution, i) { fineDistribution[i] = finalDecomp[agglom[i]]; } return fineDistribution; }
Foam::tmp<Foam::IOField<Type>> Foam::reconstructLagrangianField ( const word& cloudName, const polyMesh& mesh, const PtrList<fvMesh>& meshes, const word& fieldName ) { // Construct empty field on mesh tmp<IOField<Type>> tfield ( new IOField<Type> ( IOobject ( fieldName, mesh.time().timeName(), cloud::prefix/cloudName, mesh, IOobject::NO_READ, IOobject::NO_WRITE ), Field<Type>(0) ) ); Field<Type>& field = tfield.ref(); forAll(meshes, i) { // Check object on local mesh IOobject localIOobject ( fieldName, meshes[i].time().timeName(), cloud::prefix/cloudName, meshes[i], IOobject::MUST_READ, IOobject::NO_WRITE ); if (localIOobject.headerOk()) { IOField<Type> fieldi(localIOobject); label offset = field.size(); field.setSize(offset + fieldi.size()); forAll(fieldi, j) { field[offset + j] = fieldi[j]; } }
// Construct from mesh Foam::edgeStats::edgeStats(const polyMesh& mesh) : mesh_(mesh), normalDir_(3) { IOobject motionObj ( "motionProperties", mesh.time().constant(), mesh, IOobject::MUST_READ_IF_MODIFIED, IOobject::NO_WRITE ); if (motionObj.headerOk()) { Info<< "Reading " << mesh.time().constant() / "motionProperties" << endl << endl; IOdictionary motionProperties(motionObj); Switch twoDMotion(motionProperties.lookup("twoDMotion")); if (twoDMotion) { Info<< "Correcting for 2D motion" << endl << endl; autoPtr<twoDPointCorrector> correct2DPtr ( new twoDPointCorrector(mesh) ); normalDir_ = getNormalDir(&correct2DPtr()); } } }
// Construct from components Foam::enginePiston::enginePiston ( const polyMesh& mesh, const word& pistonPatchName, const autoPtr<coordinateSystem>& pistonCS, const scalar minLayer, const scalar maxLayer ) : mesh_(mesh), engineDB_(refCast<const engineTime>(mesh.time())), patchID_(pistonPatchName, mesh.boundaryMesh()), csPtr_(pistonCS), minLayer_(minLayer), maxLayer_(maxLayer) {}
Foam::motionSolver::motionSolver(const polyMesh& mesh) : IOdictionary ( IOobject ( "dynamicMeshDict", mesh.time().constant(), mesh, IOobject::MUST_READ, IOobject::NO_WRITE ) ), mesh_(mesh), twoDPointCorrector_(mesh) {}
// Construct from components Foam::dieselEngineValve::dieselEngineValve ( const word& name, const polyMesh& mesh, const autoPtr<coordinateSystem>& valveCS, const word& bottomPatchName, const word& poppetPatchName, const word& sidePatchName, const word& stemPatchName, const word& downInPortPatchName, const word& downInCylinderPatchName, const word& upInPortPatchName, const word& upInCylinderPatchName, const word& detachInCylinderPatchName, const word& detachInPortPatchName, const labelList& detachFaces, const scalar& detachTol, const graph& liftProfile, const scalar minLift, const scalar diameter ) : name_(name), mesh_(mesh), engineDB_(refCast<const engineTime>(mesh.time())), csPtr_(valveCS), bottomPatch_(bottomPatchName, mesh.boundaryMesh()), poppetPatch_(poppetPatchName, mesh.boundaryMesh()), sidePatch_(sidePatchName, mesh.boundaryMesh()), stemPatch_(stemPatchName, mesh.boundaryMesh()), downInPortPatch_(downInPortPatchName, mesh.boundaryMesh()), downInCylinderPatch_(downInCylinderPatchName, mesh.boundaryMesh()), upInPortPatch_(upInPortPatchName, mesh.boundaryMesh()), upInCylinderPatch_(upInCylinderPatchName, mesh.boundaryMesh()), detachInCylinderPatch_(detachInCylinderPatchName, mesh.boundaryMesh()), detachInPortPatch_(detachInPortPatchName, mesh.boundaryMesh()), detachFaces_(detachFaces), detachTol_(detachTol), liftProfile_(liftProfile), liftProfileStart_(min(liftProfile_.x())), liftProfileEnd_(max(liftProfile_.x())), minLift_(minLift), diameter_(diameter) {}
// Construct from components Foam::thoboisValve::thoboisValve ( const word& name, const polyMesh& mesh, const autoPtr<coordinateSystem>& valveCS, const word& bottomPatchName, const word& poppetPatchName, const word& sidePatchName, const word& stemPatchName, const word& detachInCylinderPatchName, const word& detachInPortPatchName, const word& detachFacesName, const graph& liftProfile, const scalar minLift, const scalar diameter, const word& staticPointsName, const word& movingPointsName, const word& movingInternalPointsName, const word& staticCellsName, const word& movingCellsName ) : name_(name), mesh_(mesh), engineDB_(refCast<const engineTime>(mesh.time())), csPtr_(valveCS), bottomPatch_(bottomPatchName, mesh.boundaryMesh()), poppetPatch_(poppetPatchName, mesh.boundaryMesh()), sidePatch_(sidePatchName, mesh.boundaryMesh()), stemPatch_(stemPatchName, mesh.boundaryMesh()), detachInCylinderPatch_(detachInCylinderPatchName, mesh.boundaryMesh()), detachInPortPatch_(detachInPortPatchName, mesh.boundaryMesh()), detachFacesName_(detachFacesName), liftProfile_(liftProfile), liftProfileStart_(min(liftProfile_.x())), liftProfileEnd_(max(liftProfile_.x())), minLift_(minLift), diameter_(diameter), staticPointsName_(staticPointsName), movingPointsName_(movingPointsName), movingInternalPointsName_(movingInternalPointsName), staticCellsName_(staticCellsName), movingCellsName_(movingCellsName) {}
void writeWeights(const polyMesh& mesh) { const polyBoundaryMesh& pbm = mesh.boundaryMesh(); const word tmName(mesh.time().timeName()); forAll(pbm, patchI) { if (isA<cyclicAMIPolyPatch>(pbm[patchI])) { const cyclicAMIPolyPatch& cpp = refCast<const cyclicAMIPolyPatch>(pbm[patchI]); if (cpp.owner()) { Info<< "Calculating AMI weights between owner patch: " << cpp.name() << " and neighbour patch: " << cpp.neighbPatch().name() << endl; const AMIPatchToPatchInterpolation& ami = cpp.AMI(); writeWeights ( ami.tgtWeightsSum(), cpp.neighbPatch(), "postProcessing", "tgt", tmName ); writeWeights ( ami.srcWeightsSum(), cpp, "postProcessing", "src", tmName ); } } } }
void Foam::meshToMeshNew::writeConnectivity ( const polyMesh& src, const polyMesh& tgt, const labelListList& srcToTargetAddr ) const { Pout<< "Source size = " << src.nCells() << endl; Pout<< "Target size = " << tgt.nCells() << endl; word fName("addressing_" + src.name() + "_to_" + tgt.name()); if (Pstream::parRun()) { fName = fName + "_proc" + Foam::name(Pstream::myProcNo()); } OFstream os(src.time().path()/fName + ".obj"); label vertI = 0; forAll(srcToTargetAddr, i) { const labelList& tgtAddress = srcToTargetAddr[i]; forAll(tgtAddress, j) { label tgtI = tgtAddress[j]; const vector& c0 = src.cellCentres()[i]; const cell& c = tgt.cells()[tgtI]; const pointField pts(c.points(tgt.faces(), tgt.points())); forAll(pts, j) { const point& p = pts[j]; os << "v " << p.x() << ' ' << p.y() << ' ' << p.z() << nl; vertI++; os << "v " << c0.x() << ' ' << c0.y() << ' ' << c0.z() << nl; vertI++; os << "l " << vertI - 1 << ' ' << vertI << nl; } } }
Foam::solidDisplacementFvMotionSolver::solidDisplacementFvMotionSolver ( const polyMesh& mesh, Istream& is ) : displacementFvMotionSolver(mesh, is), pointDisplacement_ ( IOobject ( "pointDisplacement", fvMesh_.time().timeName(), fvMesh_, IOobject::NO_READ, IOobject::AUTO_WRITE ), pointMesh::New(fvMesh_), dimensionedVector ( "pointDisplacement", dimLength, vector::zero ) ), cellDisplacement_ ( IOobject ( "cellDisplacement", mesh.time().timeName(), mesh, IOobject::READ_IF_PRESENT, IOobject::AUTO_WRITE ), fvMesh_, dimensionedVector ( "cellDisplacement", dimLength, vector::zero ) //, // cellMotionBoundaryTypes<vector>(pointDisplacement_.boundaryField()) ), pointLocation_(NULL), // diffusivityPtr_ // ( // motionDiffusivity::New(*this, lookup("diffusivity")) // ), frozenPointsZone_ ( found("frozenPointsZone") ? fvMesh_.pointZones().findZoneID(lookup("frozenPointsZone")) : -1 ) { IOobject io ( "pointLocation", fvMesh_.time().timeName(), fvMesh_, IOobject::MUST_READ, IOobject::AUTO_WRITE ); if (debug) { Info<< "solidDisplacementFvMotionSolver:" << nl // << " diffusivity : " << diffusivityPtr_().type() << nl << " frozenPoints zone : " << frozenPointsZone_ << endl; } if (io.headerOk()) { pointLocation_.reset ( new pointVectorField ( io, pointMesh::New(fvMesh_) ) ); if (debug) { Info<< "solidDisplacementFvMotionSolver :" << " Read pointVectorField " << io.name() << " to be used for boundary conditions on points." << nl << "Boundary conditions:" << pointLocation_().boundaryField().types() << endl; } } }
void Foam::pairPotentialList::readPairPotentialDict ( const List<word>& idList, const dictionary& pairPotentialDict, const polyMesh& mesh ) { Info<< nl << "Building pair potentials." << endl; rCutMax_ = 0.0; for (label a = 0; a < nIds_; ++a) { word idA = idList[a]; for (label b = a; b < nIds_; ++b) { word idB = idList[b]; word pairPotentialName; if (a == b) { if (pairPotentialDict.found(idA + "-" + idB)) { pairPotentialName = idA + "-" + idB; } else { FatalErrorInFunction << "Pair pairPotential specification subDict " << idA << "-" << idB << " not found" << nl << abort(FatalError); } } else { if (pairPotentialDict.found(idA + "-" + idB)) { pairPotentialName = idA + "-" + idB; } else if (pairPotentialDict.found(idB + "-" + idA)) { pairPotentialName = idB + "-" + idA; } else { FatalErrorInFunction << "Pair pairPotential specification subDict " << idA << "-" << idB << " or " << idB << "-" << idA << " not found" << nl << abort(FatalError); } if ( pairPotentialDict.found(idA+"-"+idB) && pairPotentialDict.found(idB+"-"+idA) ) { FatalErrorInFunction << "Pair pairPotential specification subDict " << idA << "-" << idB << " and " << idB << "-" << idA << " found multiple definition" << nl << abort(FatalError); } } (*this).set ( pairPotentialIndex(a, b), pairPotential::New ( pairPotentialName, pairPotentialDict.subDict(pairPotentialName) ) ); if ((*this)[pairPotentialIndex(a, b)].rCut() > rCutMax_) { rCutMax_ = (*this)[pairPotentialIndex(a, b)].rCut(); } if ((*this)[pairPotentialIndex(a, b)].writeTables()) { fileHandler().mkDir(mesh.time().path()); autoPtr<Ostream> ppTabFile ( fileHandler().NewOFstream ( mesh.time().path()/pairPotentialName ) ); if ( !(*this)[pairPotentialIndex(a, b)].writeEnergyAndForceTables ( ppTabFile() ) ) { FatalErrorInFunction << "Failed writing to " << ppTabFile().name() << nl << abort(FatalError); } } } } if (!pairPotentialDict.found("electrostatic")) { FatalErrorInFunction << "Pair pairPotential specification subDict electrostatic" << nl << abort(FatalError); } electrostaticPotential_ = pairPotential::New ( "electrostatic", pairPotentialDict.subDict("electrostatic") ); if (electrostaticPotential_->rCut() > rCutMax_) { rCutMax_ = electrostaticPotential_->rCut(); } if (electrostaticPotential_->writeTables()) { fileHandler().mkDir(mesh.time().path()); autoPtr<Ostream> ppTabFile ( fileHandler().NewOFstream ( mesh.time().path()/"electrostatic" ) ); if (!electrostaticPotential_->writeEnergyAndForceTables(ppTabFile())) { FatalErrorInFunction << "Failed writing to " << ppTabFile().name() << nl << abort(FatalError); } } rCutMaxSqr_ = rCutMax_*rCutMax_; }
polyIdPairs::polyIdPairs ( const polyMesh& mesh, const potential& pot ) : coeffVals_(), coeffNames_(), coeffNumIds_(), nIds_(0), coeffSize_(0), coeffType_("") { IOdictionary potentialDict ( IOobject ( "potentialDict", mesh.time().system(), mesh, IOobject::MUST_READ, IOobject::NO_WRITE ) ); //obtain information about pairs from pair subdict inside potentialdict const dictionary& pairDict(potentialDict.subDict("pair")); List<word> pairs(pairDict.toc());//generate list of pairs nIds_ = pot.siteIdList().size();//obtain size of siteidlist label coeffsize = 0; /** * traverse throught the list of pairs excluding electrostatic * further checking for interactions in pairs to take the total number * of species found which essentially provides a size of dynamic array * to be formed * loop until the first existing of coefficients are found after that * the loop is broken and no further traversal is done. */ for(int i = 0;i<pairs.size();i++){ if(pairs[i] != "electrostatic") { word pp = pairDict.subDict(pairs[i]).lookup("pairPotential"); if(pp!="noInteraction"){ List<word> coeff(pairDict.subDict(pairs[i]).subDict(pp+"Coeffs").toc()); //get the number of coeff's available coeffsize = coeff.size(); //set the size of coeffnames followed by generating //coeff names into coeffnames array coeffNames_.setSize(coeffsize); coeffVals_.setSize(coeffsize);//set the size of variables coeffNumIds_.setSize(coeffsize); coeffSize_ = coeffsize; coeffType_ = pp; for(int k=0; k<coeffsize;++k){ coeffNames_[k] = coeff[k]; coeffNumIds_[k] = k; } break;//break if the first existence of coeff found } } } int c = 0; for(;c < coeffsize; ++c) coeffVals_[c].setSize(nIds_); for(c = 0; c < coeffsize; ++c) for(int b = 0; b < nIds_; b++) coeffVals_[c][b].setSize(nIds_); //make the coeffs zero for(c=0;c < coeffsize; ++c){ for(int i=0; i<nIds_; ++i){ for(int j=0; j<nIds_; ++j){ coeffVals_[c][i][j] = 0; } } } /* * loop over each potential site id list to form pairs of each site id with another * essentially two loops a and b will be running on each site id to form pairs. * * for each pair created it will be checked with corresponding pairs inside potentialDict * if found pairPotential value for that pair will be obtained. * * if the obtained pair potential is not "noInteraction" then the resultant pairPotential value * will be used to form coeff string to determine "*Coeffs" value which could correspond to * 'lennardJonesCoeffs', 'morseCoeffs', '*Coeffs' anything related with pairPotential value for that * particular pair. * * further to read each value for the N species inside the coeffs we will be using coeffsize variable * value obtained at the beginning which essentially consists of number of Species inside coeffs, subsequently * we will be traversing the loop and will use the list of species name inside coeffsNames_ array */ for(int a=0; a<nIds_; a++) { word idA = pot.siteIdList()[a]; for(int b=0; b<nIds_; b++) { word idB = pot.siteIdList()[b]; word pname = idA+"-"+idB; if(pairDict.found(pname)){ word pp = pairDict.subDict(pname) .lookup("pairPotential"); if(pp!="noInteraction"){ const dictionary& coeffs = pairDict .subDict(pname) .subDict(pp+"Coeffs"); for(c=0; c<coeffsize; ++c){ scalar temp = readScalar(coeffs.lookup(coeffNames_[c])); coeffVals_[c][a][b] = temp; coeffVals_[c][b][a] = temp; }//c loop ends }//no interaction if ends }//first if condition ends }//b loop ends }//a loop ends }//end function
Foam::displacementLaplacianFvMotionSolver::displacementLaplacianFvMotionSolver ( const polyMesh& mesh, Istream& msData ) : fvMotionSolver(mesh), points0_ ( pointIOField ( IOobject ( "points", time().constant(), polyMesh::meshSubDir, mesh, IOobject::MUST_READ, IOobject::NO_WRITE, false ) ) ), pointDisplacement_ ( IOobject ( "pointDisplacement", fvMesh_.time().timeName(), fvMesh_, IOobject::MUST_READ, IOobject::AUTO_WRITE ), pointMesh_ ), cellDisplacement_ ( IOobject ( "cellDisplacement", mesh.time().timeName(), mesh, IOobject::READ_IF_PRESENT, IOobject::AUTO_WRITE ), fvMesh_, dimensionedVector ( "cellDisplacement", pointDisplacement_.dimensions(), vector::zero ), cellMotionBoundaryTypes<vector>(pointDisplacement_.boundaryField()) ), pointLocation_(NULL), diffusivityPtr_ ( motionDiffusivity::New(*this, lookup("diffusivity")) ), frozenPointsZone_ ( found("frozenPointsZone") ? fvMesh_.pointZones().findZoneID(lookup("frozenPointsZone")) : -1 ) { IOobject io ( "pointLocation", fvMesh_.time().timeName(), fvMesh_, IOobject::MUST_READ, IOobject::AUTO_WRITE ); if (debug) { Info<< "displacementLaplacianFvMotionSolver:" << nl << " diffusivity : " << diffusivityPtr_().type() << nl << " frozenPoints zone : " << frozenPointsZone_ << endl; } if (io.headerOk()) { pointLocation_.reset ( new pointVectorField ( io, pointMesh_ ) ); if (debug) { Info<< "displacementLaplacianFvMotionSolver :" << " Read pointVectorField " << io.name() << " to be used for boundary conditions on points." << nl << "Boundary conditions:" << pointLocation_().boundaryField().types() << endl; } } }
Foam::displacementInterpolationFvMotionSolver:: displacementInterpolationFvMotionSolver ( const polyMesh& mesh, Istream& is ) : displacementFvMotionSolver(mesh, is), dynamicMeshCoeffs_ ( IOdictionary ( IOobject ( "dynamicMeshDict", mesh.time().constant(), mesh, IOobject::MUST_READ, IOobject::NO_WRITE, false ) ).subDict(typeName + "Coeffs") ) { // Get zones and their interpolation tables for displacement // ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ List<Pair<word> > faceZoneToTable ( dynamicMeshCoeffs_.lookup("interpolationTables") ); const faceZoneMesh& fZones = mesh.faceZones(); times_.setSize(fZones.size()); displacements_.setSize(fZones.size()); forAll(faceZoneToTable, i) { const word& zoneName = faceZoneToTable[i][0]; label zoneI = fZones.findZoneID(zoneName); if (zoneI == -1) { FatalErrorIn ( "displacementInterpolationFvMotionSolver::" "displacementInterpolationFvMotionSolver(const polyMesh&," "Istream&)" ) << "Cannot find zone " << zoneName << endl << "Valid zones are " << mesh.faceZones().names() << exit(FatalError); } const word& tableName = faceZoneToTable[i][1]; IOList<Tuple2<scalar, vector> > table ( IOobject ( tableName, mesh.time().constant(), "tables", mesh, IOobject::MUST_READ, IOobject::NO_WRITE, false ) ); // Copy table times_[zoneI].setSize(table.size()); displacements_[zoneI].setSize(table.size()); forAll(table, j) { times_[zoneI][j] = table[j].first(); displacements_[zoneI][j] = table[j].second(); } }
Foam::displacementLaplacianFvMotionSolver::displacementLaplacianFvMotionSolver ( const polyMesh& mesh, const IOdictionary& dict ) : displacementMotionSolver(mesh, dict, typeName), fvMotionSolver(mesh), cellDisplacement_ ( IOobject ( "cellDisplacement", mesh.time().timeName(), mesh, IOobject::READ_IF_PRESENT, IOobject::AUTO_WRITE ), fvMesh_, dimensionedVector ( "cellDisplacement", pointDisplacement_.dimensions(), Zero ), cellMotionBoundaryTypes<vector>(pointDisplacement_.boundaryField()) ), pointLocation_(nullptr), diffusivityPtr_ ( motionDiffusivity::New(fvMesh_, coeffDict().lookup("diffusivity")) ), frozenPointsZone_ ( coeffDict().found("frozenPointsZone") ? fvMesh_.pointZones().findZoneID(coeffDict().lookup("frozenPointsZone")) : -1 ) { IOobject io ( "pointLocation", fvMesh_.time().timeName(), fvMesh_, IOobject::MUST_READ, IOobject::AUTO_WRITE ); if (debug) { Info<< "displacementLaplacianFvMotionSolver:" << nl << " diffusivity : " << diffusivityPtr_().type() << nl << " frozenPoints zone : " << frozenPointsZone_ << endl; } if (io.typeHeaderOk<pointVectorField>(true)) { pointLocation_.reset ( new pointVectorField ( io, pointMesh::New(fvMesh_) ) ); if (debug) { Info<< "displacementLaplacianFvMotionSolver :" << " Read pointVectorField " << io.name() << " to be used for boundary conditions on points." << nl << "Boundary conditions:" << pointLocation_().boundaryField().types() << endl; } } }
Foam::displacementComponentLaplacianFvMotionSolver:: displacementComponentLaplacianFvMotionSolver ( const polyMesh& mesh, const IOdictionary& dict ) : componentDisplacementMotionSolver(mesh, dict, type()), fvMotionSolverCore(mesh), cellDisplacement_ ( IOobject ( "cellDisplacement" + cmptName_, mesh.time().timeName(), mesh, IOobject::READ_IF_PRESENT, IOobject::AUTO_WRITE ), fvMesh_, dimensionedScalar ( "cellDisplacement", pointDisplacement_.dimensions(), 0 ), cellMotionBoundaryTypes<scalar>(pointDisplacement_.boundaryField()) ), pointLocation_(NULL), diffusivityPtr_ ( motionDiffusivity::New(fvMesh_, coeffDict().lookup("diffusivity")) ), frozenPointsZone_ ( coeffDict().found("frozenPointsZone") ? fvMesh_.pointZones().findZoneID(coeffDict().lookup("frozenPointsZone")) : -1 ) { Switch applyPointLocation ( coeffDict().lookupOrDefault ( "applyPointLocation", true ) ); if (applyPointLocation) { pointLocation_.reset ( new pointVectorField ( IOobject ( "pointLocation", fvMesh_.time().timeName(), fvMesh_, IOobject::MUST_READ, IOobject::AUTO_WRITE ), pointMesh::New(fvMesh_) ) ); //if (debug) { Info<< "displacementComponentLaplacianFvMotionSolver :" << " Read pointVectorField " << pointLocation_().name() << " to be used for boundary conditions on points." << nl << "Boundary conditions:" << pointLocation_().boundaryField().types() << endl; } } }
Foam::velocityComponentLaplacianFvMotionSolver:: velocityComponentLaplacianFvMotionSolver ( const polyMesh& mesh, Istream& msData ) : fvMotionSolver(mesh), cmptName_(msData), cmpt_(0), pointMotionU_ ( IOobject ( "pointMotionU" + cmptName_, fvMesh_.time().timeName(), fvMesh_, IOobject::MUST_READ, IOobject::AUTO_WRITE ), pointMesh_ ), cellMotionU_ ( IOobject ( "cellMotionU" + cmptName_, mesh.time().timeName(), mesh, IOobject::READ_IF_PRESENT, IOobject::AUTO_WRITE ), fvMesh_, dimensionedScalar ( "cellMotionU", pointMotionU_.dimensions(), 0 ), cellMotionBoundaryTypes<scalar>(pointMotionU_.boundaryField()) ), diffusivityPtr_ ( motionDiffusivity::New(*this, lookup("diffusivity")) ) { if (cmptName_ == "x") { cmpt_ = vector::X; } else if (cmptName_ == "y") { cmpt_ = vector::Y; } else if (cmptName_ == "z") { cmpt_ = vector::Z; } else { FatalErrorIn ( "velocityComponentLaplacianFvMotionSolver::" "velocityComponentLaplacianFvMotionSolver" "(const polyMesh& mesh, Istream& msData)" ) << "Given component name " << cmptName_ << " should be x, y or z" << exit(FatalError); } }
// Construct from components Foam::thoboisSlidingValve::thoboisSlidingValve ( const word& name, const polyMesh& mesh, const autoPtr<coordinateSystem>& valveCS, const word& bottomPatchName, const word& poppetPatchName, const word& sidePatchName, const word& stemPatchName, const word& curtainInPortPatchName, const word& curtainInCylinderPatchName, const word& detachInCylinderPatchName, const word& detachInPortPatchName, const labelList& detachFaces, const graph& liftProfile, const scalar minLift, const scalar diameter, const scalar deformationLift, const word& layeringFacesTopName, const word& layeringFacesBottomName, const word& movingCellsTopName, const word& movingCellsBottomName, const word& movingPointsTopName, const word& movingPointsBottomName, const scalar minTopLayer, const scalar maxTopLayer, const scalar minBottomLayer, const scalar maxBottomLayer, const word& staticPointsName, const word& movingPointsName, const word& staticCellsName, const word& movingCellsName ) : name_(name), mesh_(mesh), engineDB_(refCast<const engineTime>(mesh.time())), csPtr_(valveCS), bottomPatch_(bottomPatchName, mesh.boundaryMesh()), poppetPatch_(poppetPatchName, mesh.boundaryMesh()), sidePatch_(sidePatchName, mesh.boundaryMesh()), stemPatch_(stemPatchName, mesh.boundaryMesh()), curtainInCylinderPatch_(curtainInPortPatchName, mesh.boundaryMesh()), curtainInPortPatch_(curtainInPortPatchName, mesh.boundaryMesh()), detachInCylinderPatch_(detachInCylinderPatchName, mesh.boundaryMesh()), detachInPortPatch_(detachInPortPatchName, mesh.boundaryMesh()), detachFaces_(detachFaces), liftProfile_(liftProfile), liftProfileStart_(min(liftProfile_.x())), liftProfileEnd_(max(liftProfile_.x())), minLift_(minLift), diameter_(diameter), deformationLift_(deformationLift), layeringFacesTopName_(layeringFacesTopName), layeringFacesBottomName_(layeringFacesBottomName), movingCellsTopName_(movingCellsTopName), movingCellsBottomName_(movingCellsBottomName), movingPointsTopName_(movingPointsTopName), movingPointsBottomName_(movingPointsBottomName), minTopLayer_(minTopLayer), maxTopLayer_(maxTopLayer), minBottomLayer_(minBottomLayer), maxBottomLayer_(maxBottomLayer), staticPointsName_(staticPointsName), movingPointsName_(movingPointsName), staticCellsName_(staticCellsName), movingCellsName_(movingCellsName) {}
Foam::componentDisplacementMotionSolver::componentDisplacementMotionSolver ( const polyMesh& mesh, const dictionary& dict, const word& type ) : motionSolver(mesh, dict, type), cmptName_(coeffDict().lookup("component")), cmpt_(cmpt(cmptName_)), points0_ ( pointIOField ( IOobject ( "points", mesh.time().constant(), polyMesh::meshSubDir, mesh, IOobject::MUST_READ, IOobject::NO_WRITE, false ) ).component(cmpt_) ), pointDisplacement_ ( IOobject ( "pointDisplacement" + cmptName_, mesh.time().timeName(), mesh, IOobject::MUST_READ, IOobject::AUTO_WRITE ), pointMesh::New(mesh) ) { if (points0_.size() != mesh.nPoints()) { FatalErrorInFunction << "Number of points in mesh " << mesh.nPoints() << " differs from number of points " << points0_.size() << " read from file " << typeFilePath<pointIOField> ( IOobject ( "points", mesh.time().constant(), polyMesh::meshSubDir, mesh, IOobject::MUST_READ, IOobject::NO_WRITE, false ) ) << exit(FatalError); } }