20 static LoggerPtr logger(Logger::getLogger(
"pz.pre.pzhyperplane"));
30 typedef std::map<std::pair<int64_t, int64_t>, int64_t> midsidetype;
31 midsidetype midsidenodes;
34 for (int64_t iel = 0; iel<nelem ; iel++)
42 int nsides = gel->
NSides();
43 for (
int is=0; is<nsides; is++) {
53 if (sidenodeindexes[0] > sidenodeindexes[1]) {
54 int64_t temp = sidenodeindexes[0];
55 sidenodeindexes[0] = sidenodeindexes[1];
56 sidenodeindexes[1] = temp;
58 std::pair<int64_t, int64_t> nodepair(sidenodeindexes[0],sidenodeindexes[1]);
60 if (midsidenodes.find(nodepair) != midsidenodes.end()) {
64 inputmesh.
NodeVec()[sidenodeindexes[0]].GetCoordinates(x0);
65 inputmesh.
NodeVec()[sidenodeindexes[1]].GetCoordinates(x1);
66 bool left0 = plane.
IsLeft(x0);
67 bool left1 = plane.
IsLeft(x1);
75 targetmesh.
NodeVec()[newnode].Initialize(xnew, targetmesh);
76 midsidenodes[nodepair] = newnode;
83 for (int64_t iel = 0; iel<nelem ; iel++)
94 int nsides = gel->
NSides();
96 for (
int is=0; is<nsides; is++) {
106 if (sidenodeindexes[0] > sidenodeindexes[1]) {
107 int64_t temp = sidenodeindexes[0];
108 sidenodeindexes[0] = sidenodeindexes[1];
109 sidenodeindexes[1] = temp;
111 std::pair<int64_t, int64_t> nodepair(sidenodeindexes[0],sidenodeindexes[1]);
113 if (midsidenodes.find(nodepair) == midsidenodes.end()) {
116 sidenodepair.
Push(std::pair<int64_t,int64_t>(is,midsidenodes[nodepair]));
119 if (sidenodepair.
size() == 0) {
122 if (sidenodepair.
size() == 3) {
124 for (
int i=0; i<3; i++) {
125 nodeindices[i] = sidenodepair[i].second;
130 else if (sidenodepair.
size() == 4)
133 if (logger->isDebugEnabled()) {
134 std::stringstream sout;
135 sout <<
"Corner coords\n";
137 for (
int i=0; i<gel->
NNodes(); i++) {
141 isleft[i] = plane.
IsLeft(x);
143 sout << x <<
" distance " << distance <<
" isleft " << isleft[i] << std::endl;
148 Reorder(gel, targetmesh, sidenodepair);
152 if (logger->isDebugEnabled()) {
153 std::stringstream sout;
156 for (
int i=0; i<4; i++) {
158 targetmesh.
NodeVec()[sidenodepair[i].second].GetCoordinates(XNodes[i]);
159 sout <<
"Node " << i <<
" coordinate " << XNodes[i] << std::endl;
166 for (
int i=0; i<4; i++) {
167 nodeindices[i] = sidenodepair[i].second;
176 if (logger->isDebugEnabled()) {
177 std::stringstream sout;
178 sout <<
"cornercoordinates\n";
180 for (
int ic=0; ic<nc; ic++) {
183 sout <<
"node " << ic <<
' ' << x << std::endl;
185 sout <<
"Intersection coordinates\n";
186 int64_t sz = sidenodepair.
size();
189 for (int64_t i=0; i<sz; i++) {
191 targetmesh.
NodeVec()[sidenodepair[i].second].GetCoordinates(XNodes[i]);
192 sout <<
"Node " << i <<
" side " << sidenodepair[i].first <<
" coordinate " << XNodes[i] << std::endl;
197 int64_t numnodes = sidenodepair.
size();
198 for (int64_t in=0; in<numnodes; in++) {
200 nodeindices[0] = centerindex;
201 nodeindices[1] = sidenodepair[in].second;
202 nodeindices[2] = sidenodepair[(in+1)%numnodes].second;
207 std::cout <<
"caso com " << sidenodepair.
size() <<
" nos " << std::endl;
218 gelside.
X(edgeparam, X);
219 REAL distance = plane.
Distance(X,planejac);
221 while (
std::abs(distance) > 1.e-6 && niter < 5) {
225 gelside.
Jacobian(edgeparam,edgejac, axes, detjac, jacinv);
227 for (
int i=0; i<3; i++) {
228 inner += axes(0,i)*planejac[i];
230 edgeparam[0] -= jacinv(0,0)*distance/inner;
231 gelside.
X(edgeparam, X);
232 distance = plane.
Distance(X, planejac);
243 if (sidenodepair.size() != 4) {
249 if (logger->isDebugEnabled()) {
250 std::stringstream sout;
254 for (
int i=0; i<4; i++) {
256 target.
NodeVec()[sidenodepair[i].second].GetCoordinates(XNodes[i]);
257 sout <<
"Node " << i <<
" coordinate " << XNodes[i] << std::endl;
264 for (
int perm=0; perm<3; perm++) {
266 for (
int i=0; i<3; i++) {
267 locnodes[(i+perm)%3] = sidenodepair[i];
269 locnodes[3] = sidenodepair[3];
273 for (
int i=0; i<4; i++) {
275 target.
NodeVec()[locnodes[i].second].GetCoordinates(XNodes[i]);
278 TPZManVector<REAL,3> vecedge1(3),vecedge2(3,0.),vecedge3(3,0.), normaltri(3),vecpoint3(3),normaledge3(3);
279 vecedge1 = XNodes[1]-XNodes[0];
280 vecedge2 = XNodes[2]-XNodes[1];
281 vecedge3 = XNodes[0]-XNodes[2];
282 vecpoint3 = XNodes[3]-XNodes[2];
286 for (
int i=0; i<3; i++) {
287 inner += vecpoint3[i]*normaledge3[i];
291 if (inner > 1.e-10 || normvecpoint3 < 1.e-8 || normvecedge1 < 1.e-8) {
294 if (logger->isDebugEnabled()) {
295 std::stringstream sout;
296 sout <<
"Permutation = " << perm << std::endl;
297 sout <<
"vecpoint3 " << vecpoint3 << std::endl;
298 sout <<
"vecedge1 " << vecedge1 << std::endl;
299 sout <<
"vecedge2 " << vecedge2 << std::endl;
300 sout <<
"vecedge3 " << vecedge3 << std::endl;
301 sout <<
"normaledge3 " << normaledge3 << std::endl;
302 sout <<
"inner " << inner <<
" normvecpoint3 " << normvecpoint3 <<
" normvecedge1 " << normvecedge1 << std::endl;
303 sout <<
"locnodes " << locnodes << std::endl;
304 sout <<
"sidenodepair = " << sidenodepair << std::endl;
308 sidenodepair = locnodes;
321 for (
int node=0; node<4; node++) {
327 tr.
Apply(pt0, ptnode);
329 gel->
Jacobian(ptnode, jac, axes, detjac, jacinv);
330 normals[node].
Resize(3,0.);
331 if (
fabs(detjac) < 1.e-10) {
335 for (
int i=0; i<3; i++) {
341 for (
int i=0; i<4; i++) {
342 for (
int j=0; j<4; j++) {
344 for (
int k=0; k<3; k++) {
345 inner(i,j) += normals[i][k]*normals[j][k];
349 for (
int i=0; i<4; i++) {
350 for (
int j=0; j<4; j++) {
351 if (inner(i,j) < 0.) {
352 inner.
Print(
"inner");
362 int64_t numnodes = sidenodepair.size();
364 if (logger->isDebugEnabled()) {
365 std::stringstream sout;
368 for (int64_t i=0; i<numnodes; i++) {
370 target.
NodeVec()[sidenodepair[i].second].GetCoordinates(XNodes[i]);
371 sout <<
"Node " << i <<
" coordinate " << XNodes[i] << std::endl;
379 for (int64_t i=0; i<numnodes; i++) {
381 target.
NodeVec()[sidenodepair[i].second].GetCoordinates(XNodes[i]);
382 for (
int j=0; j<3; j++) {
383 center[j] += XNodes[i][j]/numnodes;
387 target.
NodeVec()[centerindex].Initialize(center, target);
390 int imax=0, jmax = 0, maxnorm = 0.;
392 for (int64_t in=0; in < numnodes; in++) {
394 veci = XNodes[in]-center;
396 for (int64_t jn=0; jn<numnodes; jn++) {
398 vecj = XNodes[jn]-center;
402 normalnorm(in,jn) = vecprodnorm;
403 if (vecprodnorm > maxnorm) {
404 maxnorm = vecprodnorm;
412 veci = XNodes[imax]-center;
413 vecj = XNodes[jmax]-center;
421 for (int64_t in=0; in<numnodes; in++) {
424 vecnod = XNodes[in]-center;
425 for (
int i=0; i<3; i++) {
426 x += veci[i]*vecnod[i];
427 y += vecj[i]*vecnod[i];
429 angles[in] =
atan2(x, y);
433 std::multimap<REAL, std::pair<int64_t,int64_t> > ordered;
434 for (int64_t in=0; in<numnodes; in++) {
435 ordered.insert(std::pair<REAL,std::pair<int64_t,int64_t> >(angles[in],sidenodepair[in]));
437 std::multimap<REAL, std::pair<int64_t,int64_t> >::iterator it;
439 for (it=ordered.begin(); it!= ordered.end(); it++) {
440 sidenodepair[count] = it->second;
virtual int64_t SideNodeIndex(int side, int nodenum) const =0
Returns the index of the nodenum node of side.
TPZFlopCounter atan2(const TPZFlopCounter &val1, const TPZFlopCounter &val2)
Returns the arc tangent in radians and increments the counter of the Arc Tangent. ATAN2 returns the ...
expr_ expr_ expr_ expr_ expr_ expr_ expr_ expr_ expr_ expr_ expr_ expr_ expr_ expr_ expr_ expr_ expr_ expr_ expr_ expr_ expr_ expr_ expr_ expr_ expr_ expr_ expr_ expr_ expr_ expr_ fabs
int AllocateNewElement()
Makes more room for new elements.
TPZGeoNode * NodePtr(int i) const
Returns a pointer to the ith node of the element.
Contains definitions to LOGPZ_DEBUG, LOGPZ_INFO, LOGPZ_WARN, LOGPZ_ERROR and LOGPZ_FATAL, and the implementation of the inline InitializePZLOG(string) function using log4cxx library or not. It must to be called out of "#ifdef LOG4CXX" scope.
Contains declaration of TPZGeoElRefLess class which implements the mapping between the master element...
Implements a vector class which allows to use external storage provided by the user. Utility.
virtual int NCornerNodes() const =0
Returns the number of corner nodes of the element.
int64_t NElements() const
Number of elements of the mesh.
Utility class which represents an element with its side. The Geometric approximation classes Geometry...
Implements the mapping between the master element and deformed element. Geometry. ...
TinyFad< 8, T > abs(const TinyFad< 8, T > &in)
This class implements a simple vector storage scheme for a templated class T. Utility.
void Reorder(TPZGeoEl *gel, TPZGeoMesh &target, TPZVec< std::pair< int64_t, int64_t > > &sidenodepair)
reorder the nodes to form a convex figure
virtual int NSides() const =0
Returns the number of connectivities of the element.
virtual int SideDimension(int side) const =0
Return the dimension of side.
virtual void Resize(const int64_t newsize, const T &object)
Resizes the vector object.
static void NormalizeVetor3(TPZVec< Tvar > &vetor)
Normalizes the vector with 3 elements.
static void ProdVetorial(TPZVec< Tvar > &u, TPZVec< Tvar > &v, TPZVec< Tvar > &result)
Computes the vectorial product u x v.
static void CheckElement(TPZGeoEl *gel)
int64_t size() const
Returns the number of elements of the vector.
Contains declaration of TPZMesh class which defines a geometrical mesh and contains a corresponding l...
void Push(const T object)
Pushes a copy of the object on the stack.
Defines the behaviour of all geometric elements. GeometryTPZGeoEl is the common denominator for all g...
Contains TPZMatrixclass which implements full matrix (using column major representation).
#define DebugStop()
Returns a message to user put a breakpoint in.
#define LOGPZ_DEBUG(A, B)
Define log for debug info.
void X(TPZVec< REAL > &loc, TPZVec< REAL > &result) const
X coordinate of a point loc of the side.
Contains the TPZReadMeshHR class which reads a mesh in a "human readable" format. ...
void Jacobian(TPZVec< REAL > &qsi, TPZFMatrix< REAL > &jac, TPZFMatrix< REAL > &axes, REAL &detjac, TPZFMatrix< REAL > &jacinv) const
Compute a decomposition of the gradient of the mapping function, as a rotation matrix (Jacobian) and ...
TPZAdmChunkVector< TPZGeoNode > & NodeVec()
void Intersect(TPZGeoMesh &input, const TPZHyperPlane &plane, TPZGeoMesh &target)
Compute the intersection of the geometric mesh with the plane (only leaf elements) ...
bool IsLeft(TPZVec< REAL > &point) const
REAL Distance(const TPZVec< REAL > &point, TPZVec< REAL > &jacobian) const
virtual int HasSubElement() const =0
Return 1 if the element has subelements.
virtual int NNodes() const =0
Returns the number of nodes of the element.
void BuildConnectivity()
Build the connectivity of the grid.
virtual int Dimension() const =0
Returns the dimension of the element.
virtual TPZTransform< REAL > SideToSideTransform(int sidefrom, int sideto)=0
Compute the transformation between the master element space of one side of an element to the master e...
int ReorderGeneral(TPZGeoMesh &target, TPZVec< std::pair< int64_t, int64_t > > &sidenodepair)
a version which allows for more than 4 nodes
static Tvar Norm(const TPZVec< Tvar > &vetor)
Returns the L2-norm of the vector.
This class implements a geometric mesh for the pz environment. Geometry.
This class implements a stack object. Utility.
void Jacobian(TPZVec< REAL > ¶m, TPZFMatrix< REAL > &jacobian, TPZFMatrix< REAL > &axes, REAL &detjac, TPZFMatrix< REAL > &jacinv) const
Jacobian associated with the side of the element.
virtual void Print(std::ostream &out) const
void GetCoordinates(TPZVec< REAL > &co)
Fill the coordinates of the node.
Reads a mesh in a "human readable" format, i.e. in text format and with coments. Getting Data...
virtual void Print(std::ostream &out=std::cout)
Print all relevant data of the element to cout.
Contains declaration of the TPZNumeric class which implements several methods to calculation.
Non abstract class which implements full matrices with preallocated storage with (N+1) entries...
REAL EdgeIntersect(const TPZGeoElSide &gelside, const TPZHyperPlane &plane)
Compute the intersection between the edge and the plane.
TPZAdmChunkVector< TPZGeoEl * > & ElementVec()
Methods for handling pzlists.