[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: [Getfem-users] nonlinear brick
From: |
Yves Renard |
Subject: |
Re: [Getfem-users] nonlinear brick |
Date: |
Thu, 25 Mar 2010 07:41:09 +0100 |
User-agent: |
KMail/1.9.9 |
Dear Roman,
There is at least two nonlinear working new bricks. The nonlinear elasticity
brick (getfem_nonlinear_elasticity.cc) and the contact with friction brick
(getfem_Coulomb_friction.cc). But they are not present in getfem++ 4.0.0.
They are in the svn version. You can also download the archive here (this is a
svn snapshot, not a stable release) :
http://math.univ-lyon1.fr/homes-www/renard/temp/getfem-4.0.tar.gz
I apologize, I did not yet documented how to build a nonlinear brick ! The
most important things :
model::build_version nl indicates weither the right hand side or the tangent
matrix is to be assembled.
const model::varnamelist &varl contains the variables whose value can be used
to assemble the rhs or tangent term (the value is obtained with
md.real_variable(varl[i]) as for the data).
Your term
double a = vecl[0][0];
cannot be correct. vecl is to be filled by asm_real_tangent_terms. It is
initialized with 0.
Yves.
On mercredi 24 mars 2010, Roman Putanowicz wrote:
> Dear All,
>
> Could someone, please, point me to an example involving nonlinear brick
> using the new brick system?
>
> Actually, I am trying to get the real filling of GetFEM++ internals.
> I just thought to use GetFEM++ to solve a problem which boils down
> to a single quadratic scalar equation. I know that this is not what
> GetFEM++ was meant for, but in principle GetFEM++ allows to model board
> kind of mathematical models so why not this :).
>
> I have defined the following brick:
>
> namespace getfem {
> struct my_quadratic_eq_brick : public virtual_brick {
> void asm_real_tangent_terms(const model &md,
> getfem::size_type ib,
> const model::varnamelist &varl,
> const model::varnamelist &datal,
> const model::mimlist &mims,
> model::real_matlist &matl,
> model::real_veclist &vecl,
> model::real_veclist &vecl_sym,
> size_type region,
> model::build_version nl) const {
>
> GMM_ASSERT1(matl.size() == 1, "my_quadratic_eq_brick has only one
> term"); GMM_ASSERT1(mims.size() == 0,
> "my_quadratic_eq_brick does not need mesh_im");
> GMM_ASSERT1(varl.size() == 1 && datal.size() == 1,
> "Wrong number of varibles for my_quadratic_eq_brick");
>
> /* get equation coefficients */
> const model_real_plain_vector COEFF = md.real_variable(datal[0]);
>
> gmm::dense_matrix<double> mm(1,1);
> double a = vecl[0][0];
> mm(0,0) = COEFF[0]*a*2.0 + COEFF[1];
> gmm::copy(mm, matl[0]);
> }
>
> my_quadratic_term_brick(bool symmetric_, bool coercive_) {
> set_flags("Quadratic term brick",
> false /* is linear*/,
> symmetric_ /* is symmetric */, coercive_ /* is coercive */,
> true /* is real */, true /* is complex */);
> }
> };
>
> size_type add_my_quadratic_eq_brick
> (model &md, const std::string &varname, const std::string &dataname) {
> pbrick pbr = new my_quadratic_term_brick(false, false);
> model::termlist tl;
> tl.push_back(model::term_description(varname, varname, true));
> model::varnamelist dl;
> dl.push_back(dataname);
> dl.push_back(varname);
> return md.add_brick(pbr, model::varnamelist(1, varname), dl, tl,
> model::mimlist(), size_type(-1));
> }
> } /* namespace getfem */
>
>
> Well, so far so good.
>
> Now a bit of code which uses the brick:
>
> md.add_fixed_size_variable("x", 1);
> std::vector<scalar_type> F(1);
> std::vector<scalar_type> coeff(3);
> coeff[0] = 7.0;
> coeff[1] = 11.0;
> coeff[2] = 2.0;
> md.add_initialized_fixed_size_data("coeff", coeff);
>
> md.first_iter();
>
> F[0] = 2.0;
> gmm::copy(F, md.set_real_variable("x"));
>
> getfem::size_type id = add_my_quadratic_eq_brick(md, "x", "coeff");
>
> md.assembly(getfem::model::BUILD_MATRIX);
>
> std::cout << md.real_tangent_matrix();
>
> And here is the problem. On standard output I get the 1 by 1 matrix
> whose only element value is 11 (the coefficient at linear term in the
> equation). So it seems that the "x" vector is uninitialised.
> Is there any mechanism that ensures that the tangent matrix
> will be built on the basis of supplied guessed solution?
>
> I thought that this will be done with these two lines
>
> F[0] = 2.0;
> gmm::copy(F, md.set_real_variable("x"));
>
> but apparently I miss something.
>
> I would appreciate any hint.
>
> Regards
>
> Roman
--
Yves Renard (address@hidden) tel : (33) 04.72.43.87.08
Pole de Mathematiques, INSA-Lyon fax : (33) 04.72.43.85.29
20, rue Albert Einstein
69621 Villeurbanne Cedex, FRANCE
http://math.univ-lyon1.fr/~renard
---------