Commit d3cc9703 authored by Grégory LEGRAIN's avatar Grégory LEGRAIN

Merge branch 'anisoMesh' into 'master'

Add anisotropic mesh adaptation capabilities

Needs ICITech mesher
Improve FormulationQSRemeshAniso class

See merge request !1
parents a0a5013d b353298d
Pipeline #143 skipped
......@@ -105,10 +105,6 @@ protected:
// After a new mesh has been built, transfers values contained in
// variab_manager (defined on old mesh) to new values (defined on new mesh)
void transferMaterialVariables();
private:
// Links values together and declares a dof so that this unique dof controls
// several values.
void treatmentOfRigidMotion();
// Clears disp field (double manager and spaces).
void deleteDispField(std::string="all");
......@@ -116,6 +112,11 @@ private:
// Clears state
void deleteState();
private:
// Links values together and declares a dof so that this unique dof controls
// several values.
void treatmentOfRigidMotion();
// Clears material variables (variab manager).
// void clearMaterialVariables();
protected:
......
This diff is collapsed.
/*
This source code is subject to non-permissive licence,
see the TLSDuctile/LICENSE file for conditions.
*/
#ifndef _TLSDuctile_FormulationQSRemeshAniso_h_
#define _TLSDuctile_FormulationQSRemeshAniso_h_
#include "FormulationQS.h"
class PreProcessing;
class TLSSolver;
#include "xMesh.h"
#include "mEntity.h"
#include "xField.h"
using xfem::xMesh;
using xfem::xField;
using AOMD::mEntity;
class QSFormulRemeshAniso : public QSFormulation {
public:
QSFormulRemeshAniso(TLSGeom&, TLSSolver&,
const xfem::xData&, const xParseData&,
PreProcessing&, PostProcessing&, std::function<void (xfem::xMesh&)>);
virtual ~QSFormulRemeshAniso();
QSFormulRemeshAniso(TLSGeom&, TLSSolver&,
const xfem::xData&, const xParseData&,
PreProcessing&, PostProcessing&, std::function<void (xfem::xMesh&)> );
virtual ~QSFormulRemeshAniso();
// void setBCDefinition(std::vector<std::tuple<std::function<bool (const Trellis_Util::mPoint&) >, int, int> >& BCDEF);
// std::vector<std::tuple<std::function<bool (const Trellis_Util::mPoint&) >, int, int> > BCDEF;
xfem::xLevelSet lsetAdapt;
std::function<void (xfem::xMesh&)> tagger;
private:
void updateLevelSetField();
void xReadFromParaview(std::string, std::string, xfem::xField&,xfem::xMesh&);
//void xReadFromParaviewxLevelSet(std::string, std::string, xfem::xLevelSet&,xfem::xMesh&);
void xReadFromParaviewxLevelSet(std::string, std::string, xfem::xLevelSet&);
void remesh();
void buildLSAdaptationField();
void projectPhiOnMesh(xMesh *mesh_new, std::map<mEntity *, double> &projectedValues);
void xAssignPhiValues(xField &field, xMesh *mesh, std::map<mEntity *, double> &projectedValues);
std::list<AOMD::mEntity*> constructDelocalizedList(xfem::xLevelSet&);
std::function<void (xfem::xMesh&)> tagger;
};
#endif
......@@ -84,6 +84,7 @@ void ReadData(std::string main_file_name, xfem::xData& data, xParseData& parse_d
parse_data.registerInt("do_tls_solver_matrix_optim", 0); // the mass matrix involved in computation of mean fields is sometimes not needed
parse_data.registerInt("build_unconnected_parts", 0); // creates groups of unconnected domain parts, applies b.c. to all groups except first one
parse_data.registerDouble("fit_to_vertices_ratio", 1.e-2); // is a ratio to modulate the fit to vertices threshold value: epsilon=h*fit_to_vertices_ratio
parse_data.registerInt("remesh_aniso", 0); // Anisotropic remesh
// algo related
parse_data.registerInt("nb_step_max", 100); // is the nb of steps of computation
parse_data.registerInt("nb_iter_max", 10); // is the max nb of iteration to compute equilibrium in a nonlinear context
......
......@@ -79,22 +79,28 @@ public:
void buildTLS();
void buildLocal();
void buildBndMeas();
void buildNonlocal(const std::list<AOMD::mEntity*>&);
protected:
void buildBndNonlocal();
void buildIntNonlocal();
void buildGammaIn(const xfem::xEval<xfem::xVector>&);
void deleteMesh(std::string);
void updateElementSize();
void registerMesh(std::string, xfem::xMesh*);
private:
// Helps managing the mesh
bool isRegisteredMesh(std::string) const;
void registerMesh(std::string, xfem::xMesh*);
void deleteMesh(std::string);
std::function<void (AOMD::mEntity*, xfem::xPartition&, xfem::xEntityFilter)> getPartition() const;
// Helps updating or building (creating new) sub meshes.
void buildNonlocal(const std::list<AOMD::mEntity*>&);
void updateNonlocal(const std::list<AOMD::mEntity*>&);
void updateLocal();// removes elements and vertices that are in nonlocal
void correctLocalNonlocal();// puts local isolated elements to nonlocal
void transferTLSNonlocal();
void buildBndNonlocal();
void buildGammaIn(const xfem::xEval<xfem::xVector>&);
void buildIntNonlocal();
void buildUnconnectedParts();
// Helps building meshes.
......
......@@ -73,6 +73,7 @@ public:
bool isCrackable();
void cutCrack();
xfem::xField &getField() {return field;}
const xtls::xEvalTLSDamageFunction& getDamageEval() const;
const xtls::xEvalGradTLSDamageFunction& getDamageDerivativeEval() const;
const xfem::xEval<double>& getPhiEval() const;
......@@ -81,13 +82,21 @@ public:
void saveStep(int);
void exportStep(int);
void exportMeanField(std::string, int);
private:
void restoreStep(PreProcessing&);
void deleteField(std::string="tls");
void deleteState();
void deleteField(std::string="tls");
void declareState();
protected:
void transferDomains();
xfem::xEvalField<xfem::xIdentity<double> > eval_phi;
std::list<AOMD::mEntity*> delocalized_list;
xtls::xEvalTLSDamageFunction eval_d;
private:
void restoreStep(PreProcessing&);
void computeModesFastMarching();
void correctLevelSetField();
......@@ -104,8 +113,6 @@ private:
std::map<std::string, lalg::xCSRVector*> mean_modal_vecs;
lalg::xCSRVector buf_nodal_vec;
std::list<AOMD::mEntity*> delocalized_list;
#ifndef TLSMATRIXOPTIM
bool assemble_mat;
#endif
......@@ -113,11 +120,9 @@ private:
lalg::xGraphMatrix* nonlocality_graph;
lalg::Matrix* nonlocality_matrix;
xfem::xEvalField<xfem::xIdentity<double> > eval_phi;
xtls::xEvalTLSAdimLSFromEval eval_phi_over_lc;
xfem::xEvalConstant<double> eval_lc;
xfem::xEvalBinary<std::minus<double> > eval_phi_minus_lc;
xtls::xEvalTLSDamageFunction eval_d;
xtls::xEvalGradTLSDamageFunction eval_dd_over_dphi;
const bool do_crack_cut;
......
......@@ -26,7 +26,7 @@ void LocateHotPointsCommand::execute(xfem::xGeomElem* geom_integ) {
for(int k=0; k<geom_integ->GetNbIntegrationPoints(); ++k) {
geom_integ->setUVW(k);
if (geom_appro->getEntity()!=geom_integ->getEntity()) geom_appro->setUVWForXYZ(geom_integ->getXYZ());
else geom_appro->setUVW(geom_integ->getXYZ());
else geom_appro->setUVW(geom_integ->getUVW());
double val;
eval(geom_appro, geom_integ, val);
if (val>=threshold) {
......
......@@ -4,6 +4,7 @@ MESH_FILE = mesh.msh
ZONE 101 = { MAT_CLASS = ElastoDam MAT_PARAM = mate.mat }
BC_LINE 11 = { DISPLACEMENT_Y FIX = 0. }
BC_LINE 13 = { DISPLACEMENT_Y FIX_AND_MEASURE = 1. }
BC_LINE 14 = { DISPLACEMENT_X FIX = 0. }
// can be changed
lc=1.;
H=10.;
ratioL=2./3.;
ratiol=1./3.;
costheta=1./Sqrt(2.);
sintheta=1./Sqrt(2.);
Nlc=10.;
NL=30.;
distmin=1.5*lc;
// fixed
L=ratioL*H;
l=ratiol*H;
m=H/2.-l*sintheta;
a=H;//to be sure to have the right number of elements
Point(1) = {0, 0, 0, a};
Point(2) = {L, 0, 0, a};
Point(3) = {L, H, 0, a};
Point(4) = {0, H, 0, a};
Point(5) = {L, m, 0, a};
Point(6) = {L-l*costheta, H/2., 0, a};
Point(7) = {L, H-m, 0, a};
Point(8) = {0, H/2., 0, a};
Line(5) = {1, 2};
Line(6) = {2, 5};
Line(7) = {3, 4};
Line(8) = {4, 1};
Line(9) = {5, 6};
Line(10) = {6, 7};
Line(11) = {7, 3};
Line(12) = {6, 8};
Line Loop(9) = {5, 6, 9, 10, 11, 7, 8};
Plane Surface(10) = {9};
Physical Line(11) = {5};
Physical Line(12) = {6};
Physical Line(13) = {7};
Physical Line(14) = {8};
Physical Surface(101) = {10};
Field[1]=Attractor;
Field[1].NNodesByEdge=(L-l*costheta)/lc*Nlc;
Field[1].EdgesList={12};
Field[2]=Threshold;
Field[2].IField=1;
Field[2].LcMin=lc/Nlc;
Field[2].LcMax=L/NL;
Field[2].DistMin=distmin;
Field[2].DistMax=H/4.;
Background Field=2;
......@@ -4,6 +4,11 @@
*/
#include "TLSDuctile.h"
#include "FormulationQSRemeshAniso.h"
#include "xMesh.h"
#include <boost/lexical_cast.hpp>
using namespace xfem;
int main(int argc, char* argv[]) {
......@@ -21,7 +26,41 @@ int main(int argc, char* argv[]) {
TLSGeom tls_geom(data, parse_data, pre_pro, post_pro);
TLSSolver tls_solver(tls_geom, parse_data, pre_pro, post_pro);
auto tagger=[](xfem::xMesh& mesh){ std::cout<<"Hello"<<std::endl; };
auto tagger_nothing=[](xfem::xMesh& mesh){std::cout<<"Hello"<<std::endl; };
std::vector<std::tuple<std::function<bool (const Trellis_Util::mPoint &)>, int, int> > BCDEF;
auto dirichletDef11 = [] (const Trellis_Util::mPoint& p) -> bool { return (abs(p(1)) <= 1.e-10); };
BCDEF.push_back( std::make_tuple(dirichletDef11,11,1));
auto dirichletDef13 = [] (const Trellis_Util::mPoint& p) -> bool { return (abs(p(1)-10) <= 1.e-10); };
BCDEF.push_back( std::make_tuple(dirichletDef13,13,1));
auto dirichletDef14 = [] (const Trellis_Util::mPoint& p) -> bool { return (abs(p(0)+10) <= 1.e-10) ; };
BCDEF.push_back( std::make_tuple(dirichletDef14,14,1));
auto tagger=[&BCDEF](xfem::xMesh& mesh){
xExportGmshAscii pexport_ascii;
for(std::tuple<std::function<bool (const Trellis_Util::mPoint&) >, int, int> bccurr : BCDEF){
auto filter = std::get<0>(bccurr);
int tagnum = std::get<1>(bccurr);
int dimBC = std::get<2>(bccurr);
//loop over Bnd entities
for(xfem::xIter itBnd = mesh.begin(dimBC); itBnd != mesh.end(dimBC); ++itBnd){
//check filter
xGeomElem geo(*itBnd);
if(filter(geo.getCDGxyz())){
(*itBnd)->classify(mesh.getGEntity(tagnum,dimBC));
}
}
//Export the corresponding Bnd for debug
xClassRegion bcmesh(&mesh, tagnum, dimBC);
xEvalConstant<double> cst(tagnum);
xIntegrationRuleBasic integ_export(1);
Export(cst, pexport_ascii,"TAG_BND_"+boost::lexical_cast<string>(tagnum),integ_export,bcmesh.begin(), bcmesh.end());
}
};
QSFormulRemeshAniso formulation(tls_geom, tls_solver, data, parse_data, pre_pro, post_pro, tagger);
Algorithm algorithm(formulation, parse_data);
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment