34 ComputePeriferalMaterialIds(meshvec_Hybrid);
35 ComputeNState(meshvec_Hybrid);
39 if (meshvec_Hybrid.
size() > 1 && meshvec_Hybrid[1]->NMaterials() > 0) {
40 fNState = meshvec_Hybrid[1]->MaterialVec().
begin()->second->NStateVariables();
45 int maxMatId = std::numeric_limits<int>::min();
46 for (
auto &mesh : meshvec_Hybrid) {
50 for (
auto &mat : mesh->MaterialVec()) {
51 maxMatId = std::max(maxMatId, mat.first);
54 if(meshvec_Hybrid.size())
60 for(int64_t el=0; el<nel; el++)
63 if(gel) maxMatId = std::max(maxMatId,gel->
MaterialId());
66 if (maxMatId == std::numeric_limits<int>::min()) {
69 fHDivWrapMatid = maxMatId + 1;
70 fLagrangeInterface = maxMatId + 2;
71 fInterfaceMatid = maxMatId + 3;
77 if (fHDivWrapMatid == 0 || fLagrangeInterface == 0) {
78 std::cerr <<
"Using uninitialized TPZHybridizeHDiv object. You need to call ComputePeriferalMaterialIds function first!" << std::endl;
95 gright.EqualLevelCompElementList(equalright,1,0);
98 if(equalright.
size() > 1)
102 if(equalright.
size()==1)
104 TPZGeoEl *equalgel = equalright[0].Element()->Reference();
112 if(equalright.
size()) equalright[0].Element()->Reference()->ResetReference();
127 int sideorder = cleft.
Order();
133 intelleft->LoadElementReference();
134 intelleft->SetPreferredOrder(sideorder);
138 if(cleft.
Order() != sideorder)
145 intelleft->Reference()->ResetReference();
149 if(equalright.
size() == 0)
151 intelleft->Reference()->ResetReference();
154 int rightprevorder = cright.
Order();
159 if(cright.
Order() != rightprevorder)
171 wrap2 = equalright[0].Element();
175 int64_t pressureindex;
180 pressureorder = sideorder;
182 intelleft->LoadElementReference();
184 return std::make_tuple(pressureindex, pressureorder);
191 bool isrestrained =
false;
201 if (isrestrained ==
true) {
219 if (celstack.
size() == 1) {
220 TPZGeoEl *neigh = celstack[0].Element()->Reference();
233 InsertPeriferalMaterialObjects(meshvec_Hybrid);
241 std::list<std::tuple<int64_t, int> > pressures;
242 for (int64_t el = 0; el < nel; el++) {
257 pressures.push_back(SplitConnects(celside, neighcomp, meshvec_Hybrid));
267 for (
auto pindex : pressures) {
270 std::tie(elindex, order) = pindex;
279 }
else if (intelDisc) {
286 for (
int i = 0; i < n_connects; ++i) {
296 if (fInterfaceMatid == 0) {
297 std::cerr <<
"Using uninitialized TPZHybridizeHDiv object. You need to call ComputePeriferalMaterialIds function first!" << std::endl;
303 for (int64_t el = 0; el < pressuremesh->
NElements(); el++) {
306 celpressure[el] = cel;
311 for (
auto cel : celpressure) {
320 for (
auto &celstackside : celstack) {
321 if (celstackside.Reference().Element()->Dimension() == dim - 1) {
324 TPZCompEl *celneigh = celstackside.Element();
335 TPZCompElSide clarge = gelside.LowerLevelCompElementList2(
false);
340 while(neighbour != glarge)
358 if (count != 2 && count != 0) {
367 CreateInterfaceElements(cmesh_Hybrid, cmesh_Hybrid->
MeshVector());
374 InsertPeriferalMaterialObjects(cmesh_Hybrid, Lagrange_term_multiplier);
387 meshvec_Hybrid[i] = cmesh_HDiv->
MeshVector()[i]->Clone();
389 InsertPeriferalMaterialObjects(meshvec_Hybrid);
390 HybridizeInternalSides(meshvec_Hybrid);
395 InsertPeriferalMaterialObjects(cmesh_Hybrid, Lagrange_term_multiplier);
406 InsertPeriferalMaterialObjects(cmesh_HDiv, Lagrange_term_multiplier);
407 InsertPeriferalMaterialObjects(meshvec_Hybrid);
409 HybridizeInternalSides(meshvec_Hybrid);
420 elementgroup.
Resize(nel, -1);
421 elementgroup.
Fill(-1);
426 if (!cel || !cel->Reference() || cel->Reference()->Dimension() != dim) {
429 elementgroup[cel->Index()] = cel->Index();
431 cel->BuildConnectList(connectlist);
432 for (
auto cindex : connectlist) {
434 if (groupindex[cindex] != -1) {
438 groupindex[cindex] = cel->Index();
443 if (!cel || !cel->Reference()) {
447 cel->BuildConnectList(connectlist);
449 int64_t groupfound = -1;
450 for (
auto cindex : connectlist) {
451 if (groupindex[cindex] != -1) {
452 elementgroup[cel->Index()] = groupindex[cindex];
453 if(groupfound != -1 && groupfound != groupindex[cindex])
462 groupfound = groupindex[cindex];
479 AssociateElements(cmesh, groupnumber);
480 std::map<int64_t, TPZElementGroup *> groupmap;
482 for (int64_t el = 0; el<nel; el++) {
483 int64_t groupnum = groupnumber[el];
484 if(groupnum == -1)
continue;
485 auto iter = groupmap.find(groupnum);
486 if (groupmap.find(groupnum) == groupmap.end()) {
489 groupmap[groupnum] = elgr;
494 iter->second->AddElement(cmesh->
Element(el));
500 for (int64_t el = 0; el < nel; el++) {
513 if (fLagrangeInterface == 0 || fHDivWrapMatid == 0) {
514 std::cerr <<
"Using uninitialized TPZHybridizeHDiv object. You need to call ComputePeriferalMaterialIds function first!" << std::endl;
524 matPerif->SetDimension(dim-1);
525 matPerif->SetNStateVariables(fNState);
529 if(meshvec_Hybrid[0]!=NULL){
534 matPerif->SetDimension(dim-1);
535 matPerif->SetNStateVariables(fNState);
544 if (fLagrangeInterface == 0 || fHDivWrapMatid == 0 || fInterfaceMatid == 0) {
545 std::cerr <<
"Using uninitialized TPZHybridizeHDiv object. You need to call ComputePeriferalMaterialIds function first!" << std::endl;
548 TPZFNMatrix<1, STATE> xk(fNState, fNState, 0.), xb(fNState, fNState, 0.), xc(fNState, fNState, 0.), xf(fNState, 1, 0.);
552 std::cout<<
"LagrangeInterface MatId "<<fLagrangeInterface<<std::endl;
554 matPerif->SetNStateVariables(fNState);
555 matPerif->SetDimension(dim-1);
559 std::cout<<
"HDivWrapMatid MatId "<<fHDivWrapMatid<<std::endl;
561 matPerif->SetNStateVariables(fNState);
562 matPerif->SetDimension(dim-1);
567 std::cout<<
"InterfaceMatid MatId "<<fInterfaceMatid<<std::endl;
576 for (
int i = 0; i < meshvec_HDiv.
size(); i++) {
577 meshvec_Hybrid[i] = meshvec_HDiv[i]->Clone();
579 ComputePeriferalMaterialIds(meshvec_Hybrid);
580 ComputeNState(meshvec_Hybrid);
582 InsertPeriferalMaterialObjects(meshvec_Hybrid);
583 HybridizeInternalSides(meshvec_Hybrid);
584 TPZCompMesh *cmesh_Hybrid = CreateMultiphysicsMesh(cmesh_HDiv, meshvec_Hybrid, Lagrange_term_multiplier);
585 CreateInterfaceElements(cmesh_Hybrid, meshvec_Hybrid);
587 GroupandCondenseElements(cmesh_Hybrid);
589 return std::make_tuple(cmesh_Hybrid, meshvec_Hybrid);
595 ComputePeriferalMaterialIds(multiphysics->
MeshVector());
599 TPZCompMesh *cmesh = CreateMultiphysicsMesh(multiphysics);
601 CreateInterfaceElements(result);
604 GroupandCondenseElements(result);
614 ComputePeriferalMaterialIds(multiphysics.
MeshVector());
616 ReCreateMultiphysicsMesh(&multiphysics);
617 CreateInterfaceElements(&multiphysics);
618 if (group_elements) {
619 GroupandCondenseElements(&multiphysics);
636 TPZManVector<REAL,3> ptleft(sidedim,0.),ptright(sidedim,0.),ptleftvol(meshdim,0),ptrightvol(meshdim,0);
638 int npoints = intpts->
NPoints();
639 for(
int ip = 0; ip<npoints; ip++)
641 intpts->
Point(ip,ptleft,weight);
642 tr.
Apply(ptleft,ptright);
643 trleft.
Apply(ptleft,ptleftvol);
644 trright.
Apply(ptright,ptrightvol);
652 gleft.
Jacobian(ptleft,jacobian,axes,detjac,jacinv);
653 normal[0] = axes(0,1)*axes(1,2)-axes(0,2)*axes(1,1);
654 normal[1] = -axes(0,0)*axes(1,2)+axes(0,2)*axes(1,0);
655 normal[2] = axes(0,0)*axes(1,1)-axes(0,1)*axes(1,0);
657 STATE fluxnormalleft = 0.,fluxnormalright = 0.;
658 for(
int i=0; i<3; i++)
660 fluxnormalleft += fluxleft[i]*normal[i];
661 fluxnormalright += fluxright[i]*normal[i];
663 REAL diff =
fabs(fluxnormalleft-fluxnormalright);
667 gleft.
X(ptleft,leftx);
668 gright.
X(ptright,rightx);
669 out <<
"Left geo element index " << gleft.
Element()->
Index();
670 out <<
" Right geo element index " << gright.
Element()->
Index();
671 out <<
" xleft " << leftx <<
" xright " << rightx << std::endl;
672 out <<
" fluxleft " << fluxleft << std::endl;
673 out <<
" fluxright" << fluxright << std::endl;
674 out <<
"normal " << normal << std::endl;
675 out <<
"fluxnormalleft " << fluxnormalleft << std::endl;
676 out <<
"fluxnormalright " << fluxnormalright << std::endl;
689 for(int64_t el = 0; el<nel; el++)
695 if(gel->
Dimension() != meshdim)
continue;
696 int nsides = gel->
NSides();
697 for(
int side=0; side<nsides; side++)
714 for(
int i=0; i<celsides.
size(); i++)
716 if(celsides[i].Reference().Element()->Dimension() == meshdim)
718 celneighselect = celsides[i];
int64_t NElements() const
Number of computational elements allocated.
TPZGeoMesh * Reference() const
Returns a pointer to the geometrical mesh associated.
Material which implements a Lagrange Multiplier.
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
virtual void SetConnectIndex(int i, int64_t connectindex) override=0
Sets the node pointer of node i to nod.
TPZCompMesh * Reference() const
Returns the currently loaded computational grid.
virtual int NPoints() const =0
Returns number of points for the cubature rule related.
void IncrementElConnected()
Increment fNElConnected.
Implements computational element and a side. Computational Element.
std::tuple< TPZCompMesh *, TPZVec< TPZCompMesh * > > Hybridize(TPZCompMesh *cmesh_Multiphysics, TPZVec< TPZCompMesh *> &meshvec_HDiv, bool group_elements=true, double Lagrange_term_multiplier=1.)
clones the atomic meshes in meshvec_HDiv and creates a multiphysics hybrid mesh
Represents a set of shape functions associated with a computational element/side. Computational Eleme...
Contains declaration of TPZGeoElSide class which represents an element and its side, and TPZGeoElSideIndex class which represents an TPZGeoElSide index.
int MaterialId() const
Returns the material index of the element.
void DecrementElConnected()
Decrement fNElConnected.
void CreateInterfaceElements(TPZCompMesh *cmesh_Hybrid, TPZVec< TPZCompMesh *> &meshvec_Hybrid)
Create interface elements with material id InterfaceMatid.
static void AddElements(TPZVec< TPZCompMesh *> &cmeshVec, TPZCompMesh *MFMesh)
Creating multiphysic elements into mphysics computational mesh. Method to add elements in the mesh mu...
virtual int64_t AllocateNewConnect(int nshape, int nstate, int order)
Returns an index to a new connect.
TPZGeoElSide Reference() const
Reference to the geometric element.
Contains declaration of TPZCompEl class which defines the interface of a computational element...
void ComputeNState(TPZVec< TPZCompMesh *> &meshvec_Hybrid)
Contains the declaration of the TPZElementGroup class, which implements an computational element whic...
virtual int NCornerNodes() const =0
Returns the number of corner nodes of the element.
void SetLagrangeMultiplier(unsigned char mult)
Set the connect as a pressure connect or not.
static void CompareFluxes(TPZCompElSide &left, TPZCompElSide &right, std::ostream &out)
int64_t NElements() const
Number of elements of the mesh.
TPZCompElSide LowerLevelCompElementList2(int onlyinterpolated)
return the element/side pair which contains this/side and has a computational element associated ...
Utility class which represents an element with its side. The Geometric approximation classes Geometry...
Class which groups elements to characterize dense matrices.
TPZHybridizeHDiv()=default
Contains declaration of TPZGeoElBC class, it is a structure to help the construction of geometric ele...
TPZCompMesh * CreateMultiphysicsMesh(TPZCompMesh *cmesh_HDiv, TPZVec< TPZCompMesh *> &meshvec_Hybrid, double Lagrange_term_multiplier=1.)
create a multiphysics mesh for the hybrid formulation using the materials of another mesh and the giv...
TPZGeoElSide Neighbour() const
TPZGeoMesh * Mesh() const
Returns the mesh to which the element belongs.
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.
void SideTransform3(TPZGeoElSide neighbour, TPZTransform<> &t)
Accumulates the transformations from the current element/side to the neighbour/side.
void EqualLevelCompElementList(TPZStack< TPZCompElSide > &elsidevec, int onlyinterpolated, int removeduplicates)
Returns all connected computational elements which have equal level to the current element...
void LoadReferences()
Map this grid in the geometric grid.
virtual void LoadElementReference()
Loads the geometric element reference.
void SetAllCreateFunctionsMultiphysicElem()
Create an approximation space based on multiphysics elements.
static void AddConnects(TPZVec< TPZCompMesh *> &cmeshVec, TPZCompMesh *MFMesh)
TPZConnect & SideConnect(int icon, int is)
Returns a pointer to the icon th connect object along side is.
void SetDefaultOrder(int order)
Abstract class defining integration rules. Numerical Integration.
virtual TPZIntPoints * CreateSideIntegrationRule(int side, int order)=0
Creates an integration rule for the topology of the corresponding side and able to integrate a polyno...
int64_t size() const
Returns the number of elements of the vector.
virtual void Resize(const int64_t newsize, const T &object)
Resizes the vector object reallocating the necessary storage, copying the existing objects to the new...
TPZCompEl * Element(int64_t iel)
unsigned char Order() const
Access function to return the order associated with the connect.
TPZCreateApproximationSpace & ApproxSpace()
TPZVec< TPZCompMesh * > & MeshVector()
Get the vector of computational meshes.
Defines the behaviour of all geometric elements. GeometryTPZGeoEl is the common denominator for all g...
TPZGeoEl * Element(int64_t iel)
int64_t Index() const
Returns the index of the element within the element vector of the mesh.
#define DebugStop()
Returns a message to user put a breakpoint in.
virtual int SideConnectLocId(int icon, int is) const override=0
Returns the local node number of icon along is.
void SetSequenceNumber(int64_t i)
Set the sequence number for the global system of equations of the connect object. ...
void X(TPZVec< REAL > &loc, TPZVec< REAL > &result) const
X coordinate of a point loc of the side.
Contains declaration of TPZConnect class which represents a set of shape functions associated with a ...
int Dimension() const
Returns the dimension of the simulation.
Contains the declaration of the TPZBuildmultiphysicsMesh class.
virtual void ComputeNodElCon()
Compute the number of elements connected to each connect object.
Contains the declaration of multiphysic interface class.
TPZMaterial * FindMaterial(int id)
Find the material with identity id.
TPZCompEl * Reference() const
Return a pointer to the element referenced by the geometric element.
virtual void AutoBuild(const std::set< int > *MaterialIDs)
Creates the computational elements, and the degree of freedom nodes.
int HasDependency() const
Returns whether exist dependecy information.
void ComputePeriferalMaterialIds(TPZVec< TPZCompMesh *> &meshvec_Hybrid)
compute material ids for the periferal material objects
Contains the TPZMat2dLin class which implements a bi-dimensional linear problem.
int64_t NConnects() const
Number of connects allocated including free nodes.
void HybridizeGivenMesh(TPZMultiphysicsCompMesh &multiphysics, bool group_elements=true, double Lagrange_term_multiplier=1.)
make a hybrid mesh from a H(div) multiphysics mesh
TPZAdmChunkVector< TPZConnect > & ConnectVec()
Return a reference to the connect pointers vector.
T * begin() const
Casting operator. Returns The fStore pointer.
Class which implements an element which condenses the internal connects.
Contains declaration of TPZCompMesh class which is a repository for computational elements...
static void GroupandCondenseElements(TPZCompMesh *cmesh_Hybrid)
group and condense the elements
virtual TPZConnect & Connect(int i) const
Returns a pointer to the ith node.
void SetDimModel(int dim)
Set de dimension of the domain of the problem.
TPZGeoEl * CreatedElement()
Recovers pointer to the geometric element created.
virtual void SetMultiplier(STATE mult)
virtual int NConnects() const =0
Returns the number of nodes of the element.
TPZGeoEl * Element() const
Structure to help the construction of geometric elements along side of a given geometric element...
void HybridizeInternalSides(TPZVec< TPZCompMesh *> &meshvec_Hybrid)
split the connects between flux elements and create a dim-1 pressure element
void InsertPeriferalMaterialObjects(TPZVec< TPZCompMesh *> &meshvec_Hybrid)
insert the material objects for HDivWrap and LagrangeInterface in the atomic meshes ...
virtual void SetSideOrient(int side, int sideorient)
It set the normal orientation of the element by the side. Only side that has dimension equal to my di...
int InsertMaterialObject(TPZMaterial *mat)
Insert a material object in the datastructure.
virtual void SetPreferredOrder(int order) override=0
Sets the preferred interpolation order along a side.
virtual int Dimension() const =0
Returns the dimension of the element.
TPZCompEl * Element() const
Gives a pointer to the reference computational 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...
Contains the TPZMat1dLin class which implements a one-dimensional linear problem. ...
TPZCompEl * CreateCompEl(TPZGeoEl *gel, TPZCompMesh &mesh, int64_t &index) const
Create a computational element using the function pointer for the topology.
int Dimension()
Get Dimension.
static void AssociateElements(TPZCompMesh *cmesh, TPZVec< int64_t > &elementgroup)
Associate elements with a volumetric element.
TPZGeoEl * Reference() const
Return a pointer to the corresponding geometric element if such exists, return 0 otherwise.
TPZCompElSide Reference() const
Returns a pointer to the elementside referenced by the geometric elementside.
This class implements a geometric mesh for the pz environment. Geometry.
std::tuple< int64_t, int > SplitConnects(const TPZCompElSide &left, const TPZCompElSide &right, TPZVec< TPZCompMesh *> &meshvec_Hybrid)
split the connect between two neighbouring elements
static void VerifySolutionConsistency(TPZCompMesh *fluxmesh, std::ostream &out)
verify the consistency of the solution of the flux mesh
void ResetElConnected()
Initialize with zero fNElConnected.
int Dimension() const
the dimension associated with the element/side
void ResetReference()
Reset the element referenced by the geometric element to NULL.
Computes the contribution over an interface between two discontinuous elements. Computational Element...
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.
Implements computational mesh. Computational Mesh.
TPZVec< int > & GetActiveApproximationSpaces()
Get the vector of active physics.
TPZAdmChunkVector< TPZCompEl * > & ElementVec()
Returns a reference to the element pointers vector.
void PRefine(int order) override
Changes the interpolation order of a side. Updates all constraints and block sizes ...
virtual void Solution(TPZVec< REAL > &qsi, int var, TPZVec< STATE > &sol)
Calculates the solution - sol - for the variable var at point qsi, where qsi is expressed in terms of...
Contains declaration of TPZInterpolatedElement class which implements computational element of the in...
void ReCreateMultiphysicsMesh(TPZMultiphysicsCompMesh *cmesh_HDiv, double Lagrange_term_multiplier=1.)
create a multiphysics hybridized mesh based on and input mesh
void Fill(const T ©, const int64_t from=0, const int64_t numelem=-1)
Will fill the elements of the vector with a copy object.
int Side() const
Returns the side index.
virtual void SetDegree(int degree)
Assigns the degree of the element.
void BuildMultiphysicsSpace(TPZVec< int > &active_approx_spaces, TPZVec< TPZCompMesh * > &mesh_vector)
Set active approximation spaces.
void RemoveDepend(int64_t myindex, int64_t dependindex)
Remove dependency between connects if exist.
Contains the TPZIntPoints class which defines integration rules.
void CopyMaterials(TPZCompMesh &mesh) const
Copies the materials of this mesh to the given mesh.
This class implements a discontinuous element (for use with discontinuous Galerkin). Computational Element.
void InitializeBlock()
Resequence the block object, remove unconnected connect objects and reset the dimension of the soluti...
void ResetReference()
Resets all load references in elements and nodes.
Defines the interface of a computational element. Computational Element.
Contains the declaration of the TPZCondensedCompEl class, which implements an computational element w...
void push_back(const T object)
virtual void AddElement(TPZCompEl *cel)
add an element to the element group
void SetKeepMatrix(bool keep)
Set the flag that determines whether the matrix needs to be kept or not.
Implements computational element based on an interpolation space. Computational Element.
Non abstract class which implements full matrices with preallocated storage with (N+1) entries...
virtual void Point(int i, TPZVec< REAL > &pos, REAL &w) const =0
Returns i-th point at master element and related weight.
static TPZCompElSide RightElement(TPZInterpolatedElement *intel, int side)
find an element which shares the connect and has the same dimension