geometryPhasicFlow-pass1 and triSurface and multiTriSurface tested
This commit is contained in:
parent
e10ee2b6b5
commit
fd039f234f
|
@ -63,7 +63,7 @@ Timer/Timer.cpp
|
|||
Timer/Timers.cpp
|
||||
|
||||
|
||||
|
||||
structuredData/zAxis/zAxis.cpp
|
||||
structuredData/box/box.cpp
|
||||
structuredData/line/line.cpp
|
||||
structuredData/infinitePlane/infinitePlane.cpp
|
||||
|
@ -85,6 +85,11 @@ structuredData/pointStructure/selectors/selectBox/selectBox.cpp
|
|||
structuredData/pointStructure/selectors/selectRange/selectRange.cpp
|
||||
structuredData/pointStructure/selectors/selectRandom/selectRandom.cpp
|
||||
|
||||
triSurface/subSurface.cpp
|
||||
triSurface/triSurface.cpp
|
||||
triSurface/multiTriSurface.cpp
|
||||
|
||||
|
||||
commandLine/commandLine.cpp
|
||||
|
||||
|
||||
|
|
|
@ -54,6 +54,10 @@ using uint64Field_D = Field<uint64>;
|
|||
|
||||
using uint64Field_H = Field<uint64, HostSpace> ;
|
||||
|
||||
using uint32x3Field_D = Field<uint32x3>;
|
||||
|
||||
using uint32x3Field_H = Field<uint32x3, HostSpace>;
|
||||
|
||||
using realField_D = Field<real>;
|
||||
|
||||
using realField_H = Field<real, HostSpace> ;
|
||||
|
|
|
@ -41,6 +41,8 @@ using uint32Vector = Vector<uint32>;
|
|||
|
||||
using uint64Vector = Vector<uint64>;
|
||||
|
||||
using uint32x3Vector = Vector<uint32x3>;
|
||||
|
||||
using realVector = Vector<real> ;
|
||||
|
||||
using realx3Vector = Vector<realx3>;
|
||||
|
|
|
@ -1,3 +1,4 @@
|
|||
#include "VectorSingle.hpp"
|
||||
/*------------------------------- phasicFlow ---------------------------------
|
||||
O C enter of
|
||||
O O E ngineering and
|
||||
|
@ -434,9 +435,29 @@ void pFlow::VectorSingle<T,MemorySpace>::assign(const VectorTypeHost& src)
|
|||
copy(deviceView(), src.hostView());
|
||||
}
|
||||
|
||||
template<typename T, typename MemorySpace>
|
||||
INLINE_FUNCTION_H
|
||||
auto pFlow::VectorSingle<T,MemorySpace>::getSpan()
|
||||
template <typename T, typename MemorySpace>
|
||||
void pFlow::VectorSingle<T, MemorySpace>::append
|
||||
(
|
||||
const std::vector<T> &appVec
|
||||
)
|
||||
{
|
||||
if(appVec.empty())return;
|
||||
|
||||
auto srcSize = appVec.size();
|
||||
uint32 oldSize = size();
|
||||
uint32 newSize = srcSize + oldSize;
|
||||
|
||||
changeSize(newSize);
|
||||
|
||||
hostViewType1D<const T> temp(appVec.data(), srcSize );
|
||||
auto dest = Kokkos::subview(view_, Kokkos::make_pair<uint32>(oldSize,newSize));
|
||||
|
||||
copy(dest, temp);
|
||||
|
||||
}
|
||||
|
||||
template <typename T, typename MemorySpace>
|
||||
INLINE_FUNCTION_H auto pFlow::VectorSingle<T, MemorySpace>::getSpan()
|
||||
{
|
||||
return span<T>(view_.data(), size());
|
||||
}
|
||||
|
|
|
@ -282,6 +282,9 @@ public:
|
|||
/// The capacity of *this becomes the capacity of src.
|
||||
INLINE_FUNCTION_H
|
||||
void assign(const VectorTypeHost& src);
|
||||
|
||||
INLINE_FUNCTION_H
|
||||
void append(const std::vector<T>& appVec);
|
||||
|
||||
INLINE_FUNCTION_H
|
||||
auto getSpan();
|
||||
|
@ -493,7 +496,8 @@ inline iOstream& operator << (iOstream& os, const VectorSingle<T, MemorySpace>&
|
|||
#endif //__VectorSingle_hpp__
|
||||
|
||||
|
||||
/*INLINE_FUNCTION_H
|
||||
/*
|
||||
INLINE_FUNCTION_H
|
||||
bool append(const deviceViewType1D<T>& dVec, size_t numElems)
|
||||
{
|
||||
|
||||
|
|
|
@ -1,71 +0,0 @@
|
|||
/*------------------------------- phasicFlow ---------------------------------
|
||||
O C enter of
|
||||
O O E ngineering and
|
||||
O O M ultiscale modeling of
|
||||
OOOOOOO F luid flow
|
||||
------------------------------------------------------------------------------
|
||||
Copyright (C): www.cemf.ir
|
||||
email: hamid.r.norouzi AT gmail.com
|
||||
------------------------------------------------------------------------------
|
||||
Licence:
|
||||
This file is part of phasicFlow code. It is a free software for simulating
|
||||
granular and multiphase flows. You can redistribute it and/or modify it under
|
||||
the terms of GNU General Public License v3 or any other later versions.
|
||||
|
||||
phasicFlow is distributed to help others in their research in the field of
|
||||
granular and multiphase flows, but WITHOUT ANY WARRANTY; without even the
|
||||
implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
|
||||
|
||||
-----------------------------------------------------------------------------*/
|
||||
|
||||
|
||||
#ifndef __bitTransfer_hpp__
|
||||
#define __bitTransfer_hpp__
|
||||
|
||||
|
||||
#include "types.hpp"
|
||||
#include "Vectors.hpp"
|
||||
|
||||
namespace pFlow
|
||||
{
|
||||
|
||||
// a simple functor that transfers 3 integers into a long variable and
|
||||
// transfer the long to 3 integers
|
||||
|
||||
class bitTransfer
|
||||
{
|
||||
protected:
|
||||
|
||||
static const int numBits_ = 21;
|
||||
static const int numBits2_ = 2 * numBits_;
|
||||
static const unsigned long mask1_ = 0x000000000001FFFFF;
|
||||
static const unsigned long mask2_ = 0x0000003FFFFE00000;
|
||||
static const unsigned long mask3_ = 0x07FFFFC0000000000;
|
||||
|
||||
public:
|
||||
|
||||
bitTransfer(){}
|
||||
|
||||
inline unsigned long operator()(const unit3& int3 )
|
||||
{
|
||||
return
|
||||
static_cast<long>(int3.x()) |
|
||||
static_cast<long>(int3.y()) << numBits_ |
|
||||
static_cast<long>(int3.z()) << numBits2_;
|
||||
}
|
||||
|
||||
inline unit3 operator() (const unsigned long& ul )
|
||||
{
|
||||
return unit3
|
||||
(
|
||||
ul & mask1_,
|
||||
(ul & mask2_)>> numBits_,
|
||||
(ul & mask3_)>> numBits2_
|
||||
);
|
||||
}
|
||||
};
|
||||
|
||||
}
|
||||
|
||||
|
||||
#endif
|
|
@ -1,234 +0,0 @@
|
|||
/*------------------------------- phasicFlow ---------------------------------
|
||||
O C enter of
|
||||
O O E ngineering and
|
||||
O O M ultiscale modeling of
|
||||
OOOOOOO F luid flow
|
||||
------------------------------------------------------------------------------
|
||||
Copyright (C): www.cemf.ir
|
||||
email: hamid.r.norouzi AT gmail.com
|
||||
------------------------------------------------------------------------------
|
||||
Licence:
|
||||
This file is part of phasicFlow code. It is a free software for simulating
|
||||
granular and multiphase flows. You can redistribute it and/or modify it under
|
||||
the terms of GNU General Public License v3 or any other later versions.
|
||||
|
||||
phasicFlow is distributed to help others in their research in the field of
|
||||
granular and multiphase flows, but WITHOUT ANY WARRANTY; without even the
|
||||
implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
|
||||
|
||||
-----------------------------------------------------------------------------*/
|
||||
|
||||
|
||||
#include "triSurface.hpp"
|
||||
#include "error.hpp"
|
||||
#include "iOstream.hpp"
|
||||
#include "triSurfaceKernels.hpp"
|
||||
|
||||
|
||||
pFlow::int32 pFlow::triSurface::addTriangle
|
||||
(
|
||||
const realx3x3 & tri,
|
||||
realx3Vector& points,
|
||||
int32x3Vector& vertices
|
||||
)
|
||||
{
|
||||
int32x3 newTri;
|
||||
|
||||
// first point
|
||||
if ( int32 i = find(points, tri.x()) ; i > -1)
|
||||
{
|
||||
newTri.x() = i; // existing point
|
||||
}
|
||||
else
|
||||
{
|
||||
points.push_back(tri.x()); // new point
|
||||
newTri.x() = static_cast<int32>(points.size()) - 1;
|
||||
}
|
||||
|
||||
// second point
|
||||
|
||||
if ( int32 j = find(points, tri.y()) ; j > -1)
|
||||
{
|
||||
newTri.y() = j; // existing point
|
||||
}
|
||||
else
|
||||
{
|
||||
points.push_back(tri.y()); // new point
|
||||
newTri.y() = static_cast<int32>(points.size()) - 1;
|
||||
}
|
||||
|
||||
// third point
|
||||
|
||||
if ( int32 k = find(points, tri.z()) ; k > -1)
|
||||
{
|
||||
newTri.z() = k; // existing point
|
||||
}
|
||||
else
|
||||
{
|
||||
points.push_back(tri.z()); // new point
|
||||
newTri.z() = static_cast<int32>(points.size()) - 1;
|
||||
}
|
||||
|
||||
// adds the new tirple vertices to the list
|
||||
vertices.push_back( newTri );
|
||||
|
||||
//output<< " points " <<points << endl;
|
||||
//output<< " vertices "<<vertices <<endl;
|
||||
|
||||
return static_cast<int32>(vertices.size()) -1;
|
||||
}
|
||||
|
||||
pFlow::int32 pFlow::triSurface::calcMaxIndex()const
|
||||
{
|
||||
|
||||
int32 maxIdx = -1;
|
||||
|
||||
if(vertices_.size()>0)
|
||||
{
|
||||
auto verDeviceVec = vertices_.deviceViewAll();
|
||||
|
||||
Kokkos::parallel_reduce(
|
||||
"triSurface::calcMaxIndex",
|
||||
vertices_.size(),
|
||||
LAMBDA_HD(int32 i, int32& valueToUpdate){
|
||||
valueToUpdate = max(valueToUpdate, max(verDeviceVec[i]));
|
||||
},
|
||||
Kokkos::Max<int32>( maxIdx )
|
||||
);
|
||||
}
|
||||
|
||||
return maxIdx;
|
||||
}
|
||||
|
||||
bool pFlow::triSurface::check()
|
||||
{
|
||||
|
||||
auto maxIdx = calcMaxIndex();
|
||||
maxIndex_ = maxIdx;
|
||||
if( maxIdx >= static_cast<int32>(points_.size())) return false;
|
||||
return true;
|
||||
}
|
||||
|
||||
|
||||
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * *//
|
||||
pFlow::triSurface::triSurface()
|
||||
:
|
||||
points_("points"),
|
||||
vertices_("vertices"),
|
||||
area_("area"),
|
||||
maxIndex_(-1)
|
||||
{}
|
||||
|
||||
pFlow::triSurface::triSurface
|
||||
(
|
||||
const realx3Vector& points,
|
||||
const int32x3Vector& vertices
|
||||
)
|
||||
:
|
||||
points_("points", "points", points),
|
||||
vertices_("vertices", "vertices", vertices),
|
||||
area_("area", "area"),
|
||||
maxIndex_(-1)
|
||||
{
|
||||
if( check() )
|
||||
{
|
||||
fatalErrorInFunction<<
|
||||
"the indices and number of points do not match. \n";
|
||||
fatalExit;
|
||||
}
|
||||
|
||||
area_.reallocate(vertices_.capacity(), vertices_.size());
|
||||
|
||||
pFlow::triSurfaceKernels::calculateArea(points_, vertices_, area_);
|
||||
|
||||
}
|
||||
|
||||
|
||||
pFlow::triSurface::triSurface
|
||||
(
|
||||
const realx3x3Vector& triangles
|
||||
)
|
||||
:
|
||||
points_("points"),
|
||||
vertices_("vertices"),
|
||||
area_("area")
|
||||
{
|
||||
|
||||
Vector<realx3> points;
|
||||
Vector<int32x3> vertices;
|
||||
|
||||
points.clear();
|
||||
vertices.clear();
|
||||
|
||||
for( const auto& tr: triangles)
|
||||
{
|
||||
if(auto i= addTriangle(tr, points, vertices); i < 0 )
|
||||
{
|
||||
fatalErrorInFunction <<
|
||||
"failed to insert a triangle into triSurface. \n";
|
||||
fatalExit;
|
||||
}
|
||||
}
|
||||
|
||||
points_.assign(points);
|
||||
|
||||
vertices_.assign(vertices);
|
||||
|
||||
area_.reallocate(vertices_.capacity(), vertices_.size());
|
||||
|
||||
pFlow::triSurfaceKernels::calculateArea(points_, vertices_, area_);
|
||||
|
||||
if( !check() )
|
||||
{
|
||||
fatalErrorInFunction<<
|
||||
"the indices and number of points do not match. \n";
|
||||
fatalExit;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
bool pFlow::triSurface::readTriSurface
|
||||
(
|
||||
iIstream& is
|
||||
)
|
||||
{
|
||||
|
||||
std::cout<<"triSurface file is binary "<< is.isBinary()<<std::endl;
|
||||
|
||||
is.fatalCheck(FUNCTION_NAME);
|
||||
|
||||
// from start of file
|
||||
if(!points_.read(is)) return false;
|
||||
|
||||
// from the current position
|
||||
if(!vertices_.read(is, true)) return false;
|
||||
|
||||
if( !check() )
|
||||
{
|
||||
ioErrorInFile( is.name(), is.lineNumber() ) <<
|
||||
"the indices and number of points do not match. \n";
|
||||
return false;
|
||||
}
|
||||
|
||||
area_.reallocate(vertices_.capacity(), vertices_.size());
|
||||
|
||||
pFlow::triSurfaceKernels::calculateArea(points_, vertices_, area_);
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
bool pFlow::triSurface::writeTriSurface
|
||||
(
|
||||
iOstream& os
|
||||
)const
|
||||
{
|
||||
|
||||
os << points_;
|
||||
os << vertices_;
|
||||
|
||||
return os.check(FUNCTION_NAME);;
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
|
@ -1,288 +0,0 @@
|
|||
/*------------------------------- phasicFlow ---------------------------------
|
||||
O C enter of
|
||||
O O E ngineering and
|
||||
O O M ultiscale modeling of
|
||||
OOOOOOO F luid flow
|
||||
------------------------------------------------------------------------------
|
||||
Copyright (C): www.cemf.ir
|
||||
email: hamid.r.norouzi AT gmail.com
|
||||
------------------------------------------------------------------------------
|
||||
Licence:
|
||||
This file is part of phasicFlow code. It is a free software for simulating
|
||||
granular and multiphase flows. You can redistribute it and/or modify it under
|
||||
the terms of GNU General Public License v3 or any other later versions.
|
||||
|
||||
phasicFlow is distributed to help others in their research in the field of
|
||||
granular and multiphase flows, but WITHOUT ANY WARRANTY; without even the
|
||||
implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
|
||||
|
||||
-----------------------------------------------------------------------------*/
|
||||
|
||||
|
||||
#ifndef __triSurface_hpp__
|
||||
#define __triSurface_hpp__
|
||||
|
||||
#include "eventSubscriber.hpp"
|
||||
#include "types.hpp"
|
||||
#include "Vectors.hpp"
|
||||
#include "VectorSingles.hpp"
|
||||
#include "Fields.hpp"
|
||||
|
||||
namespace pFlow
|
||||
{
|
||||
|
||||
|
||||
class iIstream;
|
||||
class iOstream;
|
||||
|
||||
class triSurface
|
||||
:
|
||||
public eventSubscriber
|
||||
{
|
||||
public:
|
||||
|
||||
class triangleAccessor
|
||||
{
|
||||
public:
|
||||
|
||||
protected:
|
||||
int32 numPoints_;
|
||||
|
||||
int32 numTriangles_;
|
||||
|
||||
deviceViewType1D<realx3> dPoints_;
|
||||
|
||||
deviceViewType1D<int32x3> dVectices_;
|
||||
public:
|
||||
|
||||
INLINE_FUNCTION_H
|
||||
triangleAccessor(
|
||||
int32 numPoints,
|
||||
deviceViewType1D<realx3> points,
|
||||
int32 numTrianlges,
|
||||
deviceViewType1D<int32x3> vertices )
|
||||
:
|
||||
numPoints_(numPoints),
|
||||
numTriangles_(numTrianlges),
|
||||
dPoints_(points),
|
||||
dVectices_(vertices)
|
||||
{}
|
||||
|
||||
INLINE_FUNCTION_HD
|
||||
triangleAccessor(const triangleAccessor&)= default;
|
||||
|
||||
INLINE_FUNCTION_HD
|
||||
triangleAccessor& operator=(const triangleAccessor&)= default;
|
||||
|
||||
INLINE_FUNCTION_HD
|
||||
triangleAccessor(triangleAccessor&&)= default;
|
||||
|
||||
INLINE_FUNCTION_HD
|
||||
triangleAccessor& operator=(triangleAccessor&&)= default;
|
||||
|
||||
INLINE_FUNCTION_HD
|
||||
~triangleAccessor()=default;
|
||||
|
||||
INLINE_FUNCTION_HD
|
||||
realx3x3 triangle(int32 i)const {
|
||||
auto v = dVectices_[i];
|
||||
return realx3x3(
|
||||
dPoints_[v.x_],
|
||||
dPoints_[v.y_],
|
||||
dPoints_[v.z_]);
|
||||
}
|
||||
|
||||
INLINE_FUNCTION_HD
|
||||
realx3x3 operator()(int32 i)const { return triangle(i); }
|
||||
|
||||
INLINE_FUNCTION_HD
|
||||
realx3x3 operator[](int32 i)const { return triangle(i); }
|
||||
|
||||
INLINE_FUNCTION_HD
|
||||
int32 numPoints()const { return numPoints_; }
|
||||
|
||||
INLINE_FUNCTION_HD
|
||||
int32 numTrianlges()const { return numTriangles_;}
|
||||
};
|
||||
|
||||
protected:
|
||||
|
||||
/// points of triangles
|
||||
realx3Field_D points_;
|
||||
|
||||
/// vectices indices of triangles
|
||||
int32x3Field_D vertices_;
|
||||
|
||||
/// area of each triangle
|
||||
realField_D area_;
|
||||
|
||||
int32 maxIndex_ = -1;
|
||||
|
||||
|
||||
// protected methods
|
||||
|
||||
|
||||
int32 addTriangle(const realx3x3 & tri, realx3Vector& points, int32x3Vector& vertices);
|
||||
|
||||
// - check if the range of indices in vectors match
|
||||
bool check();
|
||||
|
||||
public:
|
||||
|
||||
// - type info
|
||||
TypeInfo("triSurface");
|
||||
|
||||
//// - Constructors
|
||||
|
||||
// - empty
|
||||
triSurface();
|
||||
|
||||
// - construct from components
|
||||
triSurface(const realx3Vector& points, const int32x3Vector& vertices);
|
||||
|
||||
// - construct from vertices of triangles
|
||||
triSurface(const realx3x3Vector& triangles);
|
||||
|
||||
virtual ~triSurface() = default;
|
||||
|
||||
//// - Methods
|
||||
size_t numPoints() const
|
||||
{
|
||||
return points_.size();
|
||||
}
|
||||
|
||||
size_t numTriangles()const
|
||||
{
|
||||
return vertices_.size();
|
||||
}
|
||||
|
||||
size_t size()const
|
||||
{
|
||||
return numTriangles();
|
||||
}
|
||||
|
||||
size_t capacity()const
|
||||
{
|
||||
return vertices_.capacity();
|
||||
}
|
||||
|
||||
int32 maxIndex()const
|
||||
{
|
||||
return maxIndex_;
|
||||
}
|
||||
|
||||
auto getTriangleAccessor()const
|
||||
{
|
||||
return triangleAccessor(
|
||||
numPoints(),
|
||||
points_.deviceViewAll(),
|
||||
numTriangles(),
|
||||
vertices_.deviceViewAll()
|
||||
);
|
||||
}
|
||||
|
||||
const realx3Vector_D& points() const
|
||||
{
|
||||
return points_;
|
||||
}
|
||||
|
||||
realx3Vector_D& points()
|
||||
{
|
||||
return points_;
|
||||
}
|
||||
|
||||
const realVector_D& area()const
|
||||
{
|
||||
return area_;
|
||||
}
|
||||
|
||||
realVector_D& area()
|
||||
{
|
||||
return area_;
|
||||
}
|
||||
|
||||
const realx3* pointsData_D()const
|
||||
{
|
||||
return points_.deviceViewAll().data();
|
||||
}
|
||||
|
||||
realx3* pointsData_D()
|
||||
{
|
||||
return points_.deviceViewAll().data();
|
||||
}
|
||||
|
||||
const int32x3Vector_D& vertices() const
|
||||
{
|
||||
return vertices_;
|
||||
}
|
||||
|
||||
int32x3Vector_D& vertices()
|
||||
{
|
||||
return vertices_;
|
||||
}
|
||||
|
||||
int32x3* verticesData_D()
|
||||
{
|
||||
return vertices_.deviceViewAll().data();
|
||||
}
|
||||
|
||||
const int32x3* verticesData_D()const
|
||||
{
|
||||
return vertices_.deviceViewAll().data();
|
||||
}
|
||||
|
||||
void clear()
|
||||
{
|
||||
points_.clear();
|
||||
vertices_.clear();
|
||||
area_.clear();
|
||||
}
|
||||
|
||||
int32 calcMaxIndex()const;
|
||||
|
||||
//// - IO operations
|
||||
|
||||
bool readTriSurface(iIstream& is);
|
||||
|
||||
bool writeTriSurface(iOstream& os)const;
|
||||
|
||||
bool read(iIstream& is)
|
||||
{
|
||||
return readTriSurface(is);
|
||||
}
|
||||
|
||||
bool write(iOstream& os)const
|
||||
{
|
||||
return writeTriSurface(os);
|
||||
}
|
||||
|
||||
};
|
||||
|
||||
inline iIstream& operator >> (iIstream & is, triSurface & tri )
|
||||
{
|
||||
if(!tri.readTriSurface(is))
|
||||
{
|
||||
ioErrorInFile(is.name(), is.lineNumber())<<
|
||||
" error in reading triSurface from file.\n";
|
||||
fatalExit;
|
||||
}
|
||||
return is;
|
||||
}
|
||||
|
||||
inline iOstream& operator << (iOstream& os, const triSurface& tri)
|
||||
{
|
||||
if( !tri.writeTriSurface(os) )
|
||||
{
|
||||
ioErrorInFile(os.name(), os.lineNumber())<<
|
||||
" error in writing triSurface to file.\n";
|
||||
fatalExit;
|
||||
}
|
||||
return os;
|
||||
}
|
||||
|
||||
|
||||
} // pFlow
|
||||
|
||||
|
||||
|
||||
#endif
|
|
@ -21,7 +21,7 @@ Licence:
|
|||
|
||||
#include "multiTriSurface.hpp"
|
||||
|
||||
void pFlow::multiTriSurface::calculateVars()
|
||||
/*void pFlow::multiTriSurface::calculateVars()
|
||||
{
|
||||
numSurfaces_ = surfaceNames_.size();
|
||||
|
||||
|
@ -80,9 +80,9 @@ void pFlow::multiTriSurface::calculateVars()
|
|||
verticesStartPos_.syncViews();
|
||||
|
||||
|
||||
}
|
||||
}*/
|
||||
|
||||
pFlow::multiTriSurface::multiTriSurface()
|
||||
/*pFlow::multiTriSurface::multiTriSurface()
|
||||
:
|
||||
triSurface(),
|
||||
lastPointIndex_("lastPointIndex", "lastPointIndex"),
|
||||
|
@ -90,9 +90,9 @@ pFlow::multiTriSurface::multiTriSurface()
|
|||
surfaceNames_("surfaceNames", "surfaceNames")
|
||||
{
|
||||
calculateVars();
|
||||
}
|
||||
}*/
|
||||
|
||||
bool pFlow::multiTriSurface::addTriSurface
|
||||
/*bool pFlow::multiTriSurface::addTriSurface
|
||||
(
|
||||
const word& name,
|
||||
const triSurface& tSurf
|
||||
|
@ -152,17 +152,63 @@ bool pFlow::multiTriSurface::addTriSurface
|
|||
|
||||
return true;
|
||||
|
||||
}*/
|
||||
|
||||
pFlow::multiTriSurface::multiTriSurface
|
||||
(
|
||||
const objectFile &obj,
|
||||
repository *owner
|
||||
)
|
||||
:
|
||||
triSurface(obj, owner)
|
||||
{
|
||||
if( !IOobject::readObject() )
|
||||
{
|
||||
fatalErrorInFunction<<
|
||||
"Error in reading from file "<<IOobject::path()<<endl;
|
||||
fatalExit;
|
||||
}
|
||||
}
|
||||
|
||||
bool pFlow::multiTriSurface::addTriSurface
|
||||
bool pFlow::multiTriSurface::appendTriSurface
|
||||
(
|
||||
const word& name,
|
||||
const realx3x3Vector& vertices
|
||||
const word &name,
|
||||
const realx3x3Vector &triangles
|
||||
)
|
||||
{
|
||||
triSurface newSurf(vertices);
|
||||
uint32 start = size();
|
||||
uint32 pointStart = numPoints();
|
||||
|
||||
return addTriSurface(name, newSurf);
|
||||
if(!triSurface::appendTriSurface(triangles))
|
||||
{
|
||||
fatalErrorInFunction;
|
||||
return false;
|
||||
}
|
||||
uint32 end = size();
|
||||
uint32 pointEnd = numPoints();
|
||||
subSurfaces_.emplace_back(name, start, end, pointStart, pointEnd);
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
bool pFlow::multiTriSurface::read(iIstream &is, const IOPattern &iop)
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
bool pFlow::multiTriSurface::write
|
||||
(
|
||||
iOstream &os,
|
||||
const IOPattern &iop
|
||||
) const
|
||||
{
|
||||
if( iop.thisProcWriteData() )
|
||||
{
|
||||
os.writeWordEntry("subSurfaces", subSurfaces_);
|
||||
if(!os.check(FUNCTION_NAME))return false;
|
||||
}
|
||||
|
||||
return triSurface::write(os,iop);
|
||||
}
|
||||
|
||||
/*pFlow::real3*
|
||||
|
@ -205,37 +251,4 @@ const pFlow::real3*
|
|||
{
|
||||
if(i>=numSurfaces())return points_.data()+numPoints();
|
||||
return points_.data()+lastPointIndex_[i]+1;
|
||||
}*/
|
||||
|
||||
bool pFlow::multiTriSurface::readMultiTriSurface
|
||||
(
|
||||
iIstream& is
|
||||
)
|
||||
{
|
||||
if( !readTriSurface(is) )return false;
|
||||
|
||||
// from current position
|
||||
if(!lastPointIndex_.read(is, true)) return false;
|
||||
|
||||
if(!lastVertexIndex_.read(is, true) ) return false;
|
||||
|
||||
if( !surfaceNames_.read(is, true)) return false;
|
||||
|
||||
calculateVars();
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
bool pFlow::multiTriSurface::writeMultiTriSurface
|
||||
(
|
||||
iOstream& os
|
||||
)const
|
||||
{
|
||||
if(!writeTriSurface(os)) return false;
|
||||
|
||||
os << lastPointIndex_;
|
||||
os << lastVertexIndex_;
|
||||
os << surfaceNames_;
|
||||
|
||||
return os.check(FUNCTION_NAME);
|
||||
}
|
||||
}*/
|
|
@ -24,7 +24,8 @@ Licence:
|
|||
|
||||
|
||||
#include "triSurface.hpp"
|
||||
#include "VectorDuals.hpp"
|
||||
#include "subSurface.hpp"
|
||||
|
||||
|
||||
namespace pFlow
|
||||
{
|
||||
|
@ -34,70 +35,64 @@ class multiTriSurface
|
|||
:
|
||||
public triSurface
|
||||
{
|
||||
protected:
|
||||
private:
|
||||
|
||||
subSurfaceList subSurfaces_;
|
||||
|
||||
// - the index of last point of each triSurface
|
||||
int32Field_HD lastPointIndex_;
|
||||
|
||||
|
||||
// - the index of the last vertex of each triSurface
|
||||
int32Field_HD lastVertexIndex_;
|
||||
|
||||
|
||||
// - name of each surface
|
||||
wordField surfaceNames_;
|
||||
|
||||
|
||||
int32Field_HD surfaceNumPoints_;
|
||||
|
||||
int32Vector_HD pointsStartPos_;
|
||||
|
||||
int32Field_HD surfaceNumVertices_;
|
||||
|
||||
int32Vector_HD verticesStartPos_;
|
||||
|
||||
int32 numSurfaces_ = 0;
|
||||
|
||||
void calculateVars();
|
||||
//void calculateVars();
|
||||
|
||||
public:
|
||||
|
||||
// - type info
|
||||
TypeInfoNV("multiTriSurface");
|
||||
TypeInfo("multiTriSurface");
|
||||
|
||||
//// - Constructors
|
||||
|
||||
// - emtpy
|
||||
multiTriSurface();
|
||||
multiTriSurface(const objectFile& obj, repository* owner);
|
||||
|
||||
multiTriSurface(const multiTriSurface&) = default;
|
||||
/*multiTriSurface(const multiTriSurface&) = default;
|
||||
|
||||
multiTriSurface& operator = (const multiTriSurface&) = default;
|
||||
|
||||
multiTriSurface(multiTriSurface&&) = delete;
|
||||
|
||||
multiTriSurface& operator = (multiTriSurface&&) = delete;
|
||||
multiTriSurface& operator = (multiTriSurface&&) = delete; */
|
||||
|
||||
~multiTriSurface() = default;
|
||||
~multiTriSurface() override = default;
|
||||
|
||||
//// - Methods
|
||||
|
||||
bool addTriSurface(const word& name, const triSurface& tSurf);
|
||||
//bool addTriSurface(const word& name, const triSurface& tSurf);
|
||||
|
||||
bool addTriSurface(const word& name, const realx3x3Vector& vertices);
|
||||
bool appendTriSurface(const word& name, const realx3x3Vector& vertices);
|
||||
|
||||
int32 numSurfaces()const
|
||||
uint32 numSurfaces()const
|
||||
{
|
||||
return numSurfaces_;
|
||||
return subSurfaces_.size();
|
||||
}
|
||||
|
||||
void clear()
|
||||
const subSurfaceList& subSurfaces()const
|
||||
{
|
||||
return subSurfaces_;
|
||||
}
|
||||
/*void clear()
|
||||
{
|
||||
triSurface::clear();
|
||||
|
||||
lastPointIndex_.clear();
|
||||
surfaceNames_.clear();
|
||||
}
|
||||
}*/
|
||||
|
||||
|
||||
const auto& pointsStartPos()const
|
||||
/*const auto& pointsStartPos()const
|
||||
{
|
||||
return pointsStartPos_;
|
||||
}
|
||||
|
@ -135,27 +130,21 @@ public:
|
|||
word surfaceName(int32 i)const
|
||||
{
|
||||
return surfaceNames_[i];
|
||||
}
|
||||
}*/
|
||||
|
||||
//// - IO operations
|
||||
|
||||
bool readMultiTriSurface(iIstream& is);
|
||||
|
||||
|
||||
bool writeMultiTriSurface(iOstream& os)const;
|
||||
bool read(iIstream& is, const IOPattern& iop)override;
|
||||
|
||||
bool read(iIstream& is)
|
||||
{
|
||||
return readMultiTriSurface(is);
|
||||
}
|
||||
|
||||
bool write(iOstream& os)const
|
||||
{
|
||||
return writeMultiTriSurface(os);
|
||||
}
|
||||
bool write(iOstream& os, const IOPattern& iop)const override;
|
||||
|
||||
|
||||
};
|
||||
|
||||
inline iIstream& operator >> (iIstream & is, multiTriSurface & tri )
|
||||
/*inline iIstream& operator >> (iIstream & is, multiTriSurface & tri )
|
||||
{
|
||||
if(!tri.readMultiTriSurface(is))
|
||||
{
|
||||
|
@ -164,11 +153,11 @@ inline iIstream& operator >> (iIstream & is, multiTriSurface & tri )
|
|||
fatalExit;
|
||||
}
|
||||
return is;
|
||||
}
|
||||
}*/
|
||||
|
||||
inline iOstream& operator << (iOstream& os, const multiTriSurface& tri)
|
||||
{
|
||||
if( !tri.writeMultiTriSurface(os) )
|
||||
if( !tri.write(os, IOPattern::AllProcessorsDifferent) )
|
||||
{
|
||||
ioErrorInFile(os.name(), os.lineNumber())<<
|
||||
" error in writing multiTriSurface to file.\n";
|
|
@ -0,0 +1,26 @@
|
|||
#include "subSurface.hpp"
|
||||
|
||||
pFlow::iOstream& pFlow::operator<<(iOstream &str, const subSurface &sub)
|
||||
{
|
||||
|
||||
str.beginSquare()<<sub.name_<<token::SPACE<<
|
||||
sub.start_<<token::SPACE<<sub.end_<<token::SPACE<<
|
||||
sub.pointStart_<<token::SPACE<<sub.pointEnd_;
|
||||
str.endSquare();
|
||||
str.check(FUNCTION_NAME);
|
||||
return str;
|
||||
|
||||
}
|
||||
|
||||
pFlow::iIstream& pFlow::operator>>(iIstream &str, subSurface &sub)
|
||||
{
|
||||
str.readBeginSquare("subSurface");
|
||||
str >> sub.name_;
|
||||
str >> sub.start_;
|
||||
str >> sub.end_;
|
||||
str >> sub.pointStart_;
|
||||
str >> sub.pointEnd_;
|
||||
str.readEndSquare("subSurface");
|
||||
str.check(FUNCTION_NAME);
|
||||
return str;
|
||||
}
|
|
@ -0,0 +1,105 @@
|
|||
/*------------------------------- phasicFlow ---------------------------------
|
||||
O C enter of
|
||||
O O E ngineering and
|
||||
O O M ultiscale modeling of
|
||||
OOOOOOO F luid flow
|
||||
------------------------------------------------------------------------------
|
||||
Copyright (C): www.cemf.ir
|
||||
email: hamid.r.norouzi AT gmail.com
|
||||
------------------------------------------------------------------------------
|
||||
Licence:
|
||||
This file is part of phasicFlow code. It is a free software for simulating
|
||||
granular and multiphase flows. You can redistribute it and/or modify it under
|
||||
the terms of GNU General Public License v3 or any other later versions.
|
||||
|
||||
phasicFlow is distributed to help others in their research in the field of
|
||||
granular and multiphase flows, but WITHOUT ANY WARRANTY; without even the
|
||||
implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
|
||||
|
||||
-----------------------------------------------------------------------------*/
|
||||
|
||||
#include "types.hpp"
|
||||
#include "List.hpp"
|
||||
|
||||
namespace pFlow
|
||||
{
|
||||
|
||||
class subSurface
|
||||
{
|
||||
private:
|
||||
uint32 start_= 0;
|
||||
|
||||
uint32 end_ = 0;
|
||||
|
||||
uint32 pointStart_ = 0;
|
||||
|
||||
uint32 pointEnd_=0;
|
||||
|
||||
word name_;
|
||||
|
||||
public:
|
||||
subSurface()=default;
|
||||
|
||||
subSurface(const word& name, uint32 start, uint32 end, uint32 pointStart, uint32 pointEnd)
|
||||
:
|
||||
start_(start),
|
||||
end_(end),
|
||||
pointStart_(pointStart),
|
||||
pointEnd_(pointEnd),
|
||||
name_(name)
|
||||
{}
|
||||
|
||||
subSurface(const subSurface&) = default;
|
||||
|
||||
subSurface& operator = (const subSurface&) = default;
|
||||
|
||||
~subSurface()=default;
|
||||
|
||||
uint32 operator()(uint32 i)const
|
||||
{
|
||||
return start_ + i;
|
||||
}
|
||||
uint32 start()const
|
||||
{
|
||||
return start_;
|
||||
}
|
||||
|
||||
uint32 end()const
|
||||
{
|
||||
return end_;
|
||||
}
|
||||
|
||||
uint32 pointStart()const
|
||||
{
|
||||
return pointStart_;
|
||||
}
|
||||
|
||||
uint32 pointEnd()const
|
||||
{
|
||||
return pointEnd_;
|
||||
}
|
||||
|
||||
const auto& name()const
|
||||
{
|
||||
return name_;
|
||||
}
|
||||
|
||||
uint32 size()const
|
||||
{
|
||||
return end_-start_;
|
||||
}
|
||||
|
||||
friend iOstream& operator<< (iOstream& str, const subSurface & sub);
|
||||
|
||||
/// >> operator
|
||||
friend iIstream& operator >> (iIstream & str, subSurface & sub);
|
||||
};
|
||||
|
||||
iOstream& operator<< (iOstream& str, const subSurface & sub);
|
||||
|
||||
iIstream& operator >> (iIstream & str, subSurface & sub);
|
||||
|
||||
using subSurfaceList = List<subSurface>;
|
||||
|
||||
|
||||
}
|
|
@ -0,0 +1,262 @@
|
|||
/*------------------------------- phasicFlow ---------------------------------
|
||||
O C enter of
|
||||
O O E ngineering and
|
||||
O O M ultiscale modeling of
|
||||
OOOOOOO F luid flow
|
||||
------------------------------------------------------------------------------
|
||||
Copyright (C): www.cemf.ir
|
||||
email: hamid.r.norouzi AT gmail.com
|
||||
------------------------------------------------------------------------------
|
||||
Licence:
|
||||
This file is part of phasicFlow code. It is a free software for simulating
|
||||
granular and multiphase flows. You can redistribute it and/or modify it under
|
||||
the terms of GNU General Public License v3 or any other later versions.
|
||||
|
||||
phasicFlow is distributed to help others in their research in the field of
|
||||
granular and multiphase flows, but WITHOUT ANY WARRANTY; without even the
|
||||
implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
|
||||
|
||||
-----------------------------------------------------------------------------*/
|
||||
|
||||
|
||||
#include "triSurface.hpp"
|
||||
#include "Vectors.hpp"
|
||||
#include "triangleFunctions.hpp"
|
||||
#include "error.hpp"
|
||||
#include "iOstream.hpp"
|
||||
|
||||
//#include "triSurfaceKernels.hpp"
|
||||
|
||||
namespace pFlow
|
||||
{
|
||||
bool convertToTriSurfaceComponents
|
||||
(
|
||||
uint32 basePointIndex,
|
||||
span<realx3x3> tris,
|
||||
realx3Vector& points,
|
||||
uint32x3Vector& vertices,
|
||||
realVector& area,
|
||||
realx3Vector& normal
|
||||
)
|
||||
{
|
||||
auto nt = tris.size();
|
||||
|
||||
points.clear();
|
||||
points.reserve(nt);
|
||||
|
||||
vertices.clear();
|
||||
vertices.resize(nt);
|
||||
|
||||
area.clear();
|
||||
area.resize(nt);
|
||||
|
||||
normal.clear();
|
||||
normal.resize(nt);
|
||||
|
||||
for(auto i=0; i<nt; i++)
|
||||
{
|
||||
uint32x3 newTri;
|
||||
const auto& tri = tris[i];
|
||||
if(!pFlow::triangle::valid(tri.comp1(),tri.comp2(), tri.comp3()))
|
||||
{
|
||||
fatalErrorInFunction<<
|
||||
"Invalid triangle "<< tri << endl;
|
||||
return false;
|
||||
}
|
||||
|
||||
if(auto np = find(points, tri.comp1()); np<0 )
|
||||
{
|
||||
points.push_back(tri.comp1()); // new point
|
||||
newTri.comp1() = static_cast<uint32>( basePointIndex + points.size() - 1);
|
||||
}
|
||||
else
|
||||
{
|
||||
newTri.comp1() = basePointIndex+static_cast<uint32>(np);
|
||||
}
|
||||
|
||||
if(auto np = find(points, tri.comp2()); np<0 )
|
||||
{
|
||||
points.push_back(tri.comp2()); // new point
|
||||
newTri.comp2() = static_cast<uint32>( basePointIndex + points.size() - 1);
|
||||
}
|
||||
else
|
||||
{
|
||||
newTri.comp2() = basePointIndex+static_cast<uint32>(np);
|
||||
}
|
||||
|
||||
if(auto np = find(points, tri.comp3()); np<0 )
|
||||
{
|
||||
points.push_back(tri.comp3()); // new point
|
||||
newTri.comp3() = static_cast<uint32>( basePointIndex + points.size() - 1);
|
||||
}
|
||||
else
|
||||
{
|
||||
newTri.comp3() = basePointIndex+static_cast<uint32>(np);
|
||||
}
|
||||
|
||||
vertices[i] = newTri;
|
||||
normal[i] = triangle::normal(tri.comp1(), tri.comp2(), tri.comp3());
|
||||
area[i] = triangle::surface(tri.comp1(), tri.comp2(), tri.comp3());
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
|
||||
pFlow::triSurface::triSurface
|
||||
(
|
||||
const objectFile &obj,
|
||||
repository *owner
|
||||
)
|
||||
:
|
||||
IOobject
|
||||
(
|
||||
obj,
|
||||
IOPattern::AllProcessorsSimilar,
|
||||
owner
|
||||
),
|
||||
points_("points", "points"),
|
||||
vertices_("vertices", "vertices"),
|
||||
area_("area", "area"),
|
||||
normals_("normals","normals")
|
||||
{
|
||||
}
|
||||
|
||||
pFlow::triSurface::triSurface
|
||||
(
|
||||
const realx3x3Field_H &triangles,
|
||||
repository* owner
|
||||
)
|
||||
:
|
||||
IOobject
|
||||
(
|
||||
objectFile
|
||||
(
|
||||
triangles.name(),
|
||||
"",
|
||||
IOobject::READ_NEVER,
|
||||
IOobject::WRITE_ALWAYS
|
||||
),
|
||||
IOPattern::AllProcessorsSimilar,
|
||||
owner
|
||||
),
|
||||
points_("points", "points"),
|
||||
vertices_("vertices", "vertices"),
|
||||
area_("area", "area"),
|
||||
normals_("normals","normals")
|
||||
{
|
||||
if( !appendTriSurface(triangles) )
|
||||
{
|
||||
fatalExit;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
bool pFlow::triSurface::appendTriSurface
|
||||
(
|
||||
const realx3x3Field_H &triangles
|
||||
)
|
||||
{
|
||||
uint32 basePointIndex = numPoints();
|
||||
|
||||
auto triData = triangles.getSpan();
|
||||
|
||||
realx3Vector points("points");
|
||||
uint32x3Vector vertices("vertices");
|
||||
realVector area("area");
|
||||
realx3Vector normal("normal");
|
||||
|
||||
if( !convertToTriSurfaceComponents(
|
||||
basePointIndex,
|
||||
triData,
|
||||
points,
|
||||
vertices,
|
||||
area,
|
||||
normal))
|
||||
{
|
||||
fatalErrorInFunction<<
|
||||
"Error in constructing triSuface from raw data "<<triangles.name()<<endl;
|
||||
return false;
|
||||
}
|
||||
|
||||
points_.append(points);
|
||||
vertices_.append(vertices);
|
||||
area_.append(area);
|
||||
normals_.append(normal);
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
bool pFlow::triSurface::appendTriSurface(const realx3x3Vector &triangles)
|
||||
{
|
||||
uint32 basePointIndex = numPoints();
|
||||
|
||||
auto triData = triangles.getSpan();
|
||||
|
||||
realx3Vector points("points");
|
||||
uint32x3Vector vertices("vertices");
|
||||
realVector area("area");
|
||||
realx3Vector normal("normal");
|
||||
|
||||
if( !convertToTriSurfaceComponents(
|
||||
basePointIndex,
|
||||
triData,
|
||||
points,
|
||||
vertices,
|
||||
area,
|
||||
normal))
|
||||
{
|
||||
fatalErrorInFunction<<
|
||||
"Error in constructing triSuface from raw data "<<triangles.name()<<endl;
|
||||
return false;
|
||||
}
|
||||
|
||||
points_.append(points);
|
||||
vertices_.append(vertices);
|
||||
area_.append(area);
|
||||
normals_.append(normal);
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
bool pFlow::triSurface::read(iIstream &is, const IOPattern &iop)
|
||||
{
|
||||
points_.clear();
|
||||
if(!points_.read(is, iop))
|
||||
{
|
||||
ioErrorInFile(is.name(), is.lineNumber())<<
|
||||
" when reading field "<< points_.name()<<endl;
|
||||
return false;
|
||||
}
|
||||
|
||||
vertices_.clear();
|
||||
if(!vertices_.read(is, iop))
|
||||
{
|
||||
ioErrorInFile(is.name(), is.lineNumber())<<
|
||||
" when reading field "<< vertices_.name()<<endl;
|
||||
return false;
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
bool pFlow::triSurface::write(iOstream &os, const IOPattern &iop) const
|
||||
{
|
||||
if( !points_.write(os, iop))
|
||||
{
|
||||
ioErrorInFile(os.name(), os.lineNumber())<<
|
||||
"when writing field "<<points_.name()<<endl;
|
||||
return false;
|
||||
}
|
||||
|
||||
if( !vertices_.write(os,iop) )
|
||||
{
|
||||
ioErrorInFile(os.name(), os.lineNumber())<<
|
||||
"when writing field "<<vertices_.name()<<endl;
|
||||
return false;
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
|
@ -0,0 +1,177 @@
|
|||
/*------------------------------- phasicFlow ---------------------------------
|
||||
O C enter of
|
||||
O O E ngineering and
|
||||
O O M ultiscale modeling of
|
||||
OOOOOOO F luid flow
|
||||
------------------------------------------------------------------------------
|
||||
Copyright (C): www.cemf.ir
|
||||
email: hamid.r.norouzi AT gmail.com
|
||||
------------------------------------------------------------------------------
|
||||
Licence:
|
||||
This file is part of phasicFlow code. It is a free software for simulating
|
||||
granular and multiphase flows. You can redistribute it and/or modify it under
|
||||
the terms of GNU General Public License v3 or any other later versions.
|
||||
|
||||
phasicFlow is distributed to help others in their research in the field of
|
||||
granular and multiphase flows, but WITHOUT ANY WARRANTY; without even the
|
||||
implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
|
||||
|
||||
-----------------------------------------------------------------------------*/
|
||||
|
||||
|
||||
#ifndef __triSurface_hpp__
|
||||
#define __triSurface_hpp__
|
||||
|
||||
|
||||
#include "Vectors.hpp"
|
||||
#include "Fields.hpp"
|
||||
#include "IOobject.hpp"
|
||||
|
||||
namespace pFlow
|
||||
{
|
||||
|
||||
|
||||
class iIstream;
|
||||
class iOstream;
|
||||
class repository;
|
||||
|
||||
class triSurface
|
||||
:
|
||||
public IOobject
|
||||
{
|
||||
private:
|
||||
|
||||
/// points of triangles
|
||||
realx3Field_D points_;
|
||||
|
||||
/// vectices indices of triangles
|
||||
uint32x3Field_D vertices_;
|
||||
|
||||
/// area of each triangle
|
||||
realField_D area_;
|
||||
|
||||
/// normal vector of triangles
|
||||
realx3Field_D normals_;
|
||||
|
||||
protected:
|
||||
|
||||
triSurface(const objectFile& obj, repository* owner);
|
||||
|
||||
public:
|
||||
|
||||
// - type info
|
||||
TypeInfo("triSurface");
|
||||
|
||||
//// - Constructors
|
||||
|
||||
// - construct from vertices of triangles
|
||||
explicit triSurface(const realx3x3Field_H& triangles, repository* owner=nullptr);
|
||||
|
||||
// - construct from components
|
||||
//triSurface(const realx3Vector& points, const uint32x3Vector& vertices);
|
||||
|
||||
~triSurface() override = default;
|
||||
|
||||
bool appendTriSurface(const realx3x3Field_H& triangles);
|
||||
|
||||
bool appendTriSurface(const realx3x3Vector& triangles);
|
||||
|
||||
//// - Methods
|
||||
uint32 numPoints() const
|
||||
{
|
||||
return points_.size();
|
||||
}
|
||||
|
||||
uint32 size()const
|
||||
{
|
||||
return vertices_.size();
|
||||
}
|
||||
|
||||
uint32 capacity()const
|
||||
{
|
||||
return vertices_.capacity();
|
||||
}
|
||||
|
||||
const auto& points() const
|
||||
{
|
||||
return points_;
|
||||
}
|
||||
|
||||
auto& points()
|
||||
{
|
||||
return points_;
|
||||
}
|
||||
|
||||
const auto& area()const
|
||||
{
|
||||
return area_;
|
||||
}
|
||||
|
||||
auto& area()
|
||||
{
|
||||
return area_;
|
||||
}
|
||||
|
||||
const auto& vertices() const
|
||||
{
|
||||
return vertices_;
|
||||
}
|
||||
|
||||
auto& vertices()
|
||||
{
|
||||
return vertices_;
|
||||
}
|
||||
|
||||
auto& normals()
|
||||
{
|
||||
return normals_;
|
||||
}
|
||||
|
||||
const auto& normals()const
|
||||
{
|
||||
return normals_;
|
||||
}
|
||||
|
||||
void clear()
|
||||
{
|
||||
points_.clear();
|
||||
vertices_.clear();
|
||||
area_.clear();
|
||||
normals_.clear();
|
||||
}
|
||||
|
||||
//// - IO operations
|
||||
|
||||
bool read(iIstream& is, const IOPattern& iop) override;
|
||||
|
||||
bool write(iOstream& os, const IOPattern& iop)const override;
|
||||
};
|
||||
|
||||
inline iIstream& operator >> (iIstream & is, triSurface & tri )
|
||||
{
|
||||
if(!tri.read(is, IOPattern::AllProcessorsDifferent))
|
||||
{
|
||||
ioErrorInFile(is.name(), is.lineNumber())<<
|
||||
" error in reading triSurface from file.\n";
|
||||
fatalExit;
|
||||
}
|
||||
return is;
|
||||
}
|
||||
|
||||
inline iOstream& operator << (iOstream& os, const triSurface& tri)
|
||||
{
|
||||
if( !tri.write(os, IOPattern::AllProcessorsDifferent) )
|
||||
{
|
||||
ioErrorInFile(os.name(), os.lineNumber())<<
|
||||
" error in writing triSurface to file.\n";
|
||||
fatalExit;
|
||||
}
|
||||
return os;
|
||||
}
|
||||
|
||||
|
||||
} // pFlow
|
||||
|
||||
|
||||
|
||||
#endif
|
|
@ -23,17 +23,40 @@ Licence:
|
|||
|
||||
#include "types.hpp"
|
||||
|
||||
namespace pFlow::triangleFunctions
|
||||
namespace pFlow::triangle
|
||||
{
|
||||
|
||||
INLINE_FUNCTION_HD
|
||||
real triangleSurface( const realx3& p1, const realx3& p2, const realx3& p3)
|
||||
real surface( const realx3& p1, const realx3& p2, const realx3& p3)
|
||||
{
|
||||
realx3 V1 = p2 - p1;
|
||||
realx3 V2 = p3 - p1;
|
||||
return abs((cross(V1,V2)).length() / static_cast<real>(2.0));
|
||||
return abs((cross(V1,V2)).length()/2.0);
|
||||
}
|
||||
|
||||
INLINE_FUNCTION_HD
|
||||
realx3 normal(const realx3& p1, const realx3& p2, const realx3& p3)
|
||||
{
|
||||
auto n = cross(p2-p1, p3-p1);
|
||||
if( equal(n.length(), 0.0) )
|
||||
return zero3;
|
||||
else
|
||||
return normalize(n);
|
||||
}
|
||||
|
||||
INLINE_FUNCTION_HD
|
||||
bool valid
|
||||
(
|
||||
const realx3& p1,
|
||||
const realx3& p2,
|
||||
const realx3& p3
|
||||
)
|
||||
{
|
||||
return !equal(cross(p2-p1, p3-p1).length(), 0.0);
|
||||
}
|
||||
|
||||
|
||||
|
||||
}
|
||||
|
||||
#endif
|
|
@ -146,7 +146,23 @@ struct triple
|
|||
/// access component
|
||||
INLINE_FUNCTION_HD const T & z()const { return z_; }
|
||||
|
||||
INLINE_FUNCTION_HD const T& comp(uint32 i) const {return *(this+i);}
|
||||
/// access component
|
||||
INLINE_FUNCTION_HD T & comp1(){ return x_; }
|
||||
|
||||
/// access component
|
||||
INLINE_FUNCTION_HD const T & comp1()const { return x_; }
|
||||
|
||||
/// access component
|
||||
INLINE_FUNCTION_HD T & comp2(){ return y_; }
|
||||
|
||||
/// access component
|
||||
INLINE_FUNCTION_HD const T & comp2()const { return y_; }
|
||||
|
||||
/// access component
|
||||
INLINE_FUNCTION_HD T & comp3(){ return z_; }
|
||||
|
||||
/// access component
|
||||
INLINE_FUNCTION_HD const T & comp3()const { return z_; }
|
||||
|
||||
//// methods
|
||||
|
||||
|
|
|
@ -3,7 +3,7 @@
|
|||
|
||||
add_subdirectory(particlesPhasicFlow)
|
||||
|
||||
#add_subdirectory(geometryPhasicFlow)
|
||||
add_subdirectory(geometryPhasicFlow)
|
||||
|
||||
#add_subdirectory(pFlowToVTK)
|
||||
|
||||
|
|
|
@ -3,11 +3,11 @@ set(SourceFiles
|
|||
readFromTimeFolder.cpp
|
||||
readControlDict.cpp
|
||||
#vtkFile/vtkFile.cpp
|
||||
#geometryPhasicFlow/Wall/Wall.cpp
|
||||
#geometryPhasicFlow/planeWall/planeWall.cpp
|
||||
geometryPhasicFlow/Wall/Wall.cpp
|
||||
geometryPhasicFlow/planeWall/planeWall.cpp
|
||||
#geometryPhasicFlow/stlWall/stlWall.cpp
|
||||
#geometryPhasicFlow/cylinderWall/cylinderWall.cpp
|
||||
#geometryPhasicFlow/cuboidWall/cuboidWall.cpp
|
||||
geometryPhasicFlow/cylinderWall/cylinderWall.cpp
|
||||
geometryPhasicFlow/cuboidWall/cuboidWall.cpp
|
||||
)
|
||||
|
||||
#set(link_libs Kokkos::kokkos phasicFlow Particles Geometry)
|
||||
|
|
|
@ -2,6 +2,6 @@
|
|||
set(source_files
|
||||
geometryPhasicFlow.cpp
|
||||
)
|
||||
set(link_lib phasicFlow Geometry Kokkos::kokkos Utilities)
|
||||
set(link_lib phasicFlow Kokkos::kokkos Utilities)
|
||||
|
||||
pFlow_make_executable_install(geometryPhasicFlow source_files link_lib)
|
||||
|
|
|
@ -18,26 +18,19 @@ Licence:
|
|||
|
||||
-----------------------------------------------------------------------------*/
|
||||
|
||||
|
||||
#include "vocabs.hpp"
|
||||
#include "systemControl.hpp"
|
||||
#include "fileDictionary.hpp"
|
||||
#include "Wall.hpp"
|
||||
#include "Vectors.hpp"
|
||||
#include "VectorSingles.hpp"
|
||||
#include "multiTriSurface.hpp"
|
||||
#include "geometryMotion.hpp"
|
||||
//#include "geometryMotion.hpp"
|
||||
#include "commandLine.hpp"
|
||||
#include "readControlDict.hpp"
|
||||
//#include "readControlDict.hpp"
|
||||
|
||||
using pFlow::output;
|
||||
using pFlow::endl;
|
||||
using pFlow::IOobject;
|
||||
using pFlow::dictionary;
|
||||
using pFlow::objectFile;
|
||||
using pFlow::wordVector;
|
||||
using pFlow::Wall;
|
||||
using pFlow::geometry;
|
||||
using pFlow::realx3x3Vector;
|
||||
using pFlow::multiTriSurface;
|
||||
using pFlow::commandLine;
|
||||
|
||||
using namespace pFlow;
|
||||
|
||||
int main( int argc, char* argv[] )
|
||||
{
|
||||
|
@ -59,11 +52,10 @@ int main( int argc, char* argv[] )
|
|||
// this should be palced in each main
|
||||
#include "initialize_Control.hpp"
|
||||
|
||||
#include "setProperty.hpp"
|
||||
//#include "setProperty.hpp"
|
||||
|
||||
REPORT(0)<<"\nReading "<<"createGeometryDict"<<" . . ."<<endREPORT;
|
||||
auto objDict = IOobject::make<dictionary>
|
||||
(
|
||||
REPORT(0)<<"\nReading "<<"geometryDict"<<" . . ."<<END_REPORT;
|
||||
auto geometryDict = fileDictionary(
|
||||
objectFile
|
||||
(
|
||||
"geometryDict",
|
||||
|
@ -71,46 +63,55 @@ int main( int argc, char* argv[] )
|
|||
objectFile::READ_ALWAYS,
|
||||
objectFile::WRITE_NEVER
|
||||
),
|
||||
"geometryDict",
|
||||
true
|
||||
nullptr
|
||||
);
|
||||
|
||||
auto& geometryDict = objDict().getObject<dictionary>();
|
||||
|
||||
|
||||
auto& surfacesDict = geometryDict.subDict("surfaces");
|
||||
|
||||
auto wallsDictName = surfacesDict.dictionaryKeywords();
|
||||
|
||||
|
||||
|
||||
multiTriSurface surface;
|
||||
wordVector materials;
|
||||
wordVector motion;
|
||||
multiTriSurface surface
|
||||
(
|
||||
objectFile
|
||||
(
|
||||
triSurfaceFile__,
|
||||
"",
|
||||
objectFile::READ_NEVER,
|
||||
objectFile::WRITE_ALWAYS
|
||||
),
|
||||
&Control.geometry()
|
||||
);
|
||||
|
||||
//wordVector materials;
|
||||
//wordVector motion;
|
||||
|
||||
for(auto& name:wallsDictName)
|
||||
{
|
||||
REPORT(1)<<"Creating wall "<<greenText(name)<<" from file dictionary . . . "<<endREPORT;
|
||||
REPORT(1)<<"Creating wall "<<Green_Text(name)<<" from dictionary "<<surfacesDict.globalName() <<END_REPORT;
|
||||
auto wallPtr = Wall::create( surfacesDict.subDict(name));
|
||||
auto& wall = wallPtr();
|
||||
REPORT(1)<<"wall type is "<<greenText(wall.typeName())<<'\n'<<endREPORT;
|
||||
REPORT(1)<<"wall type is "<<Green_Text(wall.typeName())<<'\n'<<END_REPORT;
|
||||
|
||||
realx3x3Vector trinalges(wall.name());
|
||||
trinalges = wall.triangles();
|
||||
surface.addTriSurface(wall.name(), trinalges);
|
||||
materials.push_back(wall.materialName());
|
||||
motion.push_back(wall.motionName());
|
||||
realx3x3Vector trinalges(wall.name(), wall.triangles());
|
||||
|
||||
surface.appendTriSurface(wall.name(), trinalges);
|
||||
/*materials.push_back(wall.materialName());
|
||||
motion.push_back(wall.motionName());*/
|
||||
}
|
||||
|
||||
REPORT(1)<<"Selected wall materials are "<<cyanText(materials)<<'\n'<<endREPORT;
|
||||
output<<surface<<endl;
|
||||
//REPORT(1)<<"Selected wall materials are "<<cyanText(materials)<<'\n'<<endREPORT;
|
||||
|
||||
REPORT(0)<< "\nCreating geometry . . ."<<endREPORT;
|
||||
/*REPORT(0)<< "\nCreating geometry . . ."<<endREPORT;
|
||||
auto geomPtr = geometry::create(Control, proprties, geometryDict, surface, motion, materials);
|
||||
REPORT(1)<< "geometry type is "<< greenText(geomPtr().typeName())<<endREPORT;
|
||||
|
||||
REPORT(1)<< "Writing geometry to folder "<< geomPtr().path()<<endREPORT;
|
||||
geomPtr().write();
|
||||
geomPtr().write();*/
|
||||
|
||||
REPORT(0)<< greenText("\nFinished successfully.\n");
|
||||
REPORT(0)<< Green_Text("\nFinished successfully.\n")<<END_REPORT;
|
||||
|
||||
// this should be palced in each main
|
||||
#include "finalize.hpp"
|
||||
|
|
Loading…
Reference in New Issue