39 typename gsPde<T>::Ptr pde(
new gsBasePde<T>(patches,bconditions,rightHandSides) );
42 for (
short_t d = 0; d < m_dim; ++d)
43 m_bases.push_back(basisVel);
44 m_bases.push_back(basisPres);
46 Base::initialize(pde, m_bases, defaultOptions());
53 opt.
addReal(
"Viscosity",
"Kinematic viscosity of the fluid",0.001);
54 opt.
addReal(
"Density",
"Density of the fluid",1.);
55 opt.
addReal(
"ForceScaling",
"Force scaling parameter",1.);
64 const T bdA = m_options.getReal(
"bdA");
65 const index_t bdB = m_options.getInt(
"bdB");
66 const T bdO = m_options.getReal(
"bdO");
69 for (
index_t d = 0; d < m_bases[0][0].dim(); ++d )
70 if (m_bases[0][0].degree(d) > deg)
71 deg = m_bases[0][0].degree(d);
74 index_t numElPerColumn = pow((bdA*deg+bdB),m_dim)*m_dim + pow((2*bdA*deg+bdB),m_dim);
76 m_system.reserve(numElPerColumn*(1+bdO),1);
82 GISMO_ENSURE(m_dim == m_pde_ptr->domain().parDim(),
"The RHS dimension and the domain dimension don't match!");
83 GISMO_ENSURE(m_dim == 2 || m_dim == 3,
"Only two- and three-dimenstion domains are supported!");
85 std::vector<gsDofMapper> m_dofMappers(m_bases.size());
86 for (
unsigned d = 0; d < m_bases.size(); d++)
87 m_bases[d].getMapper((dirichlet::strategy)m_options.getInt(
"DirichletStrategy"),
88 iFace::glue,m_pde_ptr->bc(),m_dofMappers[d],d,
true);
93 for (
unsigned d = 0; d < m_bases.size(); ++d)
94 Base::computeDirichletDofs(d);
102 m_system.matrix().setZero();
104 m_system.rhs().setZero();
106 gsVisitorStokes<T> visitor(*m_pde_ptr);
107 Base::template push<gsVisitorStokes<T> >(visitor);
109 m_system.matrix().makeCompressed();
117 constructSolution(solutionVector,fixedDoFs,velocity,pressure);
118 assemble(velocity,pressure);
127 m_system.matrix().setZero();
129 m_system.rhs().setZero();
131 gsVisitorNavierStokes<T> visitor(*m_pde_ptr,velocity,pressure);
132 Base::template push<gsVisitorNavierStokes<T> >(visitor);
134 m_system.matrix().makeCompressed();
145 for (
short_t d = 0; d < m_dim; ++d)
147 Base::constructSolution(solVector,fixedDoFs,velocity,unknowns);
156 constructSolution(solVector,fixedDoFs,velocity);
158 constructPressure(solVector,fixedDoFs,pressure);
167 unknowns.
at(0) = m_dim;
168 Base::constructSolution(solVector,m_ddof,pressure,unknowns);
175 const std::vector<std::pair<index_t,boxSide> > & bdrySides,
bool split)
const
178 gsMatrix<T> quNodes, pressureValues, physGradJac, sigma;
187 force.setZero(m_dim, 2);
188 const T viscosity = m_options.getReal(
"Viscosity");
189 const T density = m_options.getReal(
"Density");
192 for (std::vector<std::pair<index_t,boxSide> >::const_iterator it = bdrySides.begin();
193 it != bdrySides.end(); ++it)
196 const gsBasis<T> & basis = m_bases[0][it->first];
201 for (; elem->good(); elem->next())
204 bdQuRule.mapTo(elem->lowerCorner(),elem->upperCorner(),quNodes,quWeights);
207 m_pde_ptr->patches().patch(it->first).computeMap(mdGeo);
210 velocity.
patch(it->first).computeMap(mdVel);
212 pressure.
patch(it->first).eval_into(quNodes,pressureValues);
215 for (
index_t q = 0; q < quWeights.rows(); ++q)
218 physGradJac = mdVel.jacobian(q)*(mdGeo.jacobian(q).cramerInverse());
220 outerNormal(mdGeo,q,it->second,normal);
223 force.col(0) += quWeights[q] * sigma * normal;
224 sigma = -1*density*viscosity*(physGradJac + physGradJac.transpose());
225 force.col(1) += quWeights[q] * sigma * normal;
232 return force.col(0) + force.col(1);
void addPiece(const gsFunction< T > &func)
Add a piece.
Definition: gsPiecewiseFunction.h:113
virtual void reserve()
a custom reserve function to allocate memory for the sparse matrix
Definition: gsNsAssembler.hpp:61
virtual gsMatrix< T > computeForce(const gsMultiPatch< T > &velocity, const gsMultiPatch< T > &pressure, const std::vector< std::pair< index_t, boxSide > > &bdrySides, bool split=false) const
Definition: gsNsAssembler.hpp:174
Gradient of the object.
Definition: gsForwardDeclarations.h:73
virtual void constructSolution(const gsMatrix< T > &solVector, const std::vector< gsMatrix< T > > &fixedDoFs, gsMultiPatch< T > &velocity) const
Construct velocity from computed solution vector and fixed degrees of freedom.
Definition: gsNsAssembler.hpp:140
#define short_t
Definition: gsConfig.h:35
Visitor class for volumetric integration of the Stokes system.
the gsMapData is a cache of pre-computed function (map) values.
Definition: gsFuncData.h:324
gsNsAssembler(const gsMultiPatch< T > &patches, const gsMultiBasis< T > &basisVel, const gsMultiBasis< T > &basisPres, const gsBoundaryConditions< T > &bconditions, const gsFunction< T > &body_force)
Constructor.
Definition: gsNsAssembler.hpp:30
#define index_t
Definition: gsConfig.h:32
#define GISMO_ENSURE(cond, message)
Definition: gsDebug.h:102
A function from a n-dimensional domain to an m-dimensional image.
Definition: gsFunction.h:59
static gsOptionList defaultOptions()
Returns the list of default options for assembly.
Definition: gsNsAssembler.hpp:50
virtual short_t targetDim() const
Dimension of the target space.
Definition: gsFunctionSet.h:560
void addInt(const std::string &label, const std::string &desc, const index_t &value)
Adds a option named label, with description desc and value value.
Definition: gsOptionList.cpp:201
T at(index_t i) const
Returns the i-th element of the vectorization of the matrix.
Definition: gsMatrix.h:211
A vector with arbitrary coefficient type and fixed or dynamic size.
Definition: gsVector.h:35
Holds a set of patch-wise bases and their topology information.
Definition: gsMultiBasis.h:36
virtual void refresh()
Refresh routine to set dof-mappers.
Definition: gsNsAssembler.hpp:80
gsGeometry< T > & patch(size_t i) const
Return the i-th patch.
Definition: gsMultiPatch.h:226
T at(index_t i) const
Returns the i-th element of the vector.
Definition: gsVector.h:177
Provides matrix and rhs assebmly for stationary and transient incompressible Stokes and Navier-Stokes...
Container class for a set of geometry patches and their topology, that is, the interface connections ...
Definition: gsMultiPatch.h:33
IMHO, a useless class, but it is necessary to use the gsAssembler class. Contains proper information ...
The density of the measure pull back.
Definition: gsForwardDeclarations.h:76
Visitor class for volumetric integration of thetangential Navier-Stokes system.
Class containing a set of boundary conditions.
Definition: gsBoundaryConditions.h:341
void addReal(const std::string &label, const std::string &desc, const Real &value)
Adds a option named label, with description desc and value value.
Definition: gsOptionList.cpp:211
Provides functions to generate structured point data.
virtual void constructPressure(const gsMatrix< T > &solVector, const std::vector< gsMatrix< T > > &fixedDoFs, gsMultiPatch< T > &pressure) const
@ brief Construct pressure from computed solution vector
Definition: gsNsAssembler.hpp:162
gsMatrix< T > points
input (parametric) points
Definition: gsFuncData.h:348
Gradient transformation matrix.
Definition: gsForwardDeclarations.h:77
Class which holds a list of parameters/options, and provides easy access to them. ...
Definition: gsOptionList.h:32
A function depending on an index i, typically referring to a patch/sub-domain. On each patch a differ...
Definition: gsPiecewiseFunction.h:28
virtual void assemble()
Main assemble routine, to be implemented in derived classes.
Definition: gsAssembler.hpp:51
Class that represents the (tensor) Gauss-Legendre quadrature rule.
Definition: gsGaussRule.h:27
virtual domainIter makeDomainIterator() const
Create a domain iterator for the computational mesh of this basis, that points to the first element o...
Definition: gsBasis.hpp:493
stationary point iteration, 1st order, yields a new solution at each iteration
Definition: gsBaseUtils.h:47
A basis represents a family of scalar basis functions defined over a common parameter domain...
Definition: gsBasis.h:78