G+Smo  25.01.0
Geometry + Simulation Modules
 
Loading...
Searching...
No Matches
gsCPPInterface.hpp
1
16#pragma once
17
18#include <gsCore/gsMultiPatch.h>
22
23namespace gismo {
24
25template<class T>
27 const gsMultiBasis<T> & basis,
28 const boundaryInterface & bi,
29 const gsOptionList & opt)
30 : m_slaveGeom( &(mp[bi.first().patch ])),
31 m_masterGeom( &(mp[bi.second().patch ])),
32 m_masterBdr((mp[bi.second().patch]).boundary(bi.second())),
33 m_slaveBasis(&(basis[bi.first().patch ])),
34 m_masterBasis(&(basis[bi.second().patch])),
35 m_boundaryInterface(bi),
36 m_Tolerance(opt.getReal("Tolerance"))
37{
38
39 GISMO_ASSERT( m_slaveGeom->geoDim()==m_masterBdr->geoDim(), "gsCPPInterface: Dimensions do not agree." );
40
41 m_fixedDir = m_boundaryInterface.second().direction();
42 // Index of the parametric direction which is normal to the boundary of the master surface
43 m_fixedParam = m_boundaryInterface.second().parameter();
44 // Value of the parameter in the fixed direction ( usually 0 or 1).
45 // This is constant on the entire master boundary
46
47 // Vector with the ordered indices of directions that are 'free' i.e. not the m_fixedDir
48 for (index_t j=0; j<m_masterBdr->domainDim(); j++)
49 {
50 if (j != m_fixedDir ) { m_freeDirs.push_back(j); }
51 }
52}
53
54
55template <class T>
57{
58 m_masterBdr = m_masterGeom->boundary(m_boundaryInterface.second());
59}
60
61template <class T>
63{
64 GISMO_ASSERT( u.rows() == domainDim(), "gsCPPInterface::eval_into: "
65 "The rows of the evaluation points must be equal to the dimension of the domain." );
66
67 gsVector<T> masterParams;
68 /* -- version with isInside check
69 gsVector<bool> isInside;
70 gsMatrix<T> slavePts, preIm;
71
72 // Get the evaluation of u on the slave surface
73 slavePts = m_slaveGeom->eval( u );
74 //check whether slave points lie within master geometry
75 m_masterGeom->locateOn(slavePts,isInside,preIm,false,m_Tolerance);
76
77 // Pick the relevant points only, wipe out the rest
78 index_t npts = 0;
79 for (index_t i=u.cols()-1; i>=0; --i)
80 if (isInside[i])
81 u.col(i).swap(u.col(npts++));
82 u.conservativeResize(u.rows(), npts);
83 result.resize(u.rows(), npts);
84
85 for (index_t i=0; i<npts; i++) // For every set( column ) of parameters
86 {
87 // Find the parameters of the point of the master surface boundary,
88 // which is closest to the slavePoint
89 m_masterBdr->closestPointTo(slavePts.col(i), masterParams, m_Tolerance);
90
91 // masterParams are 1 less than the masters' domain dimensions
92 // since only the boundary is considered in the CPP procedure
93 // but we need to return domainDim, parameters thus the following loop
94 for (size_t j=0; j<m_freeDirs.size(); j++)
95 {
96 result( m_freeDirs[j], i ) = masterParams(j);
97 }
98 result( m_fixedDir, i ) = m_fixedParam; // this param is known a priori
99 }
100
101 */
102
103 //--- closest point version
104 result.resizeLike(u);
105 gsVector<T> slavePoint;
106
107 for (index_t i=0; i<u.cols(); i++) // For every set( column ) of parameters
108 {
109 // Get the evaluation of u on the slave surface
110 slavePoint = m_slaveGeom->eval( u.col(i) );
111
112 // Find the parameters of the point of the master surface boundary,
113 // which is closest to the slavePoint
114 m_masterBdr->closestPointTo( slavePoint, masterParams, m_Tolerance);
115
116 // masterParams are 1 less than then masters domain dimensions
117 // since only the boundary is considered in the CPP procedure
118 // but we need to return domainDim, parameters thus the following loop
119 for (size_t j=0; j<m_freeDirs.size(); j++)
120 {
121 result( m_freeDirs[j], i ) = masterParams(j);
122 }
123 result( m_fixedDir, i ) = m_fixedParam; // this param is known a priori
124 }
125 //--- closest point version
126}
127
128
129template <class T>
131{
132 gsTensorDomainBoundaryIterator<T> * tdi = new gsTensorDomainBoundaryIterator<T> (*m_slaveBasis, m_boundaryInterface.first());
133 for (index_t i=0; i<domainDim(); ++i)
134 {
135 if (i!=m_boundaryInterface.first().direction())
136 tdi->setBreaks(m_breakpoints[i],i);
137 }
138 return typename gsDomainIterator<T>::uPtr(tdi);
139}
140
141
142template <class T>
143std::ostream& gsCPPInterface<T>::print(std::ostream & os) const
144{
145 os << "gsCPPInterface:"
146 << "\n First (slave) side: " << m_boundaryInterface.first()
147 << "\n Second (master) side: " << m_boundaryInterface.second();
148
149 os << "\n";
150 return os;
151}
152
153
154} // End namespace gismo
bool parameter() const
Returns the parameter value (false=0=start, true=1=end) that corresponds to this side.
Definition gsBoundary.h:128
short_t direction() const
Returns the parametric direction orthogonal to this side.
Definition gsBoundary.h:113
Provides a mapping between the corresponding sides of two patches sharing an interface,...
Definition gsCPPInterface.h:33
gsCPPInterface(const gsMultiPatch< T > &mp, const gsMultiBasis< T > &mb, const boundaryInterface &bi, const gsOptionList &opt=defaultOptions())
Constructor.
Definition gsCPPInterface.hpp:26
gsDomainIterator< T >::uPtr makeDomainIterator() const
Returns a domain iterator.
Definition gsCPPInterface.hpp:130
gsGeometry< T >::Ptr m_masterBdr
The boundary geometry of second patch – Master.
Definition gsCPPInterface.h:66
virtual void eval_into(const gsMatrix< T > &u, gsMatrix< T > &result) const
Evaluates the interface map.
Definition gsCPPInterface.hpp:62
boundaryInterface m_boundaryInterface
Corresponding boundary interface.
Definition gsCPPInterface.h:71
virtual std::ostream & print(std::ostream &os) const
Prints the state of the object.
Definition gsCPPInterface.hpp:143
memory::unique_ptr< gsDomainIterator > uPtr
Unique pointer for gsDomainIterator.
Definition gsDomainIterator.h:73
A matrix with arbitrary coefficient type and fixed or dynamic size.
Definition gsMatrix.h:41
Holds a set of patch-wise bases and their topology information.
Definition gsMultiBasis.h:37
Container class for a set of geometry patches and their topology, that is, the interface connections ...
Definition gsMultiPatch.h:100
Class which holds a list of parameters/options, and provides easy access to them.
Definition gsOptionList.h:33
Re-implements gsDomainIterator for iteration over all elements of the boundary of a tensor product pa...
Definition gsTensorDomainBoundaryIterator.h:38
void setBreaks(std::vector< T > newBreaks, index_t i)
Function to set the breakpoints in direction i manually.
Definition gsTensorDomainBoundaryIterator.h:248
A vector with arbitrary coefficient type and fixed or dynamic size.
Definition gsVector.h:37
#define index_t
Definition gsConfig.h:32
Fits a (closed) B-spline curve to some given data.
#define GISMO_ASSERT(cond, message)
Definition gsDebug.h:89
Provides declaration of the MultiPatch class.
An std::vector with sorting capabilities.
Provides declaration of TensorNurbsBasis abstract interface.
The G+Smo namespace, containing all definitions for the library.
Struct which represents an interface between two patches.
Definition gsBoundary.h:650
patchSide & second()
second, returns the second patchSide of this interface
Definition gsBoundary.h:782
Struct that defines the boundary sides and corners and types of a geometric object.
Definition gsBoundary.h:56