v0.16.0
Loading...
Searching...
No Matches
Static Public Member Functions | Static Protected Member Functions | Static Protected Attributes | List of all members
MatOps::MatOpsTagsRegistry Struct Reference

#include "src/materials/MatOps.hpp"

Collaboration diagram for MatOps::MatOpsTagsRegistry:
[legend]

Static Public Member Functions

static int atTagName (std::string name)
 
static int setTagName (std::string name, int tag=-1)
 
static std::string getTagName (int tag)
 

Static Protected Member Functions

static int getTagByName (std::string name)
 

Static Protected Attributes

static std::map< std::string, int > tagNameVsTag
 

Detailed Description

Definition at line 24 of file MatOps.hpp.

Member Function Documentation

◆ atTagName()

int MatOps::MatOpsTagsRegistry::atTagName ( std::string  name)
static
Examples
mofem/src/materials/MatOps.hpp.

Definition at line 26 of file MatOps.cpp.

26 {
27 return tagNameVsTag.at(name);
28}
static std::map< std::string, int > tagNameVsTag
Definition MatOps.hpp:32

◆ getTagByName()

int MatOps::MatOpsTagsRegistry::getTagByName ( std::string  name)
staticprotected
Examples
mofem/src/materials/MatOps.hpp.

Definition at line 73 of file MatOps.cpp.

73 {
74 auto it = tagNameVsTag.find(name);
75 if (it == tagNameVsTag.end()) {
76 int new_tag = tagNameVsTag.size() + 1;
77 tagNameVsTag[name] = new_tag;
78 return new_tag;
79 }
80 return it->second;
81}

◆ getTagName()

std::string MatOps::MatOpsTagsRegistry::getTagName ( int  tag)
static
Examples
mofem/src/materials/MatOps.hpp.

Definition at line 83 of file MatOps.cpp.

83 {
84 for (const auto &p : tagNameVsTag) {
85 if (p.second == tag) {
86 return p.first;
87 }
88 }
89 return std::string();
90}

◆ setTagName()

int MatOps::MatOpsTagsRegistry::setTagName ( std::string  name,
int  tag = -1 
)
static
Examples
ep.cpp, mofem/src/materials/MatOps.hpp, mofem/tutorials/vec-2_nonlinear_elasticity/src/NonlinearElasticExample.hpp, and mofem/users_modules/eshelbian_plasticity/ep.cpp.

Definition at line 30 of file MatOps.cpp.

30 {
31 MOFEM_LOG_CHANNEL("WORLD");
32
33 auto it = tagNameVsTag.find(name);
34
35 if (tag >= 0) {
36 if (it != tagNameVsTag.end()) {
37 MOFEM_LOG("WORLD", Sev::warning)
38 << "Tag name: " << name
39 << " is already registered with tag: " << it->second
40 << ". Overwriting with new tag: " << tag;
41 it->second = -1; // set it to invalid value to avoid confusion
42 }
43 for (auto &p : tagNameVsTag) {
44 if (p.second == tag) {
46 "Tag: " + std::to_string(tag) +
47 " is already registered with name: " + p.first);
48 }
49 }
50 // register new tag
51 tagNameVsTag[name] = tag;
52 return tag;
53 }
54
55 int max_tag = 0;
56 for (auto &p : tagNameVsTag) {
57 if (p.second > max_tag) {
58 max_tag = p.second;
59 }
60 }
61
62 if (it == tagNameVsTag.end()) {
63 tagNameVsTag[name] = max_tag + 1;
64 }
65
66 MOFEM_LOG("WORLD", Sev::inform)
67 << "Tag name: " << name
68 << " is registered with tag: " << tagNameVsTag[name];
69
70 return tagNameVsTag[name];
71}
#define CHK_THROW_MESSAGE(err, msg)
Check and throw MoFEM exception.
@ MOFEM_OPERATION_UNSUCCESSFUL
Definition definitions.h:34
#define MOFEM_LOG(channel, severity)
Log.
#define MOFEM_LOG_CHANNEL(channel)
Set and reset channel.

Member Data Documentation

◆ tagNameVsTag

std::map<std::string, int> MatOps::MatOpsTagsRegistry::tagNameVsTag
inlinestaticprotected
Examples
mofem/src/materials/MatOps.hpp.

Definition at line 32 of file MatOps.hpp.


The documentation for this struct was generated from the following files: