_elasticity_tensor[_qp] = whatever_you_want;
Have a look at ComputeIsotropicElasticityTensor. There are lots of options there, but the user must provide two numbers, and the class fills a constant RankFourTensor _Cijkl appropriately depending on what numbers the user provided. Then in computeQpElasticityTensor, it copies the values in _Cijkl into _elasticity_tensor[_qp].
Also, have a look at framework/include/utils/RankFourTensor.h and the .C file, and you'll see that initIdentitySymmetricFour gives (de_ij de_kl + de_il de_jk)/2.
a
________________________________________
From: moose...@googlegroups.com <moose...@googlegroups.com> on behalf of Edgar Rios <edga...@u.boisestate.edu>
Sent: Friday, 3 November 2017 5:10 AM
To: moose...@googlegroups.com
Subject: How to create my first material?
• Short version.
• Longer version
Hello,
--
You received this message because you are subscribed to the Google Groups "moose-users" group.
To unsubscribe from this group and stop receiving emails from it, send an email to moose-users...@googlegroups.com.
Visit this group at https://groups.google.com/group/moose-users.
To view this discussion on the web visit https://groups.google.com/d/msgid/moose-users/CAGXJvspKuP1QyGioyE1VF%2B-1yFdh43sc6ay55-4899oMot8OnA%40mail.gmail.com.
For more options, visit https://groups.google.com/d/optout.
but ComputeElasticityTensorBase would be better. That class declares a RankFourTensor MaterialProperty called _elasticity_tensor that you need to populate with values in your computeQpElasticityTensor method.
Your only piece of non-trivial code would be_elasticity_tensor[_qp] = whatever_you_want;
Have a look at ComputeIsotropicElasticityTensor. There are lots of options there, but the user must provide two numbers, and the class fills a constant RankFourTensor _Cijkl appropriately depending on what numbers the user provided.
Then in computeQpElasticityTensor, it copies the values in _Cijkl into _elasticity_tensor[_qp].
Also, have a look at framework/include/utils/RankFourTensor.h and the .C file, and you'll see that initIdentitySymmetricFour gives (de_ij de_kl + de_il de_jk)/2.
/*************************************************************/ /* Headers for a test of a new elasticity tensor in MOOSE */ /* Status: not working */ /* */ /* Copyright (C) 2017, 2018 eDgar */ /* */ /* This program is free software: you can redistribute it */ /* and/or modify it under the terms of the GNU General */ /* Public License as published by the Free Software */ /* Foundation, either version 3 of the License, or (at your */ /* option) any later version. */ /* */ /* This program is distributed in the hope that it will be */ /* useful, but WITHOUT ANY WARRANTY; without even the */ /* implied warranty of MERCHANTABILITY or FITNESS FOR A */ /* PARTICULAR PURPOSE. See the GNU General Public License */ /* for more details. */ /* */ /* You should have received a copy of the GNU General Public */ /* License along with this program. If not, see */ /* <http://www.gnu.org/licenses/>. */ /*************************************************************/ // Lines like this (starting with //) are extra documentation // This line is a conditional to make sure that the function // is not declared twice (it ends with #endif below; // everything in-between is within the conditional if it's // true) #ifndef ELASTICITYTENSORX_H // After making sure that the function hasn't been // previously defined, we state that we are now going to // define it #define ELASTICITYTENSORX_H // We are going to use functions to define the elasticity tensor // (a material needs an elasticity, strain and stress tensors), // so we load (include, import) it at compilation time. // This class provides, among others, _elasticity_tensor (a // RankFourTensor MaterialProperty--Andrew Wilkins) #include "ComputeElasticityTensorBase.h" // State what we are creating. class ElasticityTensorX; // ... and declare a (MOOSE) template for it
template <> InputParameters validParams<ElasticityTensorX>();
/** * ElasticityTensorX defines an elasticity tensor for the * St. Venant-Kirchhoff material. It is meant as a guide on * the implementation of (elasticity tensors of) new materials. */ // We inherit from ComputeElasticityTensorBase, which // "declares a RankFourTensor MaterialProperty called // _elasticity_tensor that you need to populate with values // in your computeQpElasticityTensor method" // (andrew.wilkins) class ElasticityTensorX : public ComputeElasticityTensorBase {
public: ElasticityTensorX(const InputParameters & parameters); protected
: // - Qp refers to quadrature points // - This function "Assign{s an} elasticity tensor at a given // given quad point", [see ComputeElasticityTensor.C, // 2017-11-01] // - `override' means to make sure that you inherit the right // thing (something that exists) virtual void computeQpElasticityTensor() override; // Something that belongs to your object goes with _, // but the program will run without it. // We can declare a constant, for instance const Real & _some_constant; // Following the style in, // [[moose/modules/tensor_mechanics/include/materials/ComputeIsotropicElasticityTensor.h]] // create Booleans which will be used to test if the Lamé // constants were defined in the .i (input) file bool _lambda_set; bool _mu_set; // These are just material properties which don't change // (which declaration is better?) /* Lamé constant mu (mu > 0). ComputeElasticityTensorBase already defines _lambda (Real _lambda;) */ const MaterialProperty<Real> & _mu; // We state that this class has a fourth order tensor // called _Cijkl (we could have used another name; not // even the indices are required) RankFourTensor _Cijkl; }; // This indicates that the conditional finished, and a tag // is next to it to identify which "if" it closes (there // could be nested conditionals, and they become difficult // to track). #endif // ELASTICITYTENSORX_H
/*************************************************************/ /* Source for a test of a new elasticity tensor in MOOSE */ /* Status: not working */ /* */ /* Copyright (C) 2017, 2018 eDgar */ /* */ /* This program is free software: you can redistribute it */ /* and/or modify it under the terms of the GNU General */ /* Public License as published by the Free Software */ /* Foundation, either version 3 of the License, or (at your */ /* option) any later version. */ /* */ /* This program is distributed in the hope that it will be */ /* useful, but WITHOUT ANY WARRANTY; without even the */ /* implied warranty of MERCHANTABILITY or FITNESS FOR A */ /* PARTICULAR PURPOSE. See the GNU General Public License */ /* for more details. */ /* */ /* You should have received a copy of the GNU General Public */ /* License along with this program. If not, see */ /* <http://www.gnu.org/licenses/>. */ /*************************************************************/ // We need to get the specification of how to call the // functions which will be defined below. That is the main // point of the header (.h) file #include "ElasticityTensorX.h" // Populate the template which was sketched in the header // file. The parameters given here can be used by the user // in the input file.
(); // Description which is shown in the auto-generated // documentation params.addClassDescription("DO NOT USE!!\n" "ElasticityTensorX defines an " "elasticity tensor for the " "St. Venant-Kirchhoff material. " "It is meant as a guide on the " "implementation of (elasticity " "tensors of) new materials.\n" "\(\Psi(\tensor{E}) = \frac{1}{2}\," "\lambda\,(\Tr{\tensor{E}})^{2} + " "\mu\,\tensor{E}:\tensor{E}\)"); // State that _lambda and _mu are required parameters // (technically, only one is needed) params.addRequiredParam<Real>("lambda", 1.0, "Lame's first constant for the material."); params.addRequiredParam<Real>("mu", 1.0, "Lamé second constant for the material"); return params; } ElasticityTensorX::ElasticityTensorX(const InputParameters & parameters) : ComputeElasticityTensorBase(parameters), // When this function is called, it is because the // application is compiled and executed with an input // file (.i). // // First, make sure that the parameters were given in // the .i (input) file. Note that we called it "lambda" // in the template above, but the variable in the .h // file is _lambda. For the user filling the .i (input) // file, it will be `lambda'. For calculations in the // code, it will be `_lambda'. _lambda_set(parameters.isParamValid("lambda")), _mu_set(parameters.isParamValid("mu")), // Get parameters from the input file. The following // line is an implicit conditional. It checks if the // Boolean value is True, in which case, it assigns the // value after the `?' (and before `:'). If the value is // False, then the variable gets the value indicated // after `:'. In this case, if `lambda' was set in the // .i (input) file, it gets the value from // there. Otherwise, it sets it to -1. _lambda(_lambda_set ? getParam<Real>("lambda") : -1), // The same for `mu'. _mu(_mu_set ? getParam<Real>("mu") : -1) { // St. Venant-Kirchhoff material model (example; not // useful for any practical application). // Now we are going to initialise the tensor // Make sure that the values are not both negative or zero // Holzapfel, G. A., Nonlinear solid mechanics : a // continuum approach for engineering (2000), : Wiley. p.250 if (_lambda <= 0.0 || _mu <= 0.0) mooseError("The Lamé constants must be positive in material '" + name() + "'."); // The St. Venant-Kirchhoff model is defined as // // LaTeX: // \({\cal C}_{ijkl} = \lambda\,\delta_{ij}\,\delta_{kl} // + 2\,\mu\,\delta_{ik}\,\delta_{jl} \) // // You have to make sure that whatever operatations // (including addition, subtraction, etc. work as you // think). In this case, check that the definition of // RankFourTensor has the required operations. // [[moose/framework/src/utils/RankFourTensor.C]] // LaTeX: // \( \delta_{ij} \, \delta_{kl} \) // // initIdentity() in // [[moose/framework/src/utils/RankFourTensor.C]] const RankFourTensor dij_dkl = RankFourTensor::initIdentity(); // initIdentityFour() in // [[moose/framework/src/utils/RankFourTensor.C]] const RankFourTensor dik_djl = RankFourTensor::initIdentityFour(); // Knowing that the * operator is defined as we expect // between a tensor and a scalar, as well as the + // operator between the two RankFourTensor, from the // definition: _Cijkl = _lambda * dij_dkl + 2 * _mu * dik_djl; } void ElasticityTensorX::computeQpElasticityTensor() { // This assigns an elasticity tensor at each quadrature // point (_qp) to each of the elements of the material. _elasticity_tensor[_qp] = _Cijkl; }
============================================
[Materials] [./elasticity_tensor] type = ElasticityTensorX lambda = 2.1e5 mu = 3.3e5 [../] [./strain] type = ComputeFiniteStrain displacements = 'disp_x disp_y disp_z' [../] [./stress] type = ComputeFiniteStrainElasticStress [../] []
================================================
################################################# # Makefile adapted by eDgar from # # MOOSE Application Standard Makefile # ################################################# # # Optional Environment variables # MOOSE_DIR - Root directory of the MOOSE project # # ############################################### # Use the MOOSE submodule if it exists and MOOSE_DIR is not # set MOOSE_SUBMODULE := $(CURDIR)/moose ifneq ($(wildcard $(MOOSE_SUBMODULE)/framework/Makefile),) MOOSE_DIR ?= $(MOOSE_SUBMODULE) else MOOSE_DIR ?= ../../../../../moose endif # framework FRAMEWORK_DIR := $(MOOSE_DIR)/framework include $(FRAMEWORK_DIR)/build.mk include $(FRAMEWORK_DIR)/moose.mk # MODULES ####################################### ALL_MODULES := no CHEMICAL_REACTIONS := no CONTACT := no FLUID_PROPERTIES := no HEAT_CONDUCTION := no LINEAR_ELASTICITY := no MISC := no NAVIER_STOKES := no PHASE_FIELD := no POROUS_FLOW := no RICHARDS := no SOLID_MECHANICS := no # all that we are doing is TensorMechanics TENSOR_MECHANICS := yes WATER_STEAM_EOS := no XFEM := no include $(MOOSE_DIR)/modules/modules.mk # ############################################### # dep apps APPLICATION_DIR := $(CURDIR) # Set my application name APPLICATION_NAME := hyper_materials # Make the application executable BUILD_EXEC := yes DEP_APPS := $(shell $(FRAMEWORK_DIR)/scripts/find_dep_apps.py $(APPLICATION_NAME)) include $(FRAMEWORK_DIR)/app.mk # ############################################### # Additional special case targets should be added here
Hello moose-users,
I recently made a small piece of code with the intention of creating a
new material (1, 2). I attach the code as a tar.gz. If I run make,
I get no errors, but I don't know where the executable is. I am
guessing that I made a silly mistake along the road, and would
appreciate if someone could enlighten my way. I post the my way of doing
it below. Thanks!
I compile like this:
cd spider
make -j4
This produces a ../hyper_materials-opt, which I can use
cd problems
../hyper_materials-opt -i stress.i
and tells me that
*** ERROR *** A 'spider' is not a registered object. If you are trying to find this object in a dynamically linked library, make sure that the library can be found either in your "Problem/library_path" parameter or in the MOOSE_LIBRARY_PATH environment variable.
[1] https://groups.google.com/forum/#!topic/moose-users/o9ihbxrSaDc [2] https://groups.google.com/forum/#!topic/moose-users/BMQKsvm2tfE
--
You received this message because you are subscribed to the Google Groups "moose-users" group.
To unsubscribe from this group and stop receiving emails from it, send an email to moose-users...@googlegroups.com.
Visit this group at https://groups.google.com/group/moose-users.
To view this discussion on the web visit https://groups.google.com/d/msgid/moose-users/b26b42aa-5e6b-4cc2-b1b3-2bf3911c6662%40googlegroups.com.
Every new object needs to be registered before use. See the Registration example in the middle of the "Kernels" tutorial here:
--
You received this message because you are subscribed to the Google Groups "moose-users" group.
To unsubscribe from this group and stop receiving emails from it, send an email to moose-users...@googlegroups.com.
Visit this group at https://groups.google.com/group/moose-users.
To view this discussion on the web visit https://groups.google.com/d/msgid/moose-users/c0bc55e6-cc25-44da-94a4-3a03113033d9%40googlegroups.com.