diff --git a/Solver/elasticitySolver.cpp b/Solver/elasticitySolver.cpp index c1fe43c6ac2b7e6fc00d2ad3eb0eeeb2147c6201..bc99f8d333eb3188b14555e1d139c4a3c2aef844 100644 --- a/Solver/elasticitySolver.cpp +++ b/Solver/elasticitySolver.cpp @@ -249,10 +249,12 @@ void elasticitySolver::readInputFile(const std::string &fn) /********************* end deprecated api ****************************************/ -void elasticitySolver::addDirichletBC (int dim, int entityId, int component, double value) { +#if defined (HAVE_LUA) + +void elasticitySolver::addDirichletBCLua (int dim, int entityId, int component, std::string luaFunctionName, lua_State *L) { dirichletBC diri; diri.g = new groupOfElements (dim, entityId); - diri._f= new simpleFunction<double>(value); + diri._f= new simpleFunctionLua<double>(L, luaFunctionName,0.); diri._comp=component; diri._tag=entityId; switch (dim) { @@ -264,10 +266,26 @@ void elasticitySolver::addDirichletBC (int dim, int entityId, int component, dou allDirichlet.push_back(diri); } -void elasticitySolver::addDirichletBCLua (int dim, int entityId, int component, std::string luaFunctionName, lua_State *L) { +void elasticitySolver::addNeumannBCLua (int dim, int entityId, std::string luaFunctionName, lua_State *L) { + neumannBC neu; + neu.g = new groupOfElements (dim, entityId); + neu._f= new simpleFunctionLua<SVector3>(L, luaFunctionName, SVector3(0,0,0)); + neu._tag=entityId; + switch (dim) { + case 0 : neu.onWhat=BoundaryCondition::ON_VERTEX; break; + case 1 : neu.onWhat=BoundaryCondition::ON_EDGE; break; + case 2 : neu.onWhat=BoundaryCondition::ON_FACE; break; + default : return; + } + allNeumann.push_back(neu); +} + +#endif + +void elasticitySolver::addDirichletBC (int dim, int entityId, int component, double value) { dirichletBC diri; diri.g = new groupOfElements (dim, entityId); - diri._f= new simpleFunctionLua<double>(L, luaFunctionName,0.); + diri._f= new simpleFunction<double>(value); diri._comp=component; diri._tag=entityId; switch (dim) { @@ -279,6 +297,7 @@ void elasticitySolver::addDirichletBCLua (int dim, int entityId, int component, allDirichlet.push_back(diri); } + void elasticitySolver::addNeumannBC (int dim, int entityId, const std::vector<double> value) { if(value.size()!=3) return; neumannBC neu; @@ -294,19 +313,7 @@ void elasticitySolver::addNeumannBC (int dim, int entityId, const std::vector<do allNeumann.push_back(neu); } -void elasticitySolver::addNeumannBCLua (int dim, int entityId, std::string luaFunctionName, lua_State *L) { - neumannBC neu; - neu.g = new groupOfElements (dim, entityId); - neu._f= new simpleFunctionLua<SVector3>(L, luaFunctionName, SVector3(0,0,0)); - neu._tag=entityId; - switch (dim) { - case 0 : neu.onWhat=BoundaryCondition::ON_VERTEX; break; - case 1 : neu.onWhat=BoundaryCondition::ON_EDGE; break; - case 2 : neu.onWhat=BoundaryCondition::ON_FACE; break; - default : return; - } - allNeumann.push_back(neu); -} + void elasticitySolver::addElasticDomain (int physical, double e, double nu){ elasticField field; @@ -357,7 +364,7 @@ void elasticitySolver::assemble(linearSystem<double> *lsys) // Voids for (unsigned int i = 0; i < elasticFields.size(); ++i) { - if(elasticFields[i]._E == 0.) + if(elasticFields[i]._E == 0.) FixVoidNodalDofs(*LagSpace, elasticFields[i].g->begin(), elasticFields[i].g->end(), *pAssembler); } // Neumann conditions @@ -383,7 +390,7 @@ void elasticitySolver::assemble(linearSystem<double> *lsys) LoadTerm<double> Lterm(*LagrangeMultiplierSpace, LagrangeMultiplierFields[i]._f); Assemble(Lterm, *LagrangeMultiplierSpace, LagrangeMultiplierFields[i].g->begin(), LagrangeMultiplierFields[i].g->end(), Integ_Boundary, *pAssembler); } - // Assemble elastic term for + // Assemble elastic term for GaussQuadrature Integ_Bulk(GaussQuadrature::GradGrad); for (unsigned int i = 0; i < elasticFields.size(); i++) { @@ -464,8 +471,8 @@ PView* elasticitySolver::buildDisplacementView (const std::string postFileName) vCut[e->getVertex(j)] = e->getParent(); } } - else { - for (int j = 0; j < e->getNumVertices(); ++j) + else { + for (int j = 0; j < e->getNumVertices(); ++j) v.insert(e->getVertex(j)); } } @@ -602,8 +609,11 @@ PView* elasticitySolver::buildVonMisesView(const std::string &postFileName) } #endif + +#if defined (HAVE_LUA) + #include "Bindings.h" -void elasticitySolverRegisterBindings(binding *b) +void elasticitySolverRegisterBindings(binding *b) { classBinding *cb; cb = b->addClass<elasticitySolver> ("elasticitySolver"); @@ -645,7 +655,7 @@ void elasticitySolverRegisterBindings(binding *b) cm->setArgNames ("fileName", NULL); cm = cb->addMethod ("buildDisplacementView", &elasticitySolver::buildDisplacementView); - cm->setDescription ("create a new view."); + cm->setDescription ("create a new view."); cm->setArgNames ("fileName", NULL); cm = cb->addMethod ("buildLagrangeMultiplierView", &elasticitySolver::buildLagrangeMultiplierView); @@ -663,3 +673,4 @@ void elasticitySolverRegisterBindings(binding *b) cm->setArgNames("model","tag",NULL); } +#endif diff --git a/Solver/elasticitySolver.h b/Solver/elasticitySolver.h index 3694fdbd30160ba81e7fe3edff60701bc0a9b6f0..767ef8fcfa7c216ddef7470cef1d8cc485c85b44 100644 --- a/Solver/elasticitySolver.h +++ b/Solver/elasticitySolver.h @@ -55,7 +55,6 @@ struct neumannBC : public BoundaryCondition simpleFunction<SVector3> *_f; neumannBC () : BoundaryCondition(),_f(NULL){} }; - // an elastic solver ... class elasticitySolver { @@ -73,17 +72,23 @@ class elasticitySolver std::vector<neumannBC> allNeumann; // dirichlet BC std::vector<dirichletBC> allDirichlet; - + public: elasticitySolver(int tag) : _tag(tag),LagSpace(0),pAssembler(0),LagrangeMultiplierSpace(0) {} elasticitySolver(GModel *model, int tag); + void addDirichletBC (int dim, int entityId, int component, double value); - void addDirichletBCLua (int dim, int entityId, int component, std::string luaFunctionName, lua_State *L); void addNeumannBC (int dim, int entityId, const std::vector<double> value); - void addNeumannBCLua (int dim, int entityId, std::string luaFunctionName, lua_State *L); void addElasticDomain (int tag, double e, double nu); + #if defined (HAVE_LUA) + + void addDirichletBCLua (int dim, int entityId, int component, std::string luaFunctionName, lua_State *L); + void addNeumannBCLua (int dim, int entityId, std::string luaFunctionName, lua_State *L); + + #endif + virtual ~elasticitySolver() { if (LagSpace) delete LagSpace;