bug fix for precision write to file and solid name in stl file

This commit is contained in:
hamidrezanorouzi 2023-01-18 12:19:31 +03:30
parent 990a4a8d52
commit 55ba36cc80
7 changed files with 78 additions and 11 deletions

View File

@ -229,6 +229,7 @@ public:
auto area = triSurface_.area().deviceVectorAll();
auto stress = stressWall_.deviceVectorAll();
auto numTri =triSurface_.size();
Kokkos::parallel_for(
"geometry::calculateStress",

View File

@ -31,7 +31,15 @@ pFlow::uniquePtr<pFlow::iFstream> pFlow::IOfileHeader::inStream()const
pFlow::uniquePtr<pFlow::oFstream> pFlow::IOfileHeader::outStream()const
{
return makeUnique<oFstream>(path());
auto osPtr = makeUnique<oFstream>(path());
if(osPtr && owner_)
{
auto outPrecision = owner_->outFilePrecision();
osPtr->precision(outPrecision);
}
return osPtr;
}
pFlow::IOfileHeader::IOfileHeader

View File

@ -178,6 +178,18 @@ public:
// - return number of repositories
size_t numRepositories()const;
virtual
size_t outFilePrecision() const
{
if(owner_)
{
return owner_->outFilePrecision();
}else
{
return 6;
}
}
// - return a ref to the underlaying data in the object
template<typename T>

View File

@ -135,6 +135,9 @@ pFlow::systemControl::systemControl
true
)
),
outFilePrecision_(
settingsDict_.getValOrSet("outFilePrecision", static_cast<size_t>(6))
),
Time_
(
this,

View File

@ -58,12 +58,15 @@ protected:
// - settingsDict fileDictionary
dictionary& settingsDict_;
// - precision for writing to file
size_t outFilePrecision_ = 6;
// - time repository
Time Time_;
// - if time control is managed externaly
bool externalTimeControl_ = false;
bool externalTimeControl_ = false;
// - acceleration
realx3 g_;
@ -178,6 +181,11 @@ public:
Time_.setSaveTimeFolder(saveToFile, timeName);
}
size_t outFilePrecision() const override
{
return outFilePrecision_;
}
};

View File

@ -101,6 +101,7 @@ bool pFlow::multiTriSurface::addTriSurface
const auto& newPoints = tSurf.points();
const auto& newVertices = tSurf.vertices();
const auto& newAreas = tSurf.area();
//
@ -112,8 +113,14 @@ bool pFlow::multiTriSurface::addTriSurface
auto vOldSize = vertices_.size();
auto vNewSize = vOldSize + newVertices.size();
vertices_.resize(vNewSize);
area_.resize(vNewSize);
auto verVec = vertices_.deviceVectorAll();
auto areaVec = area_.deviceVectorAll();
auto newVerVec = newVertices.deviceVectorAll();
auto newArea = newAreas.deviceVectorAll();
auto maxIdx = maxIndex();
Kokkos::parallel_for(
@ -121,6 +128,7 @@ bool pFlow::multiTriSurface::addTriSurface
newVertices.size(),
LAMBDA_HD(int32 i){
verVec[vOldSize+i] = newVerVec[i]+(maxIdx+1);
areaVec[vOldSize+i] = newArea[i];
}
);
Kokkos::fence();

View File

@ -61,19 +61,46 @@ bool pFlow::stlFile::readSolid
if(!checkWordToken(is, tok, "solid")) return false;
// check if there is a name associated with solid
name = "";
int32 nWords =0;
bool reachedFacet = false;
is >> tok;
if( badInput(is, tok) ) return false;
if(!tok.isWord()) return false;
if(tok.wordToken() != "facet" )
while (nWords < 20 )
{
name = tok.wordToken();
if( badInput(is, tok) ) return false;
//if(!tok.isWord()) return false;
nWords++;
if(tok.isWord() && tok.wordToken() != "facet" )
{
name += tok.wordToken();
}
else if( tok.isNumber())
{
auto val = tok.number();
name += real2Word(val);
}
else if( tok.isPunctuation())
{
name += tok.pToken();
}
else if (tok.isWord() && tok.wordToken() == "facet")
{
is.putBack(tok);
reachedFacet = true;
break;
}
else
{
return false;
}
is >> tok;
}
else
{
name = "";
is.putBack(tok);
}
if(!reachedFacet) return false;
vertecies.clear();
while(true )
{