Skip to content

Writing tags to a mesh without having to convert to a field #250

Closed
@a-jp

Description

@a-jp

Hi,
Based on this post tags/fields I was trying to learn about tags and fields. However, I do not seem to be able to get a tag written to a mesh, I seem to have to always convert it to a field. Is that intended? If so, how to I store integer based fields? I am using the following:

apf::MeshTag *create_int_tag(apf::Mesh *m, int dim)
{
	apf::MeshTag *tag = m->createIntTag("my_tag", 1); // 1 is size of tag
	apf::MeshEntity *elem;
	apf::MeshIterator *it = m->begin(dim);
	int vals[1];
	vals[0] = PCU_Comm_Self();
	while ((elem = m->iterate(it)))
		m->setIntTag(elem, tag, vals);
	m->end(it);
	return tag;
}

So firstly this never appears in the vtk output, secondly, if I try to adapt the convert_my_tag function in the above link to be integer based so that I can see it in the vtk file, I can't because I don't seem to be able to write integer based values. Is there something I'm doing wrong? There does not seem to be an apf::INTEGER, do I always have to cast to double? It works fine if I do, but I wanted to check.

Finally, can I ask, is this following (which I'm using) the correct way to store a single double precision number per cell/element?

apf::createField(m, fieldName, apf::SCALAR, apf::getConstant(dim));

I found that in this link. I am looking for something that will have ghost allocation automatically created and exchanged. My code is a cell-entered (collocated) finite volume code. I just want to store say pressure in every cell/element and be able to do parallel exchange on that variable automagically.
Thanks,
Andy

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions