[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[Getfem-commits] r4541 - in /trunk/getfem/src: ./ getfem/
From: |
Yves . Renard |
Subject: |
[Getfem-commits] r4541 - in /trunk/getfem/src: ./ getfem/ |
Date: |
Sun, 16 Mar 2014 12:29:16 -0000 |
Author: renard
Date: Sun Mar 16 13:29:15 2014
New Revision: 4541
URL: http://svn.gna.org/viewcvs/getfem?rev=4541&view=rev
Log:
use of im_data in the new generic assembly
Modified:
trunk/getfem/src/getfem/getfem_fem.h
trunk/getfem/src/getfem/getfem_generic_assembly.h
trunk/getfem/src/getfem/getfem_im_data.h
trunk/getfem/src/getfem/getfem_models.h
trunk/getfem/src/getfem_fem.cc
trunk/getfem/src/getfem_generic_assembly.cc
trunk/getfem/src/getfem_im_data.cc
Modified: trunk/getfem/src/getfem/getfem_fem.h
URL:
http://svn.gna.org/viewcvs/getfem/trunk/getfem/src/getfem/getfem_fem.h?rev=4541&r1=4540&r2=4541&view=diff
==============================================================================
--- trunk/getfem/src/getfem/getfem_fem.h (original)
+++ trunk/getfem/src/getfem/getfem_fem.h Sun Mar 16 13:29:15 2014
@@ -694,6 +694,8 @@
size_type convex_num() const;
/** get the current face number */
size_type face_num() const;
+ /** On a face ? */
+ bool is_on_face() const;
/** get the current fem_precomp_ */
pfem_precomp pfp() const { return pfp_; }
void set_pfp(pfem_precomp newpfp);
Modified: trunk/getfem/src/getfem/getfem_generic_assembly.h
URL:
http://svn.gna.org/viewcvs/getfem/trunk/getfem/src/getfem/getfem_generic_assembly.h?rev=4541&r1=4540&r2=4541&view=diff
==============================================================================
--- trunk/getfem/src/getfem/getfem_generic_assembly.h (original)
+++ trunk/getfem/src/getfem/getfem_generic_assembly.h Sun Mar 16 13:29:15 2014
@@ -114,15 +114,17 @@
const mesh_fem *mf;
gmm::sub_interval I;
const model_real_plain_vector *V;
+ const im_data *imd;
var_description(bool is_var,
bool is_fem,
const mesh_fem *mmf,
gmm::sub_interval I_,
- const model_real_plain_vector *v)
- : is_variable(is_var), is_fem_dofs(is_fem), mf(mmf), I(I_), V(v) {}
+ const model_real_plain_vector *v, const im_data *imd_)
+ : is_variable(is_var), is_fem_dofs(is_fem), mf(mmf), I(I_), V(v),
+ imd(imd_) {}
var_description() : is_variable(false), is_fem_dofs(false),
- mf(0), V(0) {}
+ mf(0), V(0), imd(0) {}
};
public:
@@ -240,29 +242,37 @@
const gmm::sub_interval &I,
const model_real_plain_vector &VV) {
GMM_ASSERT1(!model, "Invalid use");
- variables[name] = var_description(true, true, &mf, I, &VV);
+ variables[name] = var_description(true, true, &mf, I, &VV, 0);
}
void add_fixed_size_variable(const std::string &name,
const gmm::sub_interval &I,
const model_real_plain_vector &VV) {
GMM_ASSERT1(!model, "Invalid use");
- variables[name] = var_description(true, false, 0, I, &VV);
+ variables[name] = var_description(true, false, 0, I, &VV, 0);
}
void add_fem_constant(const std::string &name, const mesh_fem &mf,
const model_real_plain_vector &VV) {
GMM_ASSERT1(!model, "Invalid use");
variables[name] = var_description(false, true, &mf,
- gmm::sub_interval(), &VV);
+ gmm::sub_interval(), &VV, 0);
}
void add_fixed_size_constant(const std::string &name,
const model_real_plain_vector &VV) {
GMM_ASSERT1(!model, "Invalid use");
variables[name] = var_description(false, false, 0,
- gmm::sub_interval(), &VV);
- }
+ gmm::sub_interval(), &VV, 0);
+ }
+
+ void add_im_data(const std::string &name, const im_data &imd,
+ const model_real_plain_vector &VV) {
+ GMM_ASSERT1(!model, "Invalid use");
+ variables[name] = var_description(false, false, 0,
+ gmm::sub_interval(), &VV, &imd);
+ }
+
bool used_variables(model::varnamelist &vl, model::varnamelist &dl,
size_type order);
@@ -305,15 +315,35 @@
}
}
+ const im_data *associated_im_data(const std::string &name) const {
+ if (model)
+ return model->pim_data_of_variable(name);
+ else {
+ VAR_SET::const_iterator it = variables.find(name);
+ GMM_ASSERT1(it != variables.end(), "Undefined variable " << name);
+ return it->second.imd;
+ }
+ }
+
size_type qdim(const std::string &name) const {
const mesh_fem *mf = associated_mf(name);
+ const im_data *imd = associated_im_data(name);
size_type n = gmm::vect_size(value(name));
- size_type ndof = mf ? mf->nb_dof() : 0;
- return mf ? associated_mf(name)->get_qdim() * (n / ndof) : n;
+ if (mf) {
+ size_type ndof = mf->nb_dof();
+ return mf->get_qdim() * (n / ndof);
+ } else if (imd) {
+ size_type q = n / imd->nb_filtered_index();
+ GMM_ASSERT1(q % imd->nb_tensor_elem() == 0,
+ "Invalid mesh im data vector");
+ return q;
+ }
+ return n;
}
bgeot::multi_index qdims(const std::string &name) const {
const mesh_fem *mf = associated_mf(name);
+ const im_data *imd = associated_im_data(name);
size_type n = gmm::vect_size(value(name));
if (mf) {
bgeot::multi_index mi = mf->get_qdims();
@@ -322,9 +352,18 @@
if (mi.back() == 1) mi.back() *= qmult; else mi.push_back(qmult);
}
return mi;
- } else {
- bgeot::multi_index mi(1); mi[0] = n; return mi;
- }
+ } else if (imd) {
+ bgeot::multi_index mi = imd->tensor_size();
+ size_type q = n / imd->nb_filtered_index();
+ GMM_ASSERT1(q % imd->nb_tensor_elem() == 0,
+ "Invalid mesh im data vector");
+ size_type qmult = q / imd->nb_tensor_elem();
+ if (qmult > 1) {
+ if (mi.back() == 1) mi.back() *= qmult; else mi.push_back(qmult);
+ }
+ return mi;
+ }
+ bgeot::multi_index mi(1); mi[0] = n; return mi;
}
const model_real_plain_vector &value(const std::string &name) const {
Modified: trunk/getfem/src/getfem/getfem_im_data.h
URL:
http://svn.gna.org/viewcvs/getfem/trunk/getfem/src/getfem/getfem_im_data.h?rev=4541&r1=4540&r2=4541&view=diff
==============================================================================
--- trunk/getfem/src/getfem/getfem_im_data.h (original)
+++ trunk/getfem/src/getfem/getfem_im_data.h Sun Mar 16 13:29:15 2014
@@ -56,7 +56,7 @@
matrix, vector and scalar) from a vector data (generally a
fixed-size variable from the model.)
*/
- class im_data : public context_dependencies{
+ class im_data : public context_dependencies {
public:
/**
* Constructor
Modified: trunk/getfem/src/getfem/getfem_models.h
URL:
http://svn.gna.org/viewcvs/getfem/trunk/getfem/src/getfem/getfem_models.h?rev=4541&r1=4540&r2=4541&view=diff
==============================================================================
--- trunk/getfem/src/getfem/getfem_models.h (original)
+++ trunk/getfem/src/getfem/getfem_models.h Sun Mar 16 13:29:15 2014
@@ -162,8 +162,8 @@
std::vector<gmm::uint64_type> v_num_var_iter;
std::vector<gmm::uint64_type> v_num_iter;
- //im data description
- im_data * pim_data;
+ // im data description
+ im_data *pim_data;
var_description(bool is_var = false, bool is_com = false,
bool is_fem = false, size_type n_it = 1,
@@ -177,7 +177,7 @@
n_iter(std::max(size_type(1),n_it)), n_temp_iter(0),
default_iter(0), mf(mmf), m_region(m_reg), mim(mim_),
filter_var(filter_v), qdim(Q), v_num(0), v_num_data(act_counter()),
- pim_data(pimd){
+ pim_data(pimd) {
if (filter != VDESCRFILTER_NO && mf != 0)
partial_mf = new partial_mesh_fem(*mf);
// v_num_data = v_num;
@@ -481,6 +481,12 @@
return (it->second.pim_data != 0);
}
+ const im_data *pim_data_of_variable(const std::string &name) const {
+ VAR_SET::const_iterator it = variables.find(name);
+ GMM_ASSERT1(it != variables.end(), "Undefined variable " << name);
+ return it->second.pim_data;
+ }
+
/** Enable a variable. */
void enable_variable(const std::string &name) {
variables[name].is_disabled = false;
Modified: trunk/getfem/src/getfem_fem.cc
URL:
http://svn.gna.org/viewcvs/getfem/trunk/getfem/src/getfem_fem.cc?rev=4541&r1=4540&r2=4541&view=diff
==============================================================================
--- trunk/getfem/src/getfem_fem.cc (original)
+++ trunk/getfem/src/getfem_fem.cc Sun Mar 16 13:29:15 2014
@@ -54,6 +54,10 @@
GMM_ASSERT3(face_num_ != size_type(-1),
"Face number is asked but not defined");
return face_num_;
+ }
+
+ bool fem_interpolation_context::is_on_face() const {
+ return (face_num_ != size_type(-1));
}
void fem_interpolation_context::base_value(base_tensor& t,
Modified: trunk/getfem/src/getfem_generic_assembly.cc
URL:
http://svn.gna.org/viewcvs/getfem/trunk/getfem/src/getfem_generic_assembly.cc?rev=4541&r1=4540&r2=4541&view=diff
==============================================================================
--- trunk/getfem/src/getfem_generic_assembly.cc (original)
+++ trunk/getfem/src/getfem_generic_assembly.cc Sun Mar 16 13:29:15 2014
@@ -2042,13 +2042,47 @@
// Instructions for compilation: basic optimized operations on tensors
//=========================================================================
+
+
+ struct ga_instruction_extract_local_im_data : public ga_instruction {
+ base_tensor &t;
+ const im_data &imd;
+ papprox_integration &pai;
+ const base_vector &U;
+ fem_interpolation_context &ctx;
+ size_type qdim, cv_old;
+ virtual void exec(void) {
+ GA_DEBUG_INFO("Instruction: extract local im data");
+ size_type cv = ctx.convex_num();
+ if (cv != cv_old) {
+ cv_old = cv;
+ GMM_ASSERT1(imd.get_mesh_im().int_method_of_element(cv)
+ ->approx_method() == pai, "Im data have to be used only "
+ "on their original integration method.");
+ GMM_ASSERT1(!(ctx.is_on_face()),
+ "Im data cannot be used of boundaries");
+ }
+ size_type ind = imd.filtered_index_of_point(cv, ctx.ii());
+ GMM_ASSERT1(ind != size_type(-1),
+ "Im data with no data on the current integration point");
+ gmm::copy(gmm::sub_vector(U, gmm::sub_interval(ind*qdim, qdim)),
+ t.as_vector());
+ }
+ ga_instruction_extract_local_im_data
+ (base_tensor &t_, const im_data &imd_, const base_vector &U_,
+ papprox_integration &pai_, fem_interpolation_context &ctx_,
+ size_type qdim_)
+ : t(t_), imd(imd_), pai(pai_), U(U_), ctx(ctx_), qdim(qdim_),
+ cv_old(-1) {}
+ };
+
struct ga_instruction_slice_local_dofs : public ga_instruction {
const mesh_fem &mf;
const base_vector &U;
fem_interpolation_context &ctx;
base_vector &coeff;
virtual void exec(void) {
- GA_DEBUG_INFO("Instruction: Slice");
+ GA_DEBUG_INFO("Instruction: Slice local dofs");
slice_vector_on_basic_dof_of_element(mf, U, ctx.convex_num(), coeff);
}
ga_instruction_slice_local_dofs(const mesh_fem &mf_, const base_vector &U_,
@@ -3709,7 +3743,8 @@
case GA_NODE_ALLINDICES: pnode->test_function_type = 0; break;
case GA_NODE_VAL:
- if (eval_fixed_size && !(workspace.associated_mf(pnode->name))) {
+ if (eval_fixed_size && !(workspace.associated_mf(pnode->name))
+ && !(workspace.associated_im_data(pnode->name))) {
gmm::copy(workspace.value(pnode->name), pnode->t.as_vector());
pnode->node_type = GA_NODE_CONSTANT;
}
@@ -4441,8 +4476,9 @@
pnode->name = name;
const mesh_fem *mf = workspace.associated_mf(name);
+ const im_data *imd = workspace.associated_im_data(name);
if (!test) {
- if (!mf) {
+ if (!mf && !imd) {
if (val_grad_or_hess)
ga_throw_error(expr, pnode->pos, "Gradient or Hessian cannot "
"be evaluated for fixed size data.");
@@ -4457,6 +4493,13 @@
pnode->init_vector_tensor(n);
gmm::copy(workspace.value(name), pnode->t.as_vector());
}
+ } else if (imd) {
+ if (val_grad_or_hess)
+ ga_throw_error(expr, pnode->pos, "Gradient or Hessian cannot "
+ "be evaluated for im data.");
+ pnode->node_type = GA_NODE_VAL;
+ pnode->t.adjust_sizes(workspace.qdims(name));
+ pnode->test_function_type = 0;
} else {
size_type q = workspace.qdim(name), n = mf->linked_mesh().dim();
bgeot::multi_index mii = workspace.qdims(name);
@@ -5584,69 +5627,79 @@
rmi.instructions.push_back(pgai);
} else {
const mesh_fem *mf = workspace.associated_mf(pnode->name);
- GMM_ASSERT1(mf, "Internal error");
-
- // An instruction for extracting local dofs of the variable.
- if (rmi.local_dofs.find(pnode->name) == rmi.local_dofs.end()) {
- rmi.local_dofs[pnode->name] = base_vector(1);
+ const im_data *imd = workspace.associated_im_data(pnode->name);
+
+ if (imd) {
+ pgai = new ga_instruction_extract_local_im_data
+ (pnode->t, *imd, workspace.value(pnode->name), gis.pai, gis.ctx,
+ workspace.qdim(pnode->name));
+ rmi.instructions.push_back(pgai);
+ } else {
- if (gis.extended_vars.find(pnode->name) == gis.extended_vars.end()) {
- if (mf->is_reduced()) {
- base_vector U(mf->nb_basic_dof());
- mf->extend_vector(workspace.value(pnode->name), U);
- gis.really_extended_vars[pnode->name] = U;
- gis.extended_vars[pnode->name]
- = &(gis.really_extended_vars[pnode->name]);
- } else {
- gis.extended_vars[pnode->name]
- = &(workspace.value(pnode->name));
+ GMM_ASSERT1(mf, "Internal error");
+
+ // An instruction for extracting local dofs of the variable.
+ if (rmi.local_dofs.find(pnode->name) == rmi.local_dofs.end()) {
+ rmi.local_dofs[pnode->name] = base_vector(1);
+
+ if (gis.extended_vars.find(pnode->name)==gis.extended_vars.end()) {
+ if (mf->is_reduced()) {
+ base_vector U(mf->nb_basic_dof());
+ mf->extend_vector(workspace.value(pnode->name), U);
+ gis.really_extended_vars[pnode->name] = U;
+ gis.extended_vars[pnode->name]
+ = &(gis.really_extended_vars[pnode->name]);
+ } else {
+ gis.extended_vars[pnode->name]
+ = &(workspace.value(pnode->name));
+ }
}
- }
- pgai = new ga_instruction_slice_local_dofs
- (*mf, *(gis.extended_vars[pnode->name]), gis.ctx,
- rmi.local_dofs[pnode->name]);
+ pgai = new ga_instruction_slice_local_dofs
+ (*mf, *(gis.extended_vars[pnode->name]), gis.ctx,
+ rmi.local_dofs[pnode->name]);
+ rmi.instructions.push_back(pgai);
+ }
+
+ // An instruction for pfp update
+ if (rmi.pfps.find(mf) == rmi.pfps.end()) {
+ rmi.pfps[mf] = 0;
+ pgai = new ga_instruction_update_pfp
+ (*mf, rmi.pfps[mf], gis.ctx, gis.pai, gis.fp_pool);
+ rmi.instructions.push_back(pgai);
+ }
+
+ // An instruction for the base value
+ pgai = 0;
+ if (pnode->node_type == GA_NODE_VAL) {
+ if (rmi.base.find(mf) == rmi.base.end())
+ pgai = new ga_instruction_base
+ (rmi.base[mf], gis.ctx, *mf, rmi.pfps[mf]);
+ } else if (pnode->node_type == GA_NODE_GRAD) {
+ if (rmi.grad.find(mf) == rmi.grad.end())
+ pgai = new ga_instruction_grad_base
+ (rmi.grad[mf], gis.ctx, *mf, rmi.pfps[mf]);
+ } else {
+ if (rmi.hess.find(mf) == rmi.hess.end())
+ pgai = new ga_instruction_hess_base
+ (rmi.hess[mf], gis.ctx, *mf, rmi.pfps[mf]);
+ }
+ if (pgai) rmi.instructions.push_back(pgai);
+
+ // The eval instruction
+ if (pnode->node_type == GA_NODE_VAL)
+ pgai = new ga_instruction_val
+ (pnode->t, rmi.base[mf],
+ rmi.local_dofs[pnode->name], workspace.qdim(pnode->name));
+ else if (pnode->node_type == GA_NODE_GRAD)
+ pgai = new ga_instruction_grad
+ (pnode->t, rmi.grad[mf],
+ rmi.local_dofs[pnode->name], workspace.qdim(pnode->name));
+ else
+ pgai = new ga_instruction_hess
+ (pnode->t, rmi.hess[mf],
+ rmi.local_dofs[pnode->name], workspace.qdim(pnode->name));
rmi.instructions.push_back(pgai);
}
-
- // An instruction for pfp update
- if (rmi.pfps.find(mf) == rmi.pfps.end()) {
- rmi.pfps[mf] = 0;
- pgai = new ga_instruction_update_pfp
- (*mf, rmi.pfps[mf], gis.ctx, gis.pai, gis.fp_pool);
- rmi.instructions.push_back(pgai);
- }
-
- // An instruction for the base value
- pgai = 0;
- if (pnode->node_type == GA_NODE_VAL) {
- if (rmi.base.find(mf) == rmi.base.end())
- pgai = new ga_instruction_base
- (rmi.base[mf], gis.ctx, *mf, rmi.pfps[mf]);
- } else if (pnode->node_type == GA_NODE_GRAD) {
- if (rmi.grad.find(mf) == rmi.grad.end())
- pgai = new ga_instruction_grad_base
- (rmi.grad[mf], gis.ctx, *mf, rmi.pfps[mf]);
- } else {
- if (rmi.hess.find(mf) == rmi.hess.end())
- pgai = new ga_instruction_hess_base
- (rmi.hess[mf], gis.ctx, *mf, rmi.pfps[mf]);
- }
- if (pgai) rmi.instructions.push_back(pgai);
-
- // The eval instruction
- if (pnode->node_type == GA_NODE_VAL)
- pgai = new ga_instruction_val
- (pnode->t, rmi.base[mf],
- rmi.local_dofs[pnode->name], workspace.qdim(pnode->name));
- else if (pnode->node_type == GA_NODE_GRAD)
- pgai = new ga_instruction_grad
- (pnode->t, rmi.grad[mf],
- rmi.local_dofs[pnode->name], workspace.qdim(pnode->name));
- else
- pgai = new ga_instruction_hess
- (pnode->t, rmi.hess[mf],
- rmi.local_dofs[pnode->name], workspace.qdim(pnode->name));
- rmi.instructions.push_back(pgai);
}
break;
Modified: trunk/getfem/src/getfem_im_data.cc
URL:
http://svn.gna.org/viewcvs/getfem/trunk/getfem/src/getfem_im_data.cc?rev=4541&r1=4540&r2=4541&view=diff
==============================================================================
--- trunk/getfem/src/getfem_im_data.cc (original)
+++ trunk/getfem/src/getfem_im_data.cc Sun Mar 16 13:29:15 2014
@@ -75,7 +75,7 @@
size_type im_data::index_of_point(size_type cv, size_type i) const{
context_check();
if (require_update_) update_index_();
- if(cv < int_point_index_.size()) return int_point_index_[cv] + i;
+ if (cv < int_point_index_.size()) return int_point_index_[cv] + i;
else return size_type(-1);
}
[Prev in Thread] |
Current Thread |
[Next in Thread] |
- [Getfem-commits] r4541 - in /trunk/getfem/src: ./ getfem/,
Yves . Renard <=